コード例 #1
0
        private void SaveItem()
        {
            if (!Page.IsValid)
            {
                return;
            }

            // get form data
            item                   = new SharePointSite();
            item.Id                = PanelRequest.ItemID;
            item.PackageId         = PanelSecurity.PackageId;
            item.Name              = ddlWebSites.SelectedValue;
            item.LocaleID          = Utils.ParseInt(txtLocaleID.Text.Trim(), 0);
            item.OwnerLogin        = ddlSiteOwner.SelectedValue;
            item.OwnerEmail        = txtOwnerEmail.Text;
            item.DatabaseGroupName = ddlDatabaseVersion.SelectedValue;
            item.DatabaseName      = databaseName.Text;
            item.DatabaseUser      = databaseUser.Text;
            item.DatabasePassword  = databasePassword.Password;

            if (PanelRequest.ItemID == 0)
            {
                // new item
                try
                {
                    int result = ES.Services.SharePointServers.AddSharePointSite(item);
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("SHAREPOINT_ADD_SITE", ex);
                    return;
                }
            }

            // return
            RedirectSpaceHomePage();
        }
コード例 #2
0
ファイル: Schedules.ascx.cs プロジェクト: pasamsin/SolidCP
        protected void gvSchedules_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int scheduleId = Utils.ParseInt(e.CommandArgument.ToString(), 0);

            if (e.CommandName == "start")
            {
                try
                {
                    int result = ES.Services.Scheduler.StartSchedule(scheduleId);
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("SCHEDULE_START_TASK", ex);
                    return;
                }
            }
            else if (e.CommandName == "stop")
            {
                try
                {
                    int result = ES.Services.Scheduler.StopSchedule(scheduleId);
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("SCHEDULE_STOP_TASK", ex);
                    return;
                }
            }

            // rebind grid
            gvSchedules.DataBind();
        }
コード例 #3
0
        protected void cmdDeleteCluster_Click(object sender, EventArgs e)
        {
            try
            {
                int result = ES.Services.Servers.DeleteCluster(Utils.ParseInt(ddlClusters.SelectedValue, 0));
                if (result < 0)
                {
                    ShowResultMessage(result);
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("SERVER_DELETE_CLUSTER", ex);
                return;
            }

            // rebind
            BindClusters();
        }
コード例 #4
0
        private void ToggleGroupControls()
        {
            int primaryGroupId = Utils.ParseInt(ddlPrimaryGroup.SelectedValue, 0);

            for (int i = 0; i < dlServiceGroups.Items.Count; i++)
            {
                int          groupId = (int)dlServiceGroups.DataKeys[i];
                DataListItem item    = dlServiceGroups.Items[i];

                Control rowBound = item.FindControl("rowBound");
                rowBound.Visible = (groupId != primaryGroupId &&
                                    ddlPrimaryGroup.Items.Count > 2 &&
                                    ddlPrimaryGroup.SelectedIndex > 0);

                CheckBox chkBind = (CheckBox)item.FindControl("chkBind");

                Control rowDistType = item.FindControl("rowDistType");
                rowDistType.Visible = (!rowBound.Visible || !chkBind.Checked);
            }
        }
コード例 #5
0
ファイル: IPAddresses.ascx.cs プロジェクト: pasamsin/SolidCP
        protected void Page_Load(object sender, EventArgs e)
        {
            // set display preferences
            if (!IsPostBack)
            {
                // page size
                gvIPAddresses.PageSize        = UsersHelper.GetDisplayItemsPerPage();
                ddlItemsPerPage.SelectedValue = gvIPAddresses.PageSize.ToString();

                gvIPAddresses.PageIndex = PageIndex;

                // pool
                if (!String.IsNullOrEmpty(PanelRequest.PoolId))
                {
                    ddlPools.SelectedValue = PanelRequest.PoolId;
                }
            }
            else
            {
                gvIPAddresses.PageSize = Utils.ParseInt(ddlItemsPerPage.SelectedValue, 10);
            }


            if (!IsPostBack)
            {
                searchBox.AddCriteria("ExternalIP", GetLocalizedString("SearchField.ExternalIP"));
                searchBox.AddCriteria("InternalIP", GetLocalizedString("SearchField.InternalIP"));
                searchBox.AddCriteria("DefaultGateway", GetLocalizedString("SearchField.DefaultGateway"));
                searchBox.AddCriteria("ServerName", GetLocalizedString("SearchField.Server"));
                searchBox.AddCriteria("ItemName", GetLocalizedString("SearchField.ItemName"));
                searchBox.AddCriteria("Username", GetLocalizedString("SearchField.Username"));
            }
            searchBox.AjaxData = this.GetSearchBoxAjaxData();

            // toggle columns
            bool vps = ddlPools.SelectedIndex > 1;

            gvIPAddresses.Columns[3].Visible = vps;
        }
コード例 #6
0
        public void CollectFormData()
        {
            groups = new List <HostingPlanGroupInfo>();
            quotas = new List <HostingPlanQuotaInfo>();

            // gather info
            foreach (RepeaterItem item in dlGroups.Items)
            {
                Literal  litGroupId        = (Literal)item.FindControl("groupId");
                CheckBox chkEnabled        = (CheckBox)item.FindControl("chkEnabled");
                CheckBox chkCountDiskspace = (CheckBox)item.FindControl("chkCountDiskspace");
                CheckBox chkCountBandwidth = (CheckBox)item.FindControl("chkCountBandwidth");

                if (!chkEnabled.Checked)
                {
                    continue; // disabled group
                }
                HostingPlanGroupInfo group = new HostingPlanGroupInfo();
                group.GroupId            = Utils.ParseInt(litGroupId.Text, 0);
                group.Enabled            = chkEnabled.Checked;
                group.CalculateDiskSpace = chkCountDiskspace.Checked;
                group.CalculateBandwidth = chkCountBandwidth.Checked;
                groups.Add(group);

                // iterate quotas
                DataList dlQuotas = (DataList)item.FindControl("dlQuotas");
                foreach (DataListItem quotaItem in dlQuotas.Items)
                {
                    QuotaEditor quotaEditor = (QuotaEditor)quotaItem.FindControl("quotaEditor");

                    HostingPlanQuotaInfo quota = new HostingPlanQuotaInfo();
                    quota.QuotaId    = quotaEditor.QuotaId;
                    quota.QuotaValue = quotaEditor.QuotaValue;
                    quotas.Add(quota);
                }
            }
        }
コード例 #7
0
        protected void btnSetDefaultMailboxPlan_Click(object sender, EventArgs e)
        {
            // get domain
            int mailboxPlanId = Utils.ParseInt(Request.Form["DefaultMailboxPlan"], 0);

            try
            {
                var orgs = GetOrganizations();

                if ((orgs != null) && (orgs.GetLength(0) > 0))
                {
                    ES.Services.ExchangeServer.SetOrganizationDefaultExchangeMailboxPlan(orgs[0].Id, mailboxPlanId);

                    messageBox.ShowSuccessMessage("EXCHANGE_SET_DEFAULT_MAILBOXPLAN");

                    // rebind domains
                    BindMailboxPlans();
                }
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_SET_DEFAULT_MAILBOXPLAN", ex);
            }
        }
コード例 #8
0
ファイル: PhoneNumbers.ascx.cs プロジェクト: pasamsin/SolidCP
        protected void Page_Load(object sender, EventArgs e)
        {
            // set display preferences
            if (!IsPostBack)
            {
                // page size
                gvIPAddresses.PageSize        = UsersHelper.GetDisplayItemsPerPage();
                ddlItemsPerPage.SelectedValue = gvIPAddresses.PageSize.ToString();
            }
            else
            {
                gvIPAddresses.PageSize = Utils.ParseInt(ddlItemsPerPage.SelectedValue, 10);
            }


            if (!IsPostBack)
            {
                searchBox.AddCriteria("ExternalIP", GetLocalizedString("SearchField.ExternalIP"));
                searchBox.AddCriteria("ServerName", GetLocalizedString("SearchField.Server"));
                searchBox.AddCriteria("ItemName", GetLocalizedString("SearchField.ItemName"));
                searchBox.AddCriteria("Username", GetLocalizedString("SearchField.Username"));
            }
            searchBox.AjaxData = this.GetSearchBoxAjaxData();
        }
コード例 #9
0
        protected void gvSiteCollections_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteItem")
            {
                int siteCollectionId = Utils.ParseInt(e.CommandArgument.ToString(), 0);

                try
                {
                    int result = ES.Services.HostedSharePointServers.DeleteSiteCollection(siteCollectionId);
                    if (result < 0)
                    {
                        messageBox.ShowResultMessage(result);
                        return;
                    }

                    gvSiteCollections.DataBind();
                    this.BindStats();
                }
                catch (Exception ex)
                {
                    messageBox.ShowErrorMessage("HOSTEDSHAREPOINT_DELETE_SITECOLLECTION", ex);
                }
            }
        }
