Beispiel #1
0
        /// <summary>
        /// Gets the deletion tasks for the supplied deployment log.
        /// </summary>
        /// <param name="deploymentLog">The deployment log.</param>
        /// <returns>Instance of <see cref="TaskExecutor"/> with tasks and task execution context.</returns>
        public TaskExecutor BuildTasks(DeploymentLog deploymentLog)
        {
            // Create a sequential list of tasks we need to execute.
            var reversedResources = new List <ResourceLog>(deploymentLog.Resources);

            reversedResources.Reverse();

            var tasks = reversedResources
                        .Where(resource => resource.CaasId != null)
                        .Select(resource => (ITask) new DeleteResourceTask(resource))
                        .ToList();

            // Create the task execution context.
            var context = new TaskContext
            {
                Log = new DeploymentLog()
                {
                    DeploymentTime = DateTime.Now,
                    TemplateName   = deploymentLog.TemplateName,
                    Resources      = new List <ResourceLog>()
                }
            };

            return(new TaskExecutor(null, tasks, context));
        }
Beispiel #2
0
 /// <summary>
 /// Saves the deployment log.
 /// </summary>
 /// <param name="log">The log to save.</param>
 /// <param name="fileName">Path to the file.</param>
 public static void SaveToFile(this DeploymentLog log, string fileName)
 {
     using (var sw = new StreamWriter(fileName))
     {
         var json = JsonConvert.SerializeObject(log, Formatting.Indented);
         sw.Write(json);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Writes an entry to the log file.
 /// </summary>
 /// <param name="log">The log entry.</param>
 /// <param name="logFile">The log file.</param>
 private static void WriteLog(DeploymentLog log, string logFile)
 {
     using (var sw = new StreamWriter(logFile))
     {
         var json = JsonConvert.SerializeObject(log, Formatting.Indented);
         sw.Write(json);
     }
 }