private void BindPackage() { PackageInfo package = ES.Services.Packages.GetPackage(PanelSecurity.PackageId); if (package == null) { return; } rowSpaceServer.Visible = (PanelSecurity.LoggedUser.Role == UserRole.Administrator); spaceUser.UserId = package.UserId; litPackageName.Text = package.PackageName; litPurchaseDate.Text = package.PurchaseDate.ToString("d"); serverDetails.ServerId = package.ServerId; litStatus.Text = PanelFormatter.GetPackageStatusName(package.StatusId); // load hosting plan HostingPlanInfo plan = ES.Services.Packages.GetHostingPlan(package.PlanId); if (plan != null) { litHostingPlan.Text = plan.PlanName; } }
private void BindSpace() { // load space PackageInfo package = ES.Services.Packages.GetPackage(PanelSecurity.PackageId); if (package != null) { litSpaceName.Text = PortalAntiXSS.EncodeOld(package.PackageName); chkDefault.Checked = package.DefaultTopPackage; // bind space status PackageStatus status = (PackageStatus)package.StatusId; litStatus.Text = PanelFormatter.GetPackageStatusName(package.StatusId); cmdActive.Visible = (status != PackageStatus.Active); cmdSuspend.Visible = (status == PackageStatus.Active); cmdCancel.Visible = (status != PackageStatus.Cancelled); StatusBlock.Visible = (PanelSecurity.SelectedUserId != PanelSecurity.EffectiveUserId); // bind account details litCreated.Text = package.PurchaseDate.ToString(); serverDetails.ServerId = package.ServerId; // load plan HostingPlanInfo plan = ES.Services.Packages.GetHostingPlan(package.PlanId); if (plan != null) { litHostingPlan.Text = plan.PlanName; } // links lnkSummaryLetter.NavigateUrl = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "summary_letter"); lnkSummaryLetter.Visible = (PanelSecurity.PackageId > 1); lnkOverusageReport.NavigateUrl = NavigatePageURL("OverusageReport", PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString()); OverusageReport.Visible = (PanelSecurity.SelectedUser.Role != UserRole.User); lnkEditSpaceDetails.NavigateUrl = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "edit_details"); bool ownSpace = (package.UserId == PanelSecurity.EffectiveUserId); lnkEditSpaceDetails.Visible = (PanelSecurity.PackageId > 1 && !ownSpace); lnkDelete.NavigateUrl = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "delete"); if (!((PanelSecurity.LoggedUser.Role == UserRole.Reseller) | (PanelSecurity.LoggedUser.Role == UserRole.Administrator))) { lnkDelete.Visible = false; } else { lnkDelete.Visible = ((PanelSecurity.SelectedUserId != PanelSecurity.EffectiveUserId) && (PanelSecurity.PackageId > 1)); } } }
private void BindPlan() { // hide "target server" section for non-admins bool isUserAdmin = PanelSecurity.SelectedUser.Role == UserRole.Administrator; rowTargetServer.Visible = isUserAdmin; rowTargetSpace.Visible = !isUserAdmin; if (isUserAdmin) { BindServers(); } else { BindSpaces(); } if (PanelRequest.PlanID == 0) { // new plan BindQuotas(); return; } HostingPlanInfo plan = ES.Services.Packages.GetHostingPlan(PanelRequest.PlanID); if (plan == null) { // plan not found RedirectBack(); } if (ShouldCopyCurrentHostingPlan()) { plan.PlanId = 0; plan.PlanName = "Copy of " + plan.PlanName; } // bind plan txtPlanName.Text = PortalAntiXSS.DecodeOld(plan.PlanName); txtPlanDescription.Text = PortalAntiXSS.DecodeOld(plan.PlanDescription); //chkAvailable.Checked = plan.Available; //txtSetupPrice.Text = plan.SetupPrice.ToString("0.00"); //txtRecurringPrice.Text = plan.RecurringPrice.ToString("0.00"); //txtRecurrenceLength.Text = plan.RecurrenceLength.ToString(); //Utils.SelectListItem(ddlRecurrenceUnit, plan.RecurrenceUnit); Utils.SelectListItem(ddlServer, plan.ServerId); Utils.SelectListItem(ddlSpace, plan.PackageId); // bind quotas BindQuotas(); }
public IHttpActionResult AddHosting([FromBody] HostingPlanInfo planInfo, ApiBaseModel model, out string message) { message = ""; try { if (!ModelState.IsValid) { return(JSendBadRequest(ModelState)); } var result = _hostingService.AddHosting(planInfo, model, out message); return(JSendCreated("", result)); } catch (Exception ex) { return(JSendError(HttpStatusCode.InternalServerError, ex.Message)); } }
private void BindPlan() { if (PanelRequest.PlanID == 0) { // new plan BindQuotas(); return; } HostingPlanInfo plan = ES.Services.Packages.GetHostingPlan(PanelRequest.PlanID); if (plan == null) { // plan not found RedirectBack(); } if (ShouldCopyCurrentHostingAddon()) { plan.PlanId = 0; plan.PlanName = "Copy of " + plan.PlanName; } // bind plan txtPlanName.Text = PortalAntiXSS.DecodeOld(plan.PlanName); txtPlanDescription.Text = PortalAntiXSS.DecodeOld(plan.PlanDescription); //chkAvailable.Checked = plan.Available; //txtSetupPrice.Text = plan.SetupPrice.ToString("0.00"); //txtRecurringPrice.Text = plan.RecurringPrice.ToString("0.00"); //txtRecurrenceLength.Text = plan.RecurrenceLength.ToString(); //Utils.SelectListItem(ddlRecurrenceUnit, plan.RecurrenceUnit); // bind quotas BindQuotas(); }
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); } }
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 = txtPlanName.Text; plan.PlanDescription = 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 = PortalAntiXSS.Encode(GetExceedingQuotasMessage(result.ExceedingQuotas)); return; } } catch (Exception ex) { ShowErrorMessage("PLAN_UPDATE_PLAN", ex); return; } } // redirect RedirectBack(); }
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 = txtPlanName.Text; plan.PlanDescription = 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 = PortalAntiXSS.Encode(GetExceedingQuotasMessage(result.ExceedingQuotas)); if (result.Result < 0) { ShowResultMessage(result.Result); return; } } catch (Exception ex) { ShowErrorMessage("ADDON_UPDATE_ADDON", ex); return; } } // redirect RedirectBack(); }
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 void Add_Hosting() { var controller = new HostingWindowsController(new HostingServiceWindowsPanel()); HostingPlanInfo hpi = new HostingPlanInfo() { UserId = 2, PlanId = 0, IsAddon = false, PlanName = "varsayilan-plan-markumdestek", PlanDescription = null, Available = true, SetupPrice = 0, RecurringPrice = 0, RecurrenceLength = 1, RecurrenceUnit = 2, PackageId = 2, ServerId = 0, }; hpi.Groups = new HostingPlanGroupInfo[] { new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 1 }, new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 2 }, new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 3 }, new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 11 }, new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 7 }, new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 8 }, new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 22 }, }; hpi.Quotas = new HostingPlanQuotaInfo[] { new HostingPlanQuotaInfo() { QuotaId = 70, QuotaValue = 1 }, new HostingPlanQuotaInfo() { QuotaId = 106, QuotaValue = 250 }, new HostingPlanQuotaInfo() { QuotaId = 107, QuotaValue = 1 }, new HostingPlanQuotaInfo() { QuotaId = 108, QuotaValue = 1 }, new HostingPlanQuotaInfo() { QuotaId = 211, QuotaValue = 2 }, new HostingPlanQuotaInfo() { QuotaId = 212, QuotaValue = 2 }, new HostingPlanQuotaInfo() { QuotaId = 213, QuotaValue = 50 }, new HostingPlanQuotaInfo() { QuotaId = 214, QuotaValue = 1 }, new HostingPlanQuotaInfo() { QuotaId = 215, QuotaValue = 1 }, new HostingPlanQuotaInfo() { QuotaId = 216, QuotaValue = 1 }, new HostingPlanQuotaInfo() { QuotaId = 217, QuotaValue = 20 }, }; string message = ""; ApiBaseModel model = new ApiBaseModel() { PanelApiUsername = apiUser, PanelApiCryptokey = key, PanelApiPassword = pwd, PanelApiUrl = url }; var result = controller.AddHosting(hpi, model, out message); Assert.IsNotNull(result); Assert.AreEqual(result.ToString(), "1"); }
public void EmulateHostingCreating() { ApiBaseModel model = new ApiBaseModel() { PanelApiUsername = apiUser, PanelApiCryptokey = key, PanelApiPassword = pwd, PanelApiUrl = url }; // validation will be implemented before service call in panel and core projects if (_isReseller) { var controller = new HostingWindowsController(new HostingServiceWindowsPanel()); HostingPlanInfo hpi = new HostingPlanInfo() { UserId = 1, PlanId = 0, IsAddon = false, PlanName = "Standart Plan", PlanDescription = "", Available = true, SetupPrice = 0, RecurringPrice = 0, RecurrenceLength = 1, RecurrenceUnit = 2, PackageId = 808, ServerId = 0, }; hpi.Groups = new HostingPlanGroupInfo[] { new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 1 }, new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 2 }, new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 3 }, new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 11 }, new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 7 }, new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 8 }, new HostingPlanGroupInfo() { CalculateBandwidth = true, CalculateDiskSpace = true, GroupId = 22 }, }; hpi.Quotas = new HostingPlanQuotaInfo[] { new HostingPlanQuotaInfo() { QuotaId = 70, QuotaValue = 1 }, new HostingPlanQuotaInfo() { QuotaId = 106, QuotaValue = 250 }, new HostingPlanQuotaInfo() { QuotaId = 107, QuotaValue = 1 }, new HostingPlanQuotaInfo() { QuotaId = 108, QuotaValue = 1 }, new HostingPlanQuotaInfo() { QuotaId = 211, QuotaValue = 2 }, new HostingPlanQuotaInfo() { QuotaId = 212, QuotaValue = 2 }, new HostingPlanQuotaInfo() { QuotaId = 213, QuotaValue = 50 }, new HostingPlanQuotaInfo() { QuotaId = 214, QuotaValue = 1 }, new HostingPlanQuotaInfo() { QuotaId = 215, QuotaValue = 1 }, new HostingPlanQuotaInfo() { QuotaId = 216, QuotaValue = 1 }, new HostingPlanQuotaInfo() { QuotaId = 217, QuotaValue = 20 }, }; string message = ""; var result = controller.AddHosting(hpi, model, out message); //var result = controller.AddHosting(hpi, url, apiUser, parola, key, out message); } //s1------------------------------------------- var controller2 = new HostingWindowsController(new HostingServiceWindowsPanel()); string serviceId = "2"; string wspipaddressid = null; string message2 = ""; if (wspipaddressid != null) { var result2 = controller2.UpdateServiceSettings(model, serviceId, wspipaddressid, out message2); //var result2 = controller2.UpdateServiceSettings(url, apiUser, parola, key, serviceId, wspipaddressid, out message2); } //s2-------------------- var controller3 = new HostingWindowsController(new HostingServiceWindowsPanel()); UserInfo user = new UserInfo(); user.UserId = 0; user.Role = UserRole.User; user.StatusId = 1; user.OwnerId = 2; user.IsDemo = false; user.IsPeer = false; user.FirstName = "hamit"; user.LastName = "yildirim"; user.Email = "*****@*****.**"; user.Username = "******"; user.Password = "******"; string message3 = ""; var result3 = controller3.AddUser(user, model, out message3); //var result3 = controller3.AddUser(user, url, apiUser, parola, key, out message3); //s3 -------------------------------- var controller4 = new HostingWindowsController(new HostingServiceWindowsPanel()); string message4 = ""; var result4 = controller4.AddPackageWithResources(model, 808, 808, "Standart Plan", targetDomainName, out message4); //var result4 = controller4.AddPackageWithResources(url, apiUser, parola, key, 986, 6, targetDomainName, out message4); }