コード例 #10
0
ファイル: PhoneNumbers.ascx.cs プロジェクト: pasamsin/SolidCP
 protected void ddlItemsPerPage_SelectedIndexChanged(object sender, EventArgs e)
 {
     gvIPAddresses.PageSize = Utils.ParseInt(ddlItemsPerPage.SelectedValue, 10);
     gvIPAddresses.DataBind();
 }
コード例 #11
0
        protected void gvPolicy_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int mailboxPlanId = Utils.ParseInt(e.CommandArgument.ToString(), 0);

            Providers.HostedSolution.Organization[]             orgs = null;
            Providers.HostedSolution.ExchangeRetentionPolicyTag tag;

            switch (e.CommandName)
            {
            case "DeleteItem":
                try
                {
                    if (PanelSecurity.SelectedUserId != 1)
                    {
                        PackageInfo[] Packages = ES.Services.Packages.GetPackages(PanelSecurity.SelectedUserId);

                        if ((Packages != null) & (Packages.GetLength(0) > 0))
                        {
                            orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(Packages[0].PackageId, false);
                        }
                    }
                    else
                    {
                        orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(1, false);
                    }

                    tag = ES.Services.ExchangeServer.GetExchangeRetentionPolicyTag(orgs[0].Id, mailboxPlanId);

                    if (tag.ItemID != orgs[0].Id)
                    {
                        messageBox.ShowErrorMessage("EXCHANGE_UNABLE_USE_SYSTEMPLAN");
                        BindRetentionPolicy();
                        return;
                    }


                    ResultObject result = ES.Services.ExchangeServer.DeleteExchangeRetentionPolicyTag(orgs[0].Id, mailboxPlanId);
                    if (!result.IsSuccess)
                    {
                        messageBox.ShowMessage(result, "EXCHANGE_DELETE_RETENTIONPOLICY", null);
                        return;
                    }
                    else
                    {
                        messageBox.ShowSuccessMessage("EXCHANGE_DELETE_RETENTIONPOLICY");
                    }

                    ViewState["PolicyID"] = null;

                    txtPolicy.Text = string.Empty;
                    ageLimitForRetention.QuotaValue = 0;

                    btnUpdatePolicy.Enabled = (string.IsNullOrEmpty(txtPolicy.Text)) ? false : true;
                }
                catch (Exception)
                {
                    messageBox.ShowErrorMessage("EXCHANGE_DELETE_RETENTIONPOLICY");
                }

                BindRetentionPolicy();
                break;

            case "EditItem":
                ViewState["PolicyID"] = mailboxPlanId;

                if (PanelSecurity.SelectedUserId != 1)
                {
                    PackageInfo[] Packages = ES.Services.Packages.GetPackages(PanelSecurity.SelectedUserId);

                    if ((Packages != null) & (Packages.GetLength(0) > 0))
                    {
                        orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(Packages[0].PackageId, false);
                    }
                }
                else
                {
                    orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(1, false);
                }


                tag = ES.Services.ExchangeServer.GetExchangeRetentionPolicyTag(orgs[0].Id, mailboxPlanId);

                txtPolicy.Text = tag.TagName;
                Utils.SelectListItem(ddTagType, tag.TagType);
                ageLimitForRetention.QuotaValue = tag.AgeLimitForRetention;
                Utils.SelectListItem(ddRetentionAction, tag.RetentionAction);

                btnUpdatePolicy.Enabled = (string.IsNullOrEmpty(txtPolicy.Text)) ? false : true;

                break;
            }
        }
コード例 #12
0
        private void BindHostingPlan()
        {
            // plan resources
            int planId = Utils.ParseInt(ddlPlans.SelectedValue, 0);

            chkCreateResources.Visible = (planId > 0);
            bool createResources = chkCreateResources.Checked;

            ResourcesPanel.Visible = createResources & chkCreateResources.Visible;
            if (!createResources)
            {
                return;
            }

            if ((PanelSecurity.LoggedUser.Role == UserRole.ResellerCSR) |
                (PanelSecurity.LoggedUser.Role == UserRole.ResellerHelpdesk))
            {
                this.chkCreateResources.Enabled = this.chkIntegratedOUProvisioning.Enabled = false;
            }


            bool systemEnabled       = false;
            bool webEnabled          = false;
            bool ftpEnabled          = false;
            bool mailEnabled         = false;
            bool integratedOUEnabled = false;

            // load hosting context
            if (planId > 0)
            {
                HostingPlanContext cntx = PackagesHelper.GetCachedHostingPlanContext(planId);

                if (cntx != null)
                {
                    chkRedirectToCreateVPS.Checked = chkRedirectToCreateVPS.Visible = cntx.Groups.ContainsKey(ResourceGroups.VPS2012);
                    systemEnabled = cntx.Groups.ContainsKey(ResourceGroups.Os);
                    webEnabled    = cntx.Groups.ContainsKey(ResourceGroups.Web);

                    if (Utils.CheckQouta(Quotas.WEB_ENABLEHOSTNAMESUPPORT, cntx))
                    {
                        lblHostName.Visible = txtHostName.Visible = true;
                        UserSettings settings = ES.Services.Users.GetUserSettings(PanelSecurity.LoggedUserId, UserSettings.WEB_POLICY);
                        txtHostName.Text = String.IsNullOrEmpty(settings["HostName"]) ? "" : settings["HostName"];
                    }
                    else
                    {
                        lblHostName.Visible = txtHostName.Visible = false;
                        txtHostName.Text    = "";
                    }

                    ftpEnabled  = cntx.Groups.ContainsKey(ResourceGroups.Ftp);
                    mailEnabled = cntx.Groups.ContainsKey(ResourceGroups.Mail);

                    if (Utils.CheckQouta(Quotas.ORGANIZATION_DOMAINS, cntx))
                    {
                        integratedOUEnabled = true;
                    }
                }
            }

            // toggle group controls
            fsSystem.Visible = systemEnabled;

            fsWeb.Visible             = webEnabled;
            chkCreateWebSite.Checked &= webEnabled;


            fsFtp.Visible = ftpEnabled;
            chkCreateFtpAccount.Checked &= ftpEnabled;

            fsMail.Visible = mailEnabled;
            chkCreateMailAccount.Checked &= mailEnabled;

            ftpAccountName.Visible = (rbFtpAccountName.SelectedIndex == 1);

            chkIntegratedOUProvisioning.Checked = chkIntegratedOUProvisioning.Visible = (chkCreateResources.Visible && integratedOUEnabled);
        }
