Ejemplo n.º 1
0
        private bool PrepareProject(ProjectDeploymentData projectDeploymentData, DeploymentContext deploymentContext)
        {
            DeploymentInfo deploymentInfo = projectDeploymentData.DeploymentInfo;
              DeploymentTask deploymentTask = projectDeploymentData.DeploymentTask;

              PostDiagnosticMessage(string.Format("Preparing {0} '{1}'.", (deploymentInfo.IsSimulation ? " (simulation)" : ""), deploymentTask.GetType().Name), DiagnosticMessageType.Info);

              deploymentTask.DiagnosticMessagePosted += OnDeploymentTaskDiagnosticMessagePosted;

              OnDeploymentTaskStarting(deploymentInfo, deploymentTask, deploymentContext);

              try
              {
            deploymentTask.Initialize(deploymentInfo);

            deploymentTask.Prepare();

            return true;
              }
              catch (Exception exc)
              {
            PostDiagnosticMessage(string.Format("Exception while preparing: {0}", exc.Message), DiagnosticMessageType.Error);
              }
              finally
              {
            deploymentTask.DiagnosticMessagePosted -= OnDeploymentTaskDiagnosticMessagePosted;
              }

              return false;
        }
Ejemplo n.º 2
0
        private bool ExecuteProjectDeployment(ProjectDeploymentData projectDeploymentData, DeploymentContext deploymentContext)
        {
            DeploymentInfo deploymentInfo = projectDeploymentData.DeploymentInfo;
              DeploymentTask deploymentTask = projectDeploymentData.DeploymentTask;

              PostDiagnosticMessage(string.Format("Starting{0} '{1}'.", (deploymentInfo.IsSimulation ? " (simulation)" : ""), deploymentTask.GetType().Name), DiagnosticMessageType.Info);

              deploymentTask.DiagnosticMessagePosted += OnDeploymentTaskDiagnosticMessagePosted;

              try
              {
            deploymentTask.Execute();

            PostDiagnosticMessage(
              string.Format("Finished{0} '{1}' (\"{2}\").", (deploymentInfo.IsSimulation ? " (simulation)" : ""),
            deploymentTask.GetType().Name, deploymentTask.Description), DiagnosticMessageType.Info);
            PostDiagnosticMessage(
              "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -",
              DiagnosticMessageType.Info);

            return true;
              }
              catch (Exception ex)
              {
            PostDiagnosticMessage(string.Format("Exception: {0}", ex.Message), DiagnosticMessageType.Error);
            LogInnerException(ex);
              }
              finally
              {
            // TODO IMM HI: catch exceptions; pass them upstream using some mechanisms like DeploymentTask.DiagnosticMessagePosted event
            OnDeploymentTaskFinished(deploymentInfo, deploymentTask, deploymentContext);

            deploymentTask.DiagnosticMessagePosted -= OnDeploymentTaskDiagnosticMessagePosted;
              }

              return false;
        }