예제 #1
0
        /// <summary>
        /// Update the running application
        /// </summary>
        /// <returns>Returns true if the update (download) perfomed successfully</returns>
        public bool performUpdate()
        {
            bool _retVal = false;

            Console.WriteLine("Performing Update for " + this.settings.appName + "...");

            // Check if the Destination Directory allready exists
            // If not create it
            if (!Directory.Exists(this.settings.appLocalPath))
            {
                Directory.CreateDirectory(this.settings.appLocalPath);
            }


            // Da wir den Instally selber nicht so einfach ersetzen können da er ja bereits läuft müssen wir ihm einen besonderen Namen geben mit dem versionszusatz
            string _fileNameAddon = this.settings.appFileName.Replace(".exe", "") + "_" + FileVersionInfo.GetVersionInfo(this.settings.appServerPath + this.settings.appFileName).FileVersion + ".exe";

            // Set the new file name
            this.downloadFileName = this.settings.appLocalPath + _fileNameAddon;

            // perform the update of the execution file
            CopyMaster copyFiles = new CopyMaster();

            _retVal = copyFiles.copyFile(this.settings.appServerPath + this.settings.appFileName, this.downloadFileName, true);

            // Update the settings File
            // Check if the Destination Directory allready exists
            // If not create it
            if (!Directory.Exists(this.settings.settingsLocalPath))
            {
                Directory.CreateDirectory(this.settings.settingsLocalPath);
            }

            if (this.settings.settingsFileName != "" && _retVal)
            {
                // perform the update of the execution file
                bool _var = copyFiles.copyFile(this.settings.settingsServerPath + this.settings.settingsFileName, this.settings.settingsLocalPath + this.settings.settingsFileName, true);
            }

            Console.WriteLine("... Update done");

            return(_retVal);
        }
예제 #2
0
        /// <summary>
        /// Update the running application
        /// </summary>
        /// <param name="applicationName"></param>
        /// <returns></returns>
        public bool performUpdate(string applicationName)
        {
            bool _retVal = false;

            if (!this.IsSelectedToDownload)
            {
                return(_retVal);
            }

            Console.WriteLine("Performing Update for " + this.settings.appName + "...");

            // Check if the Destination Directory allready exists
            // If not create it
            if (!Directory.Exists(this.settings.appLocalPath))
            {
                Directory.CreateDirectory(this.settings.appLocalPath);
            }


            // Da wir den Instally selber nicht so einfach ersetzen können da er ja bereits läuft müssen wir ihm einen besonderen Namen geben mit dem versionszusatz
            string _fileNameAddon       = "";
            bool   _isRunningApplicatio = (this.settings.appName == applicationName) && (applicationName != "");

            if (_isRunningApplicatio)
            {
                _fileNameAddon = this.settings.appFileName.Replace(".exe", "") + "_" + FileVersionInfo.GetVersionInfo(this.settings.appServerPath + this.settings.appFileName).FileVersion + ".exe";
            }
            else
            {
                _fileNameAddon = this.settings.appFileName;
            }

            // perform the update of the execution file
            CopyMaster copyFiles = new CopyMaster();

            _retVal = copyFiles.copyFile(this.settings.appServerPath + this.settings.appFileName, this.settings.appLocalPath + _fileNameAddon, true);

            #region Update the settings File

            // Check if the Destination Directory allready exists
            // If not create it
            if (!Directory.Exists(this.settings.settingsLocalPath))
            {
                Directory.CreateDirectory(this.settings.settingsLocalPath);
            }

            if (this.settings.settingsFileName != "" && _retVal)
            {
                // perform the update of the execution file
                bool _var = copyFiles.copyFile(this.settings.settingsServerPath + this.settings.settingsFileName, this.settings.settingsLocalPath + this.settings.settingsFileName, true);
            }



            #endregion

            Console.WriteLine("... Update done");

            if (_isRunningApplicatio)
            {
                Console.WriteLine("");
                Console.WriteLine("--------ACHTUNG--------");
                Console.WriteLine("Die laufende Applikation wurde aktualisiert auf dem Verzeichniss abgelegt. Bitte die Anwendung beenden und die alte anwendung löschen und die neue in instally umbennenn");
                Console.WriteLine("");
            }
            return(_retVal);
        }