Exemple #1
0
        /// <summary>
        /// Ons the load.
        /// </summary>
        /// <param name="e">E.</param>
        protected override void OnLoad(EventArgs e)
        {
            InstallationState status = InstallationManager.GetInstallationStatus(VersionInfo.CurrentAssemblyVersion);

            switch (status)
            {
            case InstallationState.NeedsInstallation:
            case InstallationState.NeedsUpgrade:
                EnsureInstallStep("Default.aspx", "Step02_ConfigureHost.aspx");
                break;

            default:
                HostInfo info = HostInfo.LoadHost(true /* suppressException */);

                if (info == null)
                {
                    EnsureInstallStep("Step02_ConfigureHost.aspx");
                }
                if (info != null && Config.BlogCount == 0)
                {
                    EnsureInstallStep("Step03_CreateBlog.aspx");
                }
                if (info != null && Config.BlogCount > 0)
                {
                    EnsureInstallStep("InstallationComplete.aspx");
                }
                break;
            }

            base.OnLoad(e);
        }
Exemple #2
0
        public override async Task <StepResult> Execute(InstallationState state)
        {
            if (!Directory.Exists(state.TargetDirectoryPath))
            {
                Directory.CreateDirectory(state.TargetDirectoryPath);
            }

            using (var fileStream = new FileStream(state.Package.Path, FileMode.Open)) {
                using (var zipArchive = new ZipArchive(fileStream)) {
                    foreach (var entry in zipArchive.Entries)
                    {
                        if (!(entry.FullName.EndsWith("/") && string.IsNullOrEmpty(entry.Name)))
                        {
                            state.UpdateStatus($"Extracting: {entry.Name}");

                            string fullEntryPath = Path.Combine(state.TargetDirectoryPath, entry.FullName);

                            if (!Directory.Exists(Path.GetDirectoryName(fullEntryPath)))
                            {
                                Directory.CreateDirectory(Path.GetDirectoryName(fullEntryPath));
                            }

                            using (var entryFileSteam = new FileStream(fullEntryPath, FileMode.Create)) {
                                using (var entryStream = entry.Open()) {
                                    await entryStream.CopyToAsync(entryFileSteam);
                                }
                            }
                        }
                    }
                }
            }

            return(StepResult.Success);
        }
        public void HandleState(InstallationState state)
        {
            if (!_stateHandlers.ContainsKey(state))
                return;

            _dispatcher.Invoke(_stateHandlers[state]);
        }
Exemple #4
0
        /// <summary>
        /// Determines whether an installation action is required by
        /// examining the specified unhandled Exception.
        /// </summary>
        /// <param name="unhandledException">Unhandled exception.</param>
        /// <param name="assemblyVersion">The version of the currently installed assembly.</param>
        /// <returns>
        ///     <c>true</c> if an installation action is required; otherwise, <c>false</c>.
        /// </returns>
        public bool InstallationActionRequired(Version assemblyVersion, Exception unhandledException)
        {
            if (unhandledException is HostDataDoesNotExistException)
            {
                return(true);
            }

            if (IsInstallationException(unhandledException))
            {
                return(true);
            }

            InstallationState status = GetInstallationStatus(assemblyVersion);

            switch (status)
            {
            case InstallationState.NeedsInstallation:
            case InstallationState.NeedsUpgrade:
            {
                return(true);
            }
            }

            return(false);
        }
Exemple #5
0
        public bool InstallationActionRequired(InstallationState currentState)
        {
            bool needsUpgrade = (currentState == InstallationState.NeedsInstallation ||
                                 currentState == InstallationState.NeedsUpgrade);

            return(needsUpgrade);
        }
Exemple #6
0
        public override Task <StepResult> Execute(InstallationState state)
        {
            state.UpdateStatus("Cleaning up.");

            if (File.Exists(state.Package.Path))
            {
                File.Delete(state.Package.Path);
            }

            return(Task.FromResult(StepResult.Success));
        }
 /// <summary>
 /// 修改某个零件的安装状态
 /// </summary>
 /// <param name="installedNode"></param>
 public void SetInstalledNodeListStatus(Node installedNode, InstallationState installationState)
 {
     for (int i = 0; i < InstalledNodeList.Count; i++)
     {
         if (InstalledNodeList[i].nodeId == installedNode.nodeId)
         {
             InstalledNodeList[i].SetInstallationState(installationState);
             break;
         }
     }
 }
