예제 #1
0
        public ActionResult Step2(DatabaseConnectionModel model)
        {
            try
            {
                var validator         = new FluentBaseValidator <DatabaseConnectionModel, DatabaseConnectionRules>(model);
                var validationResults = validator.Validate();
                if (!validator.IsValid)
                {
                    throw new CustomValidationException(Messages.DangerInvalidEntitiy)
                          {
                              ValidationResult = validationResults
                          };
                }


                using (var context = new InstallationDatabaseContext())
                {
                    _installerLanguage = new LanguageInstaller(new Repository <Language>(context));
                    if (_installerLanguage.Exists())
                    {
                        return(RedirectToAction("Step3"));
                    }
                    foreach (var language in _installerLanguage.GetList())
                    {
                        _installerLanguage.Add(language);
                    }

                    return(RedirectToAction("Step3"));
                }
            }

            catch (CustomValidationException exception)
            {
                var validationResult = exception.ValidationResult;
                foreach (var t in validationResult)
                {
                    ModelState.AddModelError(t.PropertyName, t.ErrorMessage);
                }
            }

            catch (SqlException exception)
            {
                model.HasError = true;
                model.Message  = "Veritabanına bağlanılamadı. Lütfen bilgilerinizi kontrol ediniz." + exception.Message;
            }

            return(View(model));
        }
예제 #2
0
            public void Initialize()
            {
                WebApiConfig.Register(System.Web.Http.GlobalConfiguration.Configuration);

                //db > entityframe migrations init

                //Database.SetInitializer<DBEntities>(new MigrateDatabaseToLatestVersion<DBEntities, W3S_GCS.Migrations.Configuration>());
                //using (DBEntities db = new DBEntities()) {
                //    db.Database.Initialize(true);
                //}

                //db > via package actions
                PackageActions.InitDatabase();

                LanguageInstaller.CheckAndInstallLanguageActions();
            }
 public static ComponentInstallerBase GetInstaller(string installerType)
 {
     ComponentInstallerBase installer = null;
     switch (installerType)
     {
         case "File":
             installer = new FileInstaller();
             break;
         case "Assembly":
             installer = new AssemblyInstaller();
             break;
         case "ResourceFile":
             installer = new ResourceFileInstaller();
             break;
         case "AuthenticationSystem":
         case "Auth_System":
             installer = new AuthenticationInstaller();
             break;
         case "DashboardControl":
             installer = new DashboardInstaller();
             break;
         case "Script":
             installer = new ScriptInstaller();
             break;
         case "Config":
             installer = new ConfigInstaller();
             break;
         case "Cleanup":
             installer = new CleanupInstaller();
             break;
         case "Skin":
             installer = new SkinInstaller();
             break;
         case "Container":
             installer = new ContainerInstaller();
             break;
         case "Module":
             installer = new ModuleInstaller();
             break;
         case "CoreLanguage":
             installer = new LanguageInstaller(LanguagePackType.Core);
             break;
         case "ExtensionLanguage":
             installer = new LanguageInstaller(LanguagePackType.Extension);
             break;
         case "Provider":
             installer = new ProviderInstaller();
             break;
         case "SkinObject":
             installer = new SkinControlInstaller();
             break;
         case "Widget":
             installer = new WidgetInstaller();
             break;
         default:
             ListController listController = new ListController();
             ListEntryInfo entry = listController.GetListEntryInfo("Installer", installerType);
             if (entry != null && !string.IsNullOrEmpty(entry.Text))
             {
                 installer = (ComponentInstallerBase)Reflection.CreateObject(entry.Text, "Installer_" + entry.Value);
             }
             break;
     }
     return installer;
 }
