private void BindSettings()
        {
            try
            {
                // get settings
                ExchangeMailbox mailbox = ES.Services.ExchangeServer.GetMailboxGeneralSettings(PanelRequest.ItemID, PanelRequest.AccountID);

                //get statistics
                ExchangeMailboxStatistics stats = ES.Services.ExchangeServer.GetMailboxStatistics(PanelRequest.ItemID, PanelRequest.AccountID);

                // title
                litDisplayName.Text = mailbox.DisplayName;

                // bind form
                chkHideAddressBook.Checked = mailbox.HideFromAddressBook;
                chkDisable.Checked         = mailbox.Disabled;

                lblExchangeGuid.Text = string.IsNullOrEmpty(mailbox.ExchangeGuid) ? "<>" : mailbox.ExchangeGuid;

                // get account meta
                ExchangeAccount account = ES.Services.ExchangeServer.GetAccount(PanelRequest.ItemID, PanelRequest.AccountID);

                // get mailbox plan
                ExchangeMailboxPlan plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(PanelRequest.ItemID, account.MailboxPlanId);

                ExchangeJournalRule rule = ES.Services.ExchangeServer.GetJournalRule(PanelRequest.ItemID, account.PrimaryEmailAddress);

                cbEnabled.Checked          = rule.Enabled;
                ddlScope.SelectedValue     = rule.Scope;
                ddlRecipient.SelectedValue = rule.Recipient;

                if (account.MailboxPlanId == 0)
                {
                    mailboxPlanSelector.AddNone       = true;
                    mailboxPlanSelector.MailboxPlanId = "-1";
                }
                else
                {
                    mailboxPlanSelector.MailboxPlanId = account.MailboxPlanId.ToString();
                }

                mailboxSize.QuotaUsedValue = Convert.ToInt32(stats.TotalSize / 1024 / 1024);
                mailboxSize.QuotaValue     = (stats.MaxSize == -1) ? -1 : (int)Math.Round((double)(stats.MaxSize / 1024 / 1024));

                if (account.LevelId > 0 && Cntx.Groups.ContainsKey(ResourceGroups.ServiceLevels))
                {
                    EnterpriseServer.Base.HostedSolution.ServiceLevel serviceLevel = ES.Services.Organizations.GetSupportServiceLevel(account.LevelId);

                    litServiceLevel.Visible = true;
                    litServiceLevel.Text    = serviceLevel.LevelName;
                    litServiceLevel.ToolTip = serviceLevel.LevelDescription;
                }
                imgVipUser.Visible = account.IsVIP && Cntx.Groups.ContainsKey(ResourceGroups.ServiceLevels);
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_GET_JOURNALING_MAILBOX_SETTINGS", ex);
            }
        }
예제 #2
0
 public int SetJournalRule(int itemId, ExchangeJournalRule rule)
 {
     return(ExchangeServerController.SetJournalRule(itemId, rule));
 }
        private bool SaveSettings()
        {
            if (!Page.IsValid)
            {
                return(false);
            }

            try
            {
                if (mailboxPlanSelector.MailboxPlanId == "-1")
                {
                    messageBox.ShowErrorMessage("EXCHANGE_SPECIFY_PLAN");
                    return(false);
                }

                int result = ES.Services.ExchangeServer.SetMailboxGeneralSettings(
                    PanelRequest.ItemID, PanelRequest.AccountID,
                    chkHideAddressBook.Checked,
                    chkDisable.Checked);

                if (result < 0)
                {
                    messageBox.ShowResultMessage(result);
                    return(false);
                }
                else
                {
                    int planId = Convert.ToInt32(mailboxPlanSelector.MailboxPlanId);

                    result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(PanelRequest.ItemID, PanelRequest.AccountID, planId, -1, false);

                    if (result < 0)
                    {
                        messageBox.ShowResultMessage(result);
                        return(false);
                    }
                    else
                    {
                        ExchangeAccount     account = ES.Services.ExchangeServer.GetAccount(PanelRequest.ItemID, PanelRequest.AccountID);
                        ExchangeJournalRule rule    = ES.Services.ExchangeServer.GetJournalRule(PanelRequest.ItemID, account.PrimaryEmailAddress);
                        rule.Enabled   = cbEnabled.Checked;
                        rule.Scope     = ddlScope.SelectedValue;
                        rule.Recipient = ddlRecipient.SelectedValue;
                        result         = ES.Services.ExchangeServer.SetJournalRule(PanelRequest.ItemID, rule);
                        if (result < 0)
                        {
                            messageBox.ShowResultMessage(result);
                            return(false);
                        }
                    }
                }

                messageBox.ShowSuccessMessage("EXCHANGE_UPDATE_JOURNALING_MAILBOX_SETTINGS");
                BindSettings();
                return(true);
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_UPDATE_JOURNALING_MAILBOX_SETTINGS", ex);
                return(false);
            }
        }