public void GetRoleProcess() { Operation getDeploymentOperation; var currentDeployment = this.GetCurrentDeployment(out getDeploymentOperation); if (currentDeployment != null) { if (this.InstanceDetails.IsPresent == false) { var roleContexts = new Collection<RoleContext>(); RoleList roles = null; if (string.IsNullOrEmpty(this.RoleName)) { roles = currentDeployment.RoleList; } else { roles = new RoleList(currentDeployment.RoleList.Where(r => r.RoleName.Equals(this.RoleName, StringComparison.OrdinalIgnoreCase))); } foreach (var r in roles.Select(role => new RoleContext { InstanceCount = currentDeployment.RoleInstanceList.Count(ri => ri.RoleName.Equals(role.RoleName, StringComparison.OrdinalIgnoreCase)), RoleName = role.RoleName, OperationDescription = this.CommandRuntime.ToString(), OperationStatus = getDeploymentOperation.Status, OperationId = getDeploymentOperation.OperationTrackingId, ServiceName = this.ServiceName, DeploymentID = currentDeployment.PrivateID })) { roleContexts.Add(r); } WriteObject(roleContexts, true); } else { Collection<RoleInstanceContext> instanceContexts = new Collection<RoleInstanceContext>(); RoleInstanceList roleInstances = null; if (string.IsNullOrEmpty(this.RoleName)) { roleInstances = currentDeployment.RoleInstanceList; } else { roleInstances = new RoleInstanceList(currentDeployment.RoleInstanceList.Where(r => r.RoleName.Equals(this.RoleName, StringComparison.OrdinalIgnoreCase))); } foreach (RoleInstance role in roleInstances) { var context = new RoleInstanceContext() { ServiceName = this.ServiceName, OperationId = getDeploymentOperation.OperationTrackingId, OperationDescription = this.CommandRuntime.ToString(), OperationStatus = getDeploymentOperation.Status, InstanceErrorCode = role.InstanceErrorCode, InstanceFaultDomain = role.InstanceFaultDomain, InstanceName = role.InstanceName, InstanceSize = role.InstanceSize, InstanceStateDetails = role.InstanceStateDetails, InstanceStatus = role.InstanceStatus, InstanceUpgradeDomain = role.InstanceUpgradeDomain, RoleName = role.RoleName, DeploymentID = currentDeployment.PrivateID, InstanceEndpoints = role.InstanceEndpoints }; instanceContexts.Add(context); } WriteObject(instanceContexts, true); } } }
public void GetRoleProcess() { Operation getDeploymentOperation; var currentDeployment = this.GetCurrentDeployment(out getDeploymentOperation); if (currentDeployment != null) { if (this.InstanceDetails.IsPresent == false) { var roleContexts = new Collection <RoleContext>(); RoleList roles = null; if (string.IsNullOrEmpty(this.RoleName)) { roles = currentDeployment.RoleList; } else { roles = new RoleList(currentDeployment.RoleList.Where(r => r.RoleName.Equals(this.RoleName, StringComparison.OrdinalIgnoreCase))); } foreach (var r in roles.Select(role => new RoleContext { InstanceCount = currentDeployment.RoleInstanceList.Count(ri => ri.RoleName.Equals(role.RoleName, StringComparison.OrdinalIgnoreCase)), RoleName = role.RoleName, OperationDescription = this.CommandRuntime.ToString(), OperationStatus = getDeploymentOperation.Status, OperationId = getDeploymentOperation.OperationTrackingId, ServiceName = this.ServiceName, DeploymentID = currentDeployment.PrivateID })) { roleContexts.Add(r); } WriteObject(roleContexts, true); } else { Collection <RoleInstanceContext> instanceContexts = new Collection <RoleInstanceContext>(); RoleInstanceList roleInstances = null; if (string.IsNullOrEmpty(this.RoleName)) { roleInstances = currentDeployment.RoleInstanceList; } else { roleInstances = new RoleInstanceList(currentDeployment.RoleInstanceList.Where(r => r.RoleName.Equals(this.RoleName, StringComparison.OrdinalIgnoreCase))); } foreach (RoleInstance role in roleInstances) { var context = new RoleInstanceContext() { ServiceName = this.ServiceName, OperationId = getDeploymentOperation.OperationTrackingId, OperationDescription = this.CommandRuntime.ToString(), OperationStatus = getDeploymentOperation.Status, InstanceErrorCode = role.InstanceErrorCode, InstanceFaultDomain = role.InstanceFaultDomain, InstanceName = role.InstanceName, InstanceSize = role.InstanceSize, InstanceStateDetails = role.InstanceStateDetails, InstanceStatus = role.InstanceStatus, InstanceUpgradeDomain = role.InstanceUpgradeDomain, RoleName = role.RoleName, DeploymentID = currentDeployment.PrivateID, InstanceEndpoints = role.InstanceEndpoints }; instanceContexts.Add(context); } WriteObject(instanceContexts, true); } } }
public void GetRoleProcess() { RoleList roleList; RoleInstanceList roleInstanceList; Func <Role, bool> func = null; Func <RoleInstance, bool> func1 = null; this.GetCurrentDeployment(); if (this.currentDeployment != null) { SwitchParameter instanceDetails = this.InstanceDetails; if (instanceDetails.IsPresent) { Collection <RoleInstanceContext> roleInstanceContexts = new Collection <RoleInstanceContext>(); if (!string.IsNullOrEmpty(this.RoleName)) { RoleInstanceList roleInstanceList1 = this.currentDeployment.RoleInstanceList; if (func1 == null) { func1 = (RoleInstance r) => r.RoleName.Equals(this.RoleName, StringComparison.OrdinalIgnoreCase); } roleInstanceList = new RoleInstanceList(roleInstanceList1.Where <RoleInstance>(func1)); } else { roleInstanceList = this.currentDeployment.RoleInstanceList; } foreach (RoleInstance roleInstance in roleInstanceList) { RoleInstanceContext roleInstanceContext = new RoleInstanceContext(); roleInstanceContext.ServiceName = this.ServiceName; roleInstanceContext.set_OperationId(this.getDeploymentOperation.OperationTrackingId); roleInstanceContext.set_OperationDescription(base.CommandRuntime.ToString()); roleInstanceContext.set_OperationStatus(this.getDeploymentOperation.Status); roleInstanceContext.InstanceErrorCode = roleInstance.InstanceErrorCode; roleInstanceContext.InstanceFaultDomain = roleInstance.InstanceFaultDomain; roleInstanceContext.InstanceName = roleInstance.InstanceName; roleInstanceContext.InstanceSize = roleInstance.InstanceSize; roleInstanceContext.InstanceStateDetails = roleInstance.InstanceStateDetails; roleInstanceContext.InstanceStatus = roleInstance.InstanceStatus; roleInstanceContext.InstanceUpgradeDomain = roleInstance.InstanceUpgradeDomain; roleInstanceContext.RoleName = roleInstance.RoleName; roleInstanceContext.DeploymentID = this.currentDeployment.PrivateID; roleInstanceContext.InstanceEndpoints = roleInstance.InstanceEndpoints; RoleInstanceContext roleInstanceContext1 = roleInstanceContext; roleInstanceContexts.Add(roleInstanceContext1); } base.WriteObject(roleInstanceContexts, true); } else { Collection <RoleContext> roleContexts = new Collection <RoleContext>(); if (!string.IsNullOrEmpty(this.RoleName)) { RoleList roleList1 = this.currentDeployment.RoleList; if (func == null) { func = (Role r) => r.RoleName.Equals(this.RoleName, StringComparison.OrdinalIgnoreCase); } roleList = new RoleList(roleList1.Where <Role>(func)); } else { roleList = this.currentDeployment.RoleList; } List <Role> .Enumerator enumerator = roleList.GetEnumerator(); try { Func <RoleInstance, bool> func2 = null; while (enumerator.MoveNext()) { Role current = enumerator.Current; RoleContext roleContext = new RoleContext(); RoleContext roleContext1 = roleContext; RoleInstanceList roleInstanceList2 = this.currentDeployment.RoleInstanceList; if (func2 == null) { func2 = (RoleInstance ri) => ri.RoleName.Equals(current.RoleName, StringComparison.OrdinalIgnoreCase); } roleContext1.InstanceCount = roleInstanceList2.Where <RoleInstance>(func2).Count <RoleInstance>(); roleContext.RoleName = current.RoleName; roleContext.set_OperationDescription(base.CommandRuntime.ToString()); roleContext.set_OperationStatus(this.getDeploymentOperation.Status); roleContext.set_OperationId(this.getDeploymentOperation.OperationTrackingId); roleContext.ServiceName = this.ServiceName; roleContext.DeploymentID = this.currentDeployment.PrivateID; RoleContext roleContext2 = roleContext; roleContexts.Add(roleContext2); } } finally { enumerator.Dispose(); } base.WriteObject(roleContexts, true); return; } } }