コード例 #13
0
        protected void gvPlan_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int planId = Utils.ParseInt(e.CommandArgument.ToString(), 0);

            Providers.HostedSolution.Organization[] orgs = null;
            Providers.HostedSolution.LyncUserPlan   plan;
            int result = 0;


            switch (e.CommandName)
            {
            case "DeleteItem":
                try
                {
                    if (PanelSecurity.SelectedUserId != 1)
                    {
                        PackageInfo[] Packages = ES.Services.Packages.GetPackages(PanelSecurity.SelectedUserId);

                        if ((Packages != null) & (Packages.GetLength(0) > 0))
                        {
                            orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(Packages[0].PackageId, false);
                        }
                    }
                    else
                    {
                        orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(1, false);
                    }

                    plan = ES.Services.Lync.GetLyncUserPlan(orgs[0].Id, planId);

                    if (plan.ItemId != orgs[0].Id)
                    {
                        messageBox.ShowErrorMessage("EXCHANGE_UNABLE_USE_SYSTEMPLAN");
                        BindPlans();
                        return;
                    }


                    result = ES.Services.Lync.DeleteLyncUserPlan(orgs[0].Id, planId);
                    if (result < 0)
                    {
                        messageBox.ShowResultMessage(result);
                        return;
                    }
                    ViewState["LyncUserPlanID"] = null;

                    txtPlan.Text = string.Empty;

                    btnUpdatePlan.Enabled = (string.IsNullOrEmpty(txtPlan.Text)) ? false : true;
                }
                catch (Exception)
                {
                    messageBox.ShowErrorMessage("LYNC_DELETE_PLAN");
                }

                BindPlans();

                break;

            case "EditItem":
                try
                {
                    ViewState["LyncUserPlanID"] = planId;

                    if (PanelSecurity.SelectedUserId != 1)
                    {
                        PackageInfo[] Packages = ES.Services.Packages.GetPackages(PanelSecurity.SelectedUserId);

                        if ((Packages != null) & (Packages.GetLength(0) > 0))
                        {
                            orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(Packages[0].PackageId, false);
                        }
                    }
                    else
                    {
                        orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(1, false);
                    }

                    plan = ES.Services.Lync.GetLyncUserPlan(orgs[0].Id, planId);

                    txtPlan.Text               = plan.LyncUserPlanName;
                    chkIM.Checked              = plan.IM;
                    chkIM.Enabled              = false;
                    chkFederation.Checked      = plan.Federation;
                    chkConferencing.Checked    = plan.Conferencing;
                    chkMobility.Checked        = plan.Mobility;
                    chkEnterpriseVoice.Checked = plan.EnterpriseVoice;

                    chkRemoteUserAccess.Checked = plan.RemoteUserAccess;

                    chkAllowOrganizeMeetingsWithExternalAnonymous.Checked = plan.AllowOrganizeMeetingsWithExternalAnonymous;
                    ddTelephony.SelectedIndex = plan.Telephony;

                    tbServerURI.Text = plan.ServerURI;

                    string planArchivePolicy = "";
                    if (plan.ArchivePolicy != null)
                    {
                        planArchivePolicy = plan.ArchivePolicy;
                    }
                    string planTelephonyDialPlanPolicy = "";
                    if (plan.TelephonyDialPlanPolicy != null)
                    {
                        planTelephonyDialPlanPolicy = plan.TelephonyDialPlanPolicy;
                    }
                    string planTelephonyVoicePolicy = "";
                    if (plan.TelephonyVoicePolicy != null)
                    {
                        planTelephonyVoicePolicy = plan.TelephonyVoicePolicy;
                    }

                    ddArchivingPolicyUpdate();
                    ListItem li = ddArchivingPolicy.Items.FindByValue(planArchivePolicy);
                    if (li == null)
                    {
                        li = new System.Web.UI.WebControls.ListItem(planArchivePolicy.Replace("Tag:", ""), planArchivePolicy);
                        ddArchivingPolicy.Items.Add(li);
                    }
                    ddArchivingPolicy.SelectedIndex = ddArchivingPolicy.Items.IndexOf(li);

                    ddTelephonyDialPlanPolicy.Items.Clear();
                    ddTelephonyDialPlanPolicy.Items.Add(new System.Web.UI.WebControls.ListItem(planTelephonyDialPlanPolicy.Replace("Tag:", ""), planTelephonyDialPlanPolicy));
                    ddTelephonyVoicePolicy.Items.Clear();
                    ddTelephonyVoicePolicy.Items.Add(new System.Web.UI.WebControls.ListItem(planTelephonyVoicePolicy.Replace("Tag:", ""), planTelephonyVoicePolicy));

                    btnUpdatePlan.Enabled = (string.IsNullOrEmpty(txtPlan.Text)) ? false : true;

                    break;
                }
                catch (Exception)
                {
                }

                BindPlans();

                break;

            case "RestampItem":
                RestampLyncUsers(planId, planId);
                break;
            }
        }
コード例 #14
0
        private void SaveUser(bool switchUser)
        {
            // get owner
            UserInfo user = ES.Services.Users.GetUserById(PanelSecurity.LoggedUserId);

            if (Page.IsValid)
            {
                // gather data from form
                // account info
                user.FirstName      = txtFirstName.Text;
                user.LastName       = txtLastName.Text;
                user.Email          = txtEmail.Text;
                user.SecondaryEmail = txtSecondaryEmail.Text;
                user.HtmlMail       = ddlMailFormat.SelectedIndex == 1;

                // contact info
                user.CompanyName      = contact.CompanyName;
                user.Address          = contact.Address;
                user.City             = contact.City;
                user.Country          = contact.Country;
                user.State            = contact.State;
                user.Zip              = contact.Zip;
                user.PrimaryPhone     = contact.PrimaryPhone;
                user.SecondaryPhone   = contact.SecondaryPhone;
                user.Fax              = contact.Fax;
                user.InstantMessenger = contact.MessengerId;

                // update existing user
                try
                {
                    //int result = UsersHelper.UpdateUser(PortalId, user);
                    int result = PortalUtils.UpdateUserAccount(user);

                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }

                    // set language
                    PortalUtils.SetCurrentLanguage(ddlLanguage.SelectedValue);

                    // set items per page
                    UsersHelper.SetDisplayItemsPerPage(Utils.ParseInt(txtItemsPerPage.Text.Trim(), 10));

                    if (ddlLanguage.SelectedValue != PortalUtils.CurrentUICulture.ToString())
                    {
                        SetCurrentLanguage();
                    }

                    if (ddlTheme.SelectedValue != PortalUtils.CurrentTheme)
                    {
                        SetCurrentTheme();
                    }

                    if (!string.IsNullOrEmpty(ddlThemeStyle.SelectedValue))
                    {
                        if (ddlThemeStyle.SelectedValue != PortalUtils.CurrentThemeStyle)
                        {
                            RemoveThemeOptions();
                        }

                        HttpCookie UserThemeStyleCrum = new HttpCookie("UserThemeStyle", ddlThemeStyle.SelectedValue);
                        UserThemeStyleCrum.Expires = DateTime.Now.AddMonths(2);
                        HttpContext.Current.Response.Cookies.Add(UserThemeStyleCrum);

                        ES.Services.Users.UpdateUserThemeSetting(PanelSecurity.LoggedUserId, "Style", ddlThemeStyle.SelectedValue);
                    }

                    //if (!string.IsNullOrEmpty(ddlThemecolorHeader.SelectedValue))
                    //{
                    //    HttpCookie UserThemecolorHeaderCrum = new HttpCookie("UserThemecolorHeader", ddlThemecolorHeader.SelectedValue);
                    //    UserThemecolorHeaderCrum.Expires = DateTime.Now.AddMonths(2);
                    //    HttpContext.Current.Response.Cookies.Add(UserThemecolorHeaderCrum);

                    //    ES.Services.Users.UpdateUserThemeSetting(PanelSecurity.LoggedUserId, "color-Header", ddlThemecolorHeader.SelectedValue);
                    //}

                    //if (!string.IsNullOrEmpty(ddlThemecolorSidebar.SelectedValue))
                    //{
                    //    HttpCookie UserThemecolorSidebarCrum = new HttpCookie("UserThemecolorSidebar", ddlThemecolorSidebar.SelectedValue);
                    //    UserThemecolorSidebarCrum.Expires = DateTime.Now.AddMonths(2);
                    //    HttpContext.Current.Response.Cookies.Add(UserThemecolorSidebarCrum);

                    //    ES.Services.Users.UpdateUserThemeSetting(PanelSecurity.LoggedUserId, "color-Sidebar", ddlThemecolorSidebar.SelectedValue);
                    //}
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("USER_UPDATE_USER", ex);
                    return;
                }

                // show message
                ShowSuccessMessage("USER_UPDATE_USER");
            }
        }
