Kudu.Core.Deployment.DeploymentStatusFile.Save C# (CSharp) Method

Save() public method

public Save ( ) : void
return void
        public void Save()
        {
            if (String.IsNullOrEmpty(Id))
            {
                throw new InvalidOperationException();
            }

            var document = new XDocument(new XElement("deployment",
                    new XElement("id", Id),
                    new XElement("author", XmlUtility.Sanitize(Author)),
                    new XElement("deployer", Deployer),
                    new XElement("authorEmail", AuthorEmail),
                    new XElement("message", XmlUtility.Sanitize(Message)),
                    new XElement("progress", Progress),
                    new XElement("status", Status),
                    new XElement("statusText", StatusText),
                    new XElement("lastSuccessEndTime", LastSuccessEndTime),
                    new XElement("receivedTime", ReceivedTime),
                    new XElement("startTime", StartTime),
                    new XElement("endTime", EndTime),
                    new XElement("complete", Complete.ToString()),
                    new XElement("is_temp", IsTemporary.ToString()),
                    new XElement("is_readonly", IsReadOnly.ToString())
                ));

            _statusLock.LockOperation(() =>
            {
                using (Stream stream = FileSystemHelpers.CreateFile(_statusFile))
                {
                    document.Save(stream);
                }

                // Used for ETAG
                if (FileSystemHelpers.FileExists(_activeFile))
                {
                    FileSystemHelpers.SetLastWriteTimeUtc(_activeFile, DateTime.UtcNow);
                }
                else
                {
                    FileSystemHelpers.WriteAllText(_activeFile, String.Empty);
                }
            }, "Updating deployment status", DeploymentStatusManager.LockTimeout);
        }

Usage Example

Example #1
0
        /// <summary>
        /// Runs post deployment steps.
        /// - Marks the active deployment
        /// - Sets the complete flag
        /// </summary>
        private void FinishDeployment(string id, ITracer tracer, IDisposable deployStep)
        {
            DeploymentStatusFile currentStatus = null;
            ILogger logger = null;

            try
            {
                currentStatus = OpenStatusFile(id);
                logger        = GetLogger(id);

                // Write the active deployment file
                MarkActive(id);

                logger.Log(Resources.Log_DeploymentSuccessful);

                currentStatus.Status             = DeployStatus.Success;
                currentStatus.StatusText         = String.Empty;
                currentStatus.EndTime            = DateTime.Now;
                currentStatus.LastSuccessEndTime = currentStatus.EndTime;
                currentStatus.Save(_fileSystem);
            }
            catch (Exception ex)
            {
                tracer.TraceError(ex);

                MarkFailed(currentStatus);

                logger.LogUnexpetedError();
            }
            finally
            {
                // Set the deployment as complete
                currentStatus.Complete = true;
                currentStatus.Save(_fileSystem);

                ReportStatus(id);

                // End the deployment step
                deployStep.Dispose();
            }
        }
All Usage Examples Of Kudu.Core.Deployment.DeploymentStatusFile::Save