public void RegisterNewServerUINRequest()
    {
        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 (ServersNetworkSecurity.UserAccount userAccount_obj in ServersNetworkSecurity.UserAccount.UsersAccounts)
            {
                try
                {
                    if (ulong.Parse(userAccount_obj.UIN) == ulong_GeneratedUIN)
                    {
                        RegisterNewServerUINRequest();

                        return;
                    }
                }
                catch
                {
                    return;
                }
            }

            //---------------------------------------------------------------------------------------------------------------

            ServersNetworkSecurity.UserAccount userAccount_NewAccount = new ServersNetworkSecurity.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;

            ServersNetworkSecurity.AddNewUser(userAccount_NewAccount);
            ServersNetworkSecurity.StoreNewServerUserAccountToDB(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, 13);
            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;
        }
    }
    public void FillServersSecurityDataBase()
    {
        try
        {
            if (ConnectingServiceDB.ServersSecurityDataBase.Rows.Count < 0)
            {
                return;
            }

            DataRow dataRow_NewRecord = null;

            DataSet_ConnectingServiceDB.ServersSecurityDataBaseDataTable securityDataBaseDataTable_obj = ConnectingServiceDB.ServersSecurityDataBase;

            ServersNetworkSecurity.UserAccount userAccount_NewAccount = null;

            for (int int_CycleCount = 0; int_CycleCount != securityDataBaseDataTable_obj.Rows.Count; int_CycleCount++)
            {
                dataRow_NewRecord = ConnectingServiceDB.ServersSecurityDataBase.Rows[int_CycleCount];

                userAccount_NewAccount = new ServersNetworkSecurity.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.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];
                userAccount_NewAccount.IsEnabled   = (bool)dataRow_NewRecord[securityDataBaseDataTable_obj.EnabledAccountStateColumn];

                if (userAccount_NewAccount.IsActivated == true)
                {
                    userAccount_NewAccount.ActivationTime = (DateTime)dataRow_NewRecord[securityDataBaseDataTable_obj.ActivationTimeColumn];
                }


                dataRow_NewRecord = ConnectingServiceDB.ServersSecurityDataBase.Rows[int_CycleCount];

                ServersNetworkSecurity.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 LoadServersAccessRestrictionRules()
    {
        try
        {
            if (ConnectingServiceDB.ClientsAccessRestrictionRules.Rows.Count < 0)
            {
                return;
            }

            DataRow dataRow_NewRecord = null;

            DataSet_ConnectingServiceDB.ServersAccessRestrictionRulesDataTable accessRestrictionRulesDataTable_obj = ConnectingServiceDB.ServersAccessRestrictionRules;

            ////////////////////////////////////////////////////////////////////////////////

            IPAddress iPAddress_IPAddressesRangeStartValue = null;
            IPAddress iPAddress_IPAddressesRangeEndValue   = null;
            IPAddress iPAddress_IPAddress = null;

            string string_IPAddressesRangeStartValue = "", string_IPAddressesRangeEndValue = "",
                   string_IPAddress = "", string_MACAddress = "", string_IPAddressesRangeValue = "",
                   string_RuleType = "";

            bool bool_ComplementaryUseMACAddress;

            int int_RuleType = 0;

            DateTime dateTime_CreationTime;

            for (int int_CycleCount = 0; int_CycleCount != accessRestrictionRulesDataTable_obj.Rows.Count; int_CycleCount++)
            {
                iPAddress_IPAddressesRangeStartValue = iPAddress_IPAddressesRangeEndValue = iPAddress_IPAddress = null;

                string_IPAddressesRangeStartValue = string_IPAddressesRangeEndValue = string_IPAddress =
                    string_MACAddress             = string_IPAddressesRangeValue = string_RuleType = string.Empty;

                dataRow_NewRecord = ConnectingServiceDB.ServersAccessRestrictionRules.Rows[int_CycleCount];

                string_IPAddressesRangeStartValue = (string)dataRow_NewRecord[accessRestrictionRulesDataTable_obj.IPRangeStartValueColumn];
                string_IPAddressesRangeEndValue   = (string)dataRow_NewRecord[accessRestrictionRulesDataTable_obj.IPRangeEndValueColumn];

                string_IPAddress = (string)dataRow_NewRecord[accessRestrictionRulesDataTable_obj.IPAddressColumn];

                string_MACAddress = (string)dataRow_NewRecord[accessRestrictionRulesDataTable_obj.MACAddressColumn];

                dateTime_CreationTime = (DateTime)dataRow_NewRecord[accessRestrictionRulesDataTable_obj.CreationTimeColumn];

                bool_ComplementaryUseMACAddress = (bool)dataRow_NewRecord[accessRestrictionRulesDataTable_obj.ComplementaryUseMACAddressColumn];

                int_RuleType = (int)dataRow_NewRecord[accessRestrictionRulesDataTable_obj.RuleTypeColumn];

                if (string_IPAddressesRangeStartValue != string.Empty && string_IPAddressesRangeEndValue != string.Empty)
                {
                    iPAddress_IPAddressesRangeStartValue = IPAddress.Parse(string_IPAddressesRangeStartValue);

                    iPAddress_IPAddressesRangeEndValue = IPAddress.Parse(string_IPAddressesRangeEndValue);

                    string_IPAddressesRangeValue = iPAddress_IPAddressesRangeStartValue + " - " + iPAddress_IPAddressesRangeEndValue;
                }
                if (string_IPAddress != string.Empty)
                {
                    iPAddress_IPAddress = IPAddress.Parse(string_IPAddress);
                }

                if (int_RuleType == 0)
                {
                    string_RuleType = ServerStringFactory.GetString(197, MainForm.CurrentLanguage);
                }
                else
                {
                    string_RuleType = ServerStringFactory.GetString(198, MainForm.CurrentLanguage);
                }

                bool bool_IsRuleEnabled = (bool)dataRow_NewRecord[accessRestrictionRulesDataTable_obj.IsRestrictionEnabledColumn];

                ServersNetworkSecurity.AddNewAccessRestrictionRule(iPAddress_IPAddressesRangeStartValue, iPAddress_IPAddressesRangeEndValue, iPAddress_IPAddress,
                                                                   string_MACAddress, bool_ComplementaryUseMACAddress, dateTime_CreationTime, int_RuleType, bool_IsRuleEnabled);

                ObjCopy.obj_MainForm.AddServerAccessRestrictionRuleToListView(string_IPAddressesRangeValue, string_IPAddress, string_MACAddress, dateTime_CreationTime, string_RuleType, bool_IsRuleEnabled);
            }
        }

        catch (Exception)
        {
            if (File.Exists("ConnectingServiceDB"))
            {
                File.Delete("ConnectingServiceDB");
            }

            MessageBox.Show(ServerStringFactory.GetString(128, MainForm.CurrentLanguage), ServerStringFactory.GetString(1, MainForm.CurrentLanguage));

            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 != ServersNetworkSecurity.UserAccount.UsersAccounts.Count; int_intCycleCount++)
        {
            if (ServersNetworkSecurity.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;
        }


        ServersNetworkSecurity.UserAccount userAccount_NewAccount = new ServersNetworkSecurity.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 (ServersNetworkSecurity.AddNewUser(userAccount_NewAccount) == true)
        {
            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);

            ServersNetworkSecurity.StoreNewServerUserAccountToDB(userAccount_NewAccount);
        }

        this.Close();
    }