新增角色管理功能,初步新增多语言版本功能,更新readme,v1.6.0
This commit is contained in:
35
CommonLibrary/AccountSupport/Attribute.cs
Normal file
35
CommonLibrary/AccountSupport/Attribute.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace CommonLibrary
|
||||
{
|
||||
|
||||
|
||||
/*************************************************************************************
|
||||
*
|
||||
* 说明:本来考虑使用特性来给账户标注,但是考虑到以后将要实现多语言版本,那么特性支持就
|
||||
* 不是个好选择,所以放弃了,保留了特性类
|
||||
*
|
||||
*************************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class HslDisplayAttribute : Attribute
|
||||
{
|
||||
public string m_display;
|
||||
|
||||
|
||||
public HslDisplayAttribute(string display)
|
||||
{
|
||||
m_display = display;
|
||||
}
|
||||
}
|
||||
}
|
||||
105
CommonLibrary/AccountSupport/RoleAssign.cs
Normal file
105
CommonLibrary/AccountSupport/RoleAssign.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using HslCommunication;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace CommonLibrary
|
||||
{
|
||||
|
||||
/**********************************************************************************
|
||||
*
|
||||
* 说明:本系统的角色设计
|
||||
*
|
||||
* 角色功能的设计就是针对一些特殊功能权限的账户设计的,我们希望实现对某一个功能的角色可以
|
||||
* 任意的配置账户
|
||||
*
|
||||
**********************************************************************************/
|
||||
|
||||
|
||||
|
||||
public class RoleAssign : HslCommunication.BasicFramework.SoftFileSaveBase
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
public RoleAssign()
|
||||
{
|
||||
// 添加一个初始化的测试例子
|
||||
m_roles.Add(new RoleItem()
|
||||
{
|
||||
RoleName = "审计员",
|
||||
Accounts = new List<string>()
|
||||
{
|
||||
"admin"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override Method
|
||||
|
||||
public override string ToSaveString()
|
||||
{
|
||||
string json = string.Empty;
|
||||
hybirdLock.Enter();
|
||||
json = JArray.FromObject(m_roles).ToString();
|
||||
hybirdLock.Leave();
|
||||
return json;
|
||||
}
|
||||
|
||||
public override void LoadByString(string content)
|
||||
{
|
||||
hybirdLock.Enter();
|
||||
m_roles = JArray.Parse(content).ToObject<List<RoleItem>>();
|
||||
hybirdLock.Leave();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Method
|
||||
|
||||
public bool IsAllowAccountOperate(string role,string name)
|
||||
{
|
||||
bool result = false;
|
||||
hybirdLock.Enter();
|
||||
|
||||
for (int i = 0; i < m_roles.Count; i++)
|
||||
{
|
||||
if (m_roles[i].RoleName == role)
|
||||
{
|
||||
if(m_roles[i].Accounts.Contains(name))
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hybirdLock.Leave();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Members
|
||||
|
||||
private List<RoleItem> m_roles = new List<RoleItem>();
|
||||
private SimpleHybirdLock hybirdLock = new SimpleHybirdLock();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
public class RoleItem
|
||||
{
|
||||
public string RoleName { get; set; }
|
||||
public List<string> Accounts { get; set; } = new List<string>();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return RoleName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
|
||||
namespace CommonLibrary
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
120
CommonLibrary/BasicSupport/FormGetInputString.resx
Normal file
120
CommonLibrary/BasicSupport/FormGetInputString.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -47,6 +47,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AccountSupport\Attribute.cs" />
|
||||
<Compile Include="AccountSupport\FormAccountManage.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -65,6 +66,7 @@
|
||||
<Compile Include="AccountSupport\FormPasswordModify.designer.cs">
|
||||
<DependentUpon>FormPasswordModify.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="AccountSupport\RoleAssign.cs" />
|
||||
<Compile Include="AccountSupport\ServerAccount.cs" />
|
||||
<Compile Include="AccountSupport\UserAccount.cs" />
|
||||
<Compile Include="BasicSupport\FormSuper.cs">
|
||||
@@ -86,6 +88,9 @@
|
||||
<DependentUpon>FormVersionControl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BasicSupport\SoftSettings.cs" />
|
||||
<Compile Include="LocalizationSupport\ChineseLocalization.cs" />
|
||||
<Compile Include="LocalizationSupport\EnglishLocalization.cs" />
|
||||
<Compile Include="LocalizationSupport\Localization.cs" />
|
||||
<Compile Include="ProtocolSupport\CommonProtocol.cs" />
|
||||
<Compile Include="ProtocolSupport\CustomerCode.cs" />
|
||||
<Compile Include="OrderSupport\ClassGoods.cs" />
|
||||
@@ -117,6 +122,7 @@
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
47
CommonLibrary/LocalizationSupport/ChineseLocalization.cs
Normal file
47
CommonLibrary/LocalizationSupport/ChineseLocalization.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace CommonLibrary
|
||||
{
|
||||
|
||||
public class ChineseLocalization : ILocalization
|
||||
{
|
||||
public string FormateDateTime { get; set; } = "yyyy-MM-dd HH:mm:ss";
|
||||
public string ButtonEnsure { get; set; } = "确认";
|
||||
|
||||
|
||||
|
||||
|
||||
public string AccountSelect { get; set; } = "选择";
|
||||
|
||||
public string AccountName { get; set; } = "用户名";
|
||||
public string AccountAlias { get; set; } = "别名";
|
||||
public string AccountPassword { get; set; } = "密码";
|
||||
public string AccountFactory { get; set; } = "部门"; // 可以在此处修改为部门
|
||||
public string AccountGrade { get; set; } = "权限";
|
||||
public string AccountRegisterTime { get; set; } = "注册时间";
|
||||
public string AccountLoginEnable { get; set; } = "是否允许登录";
|
||||
public string AccountForbidMessage { get; set; } = "禁止登录原因";
|
||||
public string AccountLoginFrequency { get; set; } = "总登录次数";
|
||||
public string AccountLastLoginTime { get; set; } = "上次登录时间";
|
||||
public string AccountLastLoginIpAddress { get; set; } = "上次登录地址";
|
||||
public string AccountLoginFailedCount { get; set; } = "登录失败次数";
|
||||
public string AccountLastLoginWay { get; set; } = "上次登录方式";
|
||||
public string AccountPortrait { get; set; } = "头像";
|
||||
public string AccountDetails { get; set; } = "账户详细信息";
|
||||
|
||||
|
||||
#region 配置相关
|
||||
|
||||
public string SettingsText { get; set; } = "配置系统的参数";
|
||||
public string SettingsSystem { get; set; } = "系统相关";
|
||||
public string SettingsGeneral { get; set; } = "常规配置";
|
||||
public string SettingsAccountFactory { get { return "配置" + AccountFactory + "信息"; } set { } }
|
||||
public string SettingsTrustClient { get; set; } = "信任客户端列表";
|
||||
public string SettingsRoleAssign { get; set; } = "配置角色信息";
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
47
CommonLibrary/LocalizationSupport/EnglishLocalization.cs
Normal file
47
CommonLibrary/LocalizationSupport/EnglishLocalization.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace CommonLibrary
|
||||
{
|
||||
public class EnglishLocalization : ILocalization
|
||||
{
|
||||
public string FormateDateTime { get; set; } = "yyyy/MM/dd HH:mm:ss";
|
||||
public string ButtonEnsure { get; set; } = "Sure";
|
||||
|
||||
|
||||
|
||||
|
||||
public string AccountSelect { get; set; } = "Select";
|
||||
|
||||
public string AccountName { get; set; } = "Name";
|
||||
public string AccountAlias { get; set; } = "Alias";
|
||||
public string AccountPassword { get; set; } = "Password";
|
||||
public string AccountFactory { get; set; } = "Factory"; // 可以在此处修改为部门
|
||||
public string AccountGrade { get; set; } = "Authority";
|
||||
public string AccountRegisterTime { get; set; } = "Register Time";
|
||||
public string AccountLoginEnable { get; set; } = "Login Enable";
|
||||
public string AccountForbidMessage { get; set; } = "Forbid Reason";
|
||||
public string AccountLoginFrequency { get; set; } = "Login Totle";
|
||||
public string AccountLastLoginTime { get; set; } = "Login Last Time";
|
||||
public string AccountLastLoginIpAddress { get; set; } = "Login Last Ip";
|
||||
public string AccountLoginFailedCount { get; set; } = "Login Failed Totle";
|
||||
public string AccountLastLoginWay { get; set; } = "Login Last Way";
|
||||
public string AccountPortrait { get; set; } = "Portrait";
|
||||
public string AccountDetails { get; set; } = "Account Details";
|
||||
|
||||
|
||||
#region 配置相关
|
||||
|
||||
public string SettingsText { get; set; } = "System parameters settings";
|
||||
public string SettingsSystem { get; set; } = "System Settings";
|
||||
public string SettingsGeneral { get; set; } = "General";
|
||||
public string SettingsAccountFactory { get { return AccountFactory + " List"; } set { } }
|
||||
public string SettingsTrustClient { get; set; } = "Trust Client";
|
||||
public string SettingsRoleAssign { get; set; } = "Role Assign";
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
90
CommonLibrary/LocalizationSupport/Localization.cs
Normal file
90
CommonLibrary/LocalizationSupport/Localization.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace CommonLibrary
|
||||
{
|
||||
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* 说明:本地化策略机制,优先完成中文版适配
|
||||
*
|
||||
*******************************************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// 整个软件系统的本地化策略
|
||||
/// </summary>
|
||||
public static class UserLocalization
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认的语言选项
|
||||
/// </summary>
|
||||
public static ILocalization Localization = new ChineseLocalization();
|
||||
|
||||
/// <summary>
|
||||
/// 设置系统的语言选项
|
||||
/// </summary>
|
||||
/// <param name="language">语言名称</param>
|
||||
public static void SettingLocalization(string language)
|
||||
{
|
||||
if(language.ToLower() == "chinese")
|
||||
{
|
||||
Localization = Chinese;
|
||||
}
|
||||
else
|
||||
{
|
||||
Localization = English;
|
||||
}
|
||||
}
|
||||
|
||||
private static ILocalization Chinese = new ChineseLocalization();
|
||||
private static ILocalization English = new EnglishLocalization();
|
||||
}
|
||||
|
||||
public interface ILocalization
|
||||
{
|
||||
string FormateDateTime { get; set; }
|
||||
|
||||
string ButtonEnsure { get; set; }
|
||||
|
||||
|
||||
#region 账户相关
|
||||
|
||||
|
||||
string AccountSelect { get; set; }
|
||||
string AccountName { get; set; }
|
||||
string AccountAlias { get; set; }
|
||||
string AccountPassword { get; set; }
|
||||
string AccountFactory { get; set; }
|
||||
string AccountGrade { get; set; }
|
||||
string AccountRegisterTime { get; set; }
|
||||
string AccountLoginEnable { get; set; }
|
||||
string AccountForbidMessage { get; set; }
|
||||
string AccountLoginFrequency { get; set; }
|
||||
string AccountLastLoginTime { get; set; }
|
||||
string AccountLastLoginIpAddress { get; set; }
|
||||
string AccountLoginFailedCount { get; set; }
|
||||
string AccountLastLoginWay { get; set; }
|
||||
string AccountPortrait { get; set; }
|
||||
string AccountDetails { get; set; }
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 配置相关
|
||||
|
||||
string SettingsText { get; set; }
|
||||
string SettingsSystem { get; set; }
|
||||
string SettingsGeneral { get; set; }
|
||||
string SettingsAccountFactory { get; set; }
|
||||
string SettingsTrustClient { get; set; }
|
||||
string SettingsRoleAssign { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -44,7 +44,7 @@ namespace CommonLibrary
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
SoftBasic.FrameworkVersion = new SystemVersion("1.5.6");
|
||||
SoftBasic.FrameworkVersion = new SystemVersion("1.6.0");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,9 @@ namespace CommonLibrary
|
||||
public static NetHandle 上传信任客户端 { get; } = new NetHandle(1, 1, 00020);
|
||||
public static NetHandle 请求一般配置 { get; } = new NetHandle(1, 1, 00021);
|
||||
public static NetHandle 上传一般配置 { get; } = new NetHandle(1, 1, 00022);
|
||||
public static NetHandle 请求角色配置 { get; } = new NetHandle(1, 1, 00023);
|
||||
public static NetHandle 上传角色配置 { get; } = new NetHandle(1, 1, 00024);
|
||||
public static NetHandle 检查角色权限 { get; } = new NetHandle(1, 1, 00025);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user