예제 #1
0
        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);
                }

                OperationManager.Attempt(() =>
                {
                    // Used for ETAG
                    if (FileSystemHelpers.FileExists(_activeFile))
                    {
                        FileSystemHelpers.SetLastWriteTimeUtc(_activeFile, DateTime.UtcNow);
                    }
                    else
                    {
                        FileSystemHelpers.WriteAllText(_activeFile, String.Empty);
                    }
                });

                OperationManager.Attempt(() =>
                {
                    // enable the feature thru configuration
                    if (ScmHostingConfigurations.DeploymentStatusCompleteFileEnabled && Complete)
                    {
                        FileSystemHelpers.CopyFile(_statusFile, _statusCompleteFile);
                    }
                    else if (FileSystemHelpers.FileExists(_statusCompleteFile))
                    {
                        FileSystemHelpers.DeleteFile(_statusCompleteFile);
                    }
                });
            }, "Updating deployment status", DeploymentStatusManager.LockTimeout);
        }
예제 #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (int)DestinationType;
         hashCode = (hashCode * 397) ^ (TopicName != null ? TopicName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ IsTopic.GetHashCode();
         hashCode = (hashCode * 397) ^ IsQueue.GetHashCode();
         hashCode = (hashCode * 397) ^ IsTemporary.GetHashCode();
         return(hashCode);
     }
 }
예제 #3
0
        public void Save()
        {
            if (String.IsNullOrEmpty(Id))
            {
                throw new InvalidOperationException();
            }

            var document = new XDocument(new XElement("deployment",
                                                      new XElement("id", Id),
                                                      new XElement("author", Author),
                                                      new XElement("deployer", Deployer),
                                                      new XElement("authorEmail", AuthorEmail),
                                                      new XElement("message", 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);
                }
            }, DeploymentStatusManager.LockTimeout);
        }