重构代码,移动了些文件,整理了一些代码的位置

This commit is contained in:
dathlin
2017-09-15 22:41:53 +08:00
parent cafc3e065d
commit 6e7da51f2f
15 changed files with 122 additions and 47 deletions

View File

@@ -55,22 +55,22 @@
<Compile Include="FormDownloading.Designer.cs">
<DependentUpon>FormDownloading.cs</DependentUpon>
</Compile>
<Compile Include="FormLogView.cs">
<Compile Include="LogsSupport\FormLogView.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormLogView.Designer.cs">
<Compile Include="LogsSupport\FormLogView.Designer.cs">
<DependentUpon>FormLogView.cs</DependentUpon>
</Compile>
<Compile Include="FormRegisterAccount.cs">
<Compile Include="AccountSupport\FormRegisterAccount.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormRegisterAccount.Designer.cs">
<Compile Include="AccountSupport\FormRegisterAccount.Designer.cs">
<DependentUpon>FormRegisterAccount.cs</DependentUpon>
</Compile>
<Compile Include="FormUpdateRemote.cs">
<Compile Include="SoftUpdateSupport\FormUpdateRemote.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormUpdateRemote.Designer.cs">
<Compile Include="SoftUpdateSupport\FormUpdateRemote.Designer.cs">
<DependentUpon>FormUpdateRemote.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -81,15 +81,16 @@
<EmbeddedResource Include="FormDownloading.resx">
<DependentUpon>FormDownloading.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormLogView.resx">
<EmbeddedResource Include="LogsSupport\FormLogView.resx">
<DependentUpon>FormLogView.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormRegisterAccount.resx">
<EmbeddedResource Include="AccountSupport\FormRegisterAccount.resx">
<DependentUpon>FormRegisterAccount.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormUpdateRemote.resx">
<EmbeddedResource Include="SoftUpdateSupport\FormUpdateRemote.resx">
<DependentUpon>FormUpdateRemote.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -19,28 +19,28 @@ namespace ClientsLibrary
/// <summary>
/// 一个通用的用户客户端类
/// 一个通用的用户客户端类, 包含了一些静态的资源
/// </summary>
public class UserClient
{
/// <summary>
/// 客户端需要进行本地存储的信息日志
/// </summary>
public static JsonSettings JsonSettings = new JsonSettings();
/// <summary>
/// 本软件的当前版本,用来验证更新的关键依据
/// </summary>
public static SystemVersion CurrentVersion { get; } = new SystemVersion("1.0.0.170914");
/// <summary>
/// 服务器的IP地址默认为127.0.0.1可用于单机调试云服务器端117.48.203.204
/// </summary>
public static string ServerIp { get; } = "127.0.0.1";//用于测试的云服务器地址
/// <summary>
/// 系统的分厂信息
/// </summary>
@@ -48,13 +48,12 @@ namespace ClientsLibrary
/// <summary>
/// 所有版本更新信息的对象
/// </summary>
public static List<VersionInfo> HistoryVersions { get; } = new List<VersionInfo>
{
//写入所有的历史版本信息,这样就能在更新日志的界面查看到信息
// 写入所有的历史版本信息,这样就能在更新日志的界面查看到信息
new VersionInfo()
{
VersionNum=new SystemVersion("1.0.0"),
@@ -67,8 +66,6 @@ namespace ClientsLibrary
};
/// <summary>
/// 设置或获取系统的公告
/// </summary>
@@ -120,7 +117,7 @@ namespace ClientsLibrary
{
if (e.ExceptionObject is Exception ex)
{
//使用UDP方法传送会服务器
// 使用TCP方法传送会服务器
string info = HslCommunication.LogNet.LogNetManagment.GetSaveStringFromException(null, ex);
Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode., info);
}

View File

@@ -17,6 +17,14 @@ namespace ClientsLibrary
/// </summary>
public class UserPortrait
{
#region Constructor
/// <summary>
/// 实例化一个新的头像管理类对象
/// </summary>
/// <param name="filePath">头像存储的文件夹路径</param>
/// <param name="loadPic">加载图片的方法</param>
/// <param name="disPic">加载前的操作</param>
public UserPortrait(string filePath, Action<string> loadPic, Action disPic)
{
if (!System.IO.Directory.Exists(filePath))
@@ -28,11 +36,13 @@ namespace ClientsLibrary
DisPic = disPic;
}
private string FileSavePath { get; set; }
#endregion
private Action<string> LoadPic = null;
private Action DisPic = null;
#region Change Portrait
/// <summary>
/// 点击更改头像后的操作打开头像选择对话框获取到2种分辨率的头像然后进行上传
/// </summary>
public void ChangePortrait()
{
using (FormPortraitSelect fps = new FormPortraitSelect())
@@ -68,7 +78,13 @@ namespace ClientsLibrary
}
#endregion
#region Download Portraint
/// <summary>
/// 加载头像信息,检查本地是否有相应的文件,没有则向服务器请求下载新的头像,然后加载,应放到线程池中执行
/// </summary>
public void DownloadUserPortraint()
{
string path = FileSavePath;
@@ -109,6 +125,10 @@ namespace ClientsLibrary
}
}
/// <summary>
/// 下载小尺寸的头像并使用委托加载它
/// </summary>
/// <param name="path"></param>
public void DownloadUserPortraint(string path)
{
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode., UserClient.UserAccount.UserName);
@@ -124,6 +144,9 @@ namespace ClientsLibrary
}
}
/// <summary>
/// 下载大尺寸的头像并打开它,该方法适合线程池
/// </summary>
public void ThreadPoolDownloadSizeLarge()
{
string path = FileSavePath;
@@ -136,11 +159,31 @@ namespace ClientsLibrary
string path32 = path + @"\" + PortraitSupport.LargePortrait;
System.IO.File.WriteAllBytes(path32, data);
System.Diagnostics.Process.Start(path32);
data = null;
}
}
Thread.Sleep(1000);
}
#endregion
#region Private Members
/// <summary>
/// 文件的路径
/// </summary>
private string FileSavePath { get; set; }
/// <summary>
/// 加载图片的操作
/// </summary>
private Action<string> LoadPic = null;
/// <summary>
/// 加载图片前的操作
/// </summary>
private Action DisPic = null;
#endregion
}
}

View File

@@ -11,6 +11,8 @@ namespace CommonLibrary
/// </summary>
public class UserAccount
{
#region Public Members
/// <summary>
/// 用户名称,该名称唯一
/// </summary>
@@ -63,6 +65,11 @@ namespace CommonLibrary
/// 上次登录系统的方式有winform版wpf版web版
/// </summary>
public string LastLoginWay { get; set; } = string.Empty;
#endregion
#region Static Members
/// <summary>
/// 用于存储和传送的名称
/// </summary>
@@ -76,22 +83,14 @@ namespace CommonLibrary
/// </summary>
public static string LoginWayText { get { return "LoginWay"; } }
/// <summary>
/// 深度拷贝当前的账户信息
/// 登录系统的唯一设备ID
/// </summary>
/// <typeparam name="T">返回的类型,应该为继承后的类型</typeparam>
/// <returns>新的对象</returns>
public T DeepCopy<T>() where T : UserAccount
{
return JObject.FromObject(this).ToObject<T>();
}
/// <summary>
/// 获取账号的用户名
/// </summary>
/// <returns></returns>
public override string ToString()
{
return UserName;
}
public static string DeviceUniqueID { get { return "DeviceUniqueID"; } }
#endregion
#region Public Method
/// <summary>
/// 获取本账号的JSON字符串用于在网络中数据传输
/// </summary>
@@ -100,10 +99,34 @@ namespace CommonLibrary
{
return JObject.FromObject(this).ToString();
}
/// <summary>
/// 深度拷贝当前的账户信息
/// </summary>
/// <typeparam name="T">返回的类型,应该为继承后的类型</typeparam>
/// <returns>新的对象</returns>
public T DeepCopy<T>() where T : UserAccount
{
return JObject.FromObject(this).ToObject<T>();
}
#endregion
#region Override Method
/// <summary>
/// 获取账号的用户名
/// </summary>
/// <returns></returns>
public override string ToString()
{
return UserName;
}
#endregion
}
/// <summary>
/// 账户的等级
/// </summary>

View File

@@ -17,7 +17,11 @@ namespace CommonLibrary
/// </summary>
public const string LargePortrait = "Size_300_.png";
/// <summary>
/// 获取小尺寸的头像文件
/// </summary>
/// <param name="dirPath">目录</param>
/// <returns>文件的完整路径</returns>
public static string GetSmallPortraitFileName(string dirPath)
{
string[] files = Directory.GetFiles(dirPath);
@@ -30,6 +34,12 @@ namespace CommonLibrary
}
return string.Empty;
}
/// <summary>
/// 获取大尺寸的头像文件
/// </summary>
/// <param name="dirPath">目录</param>
/// <returns>文件的完整路径</returns>
public static string GetLargePortraitFileName(string dirPath)
{
string[] files = Directory.GetFiles(dirPath);

View File

@@ -211,7 +211,8 @@ namespace 软件系统客户端模版
{
{ UserAccount.UserNameText, new JValue(textBox_userName.Text) },
{ UserAccount.PasswordText, new JValue(textBox_password.Text) },
{ UserAccount.LoginWayText, new JValue("winform") }
{ UserAccount.LoginWayText, new JValue("winform") },
{ UserAccount.DeviceUniqueID, new JValue(UserClient.JsonSettings.SystemInfo) }
};
result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode., json.ToString());
if (result.IsSuccess)