Exemple #1
0
        /// <summary>
        /// Startet den Updatevorgang.
        /// </summary>
        public void runUpdate()
        {
            foreach (updatePackage currentPackage in m_config.Result)
            {
                //Füge eine Action zum validieren der Signatur hinzu
                applyUpdateBase validationAction = new applyValidatePackageSignature(new validatePackageAction(), currentConfig,
                                                                                     currentPackage);
                validationAction.actionFinished  += action_actionFinished;
                validationAction.progressChanged += action_progressChanged;
                validationAction.ownerForm        = m_ownerForm;
                m_updateActions.Add(validationAction);

                //Updateaktionen hinzufügen
                foreach (string id in currentPackage.actionOrder)
                {
                    applyUpdateBase action = getActionById(id, currentPackage);

                    if (action == null)
                    {
                        continue;
                    }

                    action.ownerForm             = m_ownerForm;
                    action.actionFinished       += action_actionFinished;
                    action.progressChanged      += action_progressChanged;
                    action.interfaceInteraction += action_interfaceInteraction;
                    m_updateActions.Add(action);
                }
            }

            //Registryversion aktualisieren
            if (!string.IsNullOrEmpty(currentConfig.ServerConfiguration.setupId))
            {
                string latestVersion =
                    currentConfig.ServerConfiguration.updatePackages[currentConfig.ServerConfiguration.updatePackages.Count - 1].
                    releaseInfo.Version;
                applyUpdateBase updateReg = new applyUpdateRegistryAction(new updateRegistryAction {
                    newVersion = latestVersion
                },
                                                                          currentConfig);
                updateReg.actionFinished  += action_actionFinished;
                updateReg.progressChanged += action_progressChanged;
                m_updateActions.Add(updateReg);
            }

            //Cleanupaction zum löschen der Updatedateien hinzufügen
            applyUpdateBase cleanup = new applyCleanupAction(new cleanupAction(), currentConfig);

            cleanup.actionFinished  += action_actionFinished;
            cleanup.progressChanged += action_progressChanged;
            m_updateActions.Add(cleanup);

            //Erste Aktion ausführen
            m_updateActions[applyUpdateActionCount].runAction();
        }
		private void action_actionFinished(object sender, applyUpdateActionFinishedEventArgs e) {
			//Sender zur Liste ausgeführter Aktionen hinzufügen
			m_performedUpdateActions.Add((applyUpdateBase) sender);

			//Überprüfe ob während der Aktion ein Fehler aufgetreten ist
			if ((e.actionException != null && !m_onRollback) || (m_cancellationPending && m_waitForRollback)) {
				m_onRollback = true;
				if (e.actionException == null) {
					m_updateException = new userCancelledException();
				}
				else {
					m_updateException = e.actionException;
				}
				applyUpdateActionCount = 0;

				m_currentAction = m_performedUpdateActions[applyUpdateActionCount];
				m_currentAction.runRollback();
				m_waitForRollback = false;
				//m_performedUpdateActions[applyUpdateActionCount].runRollback();
			}
			else {
				applyUpdateActionCount++;
				if (m_onRollback) {
					if (applyUpdateActionCount >= m_updateActions.Count) {
						if (rollbackFinished != null) {
							rollbackFinished(this, new applyUpdateActionFinishedEventArgs(m_updateException));
						}
					}
					else {
						m_currentAction = m_performedUpdateActions[applyUpdateActionCount];
						m_currentAction.runRollback();
						//m_performedUpdateActions[applyUpdateActionCount].runRollback();
					}
				}
				else {
					//Überpüfe ob alle Aktionen abgearbeitet wurden
					if (applyUpdateActionCount >= m_updateActions.Count) {
						if (updateFinished != null) {
							updateFinished(this, e);
						}
					}
					else {
						m_currentAction = m_updateActions[applyUpdateActionCount];
						m_currentAction.runAction();
						//m_updateActions[applyUpdateActionCount].runAction();
					}
				}
			}
		}
Exemple #3
0
        private void action_actionFinished(object sender, applyUpdateActionFinishedEventArgs e)
        {
            //Sender zur Liste ausgeführter Aktionen hinzufügen
            m_performedUpdateActions.Add((applyUpdateBase)sender);

            //Überprüfe ob während der Aktion ein Fehler aufgetreten ist
            if ((e.actionException != null && !m_onRollback) || (m_cancellationPending && m_waitForRollback))
            {
                m_onRollback = true;
                if (e.actionException == null)
                {
                    m_updateException = new userCancelledException();
                }
                else
                {
                    m_updateException = e.actionException;
                }
                applyUpdateActionCount = 0;

                m_currentAction = m_performedUpdateActions[applyUpdateActionCount];
                m_currentAction.runRollback();
                m_waitForRollback = false;
                //m_performedUpdateActions[applyUpdateActionCount].runRollback();
            }
            else
            {
                applyUpdateActionCount++;
                if (m_onRollback)
                {
                    if (applyUpdateActionCount >= m_updateActions.Count)
                    {
                        if (rollbackFinished != null)
                        {
                            rollbackFinished(this, new applyUpdateActionFinishedEventArgs(m_updateException));
                        }
                    }
                    else
                    {
                        m_currentAction = m_performedUpdateActions[applyUpdateActionCount];
                        m_currentAction.runRollback();
                        //m_performedUpdateActions[applyUpdateActionCount].runRollback();
                    }
                }
                else
                {
                    //Überpüfe ob alle Aktionen abgearbeitet wurden
                    if (applyUpdateActionCount >= m_updateActions.Count)
                    {
                        if (updateFinished != null)
                        {
                            updateFinished(this, e);
                        }
                    }
                    else
                    {
                        m_currentAction = m_updateActions[applyUpdateActionCount];
                        m_currentAction.runAction();
                        //m_updateActions[applyUpdateActionCount].runAction();
                    }
                }
            }
        }