/// <summary> /// "BootstrapServiceDomain_EntHttpBsGetSuperNodeIP" function is use by Node for getting their supernode IP. /// in this function bootstrap will check whether supernode is available or not if supernode is available the it will give this supernode IP to /// Node. Node will communicate (Open HTTP or P2P clients) based on this IP. /// </summary> /// <param name="uName"></param> /// <param name="IP"></param> /// <param name="blSuperNode"></param> /// <returns></returns> VMukti.Business.WCFServices.SuperNodeServices.DataContract.clsSuperNodeDataContract BootstrapServiceDomain_EntHttpBsGetSuperNodeIP(string uName, string IP, bool blSuperNode) { // SqlCeConnection Conn = new SqlCeConnection(awClientConnectionString); SqlCeCommand sqlcmd = null; try { clsSuperNodeDataContract objSuperNodeInfo = new clsSuperNodeDataContract(); //super node checking #region Node is not SuperNode if (!blSuperNode) //Find Free SuperNode from the list and allocate itto Node { //code for super node service availabity checking //if super node is still available than findAvailableIp=true Boolean isSuperNodeAvailable = false; int intIncrementCounter = 0; String SupId = null; //Find Free available SuperNode untill can not be found while (isSuperNodeAvailable == false) { //Find Free available SuperNode SqlCeDataAdapter sqlDataAdap = null; DataTable dt = null; // Conn.Open(); OpenConnection(); sqlcmd = new SqlCeCommand("SELECT count(*) FROM SuperNode_Info"); sqlcmd.Connection = LocalSQLConn; object objSuperNodeCount = sqlcmd.ExecuteScalar(); sqlDataAdap = null; if (int.Parse(objSuperNodeCount.ToString()) > 1) // This means more than one supernode is present(1Bootstrap + supernodes) { // ClsException.WriteToLogFile("More Than One supernode available"); sqlDataAdap = new SqlCeDataAdapter("SELECT * FROM SuperNode_Info WHERE SuperNodeIP <> '" + strCurrentMachineIP + "' ORDER BY NodeCount", LocalSQLConn); dt = new DataTable(); sqlDataAdap.Fill(dt); // ClsException.WriteToLogFile("Row Count is :: " + dt.Rows.Count.ToString()); objSuperNodeInfo.SuperNodeIP = dt.Rows[0]["SuperNodeIP"].ToString(); // ClsException.WriteToLogFile("Node :: "+ IP + " SuperNode IP :: " + objSuperNodeInfo.SuperNodeIP); isSuperNodeAvailable = checkSuperNodeAvailable(objSuperNodeInfo.SuperNodeIP); //ClsException.WriteToLogFile("Available SuperNode IP is...... :: " + objSuperNodeInfo.SuperNodeIP); } else { // ClsException.WriteToLogFile("Only One supernode available That means BootStap"); sqlDataAdap = new SqlCeDataAdapter("SELECT * FROM SuperNode_Info ORDER BY NodeCount", LocalSQLConn); dt = new DataTable(); sqlDataAdap.Fill(dt); // ClsException.WriteToLogFile("Row Count is :: " + dt.Rows.Count.ToString()); objSuperNodeInfo.SuperNodeIP = dt.Rows[0]["SuperNodeIP"].ToString(); //ClsException.WriteToLogFile("Available SuperNode IP :: " + objSuperNodeInfo.SuperNodeIP); //shilpa 5-Feb-2008 //isSuperNodeAvailable = true because we are assigning boostrap as super node //which will be running continuesly isSuperNodeAvailable = true; } //shilpa code 5-Feb-2008 //method for super node service checking if (!isSuperNodeAvailable) { //assign all its node to the another super node //shilpa code //6-Feb-2008 //deleting the super node entry adjustSuperNode(objSuperNodeInfo.SuperNodeIP); } else { //continue //with the same super node ip //exit from the while loop intIncrementCounter = int.Parse(dt.Rows[0]["NodeCount"].ToString()) + 1; SupId = dt.Rows[0]["Id"].ToString(); } dt.Clear(); dt.Reset(); // Conn.Close(); } // end while // end code // shilpa 5-Feb-2008 // Conn.Open(); //int intIncrementCounter = int.Parse(dt.Rows[0]["NodeCount"].ToString()) + 1; OpenConnection(); sqlcmd = new SqlCeCommand("Update SuperNode_Info Set NodeCount = '" + intIncrementCounter + "' where Id='" + SupId + "'"); sqlcmd.Connection = LocalSQLConn; int TotUpdate = sqlcmd.ExecuteNonQuery(); sqlcmd = new SqlCeCommand("Select Id from SuperNode_Node_Info where Node_Name = '" + uName + "'"); sqlcmd.Connection = LocalSQLConn; object objTemp = sqlcmd.ExecuteScalar(); if (objTemp != null) { sqlcmd = new SqlCeCommand("Update SuperNode_Node_Info set SuperNode_Id='" + SupId + "' where Node_Name='" + uName + "'"); sqlcmd.Connection = LocalSQLConn; sqlcmd.ExecuteNonQuery(); } else { sqlcmd = new SqlCeCommand("INSERT INTO SuperNode_Node_Info (SuperNode_Id,Node_Name) VALUES ('" + SupId + "','" + uName + "')"); sqlcmd.Connection = LocalSQLConn; sqlcmd.ExecuteNonQuery(); } } #endregion #region Node is SuperNode else //Add New SuperNode to available superNode List { OpenConnection(); sqlcmd = new SqlCeCommand("SELECT Count(*) from SuperNode_Info where SuperNodeIP = '" + IP + "'"); sqlcmd.Connection = LocalSQLConn; object temp = sqlcmd.ExecuteScalar(); if (int.Parse(temp.ToString()) <= 0) { sqlcmd = new SqlCeCommand("INSERT INTO SuperNode_Info (SuperNodeIP, NodeCount,SuperNodeName) VALUES ('" + IP + "', '0','" + uName + "')"); sqlcmd.Connection = LocalSQLConn; sqlcmd.ExecuteNonQuery(); } objSuperNodeInfo.SuperNodeIP = IP; // ** if (!lstsSuperNodeInfo.Contains(IP)) { lstsSuperNodeInfo.Add(IP); } } #endregion // Meet Code For Buddylist Implementation. if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrAuthType == AuthType.SIPAuthentication) { objSuperNodeInfo.FileExists = false; sqlcmd = new SqlCeCommand("SELECT SIP_Number FROM SIP_Info WHERE UserName='******'"); sqlcmd.Connection = LocalSQLConn; object objTempSipNumber = sqlcmd.ExecuteScalar(); sqlcmd = new SqlCeCommand("INSERT INTO Registered_Users (UserName,SIPNumber) VALUES ('" + uName + "','" + objTempSipNumber.ToString() + "')"); sqlcmd.Connection = LocalSQLConn; sqlcmd.ExecuteNonQuery(); } return objSuperNodeInfo; } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "BootStrapServiceDomain_EntHTTPBsGetSuperNodeIP", "Domains\\BootstrapServiceDomain.cs"); return null; } }
public void Dispose() { try { if (objRTCAuthClient != null) { objRTCAuthClient = null; } if (EntAutherized != null) { EntAutherized = null; } if (objSuperNodeDataContract != null) { objSuperNodeDataContract = null; } if (txtEmail != null) { txtEmail = null; } if (dispTimer4DomainLoading != null) { dispTimer4DomainLoading = null; } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "Dispose()", "Controls\\CtlLogin.xaml.cs"); } }