public int AddHostingPlan(HostingPlanInfo plan) { return PackageController.AddHostingPlan(plan); }
public PackageResult UpdateHostingPlan(HostingPlanInfo plan) { return PackageController.UpdateHostingPlan(plan); }
public static PackageResult UpdateHostingPlan(HostingPlanInfo plan) { PackageResult result = new PackageResult(); // check account result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive | DemandAccount.IsReseller); if (result.Result < 0) return result; string quotasXml = BuildPlanQuotasXml(plan.Groups, plan.Quotas); result.ExceedingQuotas = DataProvider.UpdateHostingPlan(SecurityContext.User.UserId, plan.PlanId, plan.PackageId, plan.ServerId, plan.PlanName, plan.PlanDescription, plan.Available, plan.SetupPrice, plan.RecurringPrice, plan.RecurrenceUnit, plan.RecurrenceLength, quotasXml); if (result.ExceedingQuotas.Tables[0].Rows.Count > 0) result.Result = BusinessErrorCodes.ERROR_PACKAGE_QUOTA_EXCEED; return result; }
private int AddHostingPlan(string name, int serverId) { try { Log.WriteStart("Adding hosting plan"); // gather form info HostingPlanInfo plan = new HostingPlanInfo(); plan.UserId = 1; plan.PlanId = 0; plan.IsAddon = false; plan.PlanName = name; plan.PlanDescription = ""; plan.Available = true; // always available plan.SetupPrice = 0; plan.RecurringPrice = 0; plan.RecurrenceLength = 1; plan.RecurrenceUnit = 2; // month plan.PackageId = 0; plan.ServerId = serverId; List<HostingPlanGroupInfo> groups = new List<HostingPlanGroupInfo>(); List<HostingPlanQuotaInfo> quotas = new List<HostingPlanQuotaInfo>(); DataSet ds = ES.Services.Packages.GetHostingPlanQuotas(-1, 0, serverId); foreach (DataRow groupRow in ds.Tables[0].Rows) { bool enabled = (bool)groupRow["ParentEnabled"]; if (!enabled) continue; // disabled group int groupId = (int)groupRow["GroupId"]; ; HostingPlanGroupInfo group = new HostingPlanGroupInfo(); group.GroupId = groupId; group.Enabled = true; group.GroupName = Convert.ToString(groupRow["GroupName"]); group.CalculateDiskSpace = (bool)groupRow["CalculateDiskSpace"]; group.CalculateBandwidth = (bool)groupRow["CalculateBandwidth"]; groups.Add(group); DataView dvQuotas = new DataView(ds.Tables[1], "GroupID=" + group.GroupId.ToString(), "", DataViewRowState.CurrentRows); List<HostingPlanQuotaInfo> groupQuotas = GetGroupQuotas(groupId, dvQuotas); quotas.AddRange(groupQuotas); } plan.Groups = groups.ToArray(); plan.Quotas = quotas.ToArray(); // Add Web Deploy publishing support if enabled by default if (Utils.IsWebDeployInstalled()) { var resGroupWeb = Array.Find(plan.Groups, x => x.GroupName.Equals(ResourceGroups.Web, StringComparison.OrdinalIgnoreCase)); // if (resGroupWeb != null) { EnableRemoteManagementQuota(quotas, new DataView(ds.Tables[1], String.Format("GroupID = {0}", resGroupWeb.GroupId), "", DataViewRowState.CurrentRows)); } } int planId = ES.Services.Packages.AddHostingPlan(plan); if (planId > 0) { Log.WriteEnd("Added hosting plan"); } else { Log.WriteError(string.Format("Enterprise Server error: {0}", planId)); } return planId; } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) Log.WriteError("Hosting plan configuration error", ex); return -1; } }
public PackageResult UpdateHostingPlan(HostingPlanInfo plan) { return(PackageController.UpdateHostingPlan(plan)); }
public static int AddHostingPlan(HostingPlanInfo plan) { // check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive | DemandAccount.IsReseller); if (accountCheck < 0) return accountCheck; string quotasXml = BuildPlanQuotasXml(plan.Groups, plan.Quotas); return DataProvider.AddHostingPlan(SecurityContext.User.UserId, plan.UserId, plan.PackageId, plan.PlanName, plan.PlanDescription, plan.Available, plan.ServerId, plan.SetupPrice, plan.RecurringPrice, plan.RecurrenceUnit, plan.RecurrenceLength, plan.IsAddon, quotasXml); }
private void SavePlan() { if (!Page.IsValid) return; // gather form info HostingPlanInfo plan = new HostingPlanInfo(); plan.UserId = PanelSecurity.SelectedUserId; plan.PlanId = PanelRequest.PlanID; plan.IsAddon = true; plan.PlanName = Server.HtmlEncode(txtPlanName.Text); plan.PlanDescription = Server.HtmlEncode(txtPlanDescription.Text); plan.Available = true; // always available plan.SetupPrice = 0; plan.RecurringPrice = 0; plan.RecurrenceLength = 1; plan.RecurrenceUnit = 2; // month plan.Groups = hostingPlansQuotas.Groups; plan.Quotas = hostingPlansQuotas.Quotas; int planId = PanelRequest.PlanID; if ((PanelRequest.PlanID == 0) || ShouldCopyCurrentHostingAddon()) { // new plan try { planId = ES.Services.Packages.AddHostingPlan(plan); if (planId < 0) { ShowResultMessage(planId); return; } } catch (Exception ex) { ShowErrorMessage("ADDON_ADD_ADDON", ex); return; } } else { // update plan try { PackageResult result = ES.Services.Packages.UpdateHostingPlan(plan); lblMessage.Text = AntiXss.HtmlEncode(GetExceedingQuotasMessage(result.ExceedingQuotas)); if (result.Result < 0) { ShowResultMessage(result.Result); return; } } catch (Exception ex) { ShowErrorMessage("ADDON_UPDATE_ADDON", ex); return; } } // redirect RedirectBack(); }
public int AddHostingPlan(HostingPlanInfo plan) { object[] results = this.Invoke("AddHostingPlan", new object[] { plan}); return ((int)(results[0])); }
/// <remarks/> public void UpdateHostingPlanAsync(HostingPlanInfo plan) { this.UpdateHostingPlanAsync(plan, null); }
/// <remarks/> public void UpdateHostingPlanAsync(HostingPlanInfo plan, object userState) { if ((this.UpdateHostingPlanOperationCompleted == null)) { this.UpdateHostingPlanOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateHostingPlanOperationCompleted); } this.InvokeAsync("UpdateHostingPlan", new object[] { plan}, this.UpdateHostingPlanOperationCompleted, userState); }
/// <remarks/> public System.IAsyncResult BeginUpdateHostingPlan(HostingPlanInfo plan, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("UpdateHostingPlan", new object[] { plan}, callback, asyncState); }
public PackageResult UpdateHostingPlan(HostingPlanInfo plan) { object[] results = this.Invoke("UpdateHostingPlan", new object[] { plan}); return ((PackageResult)(results[0])); }
/// <remarks/> public void AddHostingPlanAsync(HostingPlanInfo plan) { this.AddHostingPlanAsync(plan, null); }
private void SavePlan() { if (!Page.IsValid) return; // gather form info HostingPlanInfo plan = new HostingPlanInfo(); plan.UserId = PanelSecurity.SelectedUserId; plan.PlanId = PanelRequest.PlanID; plan.IsAddon = false; plan.PlanName = Server.HtmlEncode(txtPlanName.Text); plan.PlanDescription = Server.HtmlEncode(txtPlanDescription.Text); plan.Available = true; // always available plan.SetupPrice = 0; plan.RecurringPrice = 0; plan.RecurrenceLength = 1; plan.RecurrenceUnit = 2; // month plan.PackageId = Utils.ParseInt(ddlSpace.SelectedValue, 0); plan.ServerId = Utils.ParseInt(ddlServer.SelectedValue, 0); // if this is non-admin // get server info from parent package if (PanelSecurity.EffectiveUser.Role != UserRole.Administrator) { try { PackageInfo package = ES.Services.Packages.GetPackage(plan.PackageId); if (package != null) plan.ServerId = package.ServerId; } catch (Exception ex) { ShowErrorMessage("PACKAGE_GET_PACKAGE", ex); return; } } plan.Groups = hostingPlansQuotas.Groups; plan.Quotas = hostingPlansQuotas.Quotas; int planId = PanelRequest.PlanID; if ((PanelRequest.PlanID == 0) || ShouldCopyCurrentHostingPlan()) { // new plan try { planId = ES.Services.Packages.AddHostingPlan(plan); if (planId < 0) { ShowResultMessage(planId); return; } } catch (Exception ex) { ShowErrorMessage("PLAN_ADD_PLAN", ex); return; } } else { // update plan try { PackageResult result = ES.Services.Packages.UpdateHostingPlan(plan); if (result.Result < 0) { ShowResultMessage(result.Result); lblMessage.Text = AntiXss.HtmlEncode(GetExceedingQuotasMessage(result.ExceedingQuotas)); return; } } catch (Exception ex) { ShowErrorMessage("PLAN_UPDATE_PLAN", ex); return; } } // redirect RedirectBack(); }
public int AddHostingPlan(HostingPlanInfo plan) { return(PackageController.AddHostingPlan(plan)); }
private int AddHostingPlan(string name, int serverId) { try { Log.WriteStart("Adding hosting plan"); // gather form info HostingPlanInfo plan = new HostingPlanInfo(); plan.UserId = 1; plan.PlanId = 0; plan.IsAddon = false; plan.PlanName = name; plan.PlanDescription = ""; plan.Available = true; // always available plan.SetupPrice = 0; plan.RecurringPrice = 0; plan.RecurrenceLength = 1; plan.RecurrenceUnit = 2; // month plan.PackageId = 0; plan.ServerId = serverId; List<HostingPlanGroupInfo> groups = new List<HostingPlanGroupInfo>(); List<HostingPlanQuotaInfo> quotas = new List<HostingPlanQuotaInfo>(); DataSet ds = ES.Services.Packages.GetHostingPlanQuotas(-1, 0, serverId); foreach (DataRow groupRow in ds.Tables[0].Rows) { bool enabled = (bool)groupRow["ParentEnabled"]; if (!enabled) continue; // disabled group int groupId = (int)groupRow["GroupId"]; ; HostingPlanGroupInfo group = new HostingPlanGroupInfo(); group.GroupId = groupId; group.Enabled = true; group.CalculateDiskSpace = (bool)groupRow["CalculateDiskSpace"]; group.CalculateBandwidth = (bool)groupRow["CalculateBandwidth"]; groups.Add(group); DataView dvQuotas = new DataView(ds.Tables[1], "GroupID=" + group.GroupId.ToString(), "", DataViewRowState.CurrentRows); List<HostingPlanQuotaInfo> groupQuotas = GetGroupQuotas(groupId, dvQuotas); quotas.AddRange(groupQuotas); } plan.Groups = groups.ToArray(); plan.Quotas = quotas.ToArray(); int planId = ES.Services.Packages.AddHostingPlan(plan); if (planId > 0) { Log.WriteEnd("Added hosting plan"); } else { Log.WriteError(string.Format("Enterprise Server error: {0}", planId)); } return planId; } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) Log.WriteError("Hosting plan configuration error", ex); return -1; } }
public int CreateUserAccountInternal(int parentPackageId, string username, string password, int roleId, string firstName, string lastName, string email, string secondaryEmail, bool htmlMail, bool sendAccountLetter, bool createPackage, int planId, bool sendPackageLetter, string domainName, bool tempDomain, bool createWebSite, bool createFtpAccount, string ftpAccountName, bool createMailAccount, string hostName, bool createZoneRecord) { // check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive | DemandAccount.IsReseller); if (accountCheck < 0) { return(accountCheck); } // check package int packageCheck = SecurityContext.CheckPackage(parentPackageId, DemandPackage.IsActive); if (packageCheck < 0) { return(packageCheck); } // check if username exists if (UserController.UserExists(username)) { return(BusinessErrorCodes.ERROR_ACCOUNT_WIZARD_USER_EXISTS); } // check if domain exists int checkDomainResult = ServerController.CheckDomain(domainName); if (checkDomainResult < 0) { return(checkDomainResult); } // check if FTP account exists if (String.IsNullOrEmpty(ftpAccountName)) { ftpAccountName = username; } if (FtpServerController.FtpAccountExists(ftpAccountName)) { return(BusinessErrorCodes.ERROR_ACCOUNT_WIZARD_FTP_ACCOUNT_EXISTS); } // load parent package PackageInfo parentPackage = PackageController.GetPackage(parentPackageId); /******************************************** * CREATE USER ACCOUNT * *****************************************/ UserInfo user = new UserInfo(); user.RoleId = roleId; user.StatusId = (int)UserStatus.Active; user.OwnerId = parentPackage.UserId; user.IsDemo = false; user.IsPeer = false; // account info user.FirstName = firstName; user.LastName = lastName; user.Email = email; user.SecondaryEmail = secondaryEmail; user.Username = username; // user.Password = password; user.HtmlMail = htmlMail; // add a new user createdUserId = UserController.AddUser(user, false, password); if (createdUserId < 0) { // exit return(createdUserId); } userCreated = true; // create package // load hosting plan createdPackageId = -1; if (createPackage) { try { HostingPlanInfo plan = PackageController.GetHostingPlan(planId); PackageResult packageResult = PackageController.AddPackage( createdUserId, planId, plan.PlanName, "", (int)PackageStatus.Active, DateTime.Now, false); createdPackageId = packageResult.Result; } catch (Exception ex) { // error while adding package // remove user account UserController.DeleteUser(createdUserId); throw ex; } if (createdPackageId < 0) { // rollback wizard Rollback(); // return code return(createdPackageId); } // create domain int domainId = 0; if ((createWebSite || createMailAccount || createZoneRecord) && !String.IsNullOrEmpty(domainName)) { try { DomainInfo domain = new DomainInfo(); domain.PackageId = createdPackageId; domain.DomainName = domainName; domain.HostingAllowed = false; domainId = ServerController.AddDomain(domain, false, false); if (domainId < 0) { // rollback wizard Rollback(); // return return(domainId); } } catch (Exception ex) { // rollback wizard Rollback(); // error while adding domain throw new Exception("Could not add domain", ex); } } if (createWebSite && (domainId > 0)) { // create web site try { int webSiteId = WebServerController.AddWebSite( createdPackageId, hostName, domainId, 0, true, false); if (webSiteId < 0) { // rollback wizard Rollback(); // return return(webSiteId); } } catch (Exception ex) { // rollback wizard Rollback(); // error while creating web site throw new Exception("Could not create web site", ex); } } // create FTP account if (createFtpAccount) { try { FtpAccount ftpAccount = new FtpAccount(); ftpAccount.PackageId = createdPackageId; ftpAccount.Name = ftpAccountName; ftpAccount.Password = password; ftpAccount.Folder = "\\"; ftpAccount.CanRead = true; ftpAccount.CanWrite = true; int ftpAccountId = FtpServerController.AddFtpAccount(ftpAccount); if (ftpAccountId < 0) { // rollback wizard Rollback(); // return return(ftpAccountId); } } catch (Exception ex) { // rollback wizard Rollback(); // error while creating ftp account throw new Exception("Could not create FTP account", ex); } } if (createMailAccount && (domainId > 0)) { // create default mailbox try { // load mail policy UserSettings settings = UserController.GetUserSettings(createdUserId, UserSettings.MAIL_POLICY); string catchAllName = !String.IsNullOrEmpty(settings["CatchAllName"]) ? settings["CatchAllName"] : "mail"; MailAccount mailbox = new MailAccount(); mailbox.Name = catchAllName + "@" + domainName; mailbox.PackageId = createdPackageId; // gather information from the form mailbox.Enabled = true; mailbox.ResponderEnabled = false; mailbox.ReplyTo = ""; mailbox.ResponderSubject = ""; mailbox.ResponderMessage = ""; // password mailbox.Password = password; // redirection mailbox.ForwardingAddresses = new string[] { }; mailbox.DeleteOnForward = false; mailbox.MaxMailboxSize = 0; int mailAccountId = MailServerController.AddMailAccount(mailbox); if (mailAccountId < 0) { // rollback wizard Rollback(); // return return(mailAccountId); } // set catch-all account MailDomain mailDomain = MailServerController.GetMailDomain(createdPackageId, domainName); mailDomain.CatchAllAccount = "mail"; mailDomain.PostmasterAccount = "mail"; mailDomain.AbuseAccount = "mail"; MailServerController.UpdateMailDomain(mailDomain); int mailDomainId = mailDomain.Id; } catch (Exception ex) { // rollback wizard Rollback(); // error while creating mail account throw new Exception("Could not create mail account", ex); } } // Instant Alias / Temporary URL if (tempDomain && (domainId > 0)) { int instantAliasId = ServerController.CreateDomainInstantAlias("", domainId); if (instantAliasId < 0) { // rollback wizard Rollback(); return(instantAliasId); } } // Domain DNS Zone if (createZoneRecord && (domainId > 0)) { ServerController.EnableDomainDns(domainId); } } // send welcome letters if (sendAccountLetter) { int result = PackageController.SendAccountSummaryLetter(createdUserId, null, null, true); if (result < 0) { // rollback wizard Rollback(); // return return(result); } } if (createPackage && sendPackageLetter) { int result = PackageController.SendPackageSummaryLetter(createdPackageId, null, null, true); if (result < 0) { // rollback wizard Rollback(); // return return(result); } } return(createdUserId); }