public ResultObject UpdateExchangeOrganizationQuotas(int itemId, int mailboxesNumber, int contactsNumber, int distributionListsNumber) { return(ExchangeHostedEditionController.UpdateOrganizationQuotas(itemId, mailboxesNumber, contactsNumber, distributionListsNumber)); }
public static IntResult CreateOrganization(int packageId, string organizationId, string domain, string adminName, string adminEmail, string adminPassword) { IntResult result = new IntResult(); result.IsSuccess = true; try { // initialize task manager TaskManager.StartTask(TaskManagerSource, "CREATE_ORGANIZATION"); TaskManager.WriteParameter("packageId", packageId); TaskManager.WriteParameter("organizationId", organizationId); TaskManager.WriteParameter("domain", domain); TaskManager.WriteParameter("adminName", adminName); TaskManager.WriteParameter("adminEmail", adminEmail); TaskManager.WriteParameter("adminPassword", adminPassword); // get Exchange service ID int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.ExchangeHostedEdition); if (serviceId < 1) { return(Error <IntResult>(ExchangeServiceNotEnabledError)); } #region Check Space and Account // Check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); if (accountCheck < 0) { return(Warning <IntResult>((-accountCheck).ToString())); } // Check space int packageCheck = SecurityContext.CheckPackage(packageId, DemandPackage.IsActive); if (packageCheck < 0) { return(Warning <IntResult>((-packageCheck).ToString())); } #endregion // get Exchange service ExchangeServerHostedEdition exchange = GetExchangeService(serviceId); // load service settings to know ProgramID, OfferID StringDictionary serviceSettings = ServerController.GetServiceSettings(serviceId); string programId = serviceSettings["programID"]; string offerId = serviceSettings["offerID"]; // check settings if (String.IsNullOrEmpty(programId)) { result.ErrorCodes.Add(ProgramIdIsNotSetError); } if (String.IsNullOrEmpty(offerId)) { result.ErrorCodes.Add(OfferIdIsNotSetError); } if (result.ErrorCodes.Count > 0) { result.IsSuccess = false; return(result); } #region Create organization int itemId = -1; ExchangeOrganization org = null; try { // create organization exchange.CreateOrganization(organizationId, programId, offerId, domain, adminName, adminEmail, adminPassword); // save item into meta-base org = new ExchangeOrganization(); org.Name = organizationId; org.PackageId = packageId; org.ServiceId = serviceId; itemId = PackageController.AddPackageItem(org); } catch (Exception ex) { // log error TaskManager.WriteError(ex); return(Error <IntResult>(CreateOrganizationError)); } #endregion #region Update organization quotas // update max org quotas UpdateOrganizationQuotas(org); // override quotas ResultObject quotasResult = ExchangeHostedEditionController.UpdateOrganizationQuotas(itemId, org.MaxMailboxCountQuota, org.MaxContactCountQuota, org.MaxDistributionListCountQuota); if (!quotasResult.IsSuccess) { return(Error <IntResult>(quotasResult, CreateOrganizationError)); } #endregion #region Add temporary domain // load settings PackageSettings settings = GetExchangePackageSettings(org); string tempDomainTemplate = settings[TempDomainSetting]; if (!String.IsNullOrEmpty(tempDomainTemplate)) { // add temp domain string tempDomain = String.Format("{0}.{1}", domain, tempDomainTemplate); AddOrganizationDomain(itemId, tempDomain); } #endregion result.Value = itemId; return(result); } catch (Exception ex) { // log error TaskManager.WriteError(ex); // exit with error code return(Error <IntResult>(GeneralError, ex.Message)); } finally { TaskManager.CompleteTask(); } }