/// <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);
        }
예제 #2
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);
     }
 }