public Upgrade(UpgradeViewModel viewModel)
        {
            InitializeComponent();

            this.DataContext = viewModel;

            Closing += new System.ComponentModel.CancelEventHandler(Upgrade_Closing);
        }
Exemple #2
0
        private void Initialize()
        {
            try { context.Entry(upgradeViewModel).State = EntityState.Detached; }
            catch (Exception) { }

            upgradeViewModel = new UpgradeViewModel()
            {
                Code = "123456"
            };
        }
Exemple #3
0
        public ActionResult Upgrade()
        {
            var upgrades = _upgradeServices.GetAvailableUpgrades();
            var model    = new UpgradeViewModel()
            {
                AvailableUpgrades = upgrades
            };

            return(View(model));
        }
        public IActionResult Upgrade(string returnUrl = "")
        {
            SendEmail();

            var model = new UpgradeViewModel {
                ReturnUrl = returnUrl
            };

            return(View(model));
        }
Exemple #5
0
 public UpgradePage()
 {
     InitializeComponent();
     vm = new UpgradeViewModel
     {
         Title = Data.Language.Hardcoded.GetValue("Upgrade"),
         From  = this,
     };
     DataContext = vm;
     Init();
 }
Exemple #6
0
        public DeviceManageViewModel()
        {
            DevicemaCommand = new DelegateCommand <object>(DevicemaShow);
            UseCommand      = new DelegateCommand <object>(UseShow);
            NetCommand      = new DelegateCommand <object>(NetShow);
            UpgradeCommand  = new DelegateCommand <object>(UpgradeShow);
            AbnormalCommand = new DelegateCommand <object>(AbnormalShow);
            HardwareCommand = new DelegateCommand <object>(HardwareShow);

            _DevicemaViewModel = new DevicemaViewModel();
            _UserViewModel     = new UserViewModel();
            _NetViewModel      = new NetViewModel();
            _UpgradeViewModel  = new UpgradeViewModel();
            _AbnormalViewModel = new AbnormalViewModel();
            _HardwareViewModel = new HardwareViewModel();



            bShowPage = DeviceVisibleEnum.DeviceVisibleEnum_Device;
        }
Exemple #7
0
        public ActionResult Upgrade(string uid = null)
        {
            if (!_rohamConfigs.IsInstalled)
            {
                // Redirect to upgrade is invalid and should not happen
                throw new InvalidOperationException("Application is not installed yet");
            }

            var vm = new UpgradeViewModel
            {
                UpgradeOutput = new List <string>()
            };

            if (uid != null)
            {
                MemoryCache.TryGet(GetUpgradeCacheKey(uid), out vm);
            }

            return(View("Upgrade", vm));
        }
        public async Task <IActionResult> Upgrade(UpgradeViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.Code == HttpContext.Session.GetString("emailCode"))
                {
                    SellerAccount sellerAccount = new SellerAccount();
                    sellerAccount.AccountId = Int32.Parse(HttpContext.Session.GetString("userId"));
                    HttpContext.Session.SetInt32("sellerId", sellerAccount.SellerId);

                    SellerAccountsController sellerAccountsController = new SellerAccountsController(_context, _hostEnvironment);
                    await sellerAccountsController.Create(sellerAccount);

                    return(View("UpgradeSuccess"));
                }
                ModelState.AddModelError("", "Code is invalid");
            }
            ModelState.AddModelError("", "Invalid Attempt");
            return(View(model));
        }
Exemple #9
0
        public ActionResult Install(InstallViewModel model)
        {
            if (_rohamConfigs.IsInstalled)
            {
                // Redirect to upgrade is invalid and should not happen here
                throw new InvalidOperationException("Application is not installed yet");
            }

            if (model != null && IsKeyVerified(model.Uid))
            {
                ViewBag.KeyVerified = true;
            }
            if (!ModelState.IsValid || model == null)
            {
                return(View("Install", model));
            }
            if (model.AdminPassword != model.ConfirmAdminPassword)
            {
                ModelState.AddModelError(nameof(ErrorMessages.PasswordAndConfirmShouldMatch), ErrorMessages.PasswordAndConfirmShouldMatch);
                return(View("Install", model));
            }

            try
            {
                var dbInfo         = ExtractDatabaseInfo(model, model.Advanced);
                var cacheInfo      = ExtractCacheInfo(model, model.AdvancedCache);
                var installCommand = new InstallPortalCommand
                {
                    DatabaseProviderName  = model.SelectedDatabaseProvider,
                    CacheProviderName     = model.SelectedCacheProvider,
                    ConnectionString      = _dbProviderFactory.Create(dbInfo.DbProvider).BuildConnectionString(dbInfo),
                    CacheConnectionString = CacheProvider.BuildConnectionString(cacheInfo),
                    UseSmtp      = model.UseSmtp,
                    SmtpFrom     = model.SmtpFrom,
                    SmtpSettings = model.Smtp != null?model.Smtp.ConvertToSettings() : null,
                                       PortalName    = model.PortalName,
                                       AdminUserName = model.AdminUserName,
                                       AdminPassword = model.AdminPassword,
                                       SiteName      = model.PortalName,
                                       SiteZones     = model.Zones.Where(z => model.SelectedZones.Contains(z.Name)).ToList()
                };

                lock (@intallLock)
                {
                    _commandDispatcher.Send(installCommand);
                }

                var upgradeVm = new UpgradeViewModel
                {
                    CacheKey      = GetUpgradeCacheKey(model.Uid),
                    UpgradeOutput = installCommand.UpgradeOutput,
                    Message       = $"{model.PortalName} installed successfully"
                };
                MemoryCache.Set(upgradeVm.CacheKey, upgradeVm);

                return(RedirectToAction("Upgrade", new { uid = model.Uid }));
            }
            catch (Exception ex)
            {
                Log.Warn("Roham installation failed", ex);

                var rohamExp = ex as RohamException;
                var errorMsg = !string.IsNullOrWhiteSpace(rohamExp?.DisplayMessage) ? rohamExp.DisplayMessage : ErrorMessages.InstallationFailed;
                ModelState.AddModelError(nameof(ErrorMessages.InstallationFailed), errorMsg);

                return(View("Install", model));
            }
        }