Пример #1
0
        private bool ComercialUpdate(string AdminsLogin, string AdminsPswd, bool bEncode)
        {
            Function.Variables.ConnectionString connectionString = new Function.Variables.ConnectionString();


            #region Проверяем "IsNullOrEmpty"

            if (String.IsNullOrEmpty(AdminsLogin) && String.IsNullOrEmpty(AdminsPswd))
            {
                return(false);
            }

            #endregion


            #region Декодируем Логин и Пароль

            if (bEncode)
            {
                Account.EncodeDecode encode = new Account.EncodeDecode();
                AdminsLogin = encode.UnionDecode(AdminsLogin);
                AdminsPswd  = encode.UnionDecode(AdminsPswd);
            }

            #endregion


            #region Проверяем Логин и Пароль

            using (DbConnectionLogin db = new DbConnectionLogin("ConnStrMSSQL"))
            {
                db.Database.Connection.Open();

                var query = db.SysAdmins.Where(x => x.AdminsLogin == AdminsLogin && x.AdminsPswd == AdminsPswd && x.AdminsActive == true).ToList();
                if (query.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            #endregion
        }
Пример #2
0
        private void SQLitePswd(int DirCustomersID, string Login, int DirLanguageID)
        {
            /*
             * using (SQLiteConnection con = new SQLiteConnection(_var.GetSQLiteBasicConnStr_DirCustomersID(DirCustomersID)))
             * {
             *  con.Open();
             *  using (SQLiteCommand cmd = new SQLiteCommand("SELECT DirEmployeeLogin, DirEmployeePswd FROM DirEmployees WHERE DirEmployeeID=1", con))
             *  {
             *      //SQLiteParameter parDirEmployeeID = new SQLiteParameter("@DirEmployeeID", System.Data.DbType.Int32) { Value = DirCustomersID }; cmd.Parameters.Add(parDirEmployeeID);
             *      using (SQLiteDataReader dr = cmd.ExecuteReader())
             *      {
             *          if (dr.Read())
             *          {
             *              SendMsg +=
             *              "Данные для входа:<br /><br />" +
             *
             *              "Web-сервис:<br />" +
             *              "Ваш Логин: <b>" + dr["DirEmployeeLogin"].ToString() + "@" + Login + "</b><br />" +
             *              "Ваш Пароль: <b>" + dr["DirEmployeePswd"].ToString() + "</b> (можно поменять в сервисе)<br /><br />" +
             *
             *              "<b>Прямая гиперссылка для входа в сервис:</b><br />" +
             *              "<a href='https://sklad.intradecloud.com/Login.aspx?username="******"DirEmployeeLogin"].ToString() + "@" + Login + "&password="******"DirEmployeePswd"].ToString() + "&language=" + DirLanguageID + "&theme=1'>" +
             *              "https://sklad.intradecloud.com/Login.aspx?username="******"DirEmployeeLogin"].ToString() + "@" + Login + "&password="******"DirEmployeePswd"].ToString() + "&language=" + DirLanguageID + "&theme=1</a><br /><br />" +
             *              "<br />";
             *          }
             *      }
             *  }
             *  con.Close(); con.Dispose();
             * }
             */

            Classes.Function.Variables.ConnectionString connectionString = new Function.Variables.ConnectionString();
            using (DbConnectionSklad db = new DbConnectionSklad(connectionString.Return(DirCustomersID, null, true)))
            {
                //"SELECT DirEmployeeLogin, DirEmployeePswd FROM DirEmployee WHERE DirEmployeeID=1"
                var query =
                    (
                        from dirEmployees in db.DirEmployees
                        where dirEmployees.DirEmployeeID == 1
                        select new
                {
                    DirEmployeeLogin = dirEmployees.DirEmployeeLogin,
                    DirEmployeePswd = dirEmployees.DirEmployeePswd
                }
                    ).ToList();

                for (int i = 0; i < query.Count(); i++)
                {
                    SendMsg +=
                        "Данные для входа:<br /><br />" +

                        "Web-сервис:<br />" +
                        "Ваш Логин: <b>" + query[0].DirEmployeeLogin + "@" + Login + "</b><br />" +
                        "Ваш Пароль: <b>" + query[0].DirEmployeePswd + "</b> (можно поменять в сервисе)<br /><br />" +

                        "<b>Прямая гиперссылка для входа в сервис:</b><br />" +
                        "<a href='https://sklad.intradecloud.com/account/login/?username="******"@" + Login + "&password="******"&language=" + DirLanguageID + "&theme=1'>" +
                        "https://sklad.intradecloud.com/account/login/?username="******"@" + Login + "&password="******"&language=" + DirLanguageID + "&theme=1</a><br /><br />" +
                        "<br />";
                }
            }
        }
Пример #3
0
        private Field Comercial(string DirEmployeeLogin, string DirEmployeePswd, bool bEncode)
        {
            Function.Variables.ConnectionString connectionString = new Function.Variables.ConnectionString();
            Field field = new Field();


            #region Проверяем "IsNullOrEmpty"

            if (String.IsNullOrEmpty(DirEmployeeLogin) && String.IsNullOrEmpty(DirEmployeePswd))
            {
                field.Access = false; field.Msg = Classes.Language.Sklad.Language.msg4;
                return(field);
            }

            #endregion


            #region Декодируем Логин и Пароль

            if (bEncode)
            {
                Account.EncodeDecode encode = new Account.EncodeDecode();
                DirEmployeeLogin = encode.UnionDecode(DirEmployeeLogin);
                field.LoginFull  = DirEmployeeLogin;
                DirEmployeePswd  = encode.UnionDecode(DirEmployeePswd);
            }

            #endregion


            #region  азщепляем Логин на 2-е составные части Логин@МояКомпания

            if (DirEmployeeLogin.IndexOf("@") == -1)
            {
                field.Access = false; field.Msg = Classes.Language.Sklad.Language.msg26;
                return(field);
            }
            else
            {
                string _Login = DirEmployeeLogin;
                int    p1     = _Login.IndexOf("@");
                DirEmployeeLogin = _Login;
                DirEmployeeLogin = DirEmployeeLogin.Remove(p1, DirEmployeeLogin.Length - p1);
                field.Login      = _Login.Remove(0, p1 + 1);
            }

            #endregion


            #region Получаем DirCustomersID (из MS SQL)

            //Получаем ID-шник в БД MS SQL
            field.DirCustomersID = connectionString.mDirCustomersID(field.Login);
            //Полученные варианты
            if (field.DirCustomersID == -1) //Не найден такой User.
            {
                field.Access = false; field.Msg = Classes.Language.Sklad.Language.msg1 + DirEmployeeLogin;
                return(field);
            }
            else if (field.DirCustomersID == 0) //Найден такой User, но не активен (долго не заходил в свой аккаунт)
            {
                field.Access = false; field.Msg = Classes.Language.Sklad.Language.msg2();
                return(field);
            }

            #endregion


            #region Проверяем Логин и Пароль

            //using (DbConnectionSklad db = new DbConnectionSklad(GetSQLiteBasicConnStr_DirCustomersID(field.DirCustomersID)))
            using (DbConnectionSklad db = new DbConnectionSklad(connectionString.Return(field.DirCustomersID, null, true)))
            {
                db.Database.Connection.Open();

                var query = db.DirEmployees.Where(x => x.DirEmployeeLogin == DirEmployeeLogin && x.DirEmployeePswd == DirEmployeePswd && x.Del == false && x.DirEmployeeActive == true).ToList();
                if (query.Count > 0)
                {
                    Models.Sklad.Dir.DirEmployee dirEmployee = query[0];

                    field.Access        = true;
                    field.DirEmployeeID = Convert.ToInt32(dirEmployee.DirEmployeeID);

                    //field.SysDirRightsID = dirEmployee.SysDirRightsID;
                    //field.RetailOnly = Convert.ToBoolean(dirEmployee.RetailOnly);
                }
                else
                {
                    field.Access = false; field.Msg = Classes.Language.Sklad.Language.msg4;
                    return(field);
                }
            }

            #endregion


            return(field);
        }
Пример #4
0
        private void Copy_Folder_DBFile(int DirCustomersID)
        {
            //Class.Settings.Variables _var = new Class.Settings.Variables();
            Classes.Function.Variables.ConnectionString connectionString = new Function.Variables.ConnectionString();

            //1.Создание папок в Users\
            // user_XXX
            //  user_XXX\Base
            //  user_XXX\File
            if (!Directory.Exists(connectionString.SQLitePathUser() + @"\user_" + DirCustomersID))
            {
                Directory.CreateDirectory(connectionString.SQLitePathUser() + @"\user_" + DirCustomersID);
            }
            if (!Directory.Exists(connectionString.SQLitePathUser() + @"\user_" + DirCustomersID + @"\Base"))
            {
                Directory.CreateDirectory(connectionString.SQLitePathUser() + @"\user_" + DirCustomersID + @"\Base");
            }
            if (!Directory.Exists(connectionString.SQLitePathUser() + @"\user_" + DirCustomersID + @"\File"))
            {
                Directory.CreateDirectory(connectionString.SQLitePathUser() + @"\user_" + DirCustomersID + @"\File");
            }
            if (!Directory.Exists(connectionString.SQLitePathUser() + @"\user_" + DirCustomersID + @"\File\Logo"))
            {
                Directory.CreateDirectory(connectionString.SQLitePathUser() + @"\user_" + DirCustomersID + @"\File\Logo");
            }
            if (!Directory.Exists(connectionString.SQLitePathUser() + @"\user_" + DirCustomersID + @"\File\Photo"))
            {
                Directory.CreateDirectory(connectionString.SQLitePathUser() + @"\user_" + DirCustomersID + @"\File\Photo");
            }
            if (!Directory.Exists(connectionString.SQLitePathUser() + @"\user_" + DirCustomersID + @"\File\Export"))
            {
                Directory.CreateDirectory(connectionString.SQLitePathUser() + @"\user_" + DirCustomersID + @"\File\Export");
            }

            //2.Копирование БД из 'Users\Etalon\Base\basic.db' в 'Users\user_XXX\Base\basic.db'
            if (!File.Exists(connectionString.SQLitePathUser() + @"\user_" + DirCustomersID + @"\Base\basic.db"))
            {
                File.Copy(connectionString.SQLitePathEtalon(), connectionString.SQLitePathUser() + @"\user_" + DirCustomersID + @"\Base\basic.db");
            }

            /*
             * using (SQLiteConnection con = new SQLiteConnection(connectionString.GetSQLiteBasicConnStr_DirCustomersID(DirCustomersID)))
             * {
             *  using (SQLiteCommand cmd = new SQLiteCommand("UPDATE DirEmployees SET DirEmployeePswd=@DirEmployeePswd", con))
             *  {
             *      SQLiteParameter parDirEmployeePswd = new SQLiteParameter("@DirEmployeePswd", System.Data.DbType.String) { Value = pPswd }; cmd.Parameters.Add(parDirEmployeePswd);
             *      con.Open(); cmd.ExecuteNonQuery(); con.Close(); con.Dispose();
             *  }
             * }
             */

            //2.1.Меняем пароль Администратору
            using (DbConnectionSklad db = new DbConnectionSklad(connectionString.Return(DirCustomersID, null, true)))
            {
                Models.Sklad.Dir.DirEmployee dirEmployee = db.DirEmployees.Where(x => x.DirEmployeeID == 1).ToList()[0];
                dirEmployee.DirEmployeePswd = pPswd;

                db.Entry(dirEmployee).State = EntityState.Modified;
                db.SaveChanges();
            }

            //3.Для файлов Users/user_x (например изображения)
            if (!Directory.Exists(connectionString.FilePathUser() + @"\user_" + DirCustomersID))
            {
                Directory.CreateDirectory(connectionString.FilePathUser() + @"\user_" + DirCustomersID);
            }
        }