Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
ACSingleStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit ffd71118
由
LN
编写于
2019-12-28 10:39:58 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
615ba250
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
209 行增加
和
5 行删除
ProCopyClient/App.config
ProCopyClient/ConfigAppSettings.cs
ProCopyClient/FrmMain.Designer.cs
ProCopyClient/FrmMain.cs
ProCopyClient/ProCopyClient.csproj
ProCopyClient/App.config
查看文件 @
ffd7111
...
@@ -3,4 +3,8 @@
...
@@ -3,4 +3,8 @@
<
startup
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.6.1"
/>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.6.1"
/>
</
startup
>
</
startup
>
<
appSettings
>
<
add
key
=
"ProName"
value
=
"ACSingleStore"
/>
</
appSettings
>
</
configuration
>
</
configuration
>
\ No newline at end of file
\ No newline at end of file
ProCopyClient/ConfigAppSettings.cs
0 → 100644
查看文件 @
ffd7111
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Configuration
;
using
System.Threading
;
using
System.Xml
;
using
System.Windows.Forms
;
namespace
ProCopyClient
{
public
class
ConfigAppSettings
{
public
static
string
GetValue
(
string
keyStr
,
string
storeStr
)
{
string
key
=
keyStr
+
storeStr
;
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
return
GetValue
(
keyStr
);
}
else
{
return
config
.
AppSettings
.
Settings
[
key
].
Value
;
}
}
public
static
decimal
GetNumValue
(
string
keyStr
,
string
storeStr
)
{
string
key
=
keyStr
+
storeStr
;
decimal
a
=
0
;
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
return
GetNumValue
(
keyStr
);
}
else
{
{
Decimal
.
TryParse
(
config
.
AppSettings
.
Settings
[
key
].
Value
,
out
a
);
}
}
return
a
;
}
public
static
int
GetIntValue
(
string
keyStr
,
string
storeStr
)
{
string
key
=
keyStr
+
storeStr
;
int
a
=
0
;
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
return
GetIntValue
(
keyStr
);
}
else
{
{
Int32
.
TryParse
(
config
.
AppSettings
.
Settings
[
key
].
Value
,
out
a
);
}
}
return
a
;
}
public
static
string
GetValue
(
string
key
)
{
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
return
""
;
}
else
{
return
config
.
AppSettings
.
Settings
[
key
].
Value
;
}
}
public
static
decimal
GetNumValue
(
string
key
)
{
decimal
a
=
0
;
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
return
a
;
}
else
{
{
Decimal
.
TryParse
(
config
.
AppSettings
.
Settings
[
key
].
Value
,
out
a
);
}
}
return
a
;
}
public
static
int
GetIntValue
(
string
key
)
{
int
a
=
0
;
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
return
a
;
}
else
{
{
Int32
.
TryParse
(
config
.
AppSettings
.
Settings
[
key
].
Value
,
out
a
);
}
}
return
a
;
}
public
static
void
SaveValue
(
string
key
,
int
value
)
{
SaveValue
(
key
,
value
.
ToString
());
}
public
static
void
SaveValue
(
string
key
,
string
value
)
{
try
{
if
(
key
.
Equals
(
""
)
||
value
.
Equals
(
""
))
{
//return;
}
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
SetValue
(
key
,
value
);
}
else
{
UpdateConfig
(
key
,
value
);
}
}
catch
(
Exception
ex
)
{
//LogUtil.error(LOGGER, "SaveValue保存配置出错:AppKey=" + key + ",AppValue=" + value + "," + ex.StackTrace);
}
}
/// <summary>
/// 更新配置文件信息
/// </summary>
/// <param name="name">配置文件字段名称</param>
/// <param name="Xvalue">值</param>
private
static
void
UpdateConfig
(
string
name
,
string
Xvalue
)
{
try
{
XmlDocument
doc
=
new
XmlDocument
();
doc
.
Load
(
Application
.
ExecutablePath
+
".config"
);
XmlNode
node
=
doc
.
SelectSingleNode
(
@"//add[@key='"
+
name
+
"']"
);
XmlElement
ele
=
(
XmlElement
)
node
;
ele
.
SetAttribute
(
"value"
,
Xvalue
);
doc
.
Save
(
Application
.
ExecutablePath
+
".config"
);
}
catch
(
Exception
ex
)
{
// LogUtil.error(LOGGER, "UpdateConfig保存配置出错:name=" + name + ",Xvalue=" + Xvalue + "," + ex.StackTrace);
}
}
///<summary>
///向.config文件的appKey结写入信息AppValue 保存设置
///</summary>
///<param name="AppKey">节点名</param>
///<param name="AppValue">值</param>
private
static
void
SetValue
(
String
AppKey
,
String
AppValue
)
{
try
{
XmlDocument
xDoc
=
new
XmlDocument
();
xDoc
.
Load
(
System
.
Windows
.
Forms
.
Application
.
ExecutablePath
+
".config"
);
XmlNode
xNode
;
XmlElement
xElem1
;
XmlElement
xElem2
;
xNode
=
xDoc
.
SelectSingleNode
(
"//appSettings"
);
xElem1
=
(
XmlElement
)
xNode
.
SelectSingleNode
(
"//add[@key='"
+
AppKey
+
"']"
);
if
(
xElem1
!=
null
)
xElem1
.
SetAttribute
(
"value"
,
AppValue
);
else
{
xElem2
=
xDoc
.
CreateElement
(
"add"
);
xElem2
.
SetAttribute
(
"key"
,
AppKey
);
xElem2
.
SetAttribute
(
"value"
,
AppValue
);
xNode
.
AppendChild
(
xElem2
);
}
xDoc
.
Save
(
System
.
Windows
.
Forms
.
Application
.
ExecutablePath
+
".config"
);
}
catch
(
Exception
ex
)
{
// LogUtil.error(LOGGER, "SetValue保存配置出错:AppKey=" + AppKey + ",AppValue=" + AppValue + "," + ex.StackTrace);
}
}
}
}
ProCopyClient/FrmMain.Designer.cs
查看文件 @
ffd7111
...
@@ -100,6 +100,7 @@
...
@@ -100,6 +100,7 @@
this
.
Name
=
"FrmMain"
;
this
.
Name
=
"FrmMain"
;
this
.
StartPosition
=
System
.
Windows
.
Forms
.
FormStartPosition
.
CenterScreen
;
this
.
StartPosition
=
System
.
Windows
.
Forms
.
FormStartPosition
.
CenterScreen
;
this
.
Text
=
"客户端复制"
;
this
.
Text
=
"客户端复制"
;
this
.
Load
+=
new
System
.
EventHandler
(
this
.
FrmMain_Load
);
this
.
ResumeLayout
(
false
);
this
.
ResumeLayout
(
false
);
this
.
PerformLayout
();
this
.
PerformLayout
();
...
...
ProCopyClient/FrmMain.cs
查看文件 @
ffd7111
...
@@ -29,17 +29,18 @@ namespace ProCopyClient
...
@@ -29,17 +29,18 @@ namespace ProCopyClient
return
;
return
;
}
}
string
proName
=
txtProName
.
Text
.
Trim
();
string
proName
=
txtProName
.
Text
.
Trim
();
ConfigAppSettings
.
SaveValue
(
"ProName"
,
proName
);
string
date
=
DateTime
.
Now
.
ToString
(
"yyyyMMdd"
);
string
date
=
DateTime
.
Now
.
ToString
(
"yyyyMMdd"
);
string
leftPath
=
Application
.
StartupPath
+
"\\"
+
date
+
"-"
+
proName
+
"L-更新"
+
"\\"
;
string
leftPath
=
Application
.
StartupPath
+
"\\"
+
date
+
"-"
+
proName
+
"L-更新"
+
"\\"
;
string
rightPath
=
Application
.
StartupPath
+
"\\"
+
date
+
"-"
+
proName
+
"R-更新"
+
"\\"
;
string
rightPath
=
Application
.
StartupPath
+
"\\"
+
date
+
"-"
+
proName
+
"R-更新"
+
"\\"
;
if
(
Directory
.
Exists
(
leftPath
))
if
(
Directory
.
Exists
(
leftPath
))
{
{
Directory
.
Delete
(
leftPath
,
true
);
Directory
.
Delete
(
leftPath
,
true
);
}
}
if
(
Directory
.
Exists
(
rightPath
))
if
(
Directory
.
Exists
(
rightPath
))
{
{
Directory
.
Delete
(
rightPath
,
true
);
Directory
.
Delete
(
rightPath
,
true
);
}
}
Directory
.
CreateDirectory
(
leftPath
);
Directory
.
CreateDirectory
(
leftPath
);
Directory
.
CreateDirectory
(
rightPath
);
Directory
.
CreateDirectory
(
rightPath
);
...
@@ -89,8 +90,9 @@ namespace ProCopyClient
...
@@ -89,8 +90,9 @@ namespace ProCopyClient
return
;
return
;
}
}
string
proName
=
txtProName
.
Text
.
Trim
();
string
proName
=
txtProName
.
Text
.
Trim
();
ConfigAppSettings
.
SaveValue
(
"ProName"
,
proName
);
string
date
=
DateTime
.
Now
.
ToString
(
"yyyyMMdd"
);
string
date
=
DateTime
.
Now
.
ToString
(
"yyyyMMdd"
);
string
leftPath
=
Application
.
StartupPath
+
"\\"
+
date
+
"-"
+
proName
+
"-更新"
+
"\\"
;
string
leftPath
=
Application
.
StartupPath
+
"\\"
+
date
+
"-"
+
proName
+
"-更新"
+
"\\"
;
if
(
Directory
.
Exists
(
leftPath
))
if
(
Directory
.
Exists
(
leftPath
))
...
@@ -133,5 +135,11 @@ namespace ProCopyClient
...
@@ -133,5 +135,11 @@ namespace ProCopyClient
{
{
this
.
Close
();
this
.
Close
();
}
}
private
void
FrmMain_Load
(
object
sender
,
EventArgs
e
)
{
txtProName
.
Text
=
ConfigAppSettings
.
GetValue
(
"ProName"
);
}
}
}
}
}
ProCopyClient/ProCopyClient.csproj
查看文件 @
ffd7111
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data.DataSetExtensions" />
...
@@ -46,6 +47,7 @@
...
@@ -46,6 +47,7 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile Include="ConfigAppSettings.cs" />
<Compile Include="FrmMain.cs">
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
<SubType>Form</SubType>
</Compile>
</Compile>
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论