Ejemplo n.º 1
0
            /// <summary>
            /// Функция добавления прав доступа для пользователя
            /// </summary>
            public static void SetAllowed(int iListenerId, int id, string val)
            {
                string query        = string.Empty;
                int    err          = -1
                , cntRows           = -1;
                DbConnection dbConn = null;

                //Проверить наличие индивидуальной записи...
                cntRows = m_tblValues.Select(@"ID_UNIT=" + id).Length;
                switch (cntRows)
                {
                case 1:     //Вставка записи...
                    query = @"INSERT INTO " + m_nameTableProfilesData + @" ([ID_EXT],[IS_ROLE],[ID_UNIT],[VALUE]) VALUES (" + Id + @",0," + id + @",'" + val + @"')";
                    break;

                case 2:     //Обновление записи...
                    query = @"UPDATE " + m_nameTableProfilesData + @" SET [VALUE]='" + val + @"' WHERE ID_EXT=" + Id + @" AND IS_ROLE=0 AND ID_UNIT=" + id;
                    break;

                default:     //Ошибка - исключение
                    throw new Exception(@"HUsers.HProfiles::SetAllowed (id=" + id + @") - не найдено ни одной записи...");
                }

                dbConn = DbSources.Sources().GetConnection(iListenerId, out err);
                if ((!(dbConn == null)) && (err == 0))
                {
                    DbTSQLInterface.ExecNonQuery(ref dbConn, query, null, null, out err);
                    //Проверить результат сохранения...
                    if (err == 0)
                    {//Обновить таблицу пользовательских настроек...
                        switch (cntRows)
                        {
                        case 1:     //Вставка записи...
                            m_tblValues.Rows.Add(new object [] { Id, 0, id, val });
                            break;

                        case 2:     //Обновление записи...
                            DataRow[] rows = m_tblValues.Select(@"ID_EXT=" + Id + @" AND IS_ROLE=0 AND ID_UNIT=" + id);
                            rows[0][@"VALUE"] = val;
                            break;

                        default:     //Ошибка - исключение
                            //Ошибка обработана - создано исключение...
                            break;
                        }
                    }
                    else
                    {
                        ;
                    }
                }
                else
                {
                    ;
                }
            }
        public void Read(int idListener, out List <ConnectionSettings> listConnSett, out int err, out string mes)
        {
            listConnSett = new List <ConnectionSettings> ();
            err          = 0;
            mes          = string.Empty;

            int i = -1;

            DbConnection conn = DbSources.Sources().GetConnection(idListener, out err);

            //DbConnection conn = DbTSQLInterface.GetConnection (m_ConnectionSettings, out err);

            if (err == 0)
            {
                DataTable tableSource = DbTSQLInterface.Select(ref conn, "SELECT * FROM SOURCE", null, null, out err),
                          tablePsw;

                if (err == 0)
                {
                    for (i = 0; i < tableSource.Rows.Count; i++)
                    {
                        listConnSett.Add(new ConnectionSettings());

                        listConnSett[i].id   = Convert.ToInt32(tableSource.Rows[i]["ID"]);
                        listConnSett[i].name = tableSource.Rows[i]["NAME_SHR"].ToString();

                        listConnSett [i].server  = tableSource.Rows [i] ["IP"].ToString();
                        listConnSett[i].instance = (!(tableSource.Rows[i]["INSTANCE"] is DBNull)) ? tableSource.Rows[i]["INSTANCE"].ToString().Trim() : string.Empty;
                        listConnSett[i].port     = Convert.ToInt32(tableSource.Rows[i]["PORT"]);
                        listConnSett[i].dbName   = tableSource.Rows[i]["DB_NAME"].ToString();
                        listConnSett[i].userName = tableSource.Rows[i]["UID"].ToString();
                        ////Ignore
                        //listConnSett[i].ignore = tableSource.Columns.IndexOf(@"IGNORE") < 0 ? false : Convert.ToInt32(tableSource.Rows[i]["IGNORE"].ToString()) == 1;

                        //TYPE_DATABASE_CFG.CFG_200 = ???
                        tablePsw = DbTSQLInterface.Select(ref conn, PasswordRequest(Convert.ToInt32(tableSource.Rows[i]["ID"]), 501), null, null, out err);

                        tableSource = GetConnectionSettings(ref tableSource, i, ref tablePsw, 0);
                        //Password
                        listConnSett[i].password = tableSource.Rows[i]["PASSWORD"].ToString();
                    }
                }
                else
                {
                    ;
                }
            }
            else
            {
                ;
            }

            //DbTSQLInterface.CloseConnection (conn, out err);
        }
