//public ClsPeer() //{ // _xmlDoc.Load(AppDomain.CurrentDomain.BaseDirectory + "VMukti.Presentation.exe.config"); // if (AppDomain.CurrentDomain.FriendlyName != "BootStrapDomain" && AppDomain.CurrentDomain.FriendlyName != "SuperNodeDomain") // { // if (KeyExists("_ID")) // { // DeleteKey("_ID"); // } // if (KeyExists("_DisplayName")) // { // DeleteKey("_DisplayName"); // } // if (KeyExists("_RoleID")) // { // DeleteKey("_RoleID"); // } // if (KeyExists("_FName")) // { // DeleteKey("_FName"); // } // if (KeyExists("_LName")) // { // DeleteKey("_LName"); // } // if (KeyExists("_EMail")) // { // DeleteKey("_EMail"); // } // if (KeyExists("_PassWord")) // { // DeleteKey("_PassWord"); // } // if (KeyExists("_IsActive")) // { // DeleteKey("_IsActive"); // } // if (KeyExists("_MeshID")) // { // DeleteKey("_MeshID"); // } // if (KeyExists("_Status")) // { // DeleteKey("_Status"); // } // if (KeyExists("_CurrPeerType")) // { // DeleteKey("_CurrPeerType"); // } // if (KeyExists("_CurrAuthType")) // { // DeleteKey("_CurrAuthType"); // } // if (KeyExists("_Port4000Status")) // { // DeleteKey("_Port4000Status"); // } // if (KeyExists("_Port5060Status")) // { // DeleteKey("_Port5060Status"); // } // if (KeyExists("_Port1433Status")) // { // DeleteKey("_Port1433Status"); // } // if (KeyExists("_AuthServerIP")) // { // DeleteKey("_AuthServerIP"); // } // if (KeyExists("_SuperNodeIP")) // { // DeleteKey("_SuperNodeIP"); // } // if (KeyExists("_NodeIPs")) // { // int _NodeIPsCount = int.Parse(System.Configuration.ConfigurationManager.AppSettings["_NodeIPs"].ToString()); // for (int i = 0; i < _NodeIPsCount; i++) // { // if (KeyExists("_NodeIPs" + i.ToString())) // { // DeleteKey("_NodeIPs" + i.ToString()); // } // } // DeleteKey("_NodeIPs"); // } // //===============================-----------------------================================= // AddKey("_ID", ClsConstants.NullInt.ToString()); // AddKey("_DisplayName", ClsConstants.NullString.ToString()); // AddKey("_RoleID", ClsConstants.NullInt.ToString()); // AddKey("_FName", ClsConstants.NullString.ToString()); // AddKey("_LName", ClsConstants.NullString.ToString()); // AddKey("_EMail", ClsConstants.NullString.ToString()); // AddKey("_PassWord", ClsConstants.NullString.ToString()); // AddKey("_IsActive", "false"); // AddKey("_MeshID", ClsConstants.NullString.ToString()); // AddKey("_Status", ClsConstants.NullString.ToString()); // AddKey("_CurrPeerType", "NotDecided"); // AddKey("_CurrAuthType", "NotDecided"); // AddKey("_Port4000Status", "NotDecided"); // AddKey("_Port5060Status", "NotDecided"); // AddKey("_Port1433Status", "NotDecided"); // AddKey("_AuthServerIP", ClsConstants.NullString.ToString()); // AddKey("_SuperNodeIP", ClsConstants.NullString.ToString()); // AddKey("_NodeIPs", "0"); // } // //else // //{ // // loadFromConfig(); // //} //} //private string GetKeyValue(string strKey) //{ // XmlNode appSettingsNode = _xmlDoc.SelectSingleNode("configuration/appSettings"); // foreach (XmlNode childNode in appSettingsNode) // { // if (childNode.Attributes["key"].Value == strKey) // { // return childNode.Attributes["value"].Value.ToString(); // } // } // return ""; //} //private void AddKey(string strKey, string strValue) //{ // XmlNode appSettingsNode = _xmlDoc.SelectSingleNode("configuration/appSettings"); // try // { // if (KeyExists(strKey)) // throw new ArgumentException("Key name: <" + strKey + "> already exists in the configuration."); // XmlNode newChild = appSettingsNode.FirstChild.Clone(); // newChild.Attributes["key"].Value = strKey; // newChild.Attributes["value"].Value = strValue; // appSettingsNode.AppendChild(newChild); // _xmlDoc.Save(AppDomain.CurrentDomain.BaseDirectory + "VMukti.Presentation.exe.config"); // _xmlDoc.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); // } // catch (Exception ex) // { // throw ex; // } //} //private void UpdateKey(string strKey, string newValue) //{ // if (!KeyExists(strKey)) // throw new ArgumentNullException("Key", "<" + strKey + "> does not exist in the configuration. Update failed."); // XmlNode appSettingsNode =_xmlDoc.SelectSingleNode("configuration/appSettings"); // // Attempt to locate the requested setting. // foreach (XmlNode childNode in appSettingsNode) // { // if (childNode.Attributes["key"].Value == strKey) // childNode.Attributes["value"].Value = newValue; // } // _xmlDoc.Save(AppDomain.CurrentDomain.BaseDirectory + "VMukti.Presentation.exe.config"); // _xmlDoc.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); //} //private void DeleteKey(string strKey) //{ // if (!KeyExists(strKey)) // throw new ArgumentNullException("Key", "<" + strKey + "> does not exist in the configuration. Update failed."); // XmlNode appSettingsNode = _xmlDoc.SelectSingleNode("configuration/appSettings"); // // Attempt to locate the requested setting. // foreach (XmlNode childNode in appSettingsNode) // { // if (childNode.Attributes["key"].Value == strKey) // appSettingsNode.RemoveChild(childNode); // } // _xmlDoc.Save(AppDomain.CurrentDomain.BaseDirectory + "VMukti.Presentation.exe.config"); // _xmlDoc.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); //} //private bool KeyExists(string strKey) //{ // XmlNode appSettingsNode = _xmlDoc.SelectSingleNode("configuration/appSettings"); // // Attempt to locate the requested setting. // foreach (XmlNode childNode in appSettingsNode) // { // if (childNode.Attributes["key"].Value == strKey) // return true; // } // return false; //} //private void loadFromConfig() //{ // XmlNode appSettingsNode = _xmlDoc.SelectSingleNode("configuration/appSettings"); // foreach (XmlNode node in appSettingsNode.ChildNodes) // { // switch (node.Attributes["key"].Value.ToString()) // { // case "_ID": // this._ID = int.Parse(node.Attributes["value"].Value.ToString()); // break; // case "_DisplayName": // this._DisplayName = node.Attributes["value"].Value.ToString(); // break; // case "_RoleID": // this._RoleID = int.Parse(node.Attributes["value"].Value.ToString()); // break; // case "_FName": // this._FName = node.Attributes["value"].Value.ToString(); // break; // case "_LName": // this._LName = node.Attributes["value"].Value.ToString(); // break; // case "_EMail": // this._EMail = node.Attributes["value"].Value.ToString(); // break; // case "_PassWord": // this._PassWord = node.Attributes["value"].Value.ToString(); // break; // case "_IsActive": // if(node.Attributes["value"].Value.ToString()=="true") // { // this._IsActive = true; // } // else if (node.Attributes["value"].Value.ToString() == "false") // { // this._IsActive = false; // } // break; // case "_MeshID": // this._MeshID = node.Attributes["value"].Value.ToString(); // break; // case "_Status": // this._Status = node.Attributes["value"].Value.ToString(); // break; // case "_CurrPeerType": // switch (node.Attributes["value"].Value.ToString()) // { // case "NotDecided": // this._CurrPeerType = PeerType.NotDecided; // break; // case "BootStrap": // this._CurrPeerType = PeerType.BootStrap; // break; // case "SuperNode": // this._CurrPeerType = PeerType.SuperNode; // break; // case "NodeWithNetP2P": // this._CurrPeerType = PeerType.NodeWithNetP2P; // break; // case "NodeWithHttp": // this._CurrPeerType = PeerType.NodeWithHttp; // break; // } // break; // case "_CurrAuthType": // switch (node.Attributes["value"].Value.ToString()) // { // case "NotDecided": // this._CurrAuthType = AuthType.NotDecided; // break; // case "SQLAuthentication": // this._CurrAuthType = AuthType.SQLAuthentication; // break; // case "SIPAuthentication": // this._CurrAuthType = AuthType.SIPAuthentication; // break; // } // break; // case "_Port4000Status": // switch (node.Attributes["value"].Value.ToString()) // { // case "NotDecided": // this._Port4000Status = PortStatus.NotDecided; // break; // case "InBoundOpen": // this._Port4000Status = PortStatus.InBoundOpen; // break; // case "OutBoundOpen": // this._Port4000Status = PortStatus.OutBoundOpen; // break; // case "InOutBoundOpen": // this._Port4000Status = PortStatus.InOutBoundOpen; // break; // case "InOutBoundClosed": // this._Port4000Status = PortStatus.InOutBoundClosed; // break; // } // break; // case "_Port5060Status": // switch (node.Attributes["value"].Value.ToString()) // { // case "NotDecided": // this._Port5060Status = PortStatus.NotDecided; // break; // case "InBoundOpen": // this._Port5060Status = PortStatus.InBoundOpen; // break; // case "OutBoundOpen": // this._Port5060Status = PortStatus.OutBoundOpen; // break; // case "InOutBoundOpen": // this._Port5060Status = PortStatus.InOutBoundOpen; // break; // case "InOutBoundClosed": // this._Port5060Status = PortStatus.InOutBoundClosed; // break; // } // break; // case "_Port1433Status": // switch (node.Attributes["value"].Value.ToString()) // { // case "NotDecided": // this._Port1433Status = PortStatus.NotDecided; // break; // case "InBoundOpen": // this._Port1433Status = PortStatus.InBoundOpen; // break; // case "OutBoundOpen": // this._Port1433Status = PortStatus.OutBoundOpen; // break; // case "InOutBoundOpen": // this._Port1433Status = PortStatus.InOutBoundOpen; // break; // case "InOutBoundClosed": // this._Port1433Status = PortStatus.InOutBoundClosed; // break; // } // break; // case "_AuthServerIP": // this._AuthServerIP = node.Attributes["value"].Value.ToString(); // break; // case "_SuperNodeIP": // this._SuperNodeIP = node.Attributes["value"].Value.ToString(); // break; // case "_NodeIPs": // int _NodeIPsCount = int.Parse(node.Attributes["value"].Value.ToString()); // for (int i = 0; i < _NodeIPsCount; i++) // { // if (KeyExists("_NodeIPs" + i.ToString())) // { // _NodeIPs.Add(GetKeyValue("_NodeIPs" + i.ToString())); // } // } // break; // } // } //} #endregion public ClsPeerDataContract GetPeerDataContract() { ClsPeerDataContract objPeerDataContract = new ClsPeerDataContract(); objPeerDataContract.ID = this.ID; objPeerDataContract.DisplayName = this.DisplayName; objPeerDataContract.RoleID = this.RoleID; objPeerDataContract.FName = this.FName; objPeerDataContract.LName = this.LName; objPeerDataContract.EMail = this.EMail; objPeerDataContract.PassWord = this.PassWord; objPeerDataContract.IsActive = this.IsActive; objPeerDataContract.MeshID = this.MeshID; objPeerDataContract.Status = this.Status; objPeerDataContract.CurrPeerType = this.CurrPeerType; objPeerDataContract.CurrAuthType = this.CurrAuthType; objPeerDataContract.Port4000Status = this.Port4000Status; objPeerDataContract.Port5060Status = this.Port5060Status; objPeerDataContract.Port1433Status = this.Port1433Status; objPeerDataContract.AuthServerIP = this.AuthServerIP; objPeerDataContract.SuperNodeIP = this.SuperNodeIP; objPeerDataContract.NodeIPs = this.NodeIPs; return(objPeerDataContract); }
//public ClsPeer() //{ // _xmlDoc.Load(AppDomain.CurrentDomain.BaseDirectory + "VMukti.Presentation.exe.config"); // if (AppDomain.CurrentDomain.FriendlyName != "BootStrapDomain" && AppDomain.CurrentDomain.FriendlyName != "SuperNodeDomain") // { // if (KeyExists("_ID")) // { // DeleteKey("_ID"); // } // if (KeyExists("_DisplayName")) // { // DeleteKey("_DisplayName"); // } // if (KeyExists("_RoleID")) // { // DeleteKey("_RoleID"); // } // if (KeyExists("_FName")) // { // DeleteKey("_FName"); // } // if (KeyExists("_LName")) // { // DeleteKey("_LName"); // } // if (KeyExists("_EMail")) // { // DeleteKey("_EMail"); // } // if (KeyExists("_PassWord")) // { // DeleteKey("_PassWord"); // } // if (KeyExists("_IsActive")) // { // DeleteKey("_IsActive"); // } // if (KeyExists("_MeshID")) // { // DeleteKey("_MeshID"); // } // if (KeyExists("_Status")) // { // DeleteKey("_Status"); // } // if (KeyExists("_CurrPeerType")) // { // DeleteKey("_CurrPeerType"); // } // if (KeyExists("_CurrAuthType")) // { // DeleteKey("_CurrAuthType"); // } // if (KeyExists("_Port4000Status")) // { // DeleteKey("_Port4000Status"); // } // if (KeyExists("_Port5060Status")) // { // DeleteKey("_Port5060Status"); // } // if (KeyExists("_Port1433Status")) // { // DeleteKey("_Port1433Status"); // } // if (KeyExists("_AuthServerIP")) // { // DeleteKey("_AuthServerIP"); // } // if (KeyExists("_SuperNodeIP")) // { // DeleteKey("_SuperNodeIP"); // } // if (KeyExists("_NodeIPs")) // { // int _NodeIPsCount = int.Parse(System.Configuration.ConfigurationManager.AppSettings["_NodeIPs"].ToString()); // for (int i = 0; i < _NodeIPsCount; i++) // { // if (KeyExists("_NodeIPs" + i.ToString())) // { // DeleteKey("_NodeIPs" + i.ToString()); // } // } // DeleteKey("_NodeIPs"); // } // //===============================-----------------------================================= // AddKey("_ID", ClsConstants.NullInt.ToString()); // AddKey("_DisplayName", ClsConstants.NullString.ToString()); // AddKey("_RoleID", ClsConstants.NullInt.ToString()); // AddKey("_FName", ClsConstants.NullString.ToString()); // AddKey("_LName", ClsConstants.NullString.ToString()); // AddKey("_EMail", ClsConstants.NullString.ToString()); // AddKey("_PassWord", ClsConstants.NullString.ToString()); // AddKey("_IsActive", "false"); // AddKey("_MeshID", ClsConstants.NullString.ToString()); // AddKey("_Status", ClsConstants.NullString.ToString()); // AddKey("_CurrPeerType", "NotDecided"); // AddKey("_CurrAuthType", "NotDecided"); // AddKey("_Port4000Status", "NotDecided"); // AddKey("_Port5060Status", "NotDecided"); // AddKey("_Port1433Status", "NotDecided"); // AddKey("_AuthServerIP", ClsConstants.NullString.ToString()); // AddKey("_SuperNodeIP", ClsConstants.NullString.ToString()); // AddKey("_NodeIPs", "0"); // } // //else // //{ // // loadFromConfig(); // //} //} //private string GetKeyValue(string strKey) //{ // XmlNode appSettingsNode = _xmlDoc.SelectSingleNode("configuration/appSettings"); // foreach (XmlNode childNode in appSettingsNode) // { // if (childNode.Attributes["key"].Value == strKey) // { // return childNode.Attributes["value"].Value.ToString(); // } // } // return ""; //} //private void AddKey(string strKey, string strValue) //{ // XmlNode appSettingsNode = _xmlDoc.SelectSingleNode("configuration/appSettings"); // try // { // if (KeyExists(strKey)) // throw new ArgumentException("Key name: <" + strKey + "> already exists in the configuration."); // XmlNode newChild = appSettingsNode.FirstChild.Clone(); // newChild.Attributes["key"].Value = strKey; // newChild.Attributes["value"].Value = strValue; // appSettingsNode.AppendChild(newChild); // _xmlDoc.Save(AppDomain.CurrentDomain.BaseDirectory + "VMukti.Presentation.exe.config"); // _xmlDoc.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); // } // catch (Exception ex) // { // throw ex; // } //} //private void UpdateKey(string strKey, string newValue) //{ // if (!KeyExists(strKey)) // throw new ArgumentNullException("Key", "<" + strKey + "> does not exist in the configuration. Update failed."); // XmlNode appSettingsNode =_xmlDoc.SelectSingleNode("configuration/appSettings"); // // Attempt to locate the requested setting. // foreach (XmlNode childNode in appSettingsNode) // { // if (childNode.Attributes["key"].Value == strKey) // childNode.Attributes["value"].Value = newValue; // } // _xmlDoc.Save(AppDomain.CurrentDomain.BaseDirectory + "VMukti.Presentation.exe.config"); // _xmlDoc.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); //} //private void DeleteKey(string strKey) //{ // if (!KeyExists(strKey)) // throw new ArgumentNullException("Key", "<" + strKey + "> does not exist in the configuration. Update failed."); // XmlNode appSettingsNode = _xmlDoc.SelectSingleNode("configuration/appSettings"); // // Attempt to locate the requested setting. // foreach (XmlNode childNode in appSettingsNode) // { // if (childNode.Attributes["key"].Value == strKey) // appSettingsNode.RemoveChild(childNode); // } // _xmlDoc.Save(AppDomain.CurrentDomain.BaseDirectory + "VMukti.Presentation.exe.config"); // _xmlDoc.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); //} //private bool KeyExists(string strKey) //{ // XmlNode appSettingsNode = _xmlDoc.SelectSingleNode("configuration/appSettings"); // // Attempt to locate the requested setting. // foreach (XmlNode childNode in appSettingsNode) // { // if (childNode.Attributes["key"].Value == strKey) // return true; // } // return false; //} //private void loadFromConfig() //{ // XmlNode appSettingsNode = _xmlDoc.SelectSingleNode("configuration/appSettings"); // foreach (XmlNode node in appSettingsNode.ChildNodes) // { // switch (node.Attributes["key"].Value.ToString()) // { // case "_ID": // this._ID = int.Parse(node.Attributes["value"].Value.ToString()); // break; // case "_DisplayName": // this._DisplayName = node.Attributes["value"].Value.ToString(); // break; // case "_RoleID": // this._RoleID = int.Parse(node.Attributes["value"].Value.ToString()); // break; // case "_FName": // this._FName = node.Attributes["value"].Value.ToString(); // break; // case "_LName": // this._LName = node.Attributes["value"].Value.ToString(); // break; // case "_EMail": // this._EMail = node.Attributes["value"].Value.ToString(); // break; // case "_PassWord": // this._PassWord = node.Attributes["value"].Value.ToString(); // break; // case "_IsActive": // if(node.Attributes["value"].Value.ToString()=="true") // { // this._IsActive = true; // } // else if (node.Attributes["value"].Value.ToString() == "false") // { // this._IsActive = false; // } // break; // case "_MeshID": // this._MeshID = node.Attributes["value"].Value.ToString(); // break; // case "_Status": // this._Status = node.Attributes["value"].Value.ToString(); // break; // case "_CurrPeerType": // switch (node.Attributes["value"].Value.ToString()) // { // case "NotDecided": // this._CurrPeerType = PeerType.NotDecided; // break; // case "BootStrap": // this._CurrPeerType = PeerType.BootStrap; // break; // case "SuperNode": // this._CurrPeerType = PeerType.SuperNode; // break; // case "NodeWithNetP2P": // this._CurrPeerType = PeerType.NodeWithNetP2P; // break; // case "NodeWithHttp": // this._CurrPeerType = PeerType.NodeWithHttp; // break; // } // break; // case "_CurrAuthType": // switch (node.Attributes["value"].Value.ToString()) // { // case "NotDecided": // this._CurrAuthType = AuthType.NotDecided; // break; // case "SQLAuthentication": // this._CurrAuthType = AuthType.SQLAuthentication; // break; // case "SIPAuthentication": // this._CurrAuthType = AuthType.SIPAuthentication; // break; // } // break; // case "_Port4000Status": // switch (node.Attributes["value"].Value.ToString()) // { // case "NotDecided": // this._Port4000Status = PortStatus.NotDecided; // break; // case "InBoundOpen": // this._Port4000Status = PortStatus.InBoundOpen; // break; // case "OutBoundOpen": // this._Port4000Status = PortStatus.OutBoundOpen; // break; // case "InOutBoundOpen": // this._Port4000Status = PortStatus.InOutBoundOpen; // break; // case "InOutBoundClosed": // this._Port4000Status = PortStatus.InOutBoundClosed; // break; // } // break; // case "_Port5060Status": // switch (node.Attributes["value"].Value.ToString()) // { // case "NotDecided": // this._Port5060Status = PortStatus.NotDecided; // break; // case "InBoundOpen": // this._Port5060Status = PortStatus.InBoundOpen; // break; // case "OutBoundOpen": // this._Port5060Status = PortStatus.OutBoundOpen; // break; // case "InOutBoundOpen": // this._Port5060Status = PortStatus.InOutBoundOpen; // break; // case "InOutBoundClosed": // this._Port5060Status = PortStatus.InOutBoundClosed; // break; // } // break; // case "_Port1433Status": // switch (node.Attributes["value"].Value.ToString()) // { // case "NotDecided": // this._Port1433Status = PortStatus.NotDecided; // break; // case "InBoundOpen": // this._Port1433Status = PortStatus.InBoundOpen; // break; // case "OutBoundOpen": // this._Port1433Status = PortStatus.OutBoundOpen; // break; // case "InOutBoundOpen": // this._Port1433Status = PortStatus.InOutBoundOpen; // break; // case "InOutBoundClosed": // this._Port1433Status = PortStatus.InOutBoundClosed; // break; // } // break; // case "_AuthServerIP": // this._AuthServerIP = node.Attributes["value"].Value.ToString(); // break; // case "_SuperNodeIP": // this._SuperNodeIP = node.Attributes["value"].Value.ToString(); // break; // case "_NodeIPs": // int _NodeIPsCount = int.Parse(node.Attributes["value"].Value.ToString()); // for (int i = 0; i < _NodeIPsCount; i++) // { // if (KeyExists("_NodeIPs" + i.ToString())) // { // _NodeIPs.Add(GetKeyValue("_NodeIPs" + i.ToString())); // } // } // break; // } // } //} #endregion public ClsPeerDataContract GetPeerDataContract() { ClsPeerDataContract objPeerDataContract = new ClsPeerDataContract(); objPeerDataContract.ID = this.ID; objPeerDataContract.DisplayName = this.DisplayName; objPeerDataContract.RoleID = this.RoleID; objPeerDataContract.FName = this.FName; objPeerDataContract.LName = this.LName; objPeerDataContract.EMail = this.EMail; objPeerDataContract.PassWord = this.PassWord; objPeerDataContract.IsActive = this.IsActive; objPeerDataContract.MeshID = this.MeshID; objPeerDataContract.Status = this.Status; objPeerDataContract.CurrPeerType = this.CurrPeerType; objPeerDataContract.CurrAuthType = this.CurrAuthType; objPeerDataContract.Port4000Status = this.Port4000Status; objPeerDataContract.Port5060Status = this.Port5060Status; objPeerDataContract.Port1433Status = this.Port1433Status; objPeerDataContract.AuthServerIP = this.AuthServerIP; objPeerDataContract.SuperNodeIP = this.SuperNodeIP; objPeerDataContract.NodeIPs = this.NodeIPs; return objPeerDataContract; }