コード例 #15
0
        private void SaveRecord()
        {
            if (!string.IsNullOrEmpty(txtRecordData.Text))
            {
                if (!Page.IsValid)
                {
                    return;
                }
            }

            GlobalDnsRecord record = new GlobalDnsRecord();

            record.RecordId    = (int)ViewState["RecordID"];
            record.RecordType  = ddlRecordType.SelectedValue;
            record.RecordName  = txtRecordName.Text.Trim();
            record.RecordData  = txtRecordData.Text.Trim();
            record.MxPriority  = Utils.ParseInt(txtMXPriority.Text, 0);
            record.SrvPriority = Utils.ParseInt(txtSRVPriority.Text, 0);
            record.SrvWeight   = Utils.ParseInt(txtSRVWeight.Text, 0);
            record.SrvPort     = Utils.ParseInt(txtSRVPort.Text, 0);
            record.IpAddressId = ipAddress.AddressId;

            if (ServiceIdParam != null)
            {
                record.ServiceId = Utils.ParseInt(Request[ServiceIdParam], 0);
            }
            else if (ServerIdParam != null)
            {
                record.ServerId = Utils.ParseInt(Request[ServerIdParam], 0);
            }
            else if (PackageIdParam != null)
            {
                record.PackageId = Utils.ParseInt(Request[PackageIdParam], 0);
            }

            if (record.RecordId == 0)
            {
                // add record
                try
                {
                    int result = ES.Services.Servers.AddDnsRecord(record);
                    if (result < 0)
                    {
                        HostModule.ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    HostModule.ShowErrorMessage("GDNS_ADD_RECORD", ex);
                    return;
                }
            }
            else
            {
                // update record
                try
                {
                    int result = ES.Services.Servers.UpdateDnsRecord(record);
                    if (result < 0)
                    {
                        HostModule.ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    HostModule.ShowErrorMessage("GDNS_UPDATE_RECORD", ex);
                    return;
                }
            }

            // rebind and switch
            BindDnsRecords();
            ShowPanels(false);
        }
コード例 #16
0
        private void BindIPAddresses()
        {
            IPAddressInfo[] ips = null;

            if (serverIdParam != null || serverId != -1)
            {
                // get addresses by Server
                if (serverIdParam != null)
                {
                    serverId = Utils.ParseInt(Request[serverIdParam], 0);
                }

                ips = ES.Services.Servers.GetIPAddresses(IPAddressPool.General, serverId);
            }
            else
            {
                // get all IP addresses
                ips = ES.Services.Servers.GetIPAddresses(IPAddressPool.None, serverId);
            }

            // bind IP addresses
            ddlIPAddresses.Items.Clear();

            foreach (IPAddressInfo ip in ips)
            {
                string fullIP = ip.ExternalIP;
                if (ip.InternalIP != null &&
                    ip.InternalIP != "" &&
                    ip.InternalIP != ip.ExternalIP)
                {
                    fullIP += " (" + ip.InternalIP + ")";
                }

                string key = ip.AddressId.ToString();
                if (UseAddressValueAsKey)
                {
                    key = ip.ExternalIP + ";" + ip.InternalIP;
                }

                // add list item
                ddlIPAddresses.Items.Add(new ListItem(fullIP, key));
            }

            // add empty item if required
            if (AllowEmptySelection)
            {
                if (SelectValueText == null)
                {
                    SelectValueText = GetLocalizedString("Text.SelectAddress");
                }
                ddlIPAddresses.Items.Insert(0, new ListItem(SelectValueText, ""));
            }

            // select address by ID
            ListItem li = ddlIPAddresses.Items.FindByValue(addressId.ToString());

            if (li != null)
            {
                li.Selected = true;
            }

            // select address by Value
            li = ddlIPAddresses.Items.FindByValue(addressValue);
            if (li != null)
            {
                li.Selected = true;
            }
        }
コード例 #17
0
        private void SaveSpace()
        {
            if (!Page.IsValid)
            {
                return;
            }

            // gather form data
            PackageInfo package = new PackageInfo();

            // load package for update
            if (PanelSecurity.PackageId > 0)
            {
                package = ES.Services.Packages.GetPackage(PanelSecurity.PackageId);
            }

            package.PackageId       = PanelSecurity.PackageId;
            package.PackageName     = txtName.Text;
            package.PackageComments = txtComments.Text;
            package.PlanId          = Utils.ParseInt(ddlPlan.SelectedValue, 0);
            package.PurchaseDate    = PurchaseDate.SelectedDate;

            package.OverrideQuotas = rbPackageQuotas.Checked;
            if (package.OverrideQuotas)
            {
                package.Groups = editPackageQuotas.Groups;
                package.Quotas = editPackageQuotas.Quotas;
            }

            try
            {
                // update existing package
                PackageResult result = ES.Services.Packages.UpdatePackage(package);
                if (result.Result < 0)
                {
                    ShowResultMessage(result.Result);
                    lblMessage.Text = PortalAntiXSS.Encode(GetExceedingQuotasMessage(result.ExceedingQuotas));
                    return;
                }

                bool notUserRoleAndNotSelectedTheSameUser = (PanelSecurity.SelectedUserId != Convert.ToInt32(ddlUser.SelectedValue) &&
                                                             PanelSecurity.LoggedUser.Role != UserRole.User);

                if (chkMoveUser.Checked && notUserRoleAndNotSelectedTheSameUser)
                {
                    int changeResult = ES.Services.Packages.ChangePackageUser(PanelSecurity.PackageId, Convert.ToInt32(ddlUser.SelectedValue));
                    if (changeResult < 0)
                    {
                        ShowResultMessage(result.Result);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("PACKAGE_UPDATE_PACKAGE", ex);
                return;
            }

            // return
            RedirectSpaceHomePage();
        }
コード例 #18
0
        private void ToggleControls()
        {
            valCorrectLength.Attributes["dpsw"]    = EMPTY_PASSWORD;
            valRequireNumbers.Attributes["dpsw"]   = EMPTY_PASSWORD;
            valRequireUppercase.Attributes["dpsw"] = EMPTY_PASSWORD;
            valRequireSymbols.Attributes["dpsw"]   = EMPTY_PASSWORD;

            // set empty password
            if (txtPassword.Text == "" && EditMode)
            {
                txtPassword.Attributes["value"]        = EMPTY_PASSWORD;
                txtConfirmPassword.Attributes["value"] = EMPTY_PASSWORD;
            }

            // enable/disable require validators
            valRequirePassword.Enabled        = ValidationEnabled;
            valRequireConfirmPassword.Enabled = ValidationEnabled;

            // require default length
            MinimumLength = Math.Max(MIN_PASSWORD_LENGTH, MinimumLength);

            // parse and enforce policy
            if (PolicyValue != null)
            {
                bool enabled            = false;
                int  minLength          = -1;
                int  maxLength          = -1;
                bool notEqualToUsername = false;

                try
                {
                    // parse settings
                    string[] parts = PolicyValue.Split(';');
                    enabled            = Utils.ParseBool(parts[0], false);
                    minLength          = Math.Max(Utils.ParseInt(parts[1], 0), MinimumLength);
                    maxLength          = Math.Max(Utils.ParseInt(parts[2], 0), MaximumLength);
                    MinimumUppercase   = Math.Max(Utils.ParseInt(parts[3], 0), MinimumUppercase);
                    MinimumNumbers     = Math.Max(Utils.ParseInt(parts[4], 0), MinimumNumbers);
                    MinimumSymbols     = Math.Max(Utils.ParseInt(parts[5], 0), MinimumSymbols);
                    notEqualToUsername = Utils.ParseBool(parts[6], false);
                }
                catch { /* skip */ }

                // apply policy
                if (enabled)
                {
                    // min length
                    if (minLength > 0)
                    {
                        MinimumLength            = minLength;
                        valCorrectLength.Enabled = true;
                        valCorrectLength.Attributes["minimumLength"] = MinimumLength.ToString();
                        valCorrectLength.ErrorMessage = String.Format(GetLocalizedString("CorrectLength.Text"), MinimumLength);
                    }

                    // max length
                    if (maxLength > 0)
                    {
                        MaximumLength                = maxLength;
                        txtPassword.MaxLength        = maxLength;
                        txtConfirmPassword.MaxLength = maxLength;
                    }

                    // numbers
                    if (MinimumNumbers > 0)
                    {
                        valRequireNumbers.Enabled = true;
                        valRequireNumbers.Attributes["minimumNumber"] = MinimumNumbers.ToString();
                        valRequireNumbers.ErrorMessage = String.Format(
                            GetLocalizedString("RequireNumbers.Text"), MinimumNumbers);
                    }

                    // UPPERCASE
                    if (MinimumUppercase > 0)
                    {
                        valRequireUppercase.Enabled = true;
                        valRequireUppercase.Attributes["minimumNumber"] = MinimumUppercase.ToString();
                        valRequireUppercase.ErrorMessage = String.Format(
                            GetLocalizedString("RequireUppercase.Text"), MinimumUppercase);
                    }

                    // symbols
                    if (MinimumSymbols > 0)
                    {
                        valRequireSymbols.Enabled = true;
                        valRequireSymbols.Attributes["minimumNumber"] = MinimumSymbols.ToString();
                        valRequireSymbols.ErrorMessage = String.Format(
                            GetLocalizedString("RequireSymbols.Text"), MinimumSymbols);
                    }
                } // if(enabled)
            }     // if (PolicyValue != null)

            // set min password generator
            lnkGenerate.NavigateUrl = String.Format("javascript:GeneratePassword('{0}', '{1}', '{2}', '{3}', '{4}', '{5}');",
                                                    MaximumLength, MinimumUppercase, MinimumNumbers, MinimumSymbols, txtPassword.ClientID, txtConfirmPassword.ClientID);
        }
コード例 #19
0
        private void UpdateServer()
        {
            if (!Page.IsValid)
            {
                return;
            }

            ServerInfo server = new ServerInfo();

            // header
            server.ServerId       = PanelRequest.ServerId;
            server.ServerName     = txtName.Text;
            server.Comments       = txtComments.Text;
            server.PrimaryGroupId = Utils.ParseInt(ddlPrimaryGroup.SelectedValue, 0);

            // Preview Domain
            server.InstantDomainAlias = txtPreviewDomain.Text;

            // gather groups info
            List <VirtualGroupInfo> groups = new List <VirtualGroupInfo>();

            for (int i = 0; i < dlServiceGroups.Items.Count; i++)
            {
                int          groupId = (int)dlServiceGroups.DataKeys[i];
                DataListItem item    = dlServiceGroups.Items[i];

                CheckBox     chkBind     = (CheckBox)item.FindControl("chkBind");
                DropDownList ddlDistType = (DropDownList)item.FindControl("ddlDistType");
                Control      rowBound    = item.FindControl("rowBound");

                VirtualGroupInfo group = new VirtualGroupInfo();
                group.GroupId                   = groupId;
                group.DistributionType          = Utils.ParseInt(ddlDistType.SelectedValue, 0);
                group.BindDistributionToPrimary = chkBind.Checked && rowBound.Visible;
                groups.Add(group);
            }

            try
            {
                // update server
                int result = ES.Services.Servers.UpdateServer(server);
                if (result < 0)
                {
                    ShowResultMessage(result);
                    return;
                }

                // update groups
                result = ES.Services.Servers.UpdateVirtualGroups(PanelRequest.ServerId, groups.ToArray());
                if (result < 0)
                {
                    ShowResultMessage(result);
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("VSERVER_UPDATE_SERVER", ex);
                return;
            }

            // return to browse page
            RedirectToBrowsePage();
        }
コード例 #20
0
        private void ToggleControls()
        {
            // hide/show controls
            litPrefix.Visible           = ((!EditMode) && !String.IsNullOrEmpty(litPrefix.Text));
            txtName.Visible             = !EditMode;
            lblName.Visible             = EditMode;
            litSuffix.Visible           = ((!EditMode) && !String.IsNullOrEmpty(litSuffix.Text));
            valRequireUsername.Enabled  = RequiredField && !EditMode;
            valCorrectUsername.Enabled  = !EditMode;
            valCorrectMinLength.Enabled = !EditMode;

            if (EditMode)
            {
                return;
            }

            // require validator
            valRequireUsername.ErrorMessage = GetLocalizedString("CantBeBlank.Text");

            // disable min length validator
            valCorrectMinLength.Enabled = false;

            // username validator
            string defAllowedRegexp = PanelGlobals.UsernameDefaultAllowedRegExp;
            string defAllowedText   = "a-z&nbsp;&nbsp;A-Z&nbsp;&nbsp;0-9&nbsp;&nbsp;.&nbsp;&nbsp;_";

            // parse and enforce policy
            if (PolicyValue != null)
            {
                bool   enabled        = false;
                string allowedSymbols = null;
                int    minLength      = -1;
                int    maxLength      = -1;
                string prefix         = null;
                string suffix         = null;

                try
                {
                    // parse settings
                    string[] parts = PolicyValue.Split(';');
                    enabled        = Utils.ParseBool(parts[0], false);
                    allowedSymbols = parts[1];
                    minLength      = Utils.ParseInt(parts[2], -1);
                    maxLength      = Utils.ParseInt(parts[3], -1);
                    prefix         = parts[4];
                    suffix         = parts[5];
                }
                catch { /* skip */ }

                // apply policy
                if (enabled)
                {
                    // prefix
                    if (!String.IsNullOrEmpty(prefix))
                    {
                        // substitute vars
                        prefix = Utils.ReplaceStringVariable(prefix, "user_id", PolicyUser.UserId.ToString());
                        prefix = Utils.ReplaceStringVariable(prefix, "user_name", PolicyUser.Username);

                        // display
                        litPrefix.Text = prefix;

                        // adjust max length
                        maxLength -= prefix.Length;
                    }

                    // suffix
                    if (!String.IsNullOrEmpty(suffix))
                    {
                        // substitute vars
                        suffix = Utils.ReplaceStringVariable(suffix, "user_id", PolicyUser.UserId.ToString());
                        suffix = Utils.ReplaceStringVariable(suffix, "user_name", PolicyUser.Username);

                        // display
                        litSuffix.Text = suffix;

                        // adjust max length
                        maxLength -= suffix.Length;
                    }

                    // min length
                    if (minLength > 0)
                    {
                        valCorrectMinLength.Enabled = true;
                        valCorrectMinLength.ValidationExpression = "^.{" + minLength.ToString() + ",}$";
                        valCorrectMinLength.ErrorMessage         = String.Format(
                            GetLocalizedString("MinLength.Text"), minLength);
                    }

                    // max length
                    if (maxLength > 0)
                    {
                        txtName.MaxLength = maxLength;
                    }

                    // process allowed symbols
                    if (!String.IsNullOrEmpty(allowedSymbols))
                    {
                        StringBuilder sb = new StringBuilder(defAllowedRegexp);
                        for (int i = 0; i < allowedSymbols.Length; i++)
                        {
                            // Escape characters only if required
                            if (PanelGlobals.MetaCharacters2Escape.IndexOf(allowedSymbols[i]) > -1)
                            {
                                sb.Append(@"\").Append(allowedSymbols[i]);
                            }
                            else
                            {
                                sb.Append(allowedSymbols[i]);
                            }
                            //
                            defAllowedText += "&nbsp;&nbsp;" + allowedSymbols[i];
                        }
                        defAllowedRegexp = sb.ToString();
                    }
                } // if(enabled)
            }     // if (PolicyValue != null)

            valCorrectUsername.ValidationExpression = @"^[" + defAllowedRegexp + @"]*$";
            valCorrectUsername.ErrorMessage         = String.Format(GetLocalizedString("AllowedSymbols.Text"),
                                                                    defAllowedText);
        } // ToggleControls()
コード例 #21
0
        protected void gvMailboxPlan_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int mailboxPlanId = Utils.ParseInt(e.CommandArgument.ToString(), 0);

            Providers.HostedSolution.Organization[]      orgs = null;
            Providers.HostedSolution.ExchangeMailboxPlan plan;

            switch (e.CommandName)
            {
            case "DeleteItem":
                try
                {
                    orgs = GetOrganizations();

                    plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(orgs[0].Id, mailboxPlanId);

                    if (plan.ItemId != orgs[0].Id)
                    {
                        messageBox.ShowErrorMessage("EXCHANGE_UNABLE_USE_SYSTEMPLAN");
                        BindMailboxPlans();
                        return;
                    }


                    int result = ES.Services.ExchangeServer.DeleteExchangeMailboxPlan(orgs[0].Id, mailboxPlanId);
                    if (result < 0)
                    {
                        messageBox.ShowResultMessage(result);
                        return;
                    }
                    ViewState["MailboxPlanID"] = null;

                    txtMailboxPlan.Text                = string.Empty;
                    mailboxSize.QuotaValue             = 0;
                    maxRecipients.QuotaValue           = 0;
                    maxSendMessageSizeKB.QuotaValue    = 0;
                    maxReceiveMessageSizeKB.QuotaValue = 0;
                    chkPOP3.Checked                  = false;
                    chkIMAP.Checked                  = false;
                    chkOWA.Checked                   = false;
                    chkMAPI.Checked                  = false;
                    chkActiveSync.Checked            = false;
                    chkAutoReplyEnabled.Checked      = false;
                    sizeIssueWarning.ValueKB         = -1;
                    sizeProhibitSend.ValueKB         = -1;
                    sizeProhibitSendReceive.ValueKB  = -1;
                    daysKeepDeletedItems.ValueDays   = -1;
                    chkHideFromAddressBook.Checked   = false;
                    chkEnableLitigationHold.Checked  = false;
                    recoverableItemsSpace.QuotaValue = 0;
                    recoverableItemsWarning.ValueKB  = -1;
                    txtLitigationHoldMsg.Text        = string.Empty;
                    txtLitigationHoldUrl.Text        = string.Empty;

                    chkEnableArchiving.Checked  = false;
                    archiveQuota.QuotaValue     = 0;
                    archiveWarningQuota.ValueKB = 0;
                    ViewState["Tags"]           = null;
                    gvPolicy.DataSource         = null;
                    gvPolicy.DataBind();
                    UpdateTags();


                    btnUpdateMailboxPlan.Enabled = (string.IsNullOrEmpty(txtMailboxPlan.Text)) ? false : true;
                }
                catch (Exception)
                {
                    messageBox.ShowErrorMessage("EXCHANGE_DELETE_MAILBOXPLAN");
                }

                BindMailboxPlans();
                break;

            case "EditItem":
                ViewState["MailboxPlanID"] = mailboxPlanId;

                orgs = GetOrganizations();

                plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(orgs[0].Id, mailboxPlanId);
                txtMailboxPlan.Text = plan.MailboxPlan;

                if (RetentionPolicy)
                {
                    List <ExchangeMailboxPlanRetentionPolicyTag> tags = new List <ExchangeMailboxPlanRetentionPolicyTag>();
                    tags.AddRange(ES.Services.ExchangeServer.GetExchangeMailboxPlanRetentionPolicyTags(plan.MailboxPlanId));

                    ViewState["Tags"]   = tags;
                    gvPolicy.DataSource = tags;
                    gvPolicy.DataBind();
                    UpdateTags();
                }
                else
                {
                    mailboxSize.QuotaValue             = plan.MailboxSizeMB;
                    maxRecipients.QuotaValue           = plan.MaxRecipients;
                    maxSendMessageSizeKB.QuotaValue    = plan.MaxSendMessageSizeKB;
                    maxReceiveMessageSizeKB.QuotaValue = plan.MaxReceiveMessageSizeKB;
                    chkPOP3.Checked                 = plan.EnablePOP;
                    chkIMAP.Checked                 = plan.EnableIMAP;
                    chkOWA.Checked                  = plan.EnableOWA;
                    chkMAPI.Checked                 = plan.EnableMAPI;
                    chkActiveSync.Checked           = plan.EnableActiveSync;
                    chkAutoReplyEnabled.Checked     = plan.EnableAutoReply;
                    sizeIssueWarning.ValueKB        = plan.IssueWarningPct;
                    sizeProhibitSend.ValueKB        = plan.ProhibitSendPct;
                    sizeProhibitSendReceive.ValueKB = plan.ProhibitSendReceivePct;
                    if (plan.KeepDeletedItemsDays != -1)
                    {
                        daysKeepDeletedItems.ValueDays = plan.KeepDeletedItemsDays;
                    }
                    chkHideFromAddressBook.Checked   = plan.HideFromAddressBook;
                    chkEnableLitigationHold.Checked  = plan.AllowLitigationHold;
                    recoverableItemsSpace.QuotaValue = plan.RecoverableItemsSpace;
                    recoverableItemsWarning.ValueKB  = plan.RecoverableItemsWarningPct;
                    txtLitigationHoldMsg.Text        = plan.LitigationHoldMsg;
                    txtLitigationHoldUrl.Text        = plan.LitigationHoldUrl;

                    chkEnableArchiving.Checked = plan.EnableArchiving;

                    archiveQuota.QuotaValue     = plan.ArchiveSizeMB;
                    archiveWarningQuota.ValueKB = plan.ArchiveWarningPct;
                }


                btnUpdateMailboxPlan.Enabled = (string.IsNullOrEmpty(txtMailboxPlan.Text)) ? false : true;

                break;

            case "RestampItem":
                RestampMailboxes(mailboxPlanId, mailboxPlanId);
                break;

            case "StampUnassigned":
                RestampMailboxes(-1, mailboxPlanId);
                break;
            }
        }
コード例 #22
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                bool vps     = ddlPools.SelectedIndex > 1;
                int  vlantag = 0;
                try
                {
                    vlantag = Convert.ToInt32(VLAN.Text);
                }
                catch
                {
                    vlantag = 0;
                }
                if (vps)
                {
                    if (vlantag > 4096 || vlantag < 0)
                    {
                        ShowErrorMessage("Error updating IP address - Invalid VLAN TAG", "VLANTAG");
                        return;
                    }
                }
                int           serverId = Utils.ParseInt(ddlServer.SelectedValue, 0);
                IPAddressPool pool     = (IPAddressPool)Enum.Parse(typeof(IPAddressPool), ddlPools.SelectedValue, true);
                string        comments = txtComments.Text.Trim();

                // add ip address
                if (endIP.Text != "" || startIP.Text.Contains("/"))
                {
                    try
                    {
                        // add IP range
                        ResultObject res = ES.Services.Servers.AddIPAddressesRange(pool, serverId, startIP.Text, endIP.Text,
                                                                                   internalIP.Text, subnetMask.Text, defaultGateway.Text, comments, vlantag);
                        if (!res.IsSuccess)
                        {
                            // show error
                            messageBox.ShowMessage(res, "IP_ADD_IP_RANGE", "IP");
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        ShowErrorMessage("IP_ADD_IP_RANGE", ex);
                        return;
                    }
                }
                else
                {
                    // add single IP
                    try
                    {
                        IntResult res = ES.Services.Servers.AddIPAddress(pool, serverId, startIP.Text,
                                                                         internalIP.Text, subnetMask.Text, defaultGateway.Text, comments, vlantag);
                        if (!res.IsSuccess)
                        {
                            messageBox.ShowMessage(res, "IP_ADD_IP", "IP");
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        ShowErrorMessage("IP_ADD_IP", ex);
                        return;
                    }
                }

                // Redirect back to the portal home page
                RedirectBack();
            }
        }
コード例 #23
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            // validate input
            if (!Page.IsValid)
            {
                return;
            }

            service             = new ServiceInfo();
            service.ServiceId   = PanelRequest.ServiceId;
            service.ServiceName = txtServiceName.Text.Trim();
            if (ddlProviders.Items.Count > 0)
            {
                service.ProviderId = Utils.ParseInt(ddlProviders.SelectedValue, 0);
            }
            else
            {
                service.ProviderId = 0; //just to be sure that here is 0
            }
            service.ServiceQuotaValue = Utils.ParseInt(txtQuotaValue.Text, 0);
            service.ClusterId         = Utils.ParseInt(ddlClusters.SelectedValue, 0);
            service.Comments          = txtComments.Text;

            // update service
            try
            {
                int result = ES.Services.Servers.UpdateService(service);
                if (result < 0)
                {
                    ShowResultMessage(result);
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("SERVER_UPDATE_SERVICE", ex);
                return;
            }

            // save properties
            SaveServiceProperties();

            // install service
            string[] installResults = null;
            try
            {
                installResults = ES.Services.Servers.InstallService(PanelRequest.ServiceId);
            }
            catch (Exception ex)
            {
                ShowErrorMessage("SERVER_INSTALL_SERVICE", ex);
                return;
            }

            // check results
            if (installResults != null && installResults.Length > 0)
            {
                rowInstallResults.Visible = true;
                blInstallResults.Items.Clear();
                foreach (string installResult in installResults)
                {
                    blInstallResults.Items.Add(installResult);
                }

                return;
            }
            // save quotas
            //SaveServiceQuotas();

            // return
            RedirectBack();
        }
コード例 #24
0
        private void SaveTask()
        {
            // gather form parameters
            ScheduleInfo sc = new ScheduleInfo();

            sc.ScheduleId   = PanelRequest.ScheduleID;
            sc.ScheduleName = txtTaskName.Text.Trim();
            sc.TaskId       = ddlTaskType.SelectedValue;

            sc.PackageId = PanelSecurity.PackageId;

            sc.ScheduleTypeId = ddlSchedule.SelectedValue;
            sc.FromTime       = timeFromTime.SelectedValue;
            sc.ToTime         = timeToTime.SelectedValue;

            sc.StartTime = timeStartTime.SelectedValue;
            sc.Interval  = intInterval.Interval;

            // check maximum interval
            // load context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PackageId);

            if (cntx.Quotas.ContainsKey(Quotas.OS_MINIMUMTASKINTERVAL))
            {
                int minInterval = cntx.Quotas[Quotas.OS_MINIMUMTASKINTERVAL].QuotaAllocatedValue;
                if (minInterval != -1 && sc.Interval < (minInterval * 60))
                {
                    sc.Interval = (minInterval * 60);
                }
            }

            // run once
            if (ddlSchedule.SelectedIndex == 3)
            {
                DateTime tm        = timeStartTime.SelectedValue;
                DateTime dt        = DateTime.Parse(txtStartDate.Text);
                DateTime startTime = new DateTime(dt.Year, dt.Month, dt.Day, tm.Hour, tm.Minute, tm.Second);
                sc.StartTime = startTime;
            }

            sc.WeekMonthDay = Utils.ParseInt(txtWeekDay.Text, 0);
            if (ddlSchedule.SelectedIndex == 2)
            {
                sc.WeekMonthDay = Utils.ParseInt(txtMonthDay.Text, 0);
            }


            sc.Enabled          = chkEnabled.Checked;
            sc.PriorityId       = ddlPriority.SelectedValue;
            sc.HistoriesNumber  = 0;
            sc.MaxExecutionTime = intMaxExecutionTime.Interval;

            // gather parameters
            List <ScheduleTaskParameterInfo> parameters = new List <ScheduleTaskParameterInfo>();

            foreach (GridViewRow row in gvTaskParameters.Rows)
            {
                ParameterEditor txtValue = (ParameterEditor)row.FindControl("txtValue");
                if (txtValue == null)
                {
                    continue;
                }

                string prmId = (string)gvTaskParameters.DataKeys[row.RowIndex][0];

                ScheduleTaskParameterInfo parameter = new ScheduleTaskParameterInfo();
                parameter.ParameterId    = prmId;
                parameter.ParameterValue = txtValue.Value;
                parameters.Add(parameter);
            }

            sc.Parameters = parameters.ToArray();

            // Gather parameters from view.
            if (this.configurationView != null)
            {
                sc.Parameters = this.configurationView.GetParameters();
            }

            // save
            if (PanelRequest.ScheduleID == 0)
            {
                // add new schedule
                try
                {
                    int result = ES.Services.Scheduler.AddSchedule(sc);
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("SCHEDULE_ADD_TASK", ex);
                    return;
                }
            }
            else
            {
                // update existing
                try
                {
                    int result = ES.Services.Scheduler.UpdateSchedule(sc);
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("SCHEDULE_UPDATE_TASK", ex);
                    return;
                }
            }

            // redirect
            RedirectSpaceHomePage();
        }
コード例 #25
0
ファイル: ResizeImage.ashx.cs プロジェクト: pasamsin/SolidCP
        public void ProcessRequest(HttpContext context)
        {
            context.Response.Clear();
            context.Response.ContentType = "image/png";

            string imageUrl = context.Request.QueryString[URL];

            if (!string.IsNullOrEmpty(imageUrl))
            {
                // Create decoded version of the image url
                imageUrl = context.Server.UrlDecode(imageUrl);
                //
                Image img = null;

                try
                {
                    WebRequest  request  = WebRequest.Create(imageUrl);
                    WebResponse response = request.GetResponse();
                    // Load image stream from the response
                    img = new Bitmap(response.GetResponseStream());
                }
                catch (Exception ex)
                {
                    Trace.TraceError(ex.StackTrace);
                }

                int width  = Utils.ParseInt(context.Request.QueryString[WIDTH], 20);
                int height = Utils.ParseInt(context.Request.QueryString[HEIGHT], 20);

                // calculate new size
                int    h   = (img != null) ? img.Height : height;
                int    w   = (img != null) ? img.Width : width;
                int    b   = Math.Max(h, w);
                double per = b > Math.Max(width, height) ? (Math.Max(width, height) * 1.0) / b : 1.0;

                h = (int)(h * per);
                w = (int)(w * per);

                Bitmap   bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
                Graphics new_g  = Graphics.FromImage(bitmap);
                new_g.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                new_g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                // draw white background
                SolidBrush brush = new SolidBrush(Color.White);
                new_g.FillRectangle(brush, new Rectangle(0, 0, width, height));
                brush.Dispose();

                if (img != null)
                {
                    // draw image
                    new_g.DrawImage(img, 0, 0, w, h);
                    img.Dispose();
                }

                // emit it to the response stream
                bitmap.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);

                // clean-up
                bitmap.Dispose();
                new_g.Dispose();

                // set cache info if image was loaded
                if (img != null)
                {
                    context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(BitmapCacheDurationInSeconds));
                    context.Response.Cache.SetCacheability(HttpCacheability.Public);
                    context.Response.Cache.SetValidUntilExpires(true);
                }

                // end response
                context.Response.End();
            }
        }
コード例 #26
0
        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();
        }
コード例 #27
0
        private void SaveItem()
        {
            if (!Page.IsValid)
            {
                return;
            }

            // get form data
            MailAccount item = new MailAccount();

            item.Id             = PanelRequest.ItemID;
            item.PackageId      = PanelSecurity.PackageId;
            item.Name           = mailEditAddress.Email;
            item.Password       = passwordControl.Password;
            item.MaxMailboxSize = Utils.ParseInt(txtMailBoxSizeLimit.Text);

            // Only check for conflicting names if creating new item
            if (PanelRequest.ItemID == 0)
            {
                //checking if account name is different from existing e-mail lists
                MailList[] lists = ES.Services.MailServers.GetMailLists(PanelSecurity.PackageId, true);
                foreach (MailList list in lists)
                {
                    if (item.Name == list.Name)
                    {
                        ShowWarningMessage("MAIL_ACCOUNT_NAME");
                        return;
                    }
                }

                //checking if account name is different from existing e-mail groups
                MailGroup[] mailgroups = ES.Services.MailServers.GetMailGroups(PanelSecurity.PackageId, true);
                foreach (MailGroup group in mailgroups)
                {
                    if (item.Name == group.Name)
                    {
                        ShowWarningMessage("MAIL_ACCOUNT_NAME");
                        return;
                    }
                }

                //checking if account name is different from existing forwardings
                MailAlias[] forwardings = ES.Services.MailServers.GetMailForwardings(PanelSecurity.PackageId, true);
                foreach (MailAlias forwarding in forwardings)
                {
                    if (item.Name == forwarding.Name)
                    {
                        ShowWarningMessage("MAIL_ACCOUNT_NAME");
                        return;
                    }
                }
            }

            // get other props
            IMailEditAccountControl ctrl = (IMailEditAccountControl)providerControl.Controls[0];

            ctrl.SaveItem(item);

            if (PanelRequest.ItemID == 0)
            {
                // new item
                try
                {
                    int result = ES.Services.MailServers.AddMailAccount(item);
                    if (result == BusinessErrorCodes.ERROR_MAIL_ACCOUNT_PASSWORD_NOT_COMPLEXITY)
                    {
                        ShowErrorMessage("MAIL_ACCOUNT_PASSWORD_NOT_COMPLEXITY");
                        return;
                    }
                    if (result == BusinessErrorCodes.ERROR_MAIL_LICENSE_DOMAIN_QUOTA)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                    if (result == BusinessErrorCodes.ERROR_MAIL_LICENSE_USERS_QUOTA)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("MAIL_ADD_ACCOUNT", ex);
                    return;
                }
                //Add Mail Cleaner
                Knom.Helpers.Net.APIMailCleanerHelper.DomainAdd(mailEditAddress.Domain);
            }
            else
            {
                // existing item
                try
                {
                    int result = ES.Services.MailServers.UpdateMailAccount(item);
                    if (result == BusinessErrorCodes.ERROR_MAIL_ACCOUNT_PASSWORD_NOT_COMPLEXITY)
                    {
                        ShowErrorMessage("MAIL_ACCOUNT_PASSWORD_NOT_COMPLEXITY");
                        return;
                    }
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("MAIL_UPDATE_ACCOUNT", ex);
                    return;
                }
            }

            // return
            RedirectSpaceHomePage();
        }
コード例 #28
0
        protected void tree_TreeNodePopulate(object sender, TreeNodeEventArgs e)
        {
            if (e.Node.Value.StartsWith("-"))
            {
                int      itemTypeId = Utils.ParseInt(e.Node.Value.Substring(1), 0);
                string[] items      = ES.Services.Import.GetImportableItems(PanelSecurity.PackageId, itemTypeId);

                foreach (string item in items)
                {
                    TreeNode node = new TreeNode();
                    node.Text         = item;
                    node.Value        = itemTypeId.ToString() + "|" + item;
                    node.ShowCheckBox = true;
                    node.SelectAction = TreeNodeSelectAction.None;
                    e.Node.ChildNodes.Add(node);
                }
            }

            if (e.Node.Value.StartsWith("+"))
            {
                int      itemTypeId = Utils.ParseInt(e.Node.Value.Substring(1), 0);
                string[] items      = ES.Services.Import.GetImportableItems(PanelSecurity.PackageId, itemTypeId * -1);

                switch (itemTypeId)
                {
                case 100:

                    TreeNode headerNode = new TreeNode();
                    headerNode.Text         = GetSharedLocalizedString("ServiceItemType.HostHeader");
                    headerNode.Value        = "+" + itemTypeId.ToString();
                    headerNode.ShowCheckBox = true;
                    headerNode.SelectAction = TreeNodeSelectAction.None;
                    e.Node.ChildNodes.Add(headerNode);

                    foreach (string item in items)
                    {
                        string[] objectData = item.Split('|');

                        TreeNode userNode = null;
                        foreach (TreeNode n in headerNode.ChildNodes)
                        {
                            if (n.Value == "+" + itemTypeId.ToString() + "|" + objectData[1])
                            {
                                userNode = n;
                                break;
                            }
                        }

                        if (userNode == null)
                        {
                            userNode              = new TreeNode();
                            userNode.Text         = objectData[0];
                            userNode.Value        = "+" + itemTypeId.ToString() + "|" + objectData[1];
                            userNode.ShowCheckBox = true;
                            userNode.SelectAction = TreeNodeSelectAction.None;
                            headerNode.ChildNodes.Add(userNode);
                        }

                        TreeNode siteNode = new TreeNode();
                        siteNode.Text         = objectData[3];
                        siteNode.Value        = "+" + itemTypeId.ToString() + "|" + item;
                        siteNode.ShowCheckBox = true;
                        userNode.SelectAction = TreeNodeSelectAction.None;
                        userNode.ChildNodes.Add(siteNode);
                    }

                    headerNode.Expand();
                    break;
                }
            }
        }
コード例 #29
0
        private void AddDomain()
        {
            if (!Page.IsValid)
            {
                return;
            }

            // get domain type
            DomainType type = GetDomainType(Request["DomainType"]);

            // get domain name
            var domainName = DomainName.Text;

            int pointWebSiteId    = 0;
            int pointMailDomainId = 0;

            // load package context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            if (type == DomainType.DomainPointer || (type == DomainType.Domain))
            {
                if (PointWebSite.Checked && WebSitesList.Items.Count > 0)
                {
                    pointWebSiteId = Utils.ParseInt(WebSitesList.SelectedValue, 0);
                }
            }

            if (type == DomainType.DomainPointer || (type == DomainType.Domain))
            {
                if (PointMailDomain.Checked && MailDomainsList.Items.Count > 0)
                {
                    pointMailDomainId = Utils.ParseInt(MailDomainsList.SelectedValue, 0);
                }
            }


            // add domain
            int domainId = 0;

            try
            {
                domainId = ES.Services.Servers.AddDomainWithProvisioning(PanelSecurity.PackageId,
                                                                         domainName.ToLower(), type, CreateWebSite.Checked, pointWebSiteId, pointMailDomainId,
                                                                         EnableDns.Checked, CreatePreviewDomain.Checked, AllowSubDomains.Checked, (PointWebSite.Checked && WebSitesList.Items.Count > 0) ? string.Empty : txtHostName.Text.ToLower());

                if (domainId < 0)
                {
                    ShowResultMessage(domainId);
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("DOMAIN_ADD_DOMAIN", ex);
                return;
            }

            // put created domain to the cookie
            HttpCookie domainCookie = new HttpCookie("CreatedDomainId", domainId.ToString());

            Response.Cookies.Add(domainCookie);

            // return
            RedirectBack();
        }
コード例 #30
0
        private void CreateHostingSpace()
        {
            if (!Page.IsValid)
            {
                return;
            }

            string spaceName = ddlPlans.SelectedItem.Text;

            string ftpAccount = (rbFtpAccountName.SelectedIndex == 0) ? null : ftpAccountName.Text;

            string domainName = txtDomainName.Text.Trim();

            PackageResult result = null;

            try
            {
                result = ES.Services.Packages.AddPackageWithResources(PanelSecurity.SelectedUserId,
                                                                      Utils.ParseInt(ddlPlans.SelectedValue, 0),
                                                                      spaceName,
                                                                      Utils.ParseInt(ddlStatus.SelectedValue, 0),
                                                                      chkPackageLetter.Checked,
                                                                      chkCreateResources.Checked, domainName, false, chkCreateWebSite.Checked,
                                                                      chkCreateFtpAccount.Checked, ftpAccount, chkCreateMailAccount.Checked, txtHostName.Text);

                if (result.Result < 0)
                {
                    ShowResultMessage(result.Result);
                    lblMessage.Text = PortalAntiXSS.Encode(GetExceedingQuotasMessage(result.ExceedingQuotas));
                    return;
                }
                else
                {
                    if ((chkIntegratedOUProvisioning.Checked) & !string.IsNullOrEmpty(domainName))
                    {
                        UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId);

                        if (user != null)
                        {
                            if (user.Role != UserRole.Reseller)
                            {
                                UserSettings settings = ES.Services.Users.GetUserSettings(user.UserId, UserSettings.EXCHANGE_POLICY);
                                string       orgId    = domainName.ToLower();

                                if (settings != null && settings["OrgIdPolicy"] != null)
                                {
                                    orgId = GetOrgId(settings["OrgIdPolicy"], domainName, result.Result);
                                }

                                ES.Services.Organizations.CreateOrganization(result.Result, orgId, domainName.ToLower(), domainName.ToLower());

                                if (result.Result < 0)
                                {
                                    ShowErrorMessage("USERWIZARD_CREATE_ACCOUNT");
                                    return;
                                }

                                //Add Mail Cleaner
                                Knom.Helpers.Net.APIMailCleanerHelper.DomainAdd(domainName, Utils.ParseInt(ddlPlans.SelectedValue, 0));
                            }
                        }
                    }
                    if ((chkCreateMailAccount.Checked) & !string.IsNullOrEmpty(domainName))
                    {
                        //Add Mail Cleaner
                        Knom.Helpers.Net.APIMailCleanerHelper.DomainAdd(domainName, Utils.ParseInt(ddlPlans.SelectedValue, 0));
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("USERWIZARD_CREATE_ACCOUNT", ex);
                return;
            }

            // Save addons
            try
            {
                int spaceId = result.Result;
                foreach (RepeaterItem item in repHostingAddons.Items)
                {
                    PackageAddonInfo addon = new PackageAddonInfo();
                    addon.PackageAddonId = 0;       //PanelRequest.PackageAddonID;
                    addon.PackageId      = spaceId; //PanelSecurity.PackageId;
                    addon.Comments       = "";
                    addon.PlanId         = Utils.ParseInt(GetDropDownListSelectedValue(item, "ddlPlan"), 0);
                    addon.StatusId       = Utils.ParseInt(ddlStatus.SelectedValue, 0);
                    addon.PurchaseDate   = DateTime.Now;
                    addon.Quantity       = Utils.ParseInt(GetTextBoxText(item, "txtQuantity"), 1);
                    PackageResult addonResult = ES.Services.Packages.AddPackageAddon(addon);
                }

                if (rbPackageQuotas.Checked)
                {
                    //TODO: add logic to recalculate quota
                    //If checked rbPackageQuotas take all addons quota, sum it and replace to main hosting quota
                    //You can look the idea from SpaceEditDetails, but in SpaceEditDetails it is manually, need automatic here
                    //At this moment here is a lot of work, maybe later.
                }

                //PackageContext cntx = PackagesHelper.GetCachedPackageContext(spaceId);
                //string resourceGroup = "VPS2012";
                //if (cntx != null && cntx.Groups.ContainsKey(resourceGroup))
                //{
                //    string pageId = "SpaceVPS2012";
                //    string pageUrl = PortalUtils.NavigatePageURL(
                //pageId, PortalUtils.SPACE_ID_PARAM, spaceId.ToString(), null);
                //    Response.Redirect(pageUrl);
                //}
            }
            catch
            {
                //If something happens here, just ignore it. Addons not so important that a Hosting Space
            }

            if (chkRedirectToCreateVPS.Checked)
            {
                string pageId  = "SpaceVPS2012";
                string pageUrl = PortalUtils.NavigatePageURL(
                    pageId, PortalUtils.SPACE_ID_PARAM, result.Result.ToString(), null);
                Response.Redirect(pageUrl);
            }
            else
            {
                // go to space home
                Response.Redirect(PortalUtils.GetSpaceHomePageUrl(result.Result));
            }
        }