using System; using Ease.Core.Model; using Ease.Core.DataAccess; using Ease.Core.Utility; using System.Collections.Generic; using HRM.BO; using System.Data; using System.Xml; using System.Linq; using System.IO; namespace HRM.DA { #region Configaration Service public class SystemConfigarationService : ServiceTemplate, ISystemConfigaration { int _rolePermissinID = 0; private void MapChildObject(SystemConfigaration.ConfigurationAttribute ca, DataReader dr) { ca.ConfigurationID = dr.GetInt32("ParentID").Value; ca.AttributeName = dr.GetString("AttributeName"); ca.Value = dr.GetString("Value"); base.SetObjectID(ca, dr.GetInt32("AttributeID").Value); base.SetObjectState(ca, Ease.Core.ObjectState.Saved); } private SystemConfigaration.ConfigurationAttribute CreateChildObject(DataReader dr) { SystemConfigaration.ConfigurationAttribute ca = new SystemConfigaration.ConfigurationAttribute(); MapChildObject(ca, dr); return ca; } private void FillChildren(SystemConfigaration parent, DataReader dr) { while (dr.Read()) { SystemConfigaration.ConfigurationAttribute item = this.CreateChildObject(dr); parent.ConAttributes.Add(item); } } private List CreateAttribures(DataReader dr) { List oatt = new List(); while (dr.Read()) { SystemConfigaration.ConfigurationAttribute item = this.CreateChildObject(dr); oatt.Add(item); } return oatt; } private void MapObject(SystemConfigaration configuration, DataReader dr) { base.SetObjectID(configuration, dr.GetInt32("ConfigurationId").Value); configuration.Node = dr.GetString("Node"); configuration.Value = dr.GetString("Value"); configuration.Type = (EnumConfigurationType)dr.GetInt16("Type").Value; configuration.CreatedBy = dr.GetInt32("CreatedBy").Value; configuration.CreatedDate = dr.GetDateTime("CreatedDate").Value; configuration.ModifiedBy = dr.GetInt32("ModifiedBy"); configuration.ModifiedDate = dr.GetDateTime("ModifiedDate"); configuration.ParentID = dr.GetInt32("ParentID", 0); base.SetObjectState(configuration, Ease.Core.ObjectState.Saved); } protected override T CreateObject(DataReader dr) { SystemConfigaration configuration = new SystemConfigaration(); MapObject(configuration, dr); return configuration as T; } public void Save(List configurations, EnumConfigurationType type) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); //Delete All Configuration and its Attributes SystemConfigarationDA.DeleteAll(tc, type); int Id = tc.GenerateID("Configuration", "ConfigurationID"); Id = Id + 2000; int configattID = tc.GenerateID("ConfigurationAttribute", "AttributeID"); foreach (SystemConfigaration config in configurations) { this.UpdateParent(config.ID, Id, configurations); config.SetObjectID(Id); Id = Id + 1; } foreach (SystemConfigaration config in configurations) { //Insert Configuration config.Type = type; SystemConfigarationDA.Insert(tc, config); //Insert Children foreach (var item in config.ConAttributes) { item.ConfigurationID = config.ID; configattID = configattID + 1; item.ID = configattID; SystemConfigarationDA.Insert(tc, item); } } if (type == EnumConfigurationType.Menu) { SystemConfigarationDA.UpdateRolePermission(tc); } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } private void UpdateParent(int oldId, int currentID, List configurations) { foreach (SystemConfigaration config in configurations) { if (config.ParentID == oldId) { config.ParentID = currentID; } } } public void Delete(int id) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); SystemConfigarationDA.Delete(tc, id); tc.End(); //CacheInfo.ClearCache(typeof(CountryService).FullName); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public SystemConfigaration Get(int id) { SystemConfigaration configuration = null; ; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SystemConfigarationDA.Get(tc, id)); configuration = this.loadItem(dr); dr.Close(); if (configuration != null && configuration.ID != null && configuration.ID != 0) { dr = new DataReader(SystemConfigarationDA.GetChildren(tc, id)); FillChildren(configuration, dr); dr.Close(); } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return configuration; } SystemConfigaration loadItem(DataReader dr) { SystemConfigaration configuration = null; try { if (dr.Read()) configuration = this.CreateObject(dr); } catch (Exception e) { #region Handle Exception throw new ServiceException(e.Message, e); #endregion } return configuration; } public List GetAllParent() { List configurations = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SystemConfigarationDA.GetAllParent(tc)); configurations = this.CreateObjects(dr); dr.Close(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return configurations; } public List GetAllParent(EnumConfigurationType type) { #region Cache Header List configurations = new List(); #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SystemConfigarationDA.GetAllParent(tc, type)); configurations = this.CreateObjects(dr); dr.Close(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return configurations; } public List GetAllChildrens() { SystemConfigaration.ConfigurationAttributes items = new SystemConfigaration.ConfigurationAttributes(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SystemConfigarationDA.GetAllChildrens(tc)); while (dr.Read()) { SystemConfigaration.ConfigurationAttribute ca = new SystemConfigaration.ConfigurationAttribute(); MapChildObject(ca, dr); items.Add(ca); } dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return items; } public List Get(EnumConfigurationType configType) { //List configurations = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SystemConfigarationDA.Get(tc, configType)); var configurations = this.CreateObjects(dr); dr.Close(); dr = new DataReader(SystemConfigarationDA.GetChildrenbyType(tc, configType)); var atrr = this.CreateAttribures(dr); dr.Close(); configurations.ForEach(x => { var atr = atrr.FindAll(a => a.ConfigurationID == x.ID); if (atr != null) { x.ConAttributes.AddRange(atr); } }); //foreach (SystemConfigaration item in configurations) //{ // dr = new DataReader(SystemConfigarationDA.GetChildren(tc, item.ID)); // FillChildren(item, dr); // dr.Close(); //} tc.End(); return configurations; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public List GetAttributesByParentID(int nParentID) { SystemConfigaration.ConfigurationAttributes items = new SystemConfigaration.ConfigurationAttributes(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SystemConfigarationDA.GetChildrenByNode(tc, nParentID)); while (dr.Read()) { SystemConfigaration.ConfigurationAttribute ca = new SystemConfigaration.ConfigurationAttribute(); MapChildObject(ca, dr); items.Add(ca); } dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return items; } public List GetAttributesByValue(string sMenuKey) { SystemConfigaration.ConfigurationAttributes items = new SystemConfigaration.ConfigurationAttributes(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SystemConfigarationDA.GetChildrenByValue(tc, sMenuKey)); while (dr.Read()) { SystemConfigaration.ConfigurationAttribute ca = new SystemConfigaration.ConfigurationAttribute(); MapChildObject(ca, dr); items.Add(ca); } dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return items; } public List GetAllChildren() { SystemConfigaration.ConfigurationAttributes items = new SystemConfigaration.ConfigurationAttributes(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SystemConfigarationDA.GetAllChildren(tc)); while (dr.Read()) { SystemConfigaration.ConfigurationAttribute ca = new SystemConfigaration.ConfigurationAttribute(); MapChildObject(ca, dr); items.Add(ca); } dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return items; } public List GetAllChildrenByParentNode(EnumConfigurationType type, string parentNode) { List oConfigList = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(SystemConfigarationDA.GetAllChildrenByParentNode(tc, type, parentNode)); oConfigList = this.CreateObjects(oreader); oreader.Close(); if (oConfigList.Count > 0) { string parentid = ""; oConfigList.ForEach(x => { parentid = parentid + x.ID.ToString() + ", "; }); parentid = parentid.Substring(0, parentid.Length - 2); oreader = new DataReader(SystemConfigarationDA.GetallChildren(tc, parentid)); var olist = CreateAttribures(oreader); // FillChildren(ca, oreader); oConfigList.ForEach(x => { var childs = olist.FindAll(a => a.ConfigurationID == x.ID); if(childs!=null) x.ConAttributes.AddRange(childs); }); oreader.Close(); } foreach (var ca in oConfigList) { } tc.End(); } catch (Exception ex) { throw new ServiceException(ex.InnerException.Message); } return oConfigList; } public object GetconfigValue(EnumConfigurationType type, string firstParent, string secondParent) { object returnvalue = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); returnvalue =SystemConfigarationDA.getconfigValue(tc, type, firstParent,secondParent); tc.End(); } catch (Exception ex) { throw new ServiceException(ex.InnerException.Message); } return returnvalue; } public int GetconfigIntValue(EnumConfigurationType type, string firstParent, string secondParent) { object returnvalue = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); returnvalue = SystemConfigarationDA.getconfigValue(tc, type, firstParent, secondParent); tc.End(); } catch (Exception ex) { throw new ServiceException(ex.InnerException.Message); } return Convert.ToInt32( returnvalue); } public double GetconfigDoubleValue(EnumConfigurationType type, string firstParent, string secondParent) { object returnvalue = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); returnvalue = SystemConfigarationDA.getconfigValue(tc, type, firstParent, secondParent); tc.End(); } catch (Exception ex) { throw new ServiceException(ex.InnerException.Message); } return Convert.ToDouble(returnvalue); } public string GetconfigStringValue(EnumConfigurationType type, string firstParent, string secondParent) { object returnvalue = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); returnvalue = SystemConfigarationDA.getconfigValue(tc, type, firstParent, secondParent); tc.End(); } catch (Exception ex) { throw new ServiceException(ex.InnerException.Message); } if (returnvalue == null) returnvalue = ""; return Convert.ToString(returnvalue); } public bool GetconfigBooleanValue(EnumConfigurationType type, string firstParent, string secondParent) { bool returnvalue = false; TransactionContext tc = null; try { tc = TransactionContext.Begin(); object rvalue = SystemConfigarationDA.getconfigValue(tc, type, firstParent, secondParent); if (rvalue !=null && ((string)rvalue).ToUpper() =="YES") { returnvalue = true; } tc.End(); } catch (Exception ex) { throw new ServiceException(ex.InnerException.Message); } return returnvalue; } public List GetChilds(List sourceObject, string NodeName) { List destinations = new List(); SystemConfigaration fParent = sourceObject.Find(delegate (SystemConfigaration item) { return (item.Node == NodeName); }); if (fParent != null) GetChilds(sourceObject, destinations, fParent); return destinations; } private void GetChilds(List Source, List destination, SystemConfigaration parent) { IEnumerable Items = from Cnfgs in Source where Cnfgs.ParentID == parent.ID select Cnfgs; if (Items == null) return; foreach (var item in Items) { destination.Add(item); GetChilds(Source, destination, item); } } #region Menu Creation private bool IsParent(SystemConfigaration con) { if (con.ConAttributes.Count > 4 && con.ConAttributes[3].Value.Length == 0) { return true; } return false; } private bool IsChield(SystemConfigaration c, SystemConfigaration con) { if (c.ConAttributes.Count > 4 && c.ConAttributes[3].Value.ToString().ToLower() .Equals(con.ConAttributes[0].Value.ToString().ToLower())) { { return true; } } return false; } public List GetMenu(EnumConfigurationType configType) { TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(SystemConfigarationDA.Get(tc, configType)); var configurations = this.CreateObjects(dr); dr.Close(); dr = new DataReader(SystemConfigarationDA.GetChildren(tc)); var configChildrens = new List(); while (dr.Read()) { configChildrens.Add(CreateChildObject(dr)); } dr.Close(); foreach (SystemConfigaration item in configurations) { item.ConAttributes.AddRange(configChildrens.FindAll(x => x.ConfigurationID == item.ID)); } tc.End(); return configurations; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } private void Recure(List mainSource, TreeNode node, SystemConfigaration con) { List chields = mainSource.FindAll(delegate (SystemConfigaration c) { return IsChield(c, con); }); foreach (SystemConfigaration chield in chields) { TreeNode cnode = new TreeNode(); cnode.Text = chield.ConAttributes[1].Value.ToString(); cnode.Tag = chield.ConAttributes[0].Value.ToString(); Recure(mainSource, cnode, chield); node.Nodes.Add(cnode); } } public List LoadMenu() { List MenuCofiguration = this.GetMenu(EnumConfigurationType.Menu); List parents = MenuCofiguration.FindAll(delegate (SystemConfigaration con) { return IsParent(con); }); List tvMenues = new List(); foreach (SystemConfigaration con in parents) { TreeNode node = new TreeNode(); node.Text = con.ConAttributes[1].Value.ToString(); node.Tag = con.ConAttributes[0].Value.ToString(); Recure(MenuCofiguration, node, con); tvMenues.Add(node); } return tvMenues; } public List getMenuesFromConfig() { List MenuCofiguration = this.GetMenu(EnumConfigurationType.Menu); List parents = MenuCofiguration.FindAll(delegate (SystemConfigaration con) { return IsParent(con); }); List tvMenues = new List(); _rolePermissinID = 0; foreach (SystemConfigaration con in parents) { _rolePermissinID = _rolePermissinID + 1; if (con.ConAttributes.Count < 5) { continue; } Role.RolePermission node = new Role.RolePermission(); node.Name = con.ConAttributes[0].Value.ToString(); node.Name = con.ConAttributes[1].Value.ToString(); node.RoleType = Role.RolePermission.GetRoletype(con.ConAttributes[5].Value.ToString()); node.PermissionCode = con.ConAttributes[0].Value.ToString(); node.ID = tvMenues.Count + 1; tvMenues.Add(node); RecureRole(MenuCofiguration, tvMenues, node, 2); } return tvMenues; } private bool IsChield(SystemConfigaration c, Role.RolePermission parent) { if (c.ConAttributes.Count > 4 && c.ConAttributes[3].Value.ToString().ToLower().Equals(parent.PermissionCode)) { { return true; } } return false; } private void RecureRole(List mainSource, List allpermissions, Role.RolePermission parent, int nextid) { List chields = mainSource.FindAll(delegate (SystemConfigaration c) { return IsChield(c, parent); }); foreach (SystemConfigaration chield in chields) { if (chield.ConAttributes.Count < 5) { continue; } _rolePermissinID = _rolePermissinID + 1; Role.RolePermission node = new Role.RolePermission(); node.Name = chield.ConAttributes[1].Value.ToString(); node.PermissionCode = chield.ConAttributes[0].Value.ToString(); node.Link = chield.ConAttributes[2].Value.ToString(); node.parentID = parent.ID; node.RoleType = parent.RoleType; nextid = allpermissions.Count + 1; node.ID = allpermissions.Count + 1; allpermissions.Add(node); RecureRole(mainSource, allpermissions, node, nextid); } } public List LoadXMLtoObject(EnumConfigurationType type, System.IO.Stream fileName) { ConfigurationManager omanager = new ConfigurationManager(); return omanager.LoadXMLtoObject(type, fileName); } public string GetXMLFile(EnumConfigurationType type) { return new ConfigurationManager().GetXML(type); } #endregion } #endregion public class ConfigurationManager { public ConfigurationManager() { _logicCofiguration = new List(); _uiCofiguration = new List(); _menuCofiguration = new List(); } private List _logicCofiguration { get; set; } private List _uiCofiguration { get; set; } private List _menuCofiguration { get; set; } //public List LogicConfiguration //{ // get // { // return _logicCofiguration; // } //} //public List UICofiguration //{ // get // { // return _uiCofiguration; // } //} //public List MenuCofiguration //{ // get // { // return _menuCofiguration; // } //} public void SetStaticConfiguration(List configs, EnumConfigurationType type) { switch (type) { case EnumConfigurationType.UI: _uiCofiguration = configs; break; case EnumConfigurationType.Logic: _logicCofiguration = configs; break; case EnumConfigurationType.Menu: _menuCofiguration = configs; break; default: break; } } private List getSource(EnumConfigurationType type) { List SourceObject = null; switch (type) { case EnumConfigurationType.UI: SourceObject = _uiCofiguration; break; case EnumConfigurationType.Logic: SourceObject = _logicCofiguration; break; case EnumConfigurationType.Menu: SourceObject = _menuCofiguration; break; default: throw new ServiceException("Invalid configuration type"); } return SourceObject; } public SystemConfigaration GetItem(List sourceObject, string NodeName) { SystemConfigaration fParent = sourceObject.Find(delegate (SystemConfigaration item) { return (item.Node == NodeName); }); return fParent; } #region Read configuration from XMLFile to Object public List LoadXMLtoObject(EnumConfigurationType type, string fileName) { XmlDocument xmlDoc = new XmlDocument(); //Load the file into the XmlDocument List configs = new List(); xmlDoc.Load(fileName); //Find the root nede, and add it togather with its childeren XmlNode xnod = xmlDoc.DocumentElement; // Add Parent node in Collection SystemConfigaration parent = AddToColl(configs, xnod, 0, type); ReadFromXML(configs, xnod, parent, type); return configs; } public List LoadXMLtoObject(EnumConfigurationType type, System.IO.Stream fileName) { XmlDocument xmlDoc = new XmlDocument(); //Load the file into the XmlDocument List configs = new List(); xmlDoc.Load(fileName); //Find the root nede, and add it togather with its childeren XmlNode xnod = xmlDoc.DocumentElement; // Add Parent node in Collection SystemConfigaration parent = AddToColl(configs, xnod, 0, type); ReadFromXML(configs, xnod, parent, type); return configs; } private void ReadFromXML(List configs, XmlNode xnod, SystemConfigaration parent, EnumConfigurationType type) { XmlNode xnodWorking; //For an element node, retrieve the attributes if (xnod.NodeType == XmlNodeType.Element) { XmlNamedNodeMap mapAttributes = xnod.Attributes; if (xnod.HasChildNodes) { xnodWorking = xnod.FirstChild; while (xnodWorking != null) { if (xnodWorking.NodeType == XmlNodeType.Element) { SystemConfigaration oparent = AddToColl(configs, xnodWorking, parent.ID, type); //Add the attributes to the ListBox foreach (XmlAttribute xnodAttribute in xnodWorking.Attributes) oparent.ConAttributes.Add(oparent.ID, xnodAttribute.Name, xnodAttribute.Value); //If there are any child node, call this procedure recursively ReadFromXML(configs, xnodWorking, oparent, type); } xnodWorking = xnodWorking.NextSibling; } } } } private SystemConfigaration AddToColl(List configs, XmlNode node, int parentID, EnumConfigurationType type) { SystemConfigaration oConfig = new SystemConfigaration(); oConfig.Node = node.Name; // if (parentID <= 0) oConfig.Value = ""; else if (node.ChildNodes.Count != 1 || (node.ChildNodes.Count == 1 && node.ChildNodes[0].ChildNodes.Count != 0)) { oConfig.Value = ""; } else oConfig.Value = node.InnerText; oConfig.ParentID = parentID; oConfig.Type = type; oConfig.SetObjectID(configs.Count + 1); configs.Add(oConfig); return oConfig; } #endregion Read configuration from Object to XMLFile #region Write configuration from object to XMLFile public void WriteXML(string path, EnumConfigurationType type) { List configs = null; if (type == EnumConfigurationType.Logic) configs = _logicCofiguration; else if (type == EnumConfigurationType.UI) configs = _uiCofiguration; else configs = _menuCofiguration; if (configs == null || configs.Count == 0) throw new ServiceException("Source is empty"); //XmlTextWriter tw = new XmlTextWriter("C:\\testXml.xml", System.Text.Encoding.UTF8); //tw.Flush(); //tw.Formatting = Formatting.Indented; //tw.WriteStartDocument(); //tw.WriteStartElement(configs[0].Node); //ConfigurationManager.WriteXML(tw, configs, configs[0].ID); //tw.WriteEndElement(); //tw.WriteEndDocument(); XmlDocument xdoc = new XmlDocument(); XmlElement root = xdoc.CreateElement(configs[0].Node); xdoc.AppendChild(root); WriteXML(root, xdoc, configs, configs[0].ID); xdoc.Save(path); } public string GetXML( EnumConfigurationType type) { List configs = new SystemConfigarationService().Get(type); if (configs == null || configs.Count == 0) throw new ServiceException("Source is empty"); XmlDocument xdoc = new XmlDocument(); XmlElement root = xdoc.CreateElement(configs[0].Node); xdoc.AppendChild(root); WriteXML(root, xdoc, configs, configs[0].ID); // xdoc.Save(path); string sxml = xdoc.InnerXml; return sxml; } private static void WriteXML(XmlElement element, XmlDocument xdoc, List configs, int nodeId) { List childs = configs.Where(x => x.ParentID == nodeId).ToList(); if (childs != null || childs.Count > 0) { foreach (SystemConfigaration con in childs) { XmlElement chilenode = xdoc.CreateElement(con.Node); chilenode.InnerText = con.Value; foreach (SystemConfigaration.ConfigurationAttribute att in con.ConAttributes) { chilenode.SetAttribute(att.AttributeName, att.Value); } element.AppendChild(chilenode); WriteXML(chilenode, xdoc, configs, con.ID); } } } #endregion Write configuration from object to XMLFile private void GetChilds(List Source, List destination, SystemConfigaration parent) { IEnumerable Items = from Cnfgs in Source where Cnfgs.ParentID == parent.ID select Cnfgs; if (Items == null) return; foreach (var item in Items) { destination.Add(item); GetChilds(Source, destination, item); } } public static string GetStringValue(string parentNodeName, string childNodeName, EnumConfigurationType type) { try { string stringvalue = ConfigurationManager.getValue(parentNodeName, childNodeName, type); return stringvalue; } catch (Exception ex) { throw new ServiceException(ex.InnerException.Message); } } public List GetChilds(string NodeName, EnumConfigurationType type) { List destinations = new List(); List SourceObject = getSource(type); SystemConfigaration fParent = null; if (SourceObject != null) fParent = SourceObject.Find(delegate (SystemConfigaration item) { return (item.Node == NodeName); }); if (fParent != null) GetChilds(SourceObject, destinations, fParent); return destinations; } private static string getValue(string parentNodeName, string childNodeName, EnumConfigurationType type) { ConfigurationManager manager = new ConfigurationManager(); List parent = manager.GetChilds(parentNodeName, type); if (parent == null) return ""; //throw new ServiceException("parent-Tag-Name not found in the logic configuration"); SystemConfigaration child = manager.GetItem(parent, childNodeName); if (child == null) return ""; //throw new ServiceException("child-node-name not found in the logic collection"); return child.Value; } public static bool GetBoolValue(string parentNodeName, string childNodeName, EnumConfigurationType type) { try { string stringvalue = ConfigurationManager.getValue(parentNodeName, childNodeName, type); if (stringvalue.ToUpper() == "YES" || stringvalue.ToUpper() == "NO") return (stringvalue.ToUpper() == "YES"); else return false; //throw new ServiceException("Value in the " // + "logic-Configuration; Node:Root, Child-Node:RoundOfDegit, Value:" + stringvalue + " is not Integer"); } catch (Exception ex) { throw new ServiceException(ex.InnerException.Message); } } public static SystemConfigaration Get(string parentNodeName, string childNodeName, EnumConfigurationType type) { ConfigurationManager manager = new ConfigurationManager(); List parent = manager.GetChilds(parentNodeName, type); if (parent == null) return null; SystemConfigaration child = manager.GetItem(parent, childNodeName); if (child == null) return null; return child; } public static int GetAttributeIntValue(string parentNodeName, string childNodeName, string AttributeName, EnumConfigurationType type) { int intvalue = 0; try { SystemConfigaration oTag = ConfigurationManager.Get(parentNodeName, childNodeName, type); if (oTag == null) return 0; string stringvalue = oTag.ConAttributes.GetAttributeValue(AttributeName); if (stringvalue == "") return 0; if (int.TryParse(stringvalue, out intvalue)) return intvalue; else return 0; } catch (Exception ex) { throw new ServiceException(ex.InnerException.Message); } } public static int GetIntValue(string parentNodeName, string childNodeName, EnumConfigurationType type) { int intvalue = 0; try { string stringvalue = ConfigurationManager.getValue(parentNodeName, childNodeName, type); if (int.TryParse(stringvalue, out intvalue)) return intvalue; else return 0; //throw new ServiceException("Value in the " // + "logic-Configuration; Node:Root, Child-Node:RoundOfDegit, Value:" + stringvalue +" is not Integer"); } catch (Exception ex) { throw new ServiceException(ex.InnerException.Message); } } } }