Ejemplo n.º 3
0
        protected virtual int response(int idListener, out bool error, out object outobj /*, bool bIsTec*/)
        {
            //return DbSources.Sources().Response(idListener, out error, out table);

            int       iRes  = -1;
            DataTable table = null;

            iRes   = DbSources.Sources().Response(idListener, out error, out table);
            outobj = table as DataTable;

            return(iRes);
        }
Ejemplo n.º 4
0
        public bool SetPassword(string password, uint idExtPass, uint idRolePass)
        {
            int err = -1;

            passResult = Errors.NoError;

            m_idExtPass  = idExtPass;
            m_idRolePass = idRolePass;

            byte[] hash = md5.ComputeHash(Encoding.ASCII.GetBytes(password));

            StringBuilder hashedString = new StringBuilder();

            for (int i = 0; i < hash.Length; i++)
            {
                hashedString.Append(hash[i].ToString("x2"));
            }

            GetPassword(out err);

            if (!(passResult == Errors.NoError))
            {
                //MessageBox.Show(this, "ќшибка получени¤ парол¤ " + getOwnerPass () + ". ѕароль не сохранЄн.", "ќшибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MessageBox("ќшибка получени¤ парол¤ " + getOwnerPass((int)m_idRolePass) + ". ѕароль не сохранЄн.");

                return(false);
            }
            else
            {
                ;
            }

            DbConnection conn = DbSources.Sources().GetConnection(m_idListener, out err);

            if (passReceive == null)
            {
                DbTSQLInterface.ExecNonQuery(ref conn, SetPassRequest(hashedString.ToString(), true), null, null, out err);
            }
            else
            {
                DbTSQLInterface.ExecNonQuery(ref conn, SetPassRequest(hashedString.ToString(), false), null, null, out err);
            }

            if (passResult != Errors.NoError)
            {
                //MessageBox.Show(this, "ќшибка сохранени¤ парол¤ " + getOwnerPass () + ". ѕароль не сохранЄн.", "ќшибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MessageBox("ќшибка сохранени¤ парол¤ " + getOwnerPass((int)m_idRolePass) + ". ѕароль не сохранЄн.");
                return(false);
            }

            return(true);
        }
        /*public static DataTable GetConnectionSettings (ConnectionSettings connSett, int id_ext, int id_role, out int er)
         * {
         *  er = 0;
         *
         *  DataTable tableRes = DbTSQLInterface.Select(connSett, ConnectionSettingsRequest(id_ext), out er),
         *          tablePsw = DbTSQLInterface.Select(connSett, PasswordRequest(id_ext, id_role), out er);
         *
         *  return GetConnectionSettings (ref tableRes, 0, ref tablePsw, 0);
         * }*/

        public static DataTable GetConnectionSettings(TYPE_DATABASE_CFG typeDB_CFG, int idListener, int id_ext, int id_role, out int er)
        {
            DbConnection conn = DbSources.Sources().GetConnection(idListener, out er);

            if (er == 0)
            {
                return(GetConnectionSettings(typeDB_CFG, ref conn, id_ext, id_role, out er));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
 private static void disconnect()
 {
     if (!(s_iIdListener < 0))
     {
         DbSources.Sources().UnRegister(s_iIdListener);
     }
     else
     {
         ;
     }
     s_iIdListener = -1;
     s_dbConn      = null;
 }
Ejemplo n.º 7
0
        //private void fThreadProcConnSett (object obj, DoWorkEventArgs ev)
        //{
        //    INDEX_SYNCHRONIZE indx = INDEX_SYNCHRONIZE.UNKNOWN;

        //    while (! (indx == INDEX_SYNCHRONIZE.EXIT))
        //    {
        //        indx = (INDEX_SYNCHRONIZE) WaitHandle.WaitAny (m_arSyncProc);

        //        switch (indx)
        //        {
        //            case INDEX_SYNCHRONIZE.EXIT:
        //                break;
        //            case INDEX_SYNCHRONIZE.REGISTER:
        //                object []pars = m_queueToRegistered.Dequeue ();
        //                m_queueResult.Enqueue (register (pars [0], (bool)pars [1], (string)pars [2], (bool)pars [3]));
        //                break;
        //            case INDEX_SYNCHRONIZE.UNREGISTER:
        //                unRegister (m_queueToUnRegistered.Dequeue ());
        //                break;
        //            default:
        //                break;
        //        }

        //        m_arEvtComleted[(int)indx - 1].Set ();
        //    }
        //}
        /// <summary>
        /// Функция для доступа к объекту
        /// </summary>
        /// <returns>Объект для управления установленными соединениями с источниками данных</returns>
        public static DbSources Sources()
        {
            if (m_this == null)
            {
                m_this = new DbSources();
            }
            else
            {
                ;
            }

            return(m_this);
        }
Ejemplo n.º 8
0
            public void  Update(int iListenerId, int id_role, int id_user, bool bThrow)
            {
                int    err   = -1;
                string query = string.Empty
                , errMsg     = string.Empty;

                DbConnection dbConn = DbSources.Sources().GetConnection(iListenerId, out err);

                if (!(err == 0))
                {
                    errMsg = @"нет соединения с БД";
                }
                else
                {
                    query       = @"SELECT * FROM " + m_nameTableProfilesData + @" WHERE (ID_EXT=" + id_role + @" AND IS_ROLE=1)" + @" OR (ID_EXT=" + id_user + @" AND IS_ROLE=0)";
                    m_tblValues = DbTSQLInterface.Select(ref dbConn, query, null, null, out err);

                    if (!(err == 0))
                    {
                        errMsg = @"Ошибка при чтении НАСТРоек для группы(роли) (irole = " + id_role + @"), пользователя (iuser="******")";
                    }
                    else
                    {
                        query      = @"SELECT * from " + m_nameTableProfilesUnit;
                        m_tblTypes = DbTSQLInterface.Select(ref dbConn, query, null, null, out err);

                        if (!(err == 0))
                        {
                            errMsg = @"Ошибка при чтении ТИПов ДАНных настроек для группы(роли) (irole = " + id_role + @"), пользователя (iuser="******")";
                        }
                        else
                        {
                            ;
                        }
                    }
                }

                if (
                    (!(err == 0)) &&
                    (bThrow == true)
                    )
                {
                    throw new Exception(@"HProfiles::HProfiles () - " + errMsg + @"...");
                }
                else
                {
                    ;
                }
            }
Ejemplo n.º 9
0
        private void GetPassword(out int er)
        {
            DbConnection conn      = DbSources.Sources().GetConnection(m_idListener, out er);
            DataTable    passTable = DbTSQLInterface.Select(ref conn, GetPassRequest(), null, null, out er);

            if (er == 0)
            {
                if (!(passTable.Rows[0][0] is DBNull))
                {
                    passReceive = passTable.Rows[0][0].ToString();
                }
                else
                {
                    passResult = Errors.ParseError;
                }
            }
            else
            {
                passResult = Errors.NoAccess;
            }
        }
Ejemplo n.º 10
0
        private static int connect()
        {
            int err = -1;

            if (!(s_connSett == null))
            {
                s_iIdListener = DbSources.Sources().Register(s_connSett, false, @"LOGGING_DB");
                if (!(s_iIdListener < 0))
                {
                    s_dbConn = DbSources.Sources().GetConnection(s_iIdListener, out err);
                }
                else
                {
                    ;
                }
            }
            else
            {
                ;
            }

            return(err);
        }
Ejemplo n.º 11
0
        //Журналирование завершения приложения
        public static void Exit()
        {
            List <Form> listApplicationOpenForms = new List <Form>();

            foreach (Form f in Application.OpenForms)
            {
                listApplicationOpenForms.Add(f);
            }

            foreach (Form f in listApplicationOpenForms)
            {
                if (f is FormMainBase)
                {
                    (f as FormMainBase).Close(true);
                }
                else
                if (f is FormWait)
                {
                    //Здесь м. возникнуть ошибка -
                    // вызов формы из потока в котором форма не была создана ???
                    (f as FormWait).StopWaitForm();
                }
                else
                {
                    f.Close();
                }
            }

            Logging.Logg().PostStop(MessageExit);
            Logging.Logg().Stop();

            DbSources.Sources().UnRegister();

            System.ComponentModel.CancelEventArgs cancelEvtArgs = new System.ComponentModel.CancelEventArgs(true);
            Application.Exit(cancelEvtArgs);
        }
Ejemplo n.º 12
0
        private static int connect()
        {
            int err = -1;

            if (!(s_connSett == null))
            {
                s_iIdListener = DbSources.Sources().Register(s_connSett, false, @"LOGGING_DB");
                //Console.WriteLine(@"Logging::connect (active=false) - s_iIdListener=" + s_iIdListener);
                if (!(s_iIdListener < 0))
                {
                    s_dbConn = DbSources.Sources().GetConnection(s_iIdListener, out err);
                }
                else
                {
                    ;
                }
            }
            else
            {
                ;
            }

            return(err);
        }
Ejemplo n.º 13
0
 protected void register(int id, ConnectionSettings connSett, string name, int indx)
 {
     m_dictIdListeners[id][indx] = DbSources.Sources().Register(connSett, true, @"ТЭЦ=" + name + @", DESC=" + indx.ToString());
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Запуск проверки пользователя
        /// </summary>
        private void registrationEnv(object par)
        {
            int idListener = (int)par //idListener = ((int [])par)[0]
                                      //, indxDomainName = ((int[])par)[1]
            ;

            Logging.Logg().Debug(@"HUsers::HUsers () - ... registrationEnv () - вХод ... idListener = " + idListener + @"; m_bRegistration = " + m_bRegistration.ToString() + @"; m_StateRegistration = " + m_StateRegistration, Logging.INDEX_MESSAGE.NOT_SET);

            //Следующий приоритет DataBase
            if (m_bRegistration == false)
            {
                Logging.Logg().Debug(@"HUsers::HUsers () - ... registrationEnv () - m_StateRegistration [(int)INDEX_REGISTRATION.DOMAIN_NAME] = " + m_StateRegistration[(int)INDEX_REGISTRATION.DOMAIN_NAME].ToString(), Logging.INDEX_MESSAGE.NOT_SET);

                try {
                    if (m_StateRegistration [(int)INDEX_REGISTRATION.DOMAIN_NAME] == STATE_REGISTRATION.UNKNOWN)
                    {
                        Logging.Logg().Debug(@"HUsers::HUsers () - ... registrationEnv () - m_StateRegistration [(int)INDEX_REGISTRATION.DOMAIN_NAME] = " + Environment.UserDomainName + @"\" + Environment.UserName, Logging.INDEX_MESSAGE.NOT_SET);
                        //Определить из ENV
                        //Проверка ИМЯ_ПОЛЬЗОВАТЕЛЯ
                        m_DataRegistration[(int)INDEX_REGISTRATION.DOMAIN_NAME]   = Environment.UserDomainName + @"\" + Environment.UserName;
                        m_StateRegistration [(int)INDEX_REGISTRATION.DOMAIN_NAME] = STATE_REGISTRATION.ENV;
                    }
                    else
                    {
                    }
                } catch (Exception e) {
                    Logging.Logg().Exception(e, @"HUsers::HUsers () - ... registrationEnv () ... Проверка ИМЯ_ПОЛЬЗОВАТЕЛЯ ... ", Logging.INDEX_MESSAGE.NOT_SET);
                    throw e;
                }

                int       err = -1;
                DataTable dataUsers;

                DbConnection connDB = DbSources.Sources().GetConnection((int)par, out err);

                if ((!(connDB == null)) && (err == 0))
                {
                    //Проверка ИМЯ_ПОЛЬЗОВАТЕЛЯ
                    GetUsers(ref connDB, @"DOMAIN_NAME=" + @"'" + m_DataRegistration[(int)INDEX_REGISTRATION.DOMAIN_NAME] + @"'", string.Empty, out dataUsers, out err);

                    Logging.Logg().Debug(@"HUsers::HUsers () - ... registrationEnv () - найдено пользователей = " + dataUsers.Rows.Count, Logging.INDEX_MESSAGE.NOT_SET);

                    if ((err == 0) && (dataUsers.Rows.Count > 0))
                    {//Найдена хотя бы одна строка
                        int i = -1;
                        for (i = 0; i < dataUsers.Rows.Count; i++)
                        {
                            //Проверка IP-адрес
                            //for (indxIP = 0; indxIP < listIP.Length; indxIP ++) {
                            //    if (listIP[indxIP].Equals(System.Net.IPAddress.Parse (dataUsers.Rows[i][@"IP"].ToString())) == true) {
                            //        //IP найден
                            //        break;
                            //    }
                            //    else
                            //        ;
                            //}

                            //Проверка ИМЯ_ПОЛЬЗОВАТЕЛЯ
                            if (dataUsers.Rows[i][@"DOMAIN_NAME"].ToString().Trim().Equals((string)m_DataRegistration[(int)INDEX_REGISTRATION.DOMAIN_NAME], StringComparison.CurrentCultureIgnoreCase) == true)
                            {
                                break;
                            }
                            else
                            {
                                ;
                            }
                        }

                        if (i < dataUsers.Rows.Count)
                        {
                            m_DataRegistration[(int)INDEX_REGISTRATION.ID]     = Convert.ToInt32(dataUsers.Rows[i]["ID"]); m_StateRegistration[(int)INDEX_REGISTRATION.ID] = STATE_REGISTRATION.ENV;
                            m_DataRegistration[(int)INDEX_REGISTRATION.ROLE]   = Convert.ToInt32(dataUsers.Rows[i]["ID_ROLE"]); m_StateRegistration[(int)INDEX_REGISTRATION.ROLE] = STATE_REGISTRATION.ENV;
                            m_DataRegistration[(int)INDEX_REGISTRATION.ID_TEC] = Convert.ToInt32(dataUsers.Rows[i]["ID_TEC"]); m_StateRegistration[(int)INDEX_REGISTRATION.ID_TEC] = STATE_REGISTRATION.ENV;
                        }
                        else
                        {
                            throw new Exception("Пользователь не найден в списке БД конфигурации");
                        }
                    }
                    else
                    {//Не найдено ни одной строки
                        if (connDB == null)
                        {
                            throw new HException(-4, "Нет соединения с БД конфигурации");
                        }
                        else
                        if (err == 0)
                        {
                            throw new HException(-3, "Пользователь не найден в списке БД конфигурации");
                        }
                        else
                        {
                            throw new HException(-2, "Ошибка получения списка пользователей из БД конфигурации");
                        }
                    }
                }
                else    //Нет возможности для проверки
                {
                    if (connDB == null)
                    {
                        throw new HException(-4, "Нет соединения с БД конфигурации");
                    }
                    else
                    if (!(err == 0))
                    {
                        throw new HException(-3, "Не удалось установить связь с БД конфигурации");
                    }
                    else
                    {
                        ;
                    }
                }
            }
            else
            {
                Logging.Logg().Debug(@"HUsers::HUsers () - ... registrationEnv () - m_bRegistration = " + m_bRegistration.ToString(), Logging.INDEX_MESSAGE.NOT_SET);
            }

            try {
                m_profiles = createProfiles(idListener, (int)m_DataRegistration[(int)INDEX_REGISTRATION.ROLE], (int)m_DataRegistration[(int)INDEX_REGISTRATION.ID]);
            } catch (Exception e) {
                throw new HException(-6, e.Message);
            }
        }
Ejemplo n.º 15
0
        //protected abstract bool InitDbInterfaces ();

        public void Request(int idListener, string request)
        {
            DbSources.Sources().Request(m_IdListenerCurrent = idListener, request);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Регистрация источника информации с наименованием по ключю, типу, параметрами соединения
 /// </summary>
 /// <param name="id">Ключ группы источников информации</param>
 /// <param name="indx">Тип источника информации</param>
 /// <param name="connSett">Параметры соединения с источником информации</param>
 /// <param name="name">Наименование источника информации</param>
 protected virtual void register(int id, int indx, ConnectionSettings connSett, string name)
 {
     m_dictIdListeners[id][indx] = DbSources.Sources().Register(connSett, true, @"ИстчнкИнфо=" + name + @", DESC=" + indx.ToString());
 }
Ejemplo n.º 17
0
 public virtual bool Response(out bool error, out DataTable table /*, bool bIsTec*/)
 {
     return(DbSources.Sources().Response(m_IdListenerCurrent, out error, out table));
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Запуск проверки пользователя
        /// </summary>
        private void registrationEnv(object par)
        {
            int idListener = (int)par //idListener = ((int [])par)[0]
            , i            = -1
            ;

            //Следующий приоритет DataBase
            if (isRegistration == false)
            {
                Logging.Logg().Debug(string.Format(@"HUsers::HUsers () - ... registrationEnv () - s_StateRegistration [{0}] = {1}", INDEX_REGISTRATION.DOMAIN_NAME, s_StateRegistration[(int)INDEX_REGISTRATION.DOMAIN_NAME].ToString()), Logging.INDEX_MESSAGE.NOT_SET);

                try {
                    if (s_StateRegistration[(int)INDEX_REGISTRATION.ID] == STATE_REGISTRATION.CMD)
                    {
                        // идентификатор указан в командной строке
                        ;
                    }
                    else
                    // если идентификатор не указан в командной строке
                    if (s_StateRegistration[(int)INDEX_REGISTRATION.DOMAIN_NAME] == STATE_REGISTRATION.UNKNOWN)
                    {
                        //Определить из ENV
                        //Проверка ИМЯ_ПОЛЬЗОВАТЕЛЯ
                        switch (s_modeRegistration)
                        {
                        case MODE_REGISTRATION.MACHINE_DOMAINNAME:
                            s_DataRegistration[(int)INDEX_REGISTRATION.DOMAIN_NAME] = MachineName;
                            break;

                        case MODE_REGISTRATION.USER_DOMAINNAME:
                        default:
                            s_DataRegistration[(int)INDEX_REGISTRATION.DOMAIN_NAME] = Environment.UserDomainName + @"\" + Environment.UserName;
                            break;

                        case MODE_REGISTRATION.MIXED:
                            s_DataRegistration[(int)INDEX_REGISTRATION.DOMAIN_NAME] = MachineName + DELIMETER_DOMAINNAME + Environment.UserDomainName + @"\" + Environment.UserName;
                            break;
                        }

                        s_StateRegistration[(int)INDEX_REGISTRATION.DOMAIN_NAME] = STATE_REGISTRATION.ENV;

                        Logging.Logg().Debug(string.Format(@"HUsers::HUsers () - ... registrationEnv () - s_StateRegistration [{0}] = {1}", INDEX_REGISTRATION.DOMAIN_NAME, s_StateRegistration[(int)INDEX_REGISTRATION.DOMAIN_NAME]), Logging.INDEX_MESSAGE.NOT_SET);
                    }
                    else
                    {
                    }
                } catch (Exception e) {
                    Logging.Logg().Exception(e, @"HUsers::HUsers () - ... registrationEnv () ... Проверка ИМЯ_ПОЛЬЗОВАТЕЛЯ ... ", Logging.INDEX_MESSAGE.NOT_SET);
                    throw e;
                }

                int       err = -1;
                DataTable dataUsers;

                DbConnection connDB = DbSources.Sources().GetConnection((int)par, out err);

                if ((!(connDB == null)) && (err == 0))
                {
                    //Проверка ИМЯ_ПОЛЬЗОВАТЕЛЯ
                    GetUsers(ref connDB, whereQueryUsers, string.Empty, out dataUsers, out err);

                    Logging.Logg().Debug(@"HUsers::HUsers () - ... registrationEnv () - найдено пользователей = " + dataUsers.Rows.Count, Logging.INDEX_MESSAGE.NOT_SET);

                    if ((err == 0) && (dataUsers.Rows.Count > 0))
                    {//Найдена хотя бы одна строка
                        i = 0;

                        if ((s_StateRegistration[(int)INDEX_REGISTRATION.ID] == STATE_REGISTRATION.UNKNOWN) ||
                            (s_StateRegistration[(int)INDEX_REGISTRATION.DOMAIN_NAME] == STATE_REGISTRATION.ENV))
                        {
                            for (i = 0; i < dataUsers.Rows.Count; i++)
                            {
                                //Проверка IP-адрес
                                //for (indxIP = 0; indxIP < listIP.Length; indxIP ++) {
                                //    if (listIP[indxIP].Equals(System.Net.IPAddress.Parse (dataUsers.Rows[i][@"IP"].ToString())) == true) {
                                //        //IP найден
                                //        break;
                                //    }
                                //    else
                                //        ;
                                //}

                                //Проверка ИМЯ_ПОЛЬЗОВАТЕЛЯ
                                if (equalsDomainName(dataUsers.Rows[i][@"DOMAIN_NAME"].ToString(), dataUsers.Rows[i][@"COMPUTER_NAME"].ToString()) == true)
                                {
                                    break;
                                }
                                else
                                {
                                    ;
                                }
                            }
                        }
                        else
                        {
                            setDataRegistration(INDEX_REGISTRATION.DOMAIN_NAME, getUserDomainNameEnvironment(dataUsers.Rows[i][@"DOMAIN_NAME"].ToString(), dataUsers.Rows[i][@"COMPUTER_NAME"].ToString()), STATE_REGISTRATION.CMD);
                        }

                        if (i < dataUsers.Rows.Count)
                        {
                            setDataRegistration(INDEX_REGISTRATION.ID, dataUsers.Rows[i]["ID"], STATE_REGISTRATION.ENV);
                            setDataRegistration(INDEX_REGISTRATION.ROLE, dataUsers.Rows[i]["ID_ROLE"], STATE_REGISTRATION.ENV);
                            setDataRegistration(INDEX_REGISTRATION.ID_TEC, dataUsers.Rows[i]["ID_TEC"], STATE_REGISTRATION.ENV);
                        }
                        else
                        {
                            throw new HException((int)ERROR_CODE.UDN_NOT_FOUND, messageUserIDNotFind);
                        }
                    }
                    else
                    {//Не найдено ни одной строки
                        if (connDB == null)
                        {
                            throw new HException((int)ERROR_CODE.NOT_CONNECT_CONFIGDB, "Нет соединения с БД конфигурации");
                        }
                        else
                        if (err == 0)
                        {
                            throw new HException((int)ERROR_CODE.UDN_NOT_FOUND, messageUserIDNotFind);
                        }
                        else
                        {
                            throw new HException((int)ERROR_CODE.QUERY_FAILED, "Ошибка получения списка пользователей из БД конфигурации");
                        }
                    }
                }
                else    //Нет возможности для проверки
                {
                    if (connDB == null)
                    {
                        throw new HException((int)ERROR_CODE.NOT_CONNECT_CONFIGDB, "Нет соединения с БД конфигурации");
                    }
                    else //???
                    if (!(err == 0))
                    {
                        throw new HException((int)ERROR_CODE.NOT_CONNECT_CONFIGDB, "Нет соединения с БД конфигурации");
                    }
                    else
                    {
                        ;
                    }
                }
            }
            else
            {
                Logging.Logg().Debug(string.Format(@"HUsers::HUsers () - ... registrationEnv () - isRegistration = {0}", isRegistration.ToString()), Logging.INDEX_MESSAGE.NOT_SET);
            }

            try {
                m_profiles = createProfiles(idListener, (int)s_DataRegistration[(int)INDEX_REGISTRATION.ROLE], (int)s_DataRegistration[(int)INDEX_REGISTRATION.ID]);
            } catch (Exception e) {
                throw new HException(-6, e.Message);
            }
        }
        public void Save(int idListener, List <ConnectionSettings> listConnSett, out int err)
        {
            err = 1;
            int    i = -1, c = -1;
            string strQuery, psw
            , hash;

            //char []hash;
            //StringBuilder sb;

            strQuery = psw = string.Empty;

            DbConnection conn = DbSources.Sources().GetConnection(idListener, out err);

            //DbConnection conn = DbTSQLInterface.GetConnection (m_ConnectionSettings, out err);

            if (err == 0)
            {
                DataTable tableSource = null,
                          tablePsw    = null;

                if (err == 0)
                {
                    for (i = 0; i < listConnSett.Count; i++)
                    {
                        tableSource = DbTSQLInterface.Select(ref conn, ConnectionSettingsRequest(listConnSett[i].id), null, null, out err);
                        //TYPE_DATABASE_CFG.CFG_200 = ???
                        tablePsw = DbTSQLInterface.Select(ref conn, PasswordRequest(TYPE_DATABASE_CFG.CFG_200, listConnSett[i].id, 501), null, null, out err);

                        if (tableSource.Rows.Count == 0)
                        {//INSERT
                        }
                        else
                        if (tableSource.Rows.Count == 1)
                        {    //UPDATE
                            if ((listConnSett[i].server.Equals(tableSource.Rows [0]["IP"].ToString()) == false) ||
                                (listConnSett[i].dbName.Equals(tableSource.Rows[0]["DB_NAME"].ToString()) == false) ||
                                (listConnSett[i].userName.Equals(tableSource.Rows[0]["UID"].ToString()) == false))
                            {
                                strQuery += "UPDATE SOURCE SET ";

                                strQuery += "IP='" + listConnSett[i].server + "',";
                                strQuery += "DB_NAME='" + listConnSett[i].dbName + "',";
                                strQuery += "UID='" + listConnSett[i].userName + "'";

                                strQuery += " WHERE ID=" + listConnSett[i].id + ";";
                            }
                            else
                            {
                                ;     //Ничего не изменилось
                            }
                            if (listConnSett[i].password.Length > 0)
                            {
                                //sb = new StringBuilder(listConnSett[i].password);
                                //hash = Crypt.Crypting().to(sb, out err);
                                hash = Crypt.Crypting().Encrypt(listConnSett[i].password, Crypt.KEY);

                                //if (err > 0)
                                if (hash.Length > 0)
                                {
                                    if (tablePsw.Rows.Count == 0)
                                    {    //INSERT
                                        strQuery += "INSERT INTO passwords (ID_EXT, ID_ROLE, HASH) VALUES (";

                                        strQuery += listConnSett[i].id + ", ";
                                        strQuery += 501 + ", ";
                                        strQuery += "'" + hash + "'";

                                        strQuery += ");";
                                    }
                                    else
                                    if (tablePsw.Rows.Count == 1)
                                    {        //UPDATE
                                        strQuery += "UPDATE passwords SET ";

                                        strQuery += "HASH='" + hash + "'";

                                        strQuery += " WHERE ID_EXT=" + listConnSett[i].id;
                                        strQuery += " AND ";
                                        strQuery += "ID_ROLE=" + 501 + ";";
                                    }
                                    else
                                    {
                                        ;
                                    }
                                }
                                else
                                {
                                    ;     //Ошибка шифрования пароля ИЛИ нет пароля
                                }
                            }
                            else
                            {
                                ;     //Нет пароля
                            }
                        }
                        else
                        {
                            ;
                        }
                    }

                    DbTSQLInterface.ExecNonQuery(ref conn, strQuery, null, null, out err);
                }
                else
                {
                    ;
                }
            }
            else
            {
                ;
            }

            //DbTSQLInterface.CloseConnection (conn, out err);
        }