Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
Thick-Common
Commits
718601f2
Commit
718601f2
authored
Mar 19, 2020
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
地址 与 密码 添加默认值功能。 放在 default 文件夹
parent
ee279be4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
61 deletions
+115
-61
FObjServiceClientManager.cs
Project.FLY.FObjSys/FObjSys/FObjServiceClientManager.cs
+39
-4
PasswordAuthorize.cs
...ect.FLY.Thick.Base/FLY.Thick.Base.UI/PasswordAuthorize.cs
+69
-49
PgPwManager.xaml.cs
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgPwManager.xaml.cs
+7
-8
No files found.
Project.FLY.FObjSys/FObjSys/FObjServiceClientManager.cs
View file @
718601f2
...
...
@@ -39,7 +39,10 @@ namespace FObjBase
/// </summary>
[
JsonProperty
]
public
List
<
ConnAddr
>
ConnAddrs
{
get
;
}
=
new
List
<
ConnAddr
>();
/// <summary>
/// 默认地址
/// </summary>
List
<
ConnDefaultAddr
>
DefaultAddrs
{
get
;
}
=
new
List
<
ConnDefaultAddr
>();
/// <summary>
/// 连接到 另一个Obj系统
...
...
@@ -53,9 +56,14 @@ namespace FObjBase
var
connaddr
=
ConnAddrs
.
Find
(
c
=>
c
.
ConnName
==
connName
);
if
(
connaddr
==
null
)
{
string
addr
=
"0.0.0.1:12345"
;
//没有默认值,创建连接到不存在的地址,避免出错
//没有,那就创建一个
//创建连接到不存在的地址,避免出错
connaddr
=
new
ConnAddr
()
{
ConnName
=
connName
,
Addr
=
"0.0.0.1:12345"
};
//查找默认值
var
defaultAddr
=
DefaultAddrs
.
Find
(
c
=>
c
.
ConnName
==
connName
);
if
(
defaultAddr
!=
null
)
addr
=
defaultAddr
.
Addr
;
connaddr
=
new
ConnAddr
()
{
ConnName
=
connName
,
Addr
=
addr
};
ConnAddrs
.
Add
(
connaddr
);
}
...
...
@@ -113,12 +121,27 @@ namespace FObjBase
string
filename
=
"serviceManager.json"
;
string
file_default_path
=
"default/serviceManager.default.json"
;
void
LoadDefault
()
{
if
(!
File
.
Exists
(
file_default_path
))
return
;
try
{
string
json
=
File
.
ReadAllText
(
file_default_path
);
var
p
=
JsonConvert
.
DeserializeObject
<
List
<
ConnDefaultAddr
>>(
json
);
DefaultAddrs
.
AddRange
(
p
);
}
catch
(
Exception
e
)
{
}
}
/// <summary>
/// 加载配置
/// </summary>
public
void
Load
()
void
Load
()
{
LoadDefault
();
if
(
File
.
Exists
(
filename
))
{
try
...
...
@@ -190,4 +213,16 @@ namespace FObjBase
/// </summary>
public
List
<
UInt32
>
ClientIds
=
new
List
<
UInt32
>();
}
public
class
ConnDefaultAddr
{
/// <summary>
/// 连接器名称
/// </summary>
public
string
ConnName
;
/// <summary>
/// 设备地址
/// </summary>
public
string
Addr
;
}
}
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PasswordAuthorize.cs
View file @
718601f2
...
...
@@ -18,14 +18,19 @@ namespace FLY.Thick.Base.UI
public
class
PasswordAuthorize
:
INotifyPropertyChanged
{
const
string
JSONDIST_KEY
=
"password"
;
/// <summary>
/// 服务器
/// </summary>
IJsonDistService
jsonDist
;
/// <summary>
/// 数据库
/// </summary>
[
PropertyChanged
.
DoNotCheckEquality
]
public
PasswordJsonDb
Db
{
get
;
private
set
;
}
=
new
PasswordJsonDb
();
PasswordJsonDb
DbDefault
;
/// <summary>
/// 修改时间
/// 修改时间
,这个是服务器保存数据的时间。一切以服务器为准
/// </summary>
public
DateTime
Time
{
get
;
set
;
}
...
...
@@ -74,20 +79,31 @@ namespace FLY.Thick.Base.UI
}
}
/// <summary>
/// 设置默认数据
/// </summary>
void
default_db
()
void
check_db
()
{
Time
=
DateTime
.
MinValue
;
Db
=
new
PasswordJsonDb
()
if
(
DbDefault
==
null
)
return
;
if
(
DbDefault
.
UiLvs
.
Count
==
0
)
return
;
if
(
Db
==
null
)
Db
=
new
PasswordJsonDb
();
// 界面权限
foreach
(
var
uiLv
in
DbDefault
.
UiLvs
)
{
if
(!
Db
.
UiLvs
.
Any
(
u
=>
u
.
UiName
==
uiLv
.
UiName
))
{
Db
.
UiLvs
.
Add
(
new
UiLvCell
()
{
UiName
=
uiLv
.
UiName
,
Level
=
uiLv
.
Level
,
Description
=
uiLv
.
Description
});
}
}
//密码
if
(
Db
.
Pws
.
Count
()
==
0
)
{
foreach
(
var
pw
in
DbDefault
.
Pws
)
{
Pws
=
new
List
<
PasswordCell
>{
new
PasswordCell
(){
Level
=
10
,
Password
=
"flymeasure"
},
new
PasswordCell
(){
Level
=
1
,
Password
=
"1"
}
},
UiLvs
=
new
List
<
UiLvCell
>()
};
Db
.
Pws
.
Add
(
new
PasswordCell
()
{
Password
=
pw
.
Password
,
Level
=
pw
.
Level
});
}
}
}
/// <summary>
/// 从服务器获取数据
...
...
@@ -100,8 +116,7 @@ namespace FLY.Thick.Base.UI
if
(
retData
==
null
)
{
//没有数据
//放入默认值
push_db
(
Db
);
//什么都不做
}
else
{
...
...
@@ -109,15 +124,18 @@ namespace FLY.Thick.Base.UI
var
p
=
(
distCell
.
Value
).
ToObject
<
PasswordJsonDb
>();
if
(
p
==
null
||
p
.
Pws
==
null
||
p
.
Pws
.
Count
()==
0
)
//异常
{
push_db
(
Db
);
//什么都不做
}
else
{
//只要时间与服务器的不一样,全部覆盖!!
if
(
Time
!=
distCell
.
Time
)
{
Time
=
distCell
.
Time
;
Db
=
p
;
check_db
();
Save
();
Time
=
distCell
.
Time
;
}
}
}
...
...
@@ -169,21 +187,6 @@ namespace FLY.Thick.Base.UI
public
int
GetLv
(
string
uiName
)
{
Base
.
Common
.
UiLvCell
uiLvCell
;
if
(
Db
.
UiLvs
==
null
)
{
Db
.
UiLvs
=
new
List
<
Base
.
Common
.
UiLvCell
>();
uiLvCell
=
new
Base
.
Common
.
UiLvCell
()
{
UiName
=
uiName
};
//没有,添加
Db
.
UiLvs
.
Add
(
uiLvCell
);
}
else
{
uiLvCell
=
Db
.
UiLvs
.
Find
(
c
=>
c
.
UiName
==
uiName
);
if
(
uiLvCell
==
null
)
{
...
...
@@ -195,16 +198,18 @@ namespace FLY.Thick.Base.UI
//没有,添加
Db
.
UiLvs
.
Add
(
uiLvCell
);
}
}
return
uiLvCell
.
Level
;
}
string
file_path
=
"password.json"
;
string
file_default_path
=
"default/password.default.json"
;
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
void
Apply
(
PasswordJsonDb
db
)
{
//设置jsonDist,不需要设置到本地。
//jsonDist内的参数被修改后,会推送数据出来。到时再获取。
push_db
(
db
);
}
void
Save
()
...
...
@@ -214,7 +219,7 @@ namespace FLY.Thick.Base.UI
Db
=
Db
,
Time
=
Time
};
string
json
=
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
p
);
string
json
=
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
p
,
Newtonsoft
.
Json
.
Formatting
.
Indented
);
try
{
File
.
WriteAllText
(
file_path
,
json
);
...
...
@@ -224,29 +229,41 @@ namespace FLY.Thick.Base.UI
}
}
void
LoadDefault
()
{
if
(!
File
.
Exists
(
file_default_path
))
return
;
string
json
=
File
.
ReadAllText
(
file_default_path
);
try
{
var
p
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
PasswordJsonDb
>(
json
);
DbDefault
=
p
;
}
catch
{
}
}
void
Load
()
{
LoadDefault
();
if
(!
File
.
Exists
(
file_path
))
{
default_db
();
return
;
}
string
json
=
File
.
ReadAllText
(
"password.json"
);
string
json
=
File
.
ReadAllText
(
file_path
);
try
{
var
p
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
PasswordJsonDb2
>(
json
);
Db
=
p
.
Db
;
Time
=
p
.
Time
;
check_db
();
}
catch
{
}
if
(
Db
==
null
||
Db
.
Pws
==
null
||
Db
.
Pws
.
Count
()==
0
)
//异常
{
default_db
();
}
}
}
...
...
@@ -272,24 +289,27 @@ namespace FLY.Thick.Base.UI
public
class
PasswordJsonDb2
{
/// <summary>
/// 与服务器同步参数
/// </summary>
public
PasswordJsonDb
Db
;
/// <summary>
/// 修改时间
/// </summary>
public
DateTime
Time
;
}
public
class
PasswordJsonDb
{
/// <summary>
/// 界面授权列表
/// </summary>
public
List
<
UiLvCell
>
UiLvs
;
public
List
<
UiLvCell
>
UiLvs
{
get
;
}
=
new
List
<
UiLvCell
>()
;
/// <summary>
/// 密码列表
/// </summary>
public
List
<
PasswordCell
>
Pws
;
public
List
<
PasswordCell
>
Pws
{
get
;
}
=
new
List
<
PasswordCell
>()
;
}
}
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgPwManager.xaml.cs
View file @
718601f2
...
...
@@ -119,10 +119,8 @@ namespace FLY.Thick.Base.UI
return
;
}
}
for
(
int
i
=
0
;
i
<
UiLvs
.
Count
();
i
++
)
for
each
(
var
c
in
UiLvs
)
{
var
c
=
UiLvs
[
i
];
if
(
c
.
Level
<
0
||
c
.
Level
>
10
)
{
FLY
.
ControlLibrary
.
Window_WarningTip
.
Show
(
...
...
@@ -131,11 +129,12 @@ namespace FLY.Thick.Base.UI
return
;
}
}
this
.
passwordAuthorize
.
Apply
(
new
PasswordJsonDb
()
{
Pws
=
Pws
.
ToList
(),
UiLvs
=
UiLvs
.
ToList
()
});
var
p
=
new
PasswordJsonDb
();
p
.
Pws
.
AddRange
(
Pws
);
p
.
UiLvs
.
AddRange
(
UiLvs
);
this
.
passwordAuthorize
.
Apply
(
p
);
FLY
.
ControlLibrary
.
Window_Tip
.
ShowShortTime
(
"修改成功"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment