Inheritance: ServiceOperationContext
Ejemplo n.º 1
0
        public DeploymentInfoContext(Deployment deployment)
        {
            XDocument xDocument;
            string    empty;
            string    str;
            string    value;

            this.ns             = "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration";
            this.Slot           = deployment.DeploymentSlot;
            this.Name           = deployment.Name;
            this.DeploymentName = deployment.Name;
            this.Url            = deployment.Url;
            this.Status         = deployment.Status;
            this.DeploymentId   = deployment.PrivateID;
            this.VNetName       = deployment.VirtualNetworkName;
            this.SdkVersion     = deployment.SdkVersion;
            this.DnsSettings    = deployment.Dns;
            bool?rollbackAllowed = deployment.RollbackAllowed;

            if (rollbackAllowed.HasValue)
            {
                this.RollbackAllowed = deployment.RollbackAllowed;
            }
            if (deployment.UpgradeStatus != null)
            {
                this.CurrentUpgradeDomain      = deployment.UpgradeStatus.CurrentUpgradeDomain;
                this.CurrentUpgradeDomainState = deployment.UpgradeStatus.CurrentUpgradeDomainState;
                this.UpgradeType = deployment.UpgradeStatus.UpgradeType;
            }
            DeploymentInfoContext deploymentInfoContext = this;

            if (string.IsNullOrEmpty(deployment.Configuration))
            {
                empty = string.Empty;
            }
            else
            {
                empty = ServiceManagementHelper.DecodeFromBase64String(deployment.Configuration);
            }
            deploymentInfoContext.Configuration = empty;
            DeploymentInfoContext deploymentInfoContext1 = this;

            if (string.IsNullOrEmpty(deployment.Label))
            {
                str = string.Empty;
            }
            else
            {
                str = ServiceManagementHelper.DecodeFromBase64String(deployment.Label);
            }
            deploymentInfoContext1.Label = str;
            if (deployment.RoleInstanceList != null)
            {
                this.RoleInstanceList = new List <RoleInstance>();
                foreach (RoleInstance roleInstanceList in deployment.RoleInstanceList)
                {
                    this.RoleInstanceList.Add(roleInstanceList);
                }
            }
            if (!string.IsNullOrEmpty(deployment.Configuration))
            {
                string configuration = this.Configuration;
                using (StringReader stringReader = new StringReader(configuration))
                {
                    XmlReader xmlReader = XmlReader.Create(stringReader);
                    xDocument = XDocument.Load(xmlReader);
                }
                DeploymentInfoContext deploymentInfoContext2 = this;
                if (xDocument.Root.Attribute("osVersion") != null)
                {
                    value = xDocument.Root.Attribute("osVersion").Value;
                }
                else
                {
                    value = string.Empty;
                }
                deploymentInfoContext2.OSVersion = value;
                this.RolesConfiguration          = new Dictionary <string, RoleConfiguration>();
                IEnumerable <XElement> xElements = xDocument.Root.Descendants(this.ns + "Role");
                foreach (XElement xElement in xElements)
                {
                    this.RolesConfiguration.Add(xElement.Attribute("name").Value, new RoleConfiguration(xElement));
                }
            }
        }
Ejemplo n.º 2
0
		protected override void ProcessRecord()
		{
			try
			{
				base.ProcessRecord();
				Operation operation = null;
				Deployment deploymentProcess = this.GetDeploymentProcess(out operation);
				if (deploymentProcess != null)
				{
					if (string.IsNullOrEmpty(deploymentProcess.DeploymentSlot))
					{
						deploymentProcess.DeploymentSlot = this.Slot;
					}
					DeploymentInfoContext deploymentInfoContext = new DeploymentInfoContext(deploymentProcess);
					deploymentInfoContext.ServiceName = this.ServiceName;
					deploymentInfoContext.set_OperationId(operation.OperationTrackingId);
					deploymentInfoContext.set_OperationDescription(base.CommandRuntime.ToString());
					deploymentInfoContext.set_OperationStatus(operation.Status);
					DeploymentInfoContext deploymentInfoContext1 = deploymentInfoContext;
					base.WriteObject(deploymentInfoContext1, true);
				}
			}
			catch (Exception exception1)
			{
				Exception exception = exception1;
				base.WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.CloseError, null));
			}
		}