public void FillClientsSecurityDataBase() { try { if (ConnectingServiceDB.ClientsSecurityDataBase.Rows.Count < 0) { return; } DataRow dataRow_NewRecord = null; DataSet_ConnectingServiceDB.ClientsSecurityDataBaseDataTable securityDataBaseDataTable_obj = ConnectingServiceDB.ClientsSecurityDataBase; ClientsNetworkSecurity.UserAccount userAccount_NewAccount = null; for (int int_CycleCount = 0; int_CycleCount != securityDataBaseDataTable_obj.Rows.Count; int_CycleCount++) { dataRow_NewRecord = ConnectingServiceDB.ClientsSecurityDataBase.Rows[int_CycleCount]; userAccount_NewAccount = new ClientsNetworkSecurity.UserAccount(); userAccount_NewAccount.FirstName = (string)dataRow_NewRecord[securityDataBaseDataTable_obj.UserFirstNameColumn];; userAccount_NewAccount.SecondName = (string)dataRow_NewRecord[securityDataBaseDataTable_obj.UserMiddleNameColumn];; userAccount_NewAccount.LastName = (string)dataRow_NewRecord[securityDataBaseDataTable_obj.UserLastNameColumn]; userAccount_NewAccount.ICQ = (string)dataRow_NewRecord[securityDataBaseDataTable_obj.ICQColumn]; userAccount_NewAccount.EMail = (string)dataRow_NewRecord[securityDataBaseDataTable_obj.EMailColumn]; userAccount_NewAccount.Work = (string)dataRow_NewRecord[securityDataBaseDataTable_obj.CompanyColumn]; userAccount_NewAccount.HomePhone = (string)dataRow_NewRecord[securityDataBaseDataTable_obj.HomePhoneColumn]; userAccount_NewAccount.WorkPhone = (string)dataRow_NewRecord[securityDataBaseDataTable_obj.WorkPhoneColumn]; userAccount_NewAccount.MobilePhone = (string)dataRow_NewRecord[securityDataBaseDataTable_obj.PrivateCellularColumn]; userAccount_NewAccount.ActivationCode = (ulong)dataRow_NewRecord[securityDataBaseDataTable_obj.ActivationCodeColumn]; userAccount_NewAccount.IsActivated = (bool)dataRow_NewRecord[securityDataBaseDataTable_obj.IsActivatedColumn]; userAccount_NewAccount.IsEnabled = (bool)dataRow_NewRecord[securityDataBaseDataTable_obj.EnabledAccountStateColumn]; userAccount_NewAccount.Password = (string)dataRow_NewRecord[securityDataBaseDataTable_obj.UserPasswordColumn]; userAccount_NewAccount.UIN = (string)dataRow_NewRecord[securityDataBaseDataTable_obj.UINColumn]; userAccount_NewAccount.UserName = (string)dataRow_NewRecord[securityDataBaseDataTable_obj.UserNameColumn]; userAccount_NewAccount.CreationTime = (DateTime)dataRow_NewRecord[securityDataBaseDataTable_obj.CreationTimeColumn]; userAccount_NewAccount.IsActivated = (bool)dataRow_NewRecord[securityDataBaseDataTable_obj.IsActivatedColumn]; if (userAccount_NewAccount.IsActivated == true) { userAccount_NewAccount.ActivationTime = (DateTime)dataRow_NewRecord[securityDataBaseDataTable_obj.ActivationTimeColumn]; } dataRow_NewRecord = ConnectingServiceDB.ClientsSecurityDataBase.Rows[int_CycleCount]; ClientsNetworkSecurity.AddNewUser(userAccount_NewAccount); } } catch (Exception) { if (File.Exists("ConnectingServiceDB")) { File.Delete("ConnectingServiceDB"); } MessageBox.Show(ServerStringFactory.GetString(128, MainForm.CurrentLanguage), ServerStringFactory.GetString(1, MainForm.CurrentLanguage)); return; } }
public void RegisterNewClientUINRequest() { try { string string_UserName, string_Password, string_FirstName, string_SecondName, string_LastName, string_ICQ, string_EMail, string_Work, string_HomePhone, string_WorkPhone, string_MobilePhone; //--------------------------------------------------------------------------------------------------------------- MemoryStream memoryStream_ReceivedData = new MemoryStream(byteArray_ReceivedData, 4, byteArray_ReceivedData.Length - 4); string_UserName = CommonMethods.ReadStringFromStream(memoryStream_ReceivedData); string_Password = CommonMethods.ReadStringFromStream(memoryStream_ReceivedData); string_FirstName = CommonMethods.ReadStringFromStream(memoryStream_ReceivedData); string_SecondName = CommonMethods.ReadStringFromStream(memoryStream_ReceivedData); string_LastName = CommonMethods.ReadStringFromStream(memoryStream_ReceivedData); string_ICQ = CommonMethods.ReadStringFromStream(memoryStream_ReceivedData); string_EMail = CommonMethods.ReadStringFromStream(memoryStream_ReceivedData); string_Work = CommonMethods.ReadStringFromStream(memoryStream_ReceivedData); string_HomePhone = CommonMethods.ReadStringFromStream(memoryStream_ReceivedData); string_WorkPhone = CommonMethods.ReadStringFromStream(memoryStream_ReceivedData); string_MobilePhone = CommonMethods.ReadStringFromStream(memoryStream_ReceivedData); memoryStream_ReceivedData.Close(); //--------------------------------------------------------------------------------------------------------------- Random random_obj = new Random(); ulong ulong_GeneratedUIN = (ulong)(random_obj.Next()); foreach (ClientsNetworkSecurity.UserAccount userAccount_obj in ClientsNetworkSecurity.UserAccount.UsersAccounts) { try { if (ulong.Parse(userAccount_obj.UIN) == ulong_GeneratedUIN) { RegisterNewClientUINRequest(); return; } } catch { return; } } //--------------------------------------------------------------------------------------------------------------- ClientsNetworkSecurity.UserAccount userAccount_NewAccount = new ClientsNetworkSecurity.UserAccount(); userAccount_NewAccount.FirstName = string_FirstName; userAccount_NewAccount.SecondName = string_SecondName; userAccount_NewAccount.LastName = string_LastName; userAccount_NewAccount.ICQ = string_ICQ; userAccount_NewAccount.EMail = string_EMail; userAccount_NewAccount.Work = string_Work; userAccount_NewAccount.HomePhone = string_HomePhone; userAccount_NewAccount.WorkPhone = string_WorkPhone; userAccount_NewAccount.MobilePhone = string_MobilePhone; userAccount_NewAccount.ActivationCode = (ulong)(random_obj.Next()); userAccount_NewAccount.IsEnabled = true; userAccount_NewAccount.IsActivated = false; userAccount_NewAccount.Password = string_Password; userAccount_NewAccount.UIN = ulong_GeneratedUIN.ToString(); userAccount_NewAccount.UserName = string_UserName; userAccount_NewAccount.CreationTime = DateTime.Now; ClientsNetworkSecurity.AddNewUser(userAccount_NewAccount); ClientsNetworkSecurity.StoreNewClientUserAccountToDB(userAccount_NewAccount); //--------------------------------------------------------------------------------------------------------------- string string_Message = "Your YakSys Connecting Service Activation Code for UIN " + ulong_GeneratedUIN.ToString() + " is: " + userAccount_NewAccount.ActivationCode.ToString(); SendMail(userAccount_NewAccount.EMail, "*****@*****.**", "YakSys Connecting Service Activation Code", string_Message); //--------------------------------------------------------------------------------------------------------------- MemoryStream memoryStream_DataToSend = new MemoryStream(); CommonMethods.WriteIntToStream(memoryStream_DataToSend, 12); CommonMethods.WriteUInt64ToStream(memoryStream_DataToSend, ulong_GeneratedUIN); NecessaryBaseChannelObject.SendData(memoryStream_DataToSend.ToArray(), SentDataType.ApplicationData); memoryStream_DataToSend.Close(); } catch (Exception exception) { MessageBox.Show(exception.Message + " -- " + exception.StackTrace); return; } }
private void button_UsersAccountsManagerForm_Add_Click(object sender, System.EventArgs e) { if (this.textBox_UsersAccountsManagerForm_Login.Text.Length == 0 || this.textBox_UsersAccountsManagerForm_NewPassword.Text.Length == 0 || this.textBox_UsersAccountsManagerForm_ConfirmedPassword.Text.Length == 0 || this.textBox_UsersAccountsManagerForm_UserName.Text.Length == 0) { MessageBox.Show(ServerStringFactory.GetString(60, MainForm.CurrentLanguage), ServerStringFactory.GetString(1, MainForm.CurrentLanguage), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (this.textBox_UsersAccountsManagerForm_ConfirmedPassword.Text.Length < 6) { MessageBox.Show("password length can't be less than 6 characters"); return; } for (int int_intCycleCount = 0; int_intCycleCount != ClientsNetworkSecurity.UserAccount.UsersAccounts.Count; int_intCycleCount++) { if (ClientsNetworkSecurity.UserAccount.UsersAccounts[int_intCycleCount].UIN == this.textBox_UsersAccountsManagerForm_Login.Text) { MessageBox.Show(ServerStringFactory.GetString(61, MainForm.CurrentLanguage), ServerStringFactory.GetString(1, MainForm.CurrentLanguage), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } if (this.textBox_UsersAccountsManagerForm_NewPassword.Text != this.textBox_UsersAccountsManagerForm_ConfirmedPassword.Text) { MessageBox.Show(ServerStringFactory.GetString(115, MainForm.CurrentLanguage), ServerStringFactory.GetString(1, MainForm.CurrentLanguage), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } ClientsNetworkSecurity.UserAccount userAccount_NewAccount = new ClientsNetworkSecurity.UserAccount(); userAccount_NewAccount.FirstName = this.textBox_UsersAccountsManagerForm_FirstName.Text; userAccount_NewAccount.SecondName = this.textBox_UsersAccountsManagerForm_MiddleName.Text; userAccount_NewAccount.LastName = this.textBox_UsersAccountsManagerForm_LastName.Text; userAccount_NewAccount.ICQ = this.textBox_UsersAccountsManagerForm_ICQ.Text; userAccount_NewAccount.EMail = this.textBox_UsersAccountsManagerForm_EMailAddress.Text; userAccount_NewAccount.Work = this.textBox_UsersAccountsManagerForm_Company.Text; userAccount_NewAccount.HomePhone = this.textBox_UsersAccountsManagerForm_HomePhome.Text; userAccount_NewAccount.WorkPhone = this.textBox_UsersAccountsManagerForm_WorkPhone.Text; userAccount_NewAccount.MobilePhone = this.textBox_UsersAccountsManagerForm_PrivateCellular.Text;; userAccount_NewAccount.ActivationCode = 0; userAccount_NewAccount.IsEnabled = true; userAccount_NewAccount.IsActivated = true; userAccount_NewAccount.Password = this.textBox_UsersAccountsManagerForm_NewPassword.Text; userAccount_NewAccount.UIN = this.textBox_UsersAccountsManagerForm_Login.Text; userAccount_NewAccount.UserName = this.textBox_UsersAccountsManagerForm_UserName.Text; userAccount_NewAccount.CreationTime = DateTime.Now; userAccount_NewAccount.ActivationTime = DateTime.Now; if (ClientsNetworkSecurity.AddNewUser(userAccount_NewAccount) == true) { ClientsNetworkSecurity.StoreNewClientUserAccountToDB(userAccount_NewAccount); } #region Call Log Event ConnectingServiceLogsEvents.NewServersLogRecordEvent(ServerStringFactory.GetString(44, MainForm.CurrentLanguage), DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString(), userAccount_NewAccount.UserName, userAccount_NewAccount.UIN, ServerStringFactory.GetString(1, MainForm.CurrentLanguage), ServerStringFactory.GetString(45, MainForm.CurrentLanguage), false); #endregion this.Close(); }