예제 #4
0
        public ActionResult Step3(AdminModel model)
        {
            try
            {
                var validator         = new FluentBaseValidator <AdminModel, AdminRules>(model);
                var validationResults = validator.Validate();
                if (!validator.IsValid)
                {
                    throw new CustomValidationException(Messages.DangerInvalidEntitiy)
                          {
                              ValidationResult = validationResults
                          };
                }

                using (var context = new InstallationDatabaseContext())
                {
                    _installerPerson = new PersonInstaller(new Repository <Person>(context), new Repository <PersonHistory>(context));

                    if (_installerPerson.Exists())
                    {
                        return(RedirectToAction("Step4"));
                    }

                    var person = _installerPerson.Add(new Person
                    {
                        Id           = Guid.NewGuid(),
                        FirstName    = model.FirstName,
                        LastName     = model.LastName,
                        TcKimlikNo   = "12345678901",
                        BirthDate    = DateTime.Now.AddYears(-30),
                        DisplayOrder = 1,
                        CreateDate   = DateTime.Now,
                        IsApproved   = true
                    });
                    _installerUser     = new UserInstaller(new Repository <User>(context), new Repository <UserHistory>(context));
                    _installerLanguage = new LanguageInstaller(new Repository <Language>(context));
                    var user = _installerUser.Add(new User
                    {
                        Id              = Guid.NewGuid(),
                        Username        = model.Username,
                        Password        = model.Password,
                        ConfirmPassword = model.ConfirmPassword,
                        Email           = model.Email,
                        Person          = person,
                        Language        = _installerLanguage.GetFirst(),
                        DisplayOrder    = 1,
                        IsApproved      = true,
                        CreateDate      = DateTime.Now
                    });


                    _installerPerson.Add(new PersonHistory
                    {
                        Id               = Guid.NewGuid(),
                        PersonId         = person.Id,
                        FirstName        = person.FirstName,
                        LastName         = person.LastName,
                        DisplayOrder     = person.DisplayOrder,
                        IsApproved       = person.IsApproved,
                        CreateDate       = person.CreateDate,
                        CreatedBy        = user.Id,
                        VersionNo        = 1,
                        RestoreVersionNo = 0,
                        IsDeleted        = false
                    });


                    _installerUser.Add(new UserHistory
                    {
                        Id               = Guid.NewGuid(),
                        UserId           = user.Id,
                        Username         = user.Username,
                        Password         = user.Password,
                        Email            = user.Email,
                        PersonId         = user.Person.Id,
                        LanguageId       = user.Language.Id,
                        DisplayOrder     = user.DisplayOrder,
                        IsApproved       = user.IsApproved,
                        CreateDate       = user.CreateDate,
                        CreatedBy        = user.Id,
                        VersionNo        = 1,
                        RestoreVersionNo = 0,
                        IsDeleted        = false
                    });


                    _installerRole = new RoleInstaller(new Repository <User>(context), new Repository <Role>(context), new Repository <RoleHistory>(context), new Repository <RoleLanguageLine>(context), new Repository <RoleLanguageLineHistory>(context), new Repository <Language>(context));

                    foreach (var role in _installerRole.GetRoleList())
                    {
                        _installerRole.AddRole(role);
                    }

                    var roles = _installerRole.GetAllRoles();


                    foreach (var roleHistory in _installerRole.GetRoleHistoryList(roles))
                    {
                        _installerRole.AddRoleHistory(roleHistory);
                    }

                    var roleLanguageLines = _installerRole.GetAllRoleLanguageLines();

                    foreach (var roleLanguageLine in _installerRole.GetRoleLanguageLineList(roles))
                    {
                        _installerRole.AddRoleLanguageLine(roleLanguageLine);
                    }

                    foreach (var roleLanguageLineHistory in _installerRole.GetRoleLanguageLineHistoryList(roleLanguageLines))
                    {
                        _installerRole.AddRoleLanguageLineHistory(roleLanguageLineHistory);
                    }



                    _installerRoleUserLine = new RoleUserLineInstaller(new Repository <User>(context), new Repository <RoleUserLine>(context), new Repository <RoleUserLineHistory>(context), new Repository <Role>(context));

                    foreach (var roleUserLine in _installerRoleUserLine.GetRoleUserLineList())
                    {
                        _installerRoleUserLine.AddRoleUserLine(roleUserLine);
                    }


                    foreach (var roleUserLineHistory in _installerRoleUserLine.GetRoleUserLineHistoryList())
                    {
                        _installerRoleUserLine.AddRoleUserLineHistory(roleUserLineHistory);
                    }


                    _installerAction = new ActionInstaller(new Repository <Action>(context));

                    foreach (var action in _installerAction.GetActionList())
                    {
                        _installerAction.AddAction(action);
                    }


                    _installerApplicationSetting = new ApplicationSettingInstaller(new Repository <ApplicationSetting>(context), new Repository <ApplicationSettingHistory>(context));

                    foreach (var applicationSetting in _installerApplicationSetting.GetApplicationSettingList())
                    {
                        _installerApplicationSetting.AddApplicationSetting(applicationSetting);
                    }

                    return(RedirectToAction("Step4"));
                }
            }

            catch (CustomValidationException exception)
            {
                var validationResult = exception.ValidationResult;
                foreach (var t in validationResult)
                {
                    ModelState.AddModelError(t.PropertyName, t.ErrorMessage);
                }
            }


            catch (SqlException)
            {
                model.HasError = true;
                model.Message  = "Yönetici bilgileri kaydedilemedi. Lütfen bilgilerinizi kontrol ediniz.";
            }


            return(View(model));
        }