EchoTex_Payroll/HRM.BO/Common/SystemParameter.cs

262 lines
6.2 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Threading.Tasks;
using System.Data;
using Ease.Core.Model;
using System.IO;
namespace HRM.BO
{
public class SystemConfigaration : AuditTrailBase
{
#region Constructor
public SystemConfigaration()
{
_node = string.Empty;
_value = string.Empty;
_parentID = 0;
_type = EnumConfigurationType.None;
}
#endregion
#region Properties
#region Node : string
private string _node;
public string Node
{
get { return _node; }
set
{
_node = value;
}
}
#endregion
#region Value : string
private string _value;
public string Value
{
get { return _value; }
set
{
_value = value;
}
}
#endregion
#region ParentID : ID
private int _parentID;
public int ParentID
{
get { return _parentID; }
set
{
_parentID = value;
}
}
#endregion
#region Type : EnumConfigurationType
private EnumConfigurationType _type;
public EnumConfigurationType Type
{
get { return _type; }
set
{
_type = value;
}
}
#endregion
#region ConfigurationAttribute
public class ConfigurationAttribute : ObjectTemplate
{
#region Constructor
public ConfigurationAttribute()
{
_configurationID = 0;
_value = "";
_attributeName = "";
}
public ConfigurationAttribute(int configurationID)
{
_configurationID = configurationID;
_value = "";
_attributeName = "";
}
#endregion
#region Property ParentID : ID
private int _configurationID;
public int ConfigurationID
{
get { return _configurationID; }
set
{
_configurationID = value;
}
}
#endregion
#region AttributeName : string
private string _attributeName;
public string AttributeName
{
get { return _attributeName; }
set
{
_attributeName = value;
}
}
#endregion
#region Value : String
private string _value;
public string Value
{
get { return _value; }
set
{
_value = value;
}
}
#endregion
}
#endregion
#region ConfigurationAttributes
public class ConfigurationAttributes : List<ConfigurationAttribute>
{
#region Constructor
public ConfigurationAttributes()
{
}
public ConfigurationAttribute GetItemByParentID(int configurationID)
{
return this.Find(delegate (ConfigurationAttribute item) { return item.ConfigurationID == configurationID; });
}
public void Add(int configurationId, string nodeName, string svalue)
{
ConfigurationAttribute att = new ConfigurationAttribute();
att.Value = svalue;
att.AttributeName = nodeName;
att.SetID(this.Count + 1);
this.Add(att);
}
public string GetAttributeValue(string attributeName)
{
foreach (ConfigurationAttribute oItem in this)
{
if (oItem.AttributeName.ToLower() == attributeName.ToLower())
{
return oItem.Value == null ? "" : oItem.Value;
}
}
return "";
}
#endregion
}
#endregion
#region Property ConfigurationAttributes : ConfigurationAttributes
private ConfigurationAttributes _configurationAttributes;
public ConfigurationAttributes ConAttributes
{
get
{
if (_configurationAttributes == null)
_configurationAttributes = new ConfigurationAttributes();
return _configurationAttributes;
}
}
#endregion
#endregion
#region Functions
private void DolowerCase(List<SystemConfigaration> configs)
{
foreach (SystemConfigaration item in configs)
{
item.Node = item.Node.ToLower();
foreach (ConfigurationAttribute att in item.ConAttributes)
{
att.AttributeName = att.AttributeName.ToLower();
}
}
}
#endregion
}
public class TreeNode
{
public TreeNode()
{
Nodes = new List<TreeNode>();
}
public string Text { get; set; }
public object Tag { get; set; }
public List<TreeNode> Nodes { get; set; }
}
public interface ISystemConfigaration
{
List<SystemConfigaration> LoadXMLtoObject(EnumConfigurationType type, System.IO.Stream streamFile);
List<SystemConfigaration> Get(EnumConfigurationType configType);
List<SystemConfigaration.ConfigurationAttribute> GetAttributesByParentID(int nParentID);
void Save(List<SystemConfigaration> configurations, EnumConfigurationType type);
List<Role.RolePermission> getMenuesFromConfig();
List<SystemConfigaration> GetAllChildrenByParentNode(EnumConfigurationType type, string parentNode);
string GetXMLFile(EnumConfigurationType type);
object GetconfigValue(EnumConfigurationType type, string firstParent, string secondParent);
}
}