Beispiel #1
0
        public static void createFirstUser()
        {
            employee employee = new employee();

            employee.employeeId   = 1;
            employee.employeeName = "admin";
            employee.phone        = "0";
            employee.email        = "N/A";
            employee.gender       = "U";
            employee.registerDate = DateTime.Now;
            employee.isActive     = true;

            user user = new user();

            user.userId       = 1;
            user.employeeId   = 1;
            user.userName     = Encriptar("admin", C_Key, C_IV);
            user.userPassword = Encriptar("root", C_Key, C_IV);
            user.expireDate   = null;

            users_X_rols users_X_Rols = new users_X_rols();

            users_X_Rols.rolId  = 1;
            users_X_Rols.userId = 1;

            using (DB_CRMEntities db = new DB_CRMEntities())
            {
                db.employees.Add(employee);
                db.users.Add(user);
                db.users_X_rols.Add(users_X_Rols);

                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                }
            }
        }
Beispiel #2
0
        public static void createKeys()
        {
            using (Aes myAes = Aes.Create())
            {
                using (DB_CRMEntities db = new DB_CRMEntities())
                {
                    key keys = new key();
                    keys.id    = 1;
                    keys.C_Key = myAes.Key;
                    keys.C_IV  = myAes.IV;

                    C_Key = myAes.Key;
                    C_IV  = myAes.IV;
                    try
                    {
                        db.keys.Add(keys);
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
        }