예제 #1
0
 internal void PackageRemoved(Package package)
 {
     lock (_packageList) {
         if (_packageList.Contains(package)) {
             _packageList.Remove(package);
         }
     }
 }
예제 #2
0
 internal void PackageInstalled(Package package)
 {
     lock (_packageList) {
         if (!_packageList.Contains(package)) {
             _packageList.Add(package);
         }
     }
 }
예제 #3
0
 internal void Add(Package package)
 {
     if (!_packageList.Contains(package)) {
         _packageList.Add(package);
         Scanned = true;
         LastScanned = DateTime.Now;
         PackageManagerImpl.Instance.Updated();
     }
 }
예제 #4
0
파일: CoAppMSI.cs 프로젝트: virmitio/coapp
 public Composition GetCompositionData(Package package)
 {
     if (!IsValidPackageFile(package.PackageSessionData.LocalValidatedLocation)) {
         throw new InvalidPackageException(InvalidReason.NotCoAppMSI, package.PackageSessionData.LocalValidatedLocation);
     }
     var packageProperties = GetMsiProperties(package.PackageSessionData.LocalValidatedLocation);
     var compositionDataText = packageProperties["CoAppCompositionData"];
     if (string.IsNullOrEmpty(compositionDataText)) {
         throw new InvalidPackageException(InvalidReason.MalformedCoAppMSI, package.PackageSessionData.LocalValidatedLocation);
     }
     return compositionDataText.FromXml<Composition>("CompositionData");
 }
예제 #5
0
 internal static PackageDetails ReadPackageDetails(Uri remoteLocation, string localLocation, Package package)
 {
     return null;
 }
예제 #6
0
파일: CoAppMSI.cs 프로젝트: virmitio/coapp
        /// <summary>
        ///   Installs the specified package.
        /// </summary>
        /// <param name="package"> The package. </param>
        /// <remarks>
        /// </remarks>
        public void Install(Package package)
        {
            lock (typeof (MSIBase)) {
                int currentTotalTicks = -1;
                int currentProgress = 0;
                int progressDirection = 1;
                int actualPercent = 0;

                Installer.SetExternalUI(((messageType, message, buttons, icon, defaultButton) => {
                    switch (messageType) {
                        case InstallMessage.Progress:
                            if (message.Length >= 2) {
                                var msg = message.Split(": ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(m => m.ToInt32(0)).ToArray();

                                switch (msg[1]) {
                                        // http://msdn.microsoft.com/en-us/library/aa370354(v=VS.85).aspx
                                    case 0: //Resets progress bar and sets the expected total number of ticks in the bar.
                                        currentTotalTicks = msg[3];
                                        currentProgress = 0;
                                        if (msg.Length >= 6) {
                                            progressDirection = msg[5] == 0 ? 1 : -1;
                                        }
                                        break;
                                    case 1:
                                        //Provides information related to progress messages to be sent by the current action.
                                        break;
                                    case 2: //Increments the progress bar.
                                        if (currentTotalTicks == -1) {
                                            break;
                                        }
                                        currentProgress += msg[3]*progressDirection;
                                        break;
                                    case 3:
                                        //Enables an action (such as CustomAction) to add ticks to the expected total number of progress of the progress bar.
                                        break;
                                }
                            }

                            if (currentTotalTicks > 0) {
                                var newPercent = (currentProgress*100/currentTotalTicks);
                                if (actualPercent < newPercent) {
                                    actualPercent = newPercent;
                                    Event<IndividualProgress>.RaiseFirst(actualPercent);
                                }
                            }
                            break;
                    }
                    // capture installer messages to play back to status listener
                    return MessageResult.OK;
                }), InstallLogModes.Progress);

                try {
                    // if( WindowsVersionInfo.IsVistaOrPrior) {
                    var cachedInstaller = Path.Combine(PackageManagerSettings.CoAppPackageCache, package.CanonicalName.PackageName + ".msi");
                    if (!File.Exists(cachedInstaller)) {
                        File.Copy(package.PackageSessionData.LocalValidatedLocation, cachedInstaller);
                    }
                    // }
                    Installer.InstallProduct(package.PackageSessionData.LocalValidatedLocation,
                        @"TARGETDIR=""{0}"" ALLUSERS=1 COAPP=1 REBOOT=REALLYSUPPRESS {1}".format(package.BaseInstallDirectory,
                            package.PackageSessionData.IsWanted ? "ADD_TO_ARP=1" : ""));
                } finally {
                    SetUIHandlersToSilent();
                }
            }
        }