Exemple #8
0
 private void PlanComplete(object sender, PlanCompleteEventArgs e)
 {
     if (HResult.Succeeded(e.Status))
     {
         PreApplyState = State;
         State         = InstallationState.Applying;
         App.Current.Apply();
     }
     else
     {
         State = InstallationState.Failed;
     }
 }
Exemple #9
0
        public List <InstallationState> getCurrentValues(InstallationModel installation)
        {
            List <InstallationState> ilist  = new List <InstallationState>();
            MeasurementModel         mmodel = measurements.Last();
            InstallationState        istate = new InstallationState();

            istate.currentTime = mmodel.timestamp;
            istate.description = "Sonde";
            istate.lastValue   = Double.Parse(mmodel.measurevalue.ToString());
            istate.unit        = "Celsius";
            ilist.Add(istate);
            return(ilist);
        }
        public ActionResult UpdateModule()
        {
            try {
                WebProjectManager[] projectManagers = GetProjectManagers();
                var installed = new List <InstallationState>();
                foreach (var projectManager in projectManagers)
                {
                    var installedPackages     = this.GetInstalledPackages(projectManager);
                    var packagesList          = installedPackages.GroupBy(x => x.Id);
                    var installedPackagesList = packagesList.Select(pack => pack.Single(y => y.Version == pack.Max(x => x.Version))).ToList();

                    foreach (var installedPackage in installedPackagesList)
                    {
                        IPackage update  = projectManager.GetUpdatedPackage(installedPackage);
                        var      package = new InstallationState();
                        package.Installed = installedPackage;
                        package.Update    = update;
                        package.Source    = projectManager.SourceRepository.Source;

                        if (installed.Any(d => d.Installed.Id == package.Installed.Id))
                        {
                            var addedPackage = installed.Where(d => d.Installed.Id == package.Installed.Id).First();
                            if (package.Update != null)
                            {
                                if (addedPackage.Update == null || addedPackage.Update.Version < package.Update.Version)
                                {
                                    installed.Remove(addedPackage);
                                    installed.Add(package);
                                }
                            }
                        }
                        else
                        {
                            installed.Add(package);
                        }
                    }
                }

                var model = new UpdatesModel();
                model.Updates = installed;


                return(View(model));
            }
            catch (Exception e) {
                ErrorHandler.Publish(LogLevel.Error, "Nuget Get packages from feed", e);
                return(View("ExceptionError"));
            }
        }
Exemple #11
0
 /// <summary>
 /// 设置零件集合中的某个零件的安装状态
 /// </summary>
 /// <param name="node"></param>
 /// <param name="state"></param>
 public void SetInstallationState(int nodeID, InstallationState state)
 {
     if (null != NodesController.Instance)
     {
         if (0 < NodesController.Instance.GetNodeList().Count)
         {
             for (int i = 0; i < NodesController.Instance.GetNodeList().Count; i++)
             {
                 if (nodeID == NodesController.Instance.GetNodeList()[i].nodeId)
                 {
                     NodesController.Instance.GetNodeList()[i].SetInstallationState(state);
                 }
             }
         }
     }
 }
Exemple #12
0
        public override async Task <StepResult> Execute(InstallationState state)
        {
            state.UpdateStatus("Downloading package...");

            var package = await state.Processor.DownloadPackage(state.ComponentDefinition.Component);

            if (package != null)
            {
                state.Package = package;

                return(StepResult.Success);
            }
            else
            {
                return(StepResult.Failure);
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            InstallationState state = InstallationManager.GetInstallationStatus(VersionInfo.CurrentAssemblyVersion);

            if (state == InstallationState.NeedsUpgrade)
            {
                plcUpgradeInProgressMessage.Visible = true;
                plcNothingToSeeHere.Visible         = false;
            }
            else
            {
                plcUpgradeInProgressMessage.Visible = true;
                plcNothingToSeeHere.Visible         = false;
                lnkBlog.HRef = Url.BlogUrl();
            }
            base.OnLoad(e);
        }
Exemple #14
0
        /// <summary>
        /// 获取集合中的某个零件的安装状态
        /// </summary>
        /// <returns></returns>
        public InstallationState GetInstallationState(int nodeID)
        {
            InstallationState state = InstallationState.Installed;

            if (null != NodesController.Instance)
            {
                if (0 < NodesController.Instance.GetNodeList().Count)
                {
                    for (int i = 0; i < NodesController.Instance.GetNodeList().Count; i++)
                    {
                        if (nodeID == NodesController.Instance.GetNodeList()[i].nodeId)
                        {
                            state = NodesController.Instance.GetNodeList()[i].GetInstallationState();
                        }
                    }
                }
            }
            return(state);
        }
 // Methods
 public ActionResult Check(string packageId)
 {
     var projectManager = GetProjectManager();
     var installedPackage = GetInstalledPackage(projectManager, packageId);
     var update = projectManager.GetUpdate(installedPackage);
     var model = new InstallationState
     {
         Installed = installedPackage,
         Update = update
     };
     if (Request.IsAjaxRequest())
     {
         var data = new
         {
             Version = (update != null) ? update.Version.ToString() : null,
             UpdateAvailable = update != null
         };
         return Json(data, JsonRequestBehavior.AllowGet);
     }
     return View(model);
 }
Exemple #16
0
        /// <summary>
        /// Checks the installation status and redirects if necessary.
        /// </summary>
        public string GetInstallationRedirectUrl(BlogRequest blogRequest)
        {
            const string installUrl = "~/install/default.aspx";

            // Bypass for static files.
            if (blogRequest.RawUrl.IsStaticFileRequest())
            {
                return(null);
            }

            if (_hostInfo.Value == null && blogRequest.RequestLocation != RequestLocation.Installation)
            {
                return(installUrl);
            }

            // Want to redirect to install if installation is required,
            // or if we're missing a HostInfo record.
            if ((InstallationManager.InstallationActionRequired(VersionInfo.CurrentAssemblyVersion, null) || _hostInfo.Value == null))
            {
                InstallationState state = InstallationManager.GetInstallationStatus(VersionInfo.CurrentAssemblyVersion);
                if (state == InstallationState.NeedsInstallation &&
                    !blogRequest.IsHostAdminRequest &&
                    blogRequest.RequestLocation != RequestLocation.Installation)
                {
                    return(installUrl);
                }

                if (state == InstallationState.NeedsUpgrade)
                {
                    if (blogRequest.RequestLocation != RequestLocation.Upgrade &&
                        blogRequest.RequestLocation != RequestLocation.LoginPage &&
                        blogRequest.RequestLocation != RequestLocation.SystemMessages &&
                        blogRequest.RequestLocation != RequestLocation.HostAdmin)
                    {
                        return("~/SystemMessages/UpgradeInProgress.aspx");
                    }
                }
            }
            return(null);
        }
Exemple #17
0
        // Methods
        public ActionResult Check(string packageId)
        {
            var projectManager   = GetProjectManager();
            var installedPackage = GetInstalledPackage(projectManager, packageId);
            var update           = projectManager.GetUpdate(installedPackage);
            var model            = new InstallationState
            {
                Installed = installedPackage,
                Update    = update
            };

            if (Request.IsAjaxRequest())
            {
                var data = new
                {
                    Version         = (update != null) ? update.Version.ToString() : null,
                    UpdateAvailable = update != null
                };
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            return(View(model));
        }
        public List <InstallationState> getCurrentValues(InstallationModel installation)
        {
            List <InstallationState> ilist = new List <InstallationState>();

            try
            {
                var query = (from meas in context.Measurement
                             join mtype in context.Measurement_Type
                             on meas.typeid equals mtype.typeid
                             where meas.installationid == installation.installationid
                             group mtype by new { meas.typeid, meas.measurevalue, mtype.unit, mtype.description, meas.timestamp } into hilf
                             where hilf.Key.timestamp == (from mesl in context.Measurement where mesl.typeid == hilf.Key.typeid select mesl.timestamp).Max()
                             select new
                {
                    lastValue = hilf.Key.measurevalue,
                    description = hilf.Key.description,
                    unit = hilf.Key.unit,
                    currentTime = hilf.Key.timestamp
                });

                foreach (var item in query)
                {
                    InstallationState istate = new InstallationState();
                    istate.currentTime = item.currentTime;
                    istate.description = item.description;
                    istate.lastValue   = Double.Parse(item.lastValue.ToString());
                    istate.unit        = item.unit;
                    ilist.Add(istate);
                }
            }
            catch (Exception exp)
            {
                log.Error("InstallationState für Installation " + installation.installationid + " wurde erstellt.");
                throw new DalException("InstallationState für Installation " + installation.installationid + " wurde erstellt.", exp);
            }
            return(ilist);
        }
Exemple #19
0
        public override Task <StepResult> Execute(InstallationState state)
        {
            state.UpdateStatus("Creating shortcuts...");

            var iconPath = Path.Combine(state.TargetDirectoryPath, "Icon.ico");

            var wsh = new WshShell();

            var shortcut = wsh.CreateShortcut(Path.Combine(targetDirectory, state.ComponentDefinition.ShortName + ".lnk")) as IWshRuntimeLibrary.IWshShortcut;

            shortcut.TargetPath       = Path.Combine(state.TargetDirectoryPath, state.ComponentDefinition.ApplicationFileName);
            shortcut.WindowStyle      = 1;
            shortcut.Description      = state.ComponentDefinition.Description;
            shortcut.WorkingDirectory = state.TargetDirectoryPath;

            if (System.IO.File.Exists(iconPath))
            {
                shortcut.IconLocation = iconPath;
            }

            shortcut.Save();

            return(Task.FromResult(StepResult.Success));
        }
Exemple #20
0
 public abstract Task <StepResult> Execute(InstallationState state);
        public bool InstallationActionRequired(InstallationState currentState)
        {
            bool needsUpgrade = (currentState == InstallationState.NeedsInstallation
                                 || currentState == InstallationState.NeedsUpgrade);

            return needsUpgrade;
        }
        private void ApplyComplete(object sender, ApplyCompleteEventArgs e)
        {
            // If we're not in Full UI mode, we need to alert the dispatcher to stop and close the window for passive.
            if (ba.Command.Display != Display.Full)
            {
                // If its passive, send a message to the window to close.
                if (ba.Command.Display == Display.Passive)
                {
                    ba.Engine.Log(LogLevel.Verbose, "Automatically closing the window for non-interactive install");
                    this.TryClose();
                }
                else
                {
                    Application.Current.Shutdown();
                }
            }

            // Set the state to applied or failed unless the state has already been set back to the preapply state
            // which means we need to show the UI as it was before the apply started.
            if (this.State != this.PreApplyState)
            {
                this.State = HResultSucceeded(e.Status) ? InstallationState.Applied : InstallationState.Failed;
            }
        }
        public ActionResult Module()
        {
            var projectManagers   = GetProjectManagers();
            var packagesToInstall = new List <InstallPackagesModel>();
            var installed         = new List <InstallationState>();

            foreach (var projectManager in projectManagers)
            {
                var availablePackages = ProjectManagerHelper.GetAvailablePackagesLatestList(projectManager);

                var installedPackages = ProjectManagerHelper.GetInstalledPackagesLatestList(projectManager, false);

                foreach (var package in availablePackages)
                {
                    if (installedPackages.All(d => d.Id != package.Id))
                    {
                        var pack = new InstallPackagesModel
                        {
                            icon =
                                string.IsNullOrEmpty(package.IconUrl.ToString())
                                                   ? package.IconUrl.ToString()
                                                   : string.Empty,
                            name    = package.Id,
                            version = package.Version.ToString(),
                            author  = package.Authors.FirstOrDefault(),
                            source  = projectManager.SourceRepository.Source
                        };

                        packagesToInstall.Add(pack);
                    }
                }

                foreach (var installedPackage in installedPackages)
                {
                    var update  = projectManager.GetUpdatedPackage(availablePackages, installedPackage);
                    var package = new InstallationState();
                    package.Installed = installedPackage;
                    package.Update    = update;
                    package.Source    = projectManager.SourceRepository.Source;

                    if (installed.Any(d => d.Installed.Id == package.Installed.Id))
                    {
                        var addedPackage = installed.First(d => d.Installed.Id == package.Installed.Id);
                        if (package.Update != null)
                        {
                            if (addedPackage.Update == null || addedPackage.Update.Version < package.Update.Version)
                            {
                                installed.Remove(addedPackage);
                                installed.Add(package);
                            }
                        }
                    }
                    else
                    {
                        installed.Add(package);
                    }
                }
            }

            var model = new NugetPackagesModel {
                Install = packagesToInstall, Updates = installed
            };

            return(View(model));
        }
        private void DetectComplete(object sender, DetectCompleteEventArgs e)
        {
            if (ba.Command.Action == LaunchAction.Uninstall)
            {
                ba.Engine.Log(LogLevel.Verbose, "Invoking automatic plan for uninstall");
                Execute.OnUIThread(() =>
                {
                    this.Plan(LaunchAction.Uninstall);
                });
            }
            else if (HResultSucceeded(e.Status))
            {
                if (this.Downgrade)
                {
                    // TODO: What behavior do we want for downgrade?
                    this.State = InstallationState.DetectedNewer;
                }

                // If we're not waiting for the user to click install, dispatch plan with the default action.
                if (ba.Command.Display != Display.Full)
                {
                    ba.Engine.Log(LogLevel.Verbose, "Invoking automatic plan for non-interactive mode.");
                    Execute.OnUIThread(() =>
                    {
                        this.Plan(ba.Command.Action);
                    });
                }
            }
            else
            {
                this.State = InstallationState.Failed;
            }
        }
 private void DetectBegin(object sender, DetectBeginEventArgs e)
 {
     this.State = InstallationState.Initializing;
 }
 private void DetectedPackage(object sender, DetectPackageCompleteEventArgs e)
 {
     // The Package ID from the Bootstrapper chain.
     if (e.PackageId.Equals("SampleApp", StringComparison.Ordinal))
     {
         this.State = (e.State == PackageState.Present) ? InstallationState.DetectedPresent : InstallationState.DetectedAbsent;
     }
 }
Exemple #27
0
        public void Execute(IJobExecutionContext context_)
        {
            var context = (JobExecutionContextImpl)context_;

            var executeJob = bool.Parse(context.JobDetail.JobDataMap["ExcecuteJob"].ToString());


            if (executeJob)
            {
                var projectManagers = ProjectManagerHelper.GetProjectManagers();
                var updateList      = new List <InstallationState>();
                foreach (var projectManager in projectManagers)
                {
                    var availablePackages = ProjectManagerHelper.GetAvailablePackagesLatestList(projectManager);

                    var installedPackages = ProjectManagerHelper.GetInstalledPackagesLatestList(projectManager, true);


                    foreach (var installedPackage in installedPackages)
                    {
                        var update = projectManager.GetUpdatedPackage(availablePackages, installedPackage);
                        if (update != null)
                        {
                            var package = new InstallationState();
                            package.Installed = installedPackage;
                            package.Update    = update;
                            package.Source    = projectManager.SourceRepository.Source;

                            if (updateList.Any(d => d.Installed.Id == package.Installed.Id))
                            {
                                var addedPackage = updateList.First(d => d.Installed.Id == package.Installed.Id);
                                if (package.Update != null)
                                {
                                    if (addedPackage.Update == null || addedPackage.Update.Version < package.Update.Version)
                                    {
                                        updateList.Remove(addedPackage);
                                        updateList.Add(package);
                                    }
                                }
                            }
                            else
                            {
                                updateList.Add(package);
                            }
                        }
                    }
                }

                // UpdateList is a list with packages that has updates
                if (updateList.Any())
                {
                    var sb = new StringBuilder();
                    try
                    {
                        var entities = new SelfUpdaterEntities();

                        foreach (
                            var self in
                            updateList.Select(
                                pack =>
                                new SelfUpdatingPackages
                        {
                            PackageId = pack.Installed.Id,
                            PackageVersion = pack.Update.Version.ToString(),
                            Source = pack.Source,
                            Install = false
                        }))
                        {
                            if (!entities.SelfUpdatingPackages.Any(x => x.PackageId == self.PackageId && x.PackageVersion == self.PackageVersion))
                            {
                                entities.AddToSelfUpdatingPackages(self);
                                sb.AppendFormat("Adding package {0} version {1} to update.", self.PackageId,
                                                self.PackageVersion);
                                sb.AppendLine();
                            }
                        }

                        entities.SaveChanges();

                        var config  = WebConfigurationManager.OpenWebConfiguration("~/");
                        var section = config.GetSection("system.web/httpRuntime");
                        ((HttpRuntimeSection)section).WaitChangeNotification    = 123456789;
                        ((HttpRuntimeSection)section).MaxWaitChangeNotification = 123456789;
                        config.Save();
                    }
                    catch (Exception e)
                    {
                        ErrorHandler.Publish(LogLevel.Error, e);
                    }

                    try
                    {
                        var body     = sb.ToString();
                        var emailDir = ConfigurationManager.AppSettings["SelfUpdaterMailconfig"];
                        if (!string.IsNullOrEmpty(body) && !string.IsNullOrEmpty(emailDir))
                        {
                            var mail = new MailMessage();
                            mail.From = new MailAddress("*****@*****.**");

                            mail.To.Add(new MailAddress(emailDir));
                            mail.Subject = string.Format("Updates Manager chekcker job");

                            mail.Body       = body;
                            mail.IsBodyHtml = false;

                            using (var client = new SmtpClient())
                            {
                                client.Send(mail);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        ErrorHandler.Publish(LogLevel.Error, e);
                    }
                }
            }
        }
Exemple #28
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        internal async Task LockAsync(Identity id, Downloader.Models.IDisplayable info, InstallationState state)
        {
            Applications.AddOrUpdate(info.Name,
                                     (_) => new ApplicationLock(id.Number, info)
            {
                InstallationState = state
            },
                                     (_, item) => { item.InstallationState = state; return(item); });

            await WriteAsync();
        }
        private void ExecuteError(object sender, ErrorEventArgs e)
        {
            lock (this)
            {
                if (!this.Cancelled)
                {
                    // If the error is a cancel coming from the engine during apply we want to go back to the preapply state.
                    if (this.State == InstallationState.Applying && e.ErrorCode == ERROR_UserCancelled)
                    {
                        this.State = this.PreApplyState;
                    }
                    else
                    {
                        this.Message = e.ErrorMessage;
                        Execute.OnUIThread(() =>
                        {
                            MessageBox.Show(Application.Current.MainWindow, e.ErrorMessage, "WiX Toolset", MessageBoxButton.OK, MessageBoxImage.Error);
                        });
                    }
                }

                e.Result = this.Cancelled ? Result.Cancel : Result.Ok;
            }
        }
 private void PlanComplete(object sender, PlanCompleteEventArgs e)
 {
     if (HResultSucceeded(e.Status))
     {
         this.PreApplyState = this.State;
         this.State = InstallationState.Applying;
         ba.Engine.Apply(this.hwnd);
     }
     else
     {
         this.State = InstallationState.Failed;
     }
 }
Exemple #31
0
 internal void SetInstallationState(InstallationState installationState)
 {
     this.installationState = installationState;
 }
Exemple #32
0
 private InstallActions(LaunchAction value, Verbs verb, InstallationState successState)
 {
     Value = value;
     SuccessState = successState;
     Verb = verb;
 }
 public StateBottomButton(PagedViewModel model, InstallationState state)
     : base(model)
 {
     Command = new RelayCommand(param => Model.InstallationState = state);
 }
 public void AddHandler(InstallationState state, Action handler)
 {
     _stateHandlers[state] = handler;
 }