/// <summary> /// Modifies the product. /// </summary> /// <param name="subscription">The subscription.</param> /// <param name="mainSubscription">The main subscription.</param> /// <param name="account">The account.</param> /// <param name="productDescription">The product description.</param> /// <param name="additionalData">The additional data.</param> /// <exception cref="ArgumentException"></exception> /// <returns>Modified service.</returns> public ProvisioningService ModifyProduct(Subscription subscription, Subscription mainSubscription, BoAccount account, CustomProduct productDescription, Dictionary <string, object> additionalData) { ProvisioningService service = null; if (additionalData == null || !additionalData.ContainsKey("ModifyOperation")) { throw new AtomiaProvisioningException(string.Format("Cannot modify {0} service. Additional data are null or does not contain ModifyOperation key.", productDescription.ProvisioningService)); } string operation = additionalData["ModifyOperation"].ToString(); ProvisioningService parentService = this.GetService(subscription, productDescription, account); string serviceName = GetProductProperty(productDescription, "instanceService"); ServiceSearchCriteria ssc = new ServiceSearchCriteria { ParentService = parentService, ServiceName = serviceName }; ProvisioningService[] foundServices = this.coreService.FindServicesByPath(new[] { ssc }, null, account.Name, null, true); if (foundServices == null || foundServices.Length == 0) { throw new NullReferenceException(string.Format("Cannot modify {0} service. Service {1} cannot be found on account {2}.", productDescription.ProvisioningService, serviceName, account.Name)); } service = foundServices[0]; switch (operation) { case "Suspend": parentService.properties.First(property => property.Name == "State").propStringValue = "Suspended"; this.coreService.CallOperation("Stop", string.Empty, service, account.Name); break; case "Unsuspend": parentService.properties.First(property => property.Name == "State").propStringValue = "Ok"; this.coreService.CallOperation("Start", string.Empty, service, account.Name); break; default: throw new ArgumentException(string.Format("Cannot modify {0} service. Unknown operation: {1}.", productDescription.ProvisioningService, operation)); } try { return(this.coreService.ModifyService(parentService, account.Name)); } catch (Exception ex) { throw new AtomiaProvisioningException(ex.Message, ex); } }
/// <summary> /// Searches for clients that match the search criteria. /// </summary> public ServiceSearchItem[] SearchService(int startRow, int pageSize, string sortBy, string industry, bool forceRefresh) { TimeServiceClient timeService = null; ServiceSearchItem[] services = null; try { if (HttpContext.Current.Session[SessionName.LogonSettings] != null) { Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId; CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.ForceRefresh = forceRefresh; collectionRequest.StartRow = startRow; collectionRequest.RowCount = pageSize; ServiceSearchCriteria criteria = new ServiceSearchCriteria(); criteria.IndustryId = Convert.ToInt32(industry); criteria.OrderBy = sortBy; timeService = new TimeServiceClient(); ServiceSearchReturnValue returnValue = timeService.ServiceSearchOnIndustry(_logonId, collectionRequest, criteria); if (returnValue.Success) { _serviceRowCount = returnValue.Service.TotalRowCount; services = returnValue.Service.Rows; } else { throw new Exception(returnValue.Message); } } return(services); } catch (Exception ex) { throw ex; } finally { if (timeService != null) { if (timeService.State != System.ServiceModel.CommunicationState.Faulted) { timeService.Close(); } } } }
public List <ExampleModel> FetchObjectsWithPaging(string search, string iDisplayStart, string iDisplayLength, int sortColumn, string sortDirection, out long total) { var examples = new List <ExampleModel>(); total = 0; try { var serviceSearchCriteria = new ServiceSearchCriteria[] { new ServiceSearchCriteria { ParentService = null, ServicePath = exampleServiceData.Path, ServiceName = exampleServiceData.ServiceName } }; var searchDictionary = search.Length > 0 ? new Dictionary <string, string> { { exampleServiceData.ServiceProperties["Name"], "%*" + search + "%*" } } : null; var exampleServices = coreApi.FindServicesByPathWithPaging( out total, serviceSearchCriteria, searchDictionary, accountId, exampleServiceData.ServiceProperties["Name"], sortDirection.ToLower() == "asc", Convert.ToInt32(iDisplayStart) / Convert.ToInt32(iDisplayLength), Convert.ToInt32(iDisplayLength)); exampleServices = PackageSelectHelper.FilterServicesToSelectedPackage(controller.RouteData, exampleServices); foreach (var exampleService in exampleServices) { examples.Add(new ExampleModel { LogicalID = exampleService.logicalId, Name = GetServicePropertyValue(exampleService, "Name"), Status = GetServicePropertyValue(exampleService, "Status") }); } } catch (Exception ex) { HostingControlPanelLogger.LogHostingControlPanelException(ex); total = 0; } return(examples); }
/// <summary> /// Finds the service. /// </summary> /// <param name="productDescription">The product description.</param> /// <param name="parentServiceKey">The parent service key.</param> /// <param name="rootServiceKey">The root service key.</param> /// <param name="account">The account.</param> /// <returns>Service that was found using parent services.</returns> private ProvisioningService FindService(CustomProduct productDescription, string parentServiceKey, string rootServiceKey, BoAccount account) { string parentServiceName = GetProductProperty(productDescription, parentServiceKey); string servicePath = productDescription.CustomProductProperties[rootServiceKey].Value; ServiceSearchCriteria ssc = new ServiceSearchCriteria { ParentService = null, ServiceName = parentServiceName, ServicePath = servicePath }; ProvisioningService[] parentService = this.coreService.FindServicesByPath(new[] { ssc }, null, account.Name, null, true); if (parentService == null || parentService.Length < 1) { throw new AtomiaProvisioningException(string.Format("Cannot add {0} service. Account {1} doesn't have {2} service provisioned.", productDescription.ProvisioningService, account.Name, parentServiceName)); } return(parentService[0]); }
/// <summary> /// Creates the name of the service. /// </summary> /// <param name="accountId">The account unique identifier.</param> /// <param name="parentService">The parent service.</param> /// <param name="serviceName">Name of the _service.</param> /// <param name="name">The name.</param> /// <returns>Name for service</returns> private string GetServiceName(string accountId, ProvisioningService parentService, string serviceName, string name) { string propertyValue = GetName(name); ServiceSearchCriteria ssc = new ServiceSearchCriteria { ParentService = parentService, ServiceName = serviceName }; ProvisioningService[] foundServices = this.coreService.FindServicesByPath(new[] { ssc }, null, accountId, null, true); if (foundServices.Length > 0) { while (foundServices.Any(s => s.name == propertyValue)) { propertyValue = GetName(name); } } return(propertyValue); }
private static ProvisioningService[] SearchServices( ICoreApi coreApi, ProvisioningService parentService, string serviceName, string accountName, string servicePath = null, Dictionary <string, string> properties = null) { if (parentService != null) { servicePath = servicePath.Substring(servicePath.LastIndexOf(parentService.name) + parentService.name.Length); } var criteria = new ServiceSearchCriteria { ParentService = parentService, ServiceName = serviceName, ServicePath = servicePath }; return(coreApi.FindServicesByPath(new[] { criteria }, properties, accountName, null, true)); }
/// <summary> /// Searches for clients that match the search criteria. /// </summary> public ServiceSearchItem[] SearchService(int startRow, int pageSize, string sortBy, string industry, bool forceRefresh) { TimeServiceClient timeService = null; ServiceSearchItem[] services = null; try { if (HttpContext.Current.Session[SessionName.LogonSettings] != null) { Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId; CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.ForceRefresh = forceRefresh; collectionRequest.StartRow = startRow; collectionRequest.RowCount = pageSize; ServiceSearchCriteria criteria = new ServiceSearchCriteria(); criteria.IndustryId = Convert.ToInt32(industry); criteria.OrderBy = sortBy; timeService = new TimeServiceClient(); ServiceSearchReturnValue returnValue = timeService.ServiceSearchOnIndustry(_logonId, collectionRequest, criteria); if (returnValue.Success) { _serviceRowCount = returnValue.Service.TotalRowCount; services = returnValue.Service.Rows; } else { throw new Exception(returnValue.Message); } } return services; } catch (Exception ex) { throw ex; } finally { if (timeService != null) { if (timeService.State != System.ServiceModel.CommunicationState.Faulted) timeService.Close(); } } }
/// <summary> /// Get service search on industry /// </summary> /// <param name="oHostSecurityToken"></param> /// <param name="collectionRequest"></param> /// <param name="criteria"></param> /// <returns></returns> public ServiceSearchReturnValue ServiceSearchOnIndustry(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, ServiceSearchCriteria criteria) { ServiceSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oTimeService = new TimeService(); returnValue = oTimeService.ServiceSearchOnIndustry(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new ServiceSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return(returnValue); }
/// <summary> /// Get service search on industry /// </summary> /// <param name="oHostSecurityToken"></param> /// <param name="collectionRequest"></param> /// <param name="criteria"></param> /// <returns></returns> public ServiceSearchReturnValue ServiceSearchOnIndustry(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, ServiceSearchCriteria criteria) { ServiceSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oTimeService = new TimeService(); returnValue = oTimeService.ServiceSearchOnIndustry(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new ServiceSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }