Beispiel #1
0
        private void BindSettings()
        {
            try
            {
                // get settings
                ExchangeMailbox mailbox = ES.Services.ExchangeServer.GetMailboxMailFlowSettings(
                    PanelRequest.ItemID, PanelRequest.AccountID);

                // title
                litDisplayName.Text = mailbox.DisplayName;

                // bind form
                chkEnabledForwarding.Checked = mailbox.EnableForwarding;
                forwardingAddress.SetAccount(mailbox.ForwardingAccount);
                chkDoNotDeleteOnForward.Checked = mailbox.DoNotDeleteOnForward;

                accessAccounts.SetAccounts(mailbox.SendOnBehalfAccounts);

                acceptAccounts.SetAccounts(mailbox.AcceptAccounts);
                chkSendersAuthenticated.Checked = mailbox.RequireSenderAuthentication;
                rejectAccounts.SetAccounts(mailbox.RejectAccounts);

                // toggle
                ToggleControls();

                // get account meta
                ExchangeAccount account = ES.Services.ExchangeServer.GetAccount(PanelRequest.ItemID, PanelRequest.AccountID);
                chkPmmAllowed.Checked = (account.MailboxManagerActions & MailboxManagerActions.MailFlowSettings) > 0;
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_GET_MAILBOX_MAILFLOW", ex);
            }
        }
        private List <ExchangeAccount> GetGridViewAccounts(GridView gv, SelectedState state)
        {
            List <ExchangeAccount> accounts = new List <ExchangeAccount>();

            for (int i = 0; i < gv.Rows.Count; i++)
            {
                GridViewRow row       = gv.Rows[i];
                CheckBox    chkSelect = (CheckBox)row.FindControl("chkSelect");
                if (chkSelect == null)
                {
                    continue;
                }

                ExchangeAccount account = new ExchangeAccount();
                account.AccountType = (ExchangeAccountType)Enum.Parse(typeof(ExchangeAccountType), ((Literal)row.FindControl("litAccountType")).Text);
                account.AccountName = (string)gv.DataKeys[i][0];
                account.DisplayName = ((Literal)row.FindControl("litDisplayName")).Text;

                if (state == SelectedState.All ||
                    (state == SelectedState.Selected && chkSelect.Checked) ||
                    (state == SelectedState.Unselected && !chkSelect.Checked))
                {
                    accounts.Add(account);
                }
            }
            return(accounts);
        }
        private void resolveAccount(ExchangeAccount account)
        {
            ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;

            ExchangeService service = new ExchangeService((ExchangeVersion)account.EwsVersion)
            {
                Credentials = new WebCredentials(
                    account.Account,
                    RsaUtil.Decrypt(account.Password)
                    ),
            };

            try
            {
                if (!string.IsNullOrWhiteSpace(account.Url))
                {
                    service.Url = new Uri(account.Url);
                }
                else
                {
                    service.AutodiscoverUrl(account.Account, RedirectionUrlValidationCallback);
                }

                var match = service.ResolveName(account.Account);
                if (match.Count == 0)
                {
                    throw new Exception();
                }
            }

            catch (Exception)
            {
                ModelState.AddModelError("Account", Resources.CouldNotBeResolved);
            }
        }
Beispiel #4
0
 public ExchangeAccountDataContext(ExchangeAccount account, Action <AuthenticatedMailbox> removeMailboxAction)
 {
     _account  = account;
     Mailboxes = new AuthenticatedMailboxList(removeMailboxAction, Dispatcher.CurrentDispatcher);
     Mailboxes.SetList(account.Mailboxes.UnderlyingCollection);
     Mailboxes.CollectionChanged += (sender, args) => OnPropertyChanged("Mailboxes");
 }
        private List <ExchangeAccount> GetGridViewAccounts(GridView gv, SelectedState state)
        {
            List <ExchangeAccount> accounts = new List <ExchangeAccount>();

            for (int i = 0; i < gv.Rows.Count; i++)
            {
                GridViewRow row       = gv.Rows[i];
                CheckBox    chkSelect = (CheckBox)row.FindControl("chkSelect");
                if (chkSelect == null)
                {
                    continue;
                }

                ExchangeAccount account = new ExchangeAccount();
                account.AccountType         = (ExchangeAccountType)Enum.Parse(typeof(ExchangeAccountType), ((Literal)row.FindControl("litAccountType")).Text);
                account.AccountName         = (string)gv.DataKeys[i][0];
                account.DisplayName         = ((Literal)row.FindControl("litDisplayName")).Text;
                account.PrimaryEmailAddress = ((Literal)row.FindControl("litPrimaryEmailAddress")).Text;
                if (gv != gvPopupAccounts)
                {
                    DropDownList ddlPermissions = (DropDownList)row.FindControl("ddlPermissions");
                    //HiddenField PermissionLabel = (HiddenField)row.FindControl("PermissionLabel");
                    //account.PublicFolderPermission = PermissionLabel.Value;
                    account.PublicFolderPermission = ddlPermissions.SelectedValue;
                }
                if (state == SelectedState.All ||
                    (state == SelectedState.Selected && chkSelect.Checked) ||
                    (state == SelectedState.Unselected && !chkSelect.Checked))
                {
                    accounts.Add(account);
                }
            }
            return(accounts);
        }
 private void AddAccountClick(object sender, RoutedEventArgs e)
 {
     if (SourceComboBox.SelectedItem != null)
     {
         IMailAccount account = null;
         if ("Imap".Equals(((ComboBoxItem)(SourceComboBox.SelectedItem)).Content))
         {
             account = new ImapAccount();
         }
         else if ("Mbox".Equals(((ComboBoxItem)(SourceComboBox.SelectedItem)).Content))
         {
             account = new MboxAccount();
         }
         else if ("Exchange".Equals(((ComboBoxItem)(SourceComboBox.SelectedItem)).Content))
         {
             account = new ExchangeAccount();
         }
         else
         {
             Logger.Warn("Unsupported Account '" + ((ComboBoxItem)(SourceComboBox.SelectedItem)).Content + "'");
         }
         if (account != null)
         {
             account.AddedMailbox   += AddMailboxEvent;
             account.RemovedMailbox += RemoveMailboxEvent;
             MailSources.Add(account);
         }
     }
 }
        protected int SetMailboxPlan(List <int> userIds)
        {
            int planId;

            if (!int.TryParse(mailboxPlanSelector.MailboxPlanId, out planId))
            {
                return(0);
            }

            if (planId < 0)
            {
                return(0);
            }

            foreach (int userId in userIds)
            {
                ExchangeAccount account = ES.Services.ExchangeServer.GetAccount(PanelRequest.ItemID, userId);

                int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(PanelRequest.ItemID, userId, planId,
                                                                               account.ArchivingMailboxPlanId, account.EnableArchiving);

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

            return(0);
        }
Beispiel #8
0
 public ExchangeAccountControl(ExchangeAccount account)
 {
     InitializeComponent();
     _account     = account;
     _dataContext = new ExchangeAccountDataContext(_account, RemoveMailboxFunction);
     DataContext  = _dataContext;
 }
Beispiel #9
0
        private void BindPermissions()
        {
            try
            {
                ExchangeMailbox mailbox =
                    ES.Services.ExchangeServer.GetMailboxPermissions(PanelRequest.ItemID, PanelRequest.AccountID);

                litDisplayName.Text = mailbox.DisplayName;
                sendAsPermission.SetAccounts(mailbox.SendAsAccounts);
                fullAccessPermission.SetAccounts(mailbox.FullAccessAccounts);

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

                if (account.AccountType == ExchangeAccountType.SharedMailbox)
                {
                    litDisplayName.Text += GetSharedLocalizedString("SharedMailbox.Text");
                }

                if (account.AccountType == ExchangeAccountType.Room)
                {
                    litDisplayName.Text += GetSharedLocalizedString("RoomMailbox.Text");
                }

                if (account.AccountType == ExchangeAccountType.Equipment)
                {
                    litDisplayName.Text += GetSharedLocalizedString("EquipmentMailbox.Text");
                }
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_GET_MAILBOX_PERMISSIONS", ex);
            }
        }
        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);
            }
        }
        //
        // GET: /ExchangeAccount/Create

        public ActionResult Create()
        {
            ExchangeAccount ews = new ExchangeAccount();

            ews.init(db);
            FillVersionsSelectList();
            return(View(ews));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ExchangeAccount ews = db.ExchangeAccounts.Find(id);

            db.ExchangeAccounts.Remove(ews);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #13
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="obj">对象</param>
        /// <returns>返回:该条数据的主键Id</returns>
        public int Insert(ExchangeAccount obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            String stmtId = "ExchangeAccount.Insert";

            return(SqlMapper.Instance().QueryForObject <int>(stmtId, obj));
        }
        //
        // GET: /ExchangeAccount/Delete/5

        public ActionResult Delete(int id = 0)
        {
            ExchangeAccount ews = db.ExchangeAccounts.Find(id);

            if (ews == null)
            {
                return(View("Missing", new MissingItem(id)));
            }
            return(View(ews));
        }
Beispiel #15
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>返回:ture 成功,false 失败</returns>
        public bool Update(ExchangeAccount obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            String stmtId = "ExchangeAccount.Update";
            int    result = SqlMapper.Instance().QueryForObject <int>(stmtId, obj);

            return(result > 0 ? true : false);
        }
Beispiel #16
0
        private string GetArchivingImage()
        {
            string          result  = string.Empty;
            ExchangeAccount account = ES.Services.ExchangeServer.GetAccount(ItemId, AccountId);

            if (account != null && account.EnableArchiving)
            {
                result = "<span class=\"fa fa-archive fa-lg text-success\"></span>";
            }
            return(result);
        }
        protected void ddlPermissions_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList ddlCurrentDropDownList = (DropDownList)sender;
            GridViewRow  grdrDropDownRow        = ((GridViewRow)ddlCurrentDropDownList.Parent.Parent);

            ExchangeAccount ex = (ExchangeAccount)grdrDropDownRow.DataItem as ExchangeAccount;

            if (ex != null)
            {
                ex.PublicFolderPermission = ddlCurrentDropDownList.SelectedValue;
            }
        }
        //
        // GET: /ExchangeAccount/Edit/5

        public ActionResult Edit(int id = 0)
        {
            ExchangeAccount ews = db.ExchangeAccounts.Find(id);

            if (ews == null)
            {
                return(View("Missing", new MissingItem(id)));
            }

            FillVersionsSelectList(ews.EwsVersion);
            return(View(ews));
        }
        private void BindGrid()
        {
            ExchangeMobileDevice[] devices = ES.Services.ExchangeServer.GetMobileDevices(PanelRequest.ItemID, PanelRequest.AccountID);

            gvMobile.DataSource = devices;
            gvMobile.DataBind();

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

            litDisplayName.Text = account.DisplayName;
        }
        private void BindSettings()
        {
            try
            {
                password.SetPackagePolicy(PanelSecurity.PackageId, UserSettings.EXCHANGE_POLICY, "MailboxPasswordPolicy");
                password.EditMode = true;

                // get settings
                ExchangeMailbox mailbox = ES.Services.ExchangeServer.GetMailboxGeneralSettings(PanelRequest.ItemID,
                                                                                               PanelRequest.AccountID);

                // title
                litDisplayName.Text = mailbox.DisplayName;

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

                txtFirstName.Text = mailbox.FirstName;
                txtInitials.Text  = mailbox.Initials;
                txtLastName.Text  = mailbox.LastName;

                txtJobTitle.Text   = mailbox.JobTitle;
                txtCompany.Text    = mailbox.Company;
                txtDepartment.Text = mailbox.Department;
                txtOffice.Text     = mailbox.Office;
                manager.SetAccount(mailbox.ManagerAccount);

                txtBusinessPhone.Text = mailbox.BusinessPhone;
                txtFax.Text           = mailbox.Fax;
                txtHomePhone.Text     = mailbox.HomePhone;
                txtMobilePhone.Text   = mailbox.MobilePhone;
                txtPager.Text         = mailbox.Pager;
                txtWebPage.Text       = mailbox.WebPage;

                txtAddress.Text = mailbox.Address;
                txtCity.Text    = mailbox.City;
                txtState.Text   = mailbox.State;
                txtZip.Text     = mailbox.Zip;
                country.Country = mailbox.Country;

                txtNotes.Text = mailbox.Notes;

                // get account meta
                ExchangeAccount account = ES.Services.ExchangeServer.GetAccount(PanelRequest.ItemID, PanelRequest.AccountID);
                chkPmmAllowed.Checked = (account.MailboxManagerActions & MailboxManagerActions.GeneralSettings) > 0;
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_GET_MAILBOX_SETTINGS", ex);
            }
        }
Beispiel #21
0
        private void BindSettings()
        {
            try
            {
                // get settings
                ExchangeMailbox mailbox = ES.Services.ExchangeServer.GetMailboxAdvancedSettings(
                    PanelRequest.ItemID, PanelRequest.AccountID);

                // title
                litDisplayName.Text = mailbox.DisplayName;

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

                chkPOP3.Visible       = cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_POP3ALLOWED) && !cntx.Quotas[Quotas.EXCHANGE2007_POP3ALLOWED].QuotaExhausted;
                chkIMAP.Visible       = cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_IMAPALLOWED) && !cntx.Quotas[Quotas.EXCHANGE2007_IMAPALLOWED].QuotaExhausted;
                chkOWA.Visible        = cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_OWAALLOWED) && !cntx.Quotas[Quotas.EXCHANGE2007_OWAALLOWED].QuotaExhausted;
                chkMAPI.Visible       = cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_MAPIALLOWED) && !cntx.Quotas[Quotas.EXCHANGE2007_MAPIALLOWED].QuotaExhausted;
                chkActiveSync.Visible = cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_ACTIVESYNCALLOWED) && !cntx.Quotas[Quotas.EXCHANGE2007_ACTIVESYNCALLOWED].QuotaExhausted;

                // bind form
                chkPOP3.Checked       = mailbox.EnablePOP;
                chkIMAP.Checked       = mailbox.EnableIMAP;
                chkOWA.Checked        = mailbox.EnableOWA;
                chkMAPI.Checked       = mailbox.EnableMAPI;
                chkActiveSync.Checked = mailbox.EnableActiveSync;

                lblTotalItems.Text = mailbox.TotalItems.ToString();
                lblTotalSize.Text  = mailbox.TotalSizeMB.ToString();
                lblLastLogon.Text  = Utils.FormatDateTime(mailbox.LastLogon);
                lblLastLogoff.Text = Utils.FormatDateTime(mailbox.LastLogoff);

                sizeIssueWarning.ValueKB        = mailbox.IssueWarningKB;
                sizeProhibitSend.ValueKB        = mailbox.ProhibitSendKB;
                sizeProhibitSendReceive.ValueKB = mailbox.ProhibitSendReceiveKB;

                daysKeepDeletedItems.ValueDays = mailbox.KeepDeletedItemsDays;

                txtAccountName.Text = mailbox.Domain + "\\" + mailbox.AccountName;

                // get account meta
                ExchangeAccount account = ES.Services.ExchangeServer.GetAccount(PanelRequest.ItemID, PanelRequest.AccountID);
                chkPmmAllowed.Checked = (account.MailboxManagerActions & MailboxManagerActions.AdvancedSettings) > 0;
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_GET_MAILBOX_ADVANCED", ex);
            }
        }
Beispiel #22
0
 private void BindSelectedAccount(ExchangeAccount account)
 {
     if (account != null)
     {
         txtDisplayName.Text              = account.DisplayName;
         ViewState["AccountName"]         = account.AccountName;
         ViewState["PrimaryEmailAddress"] = account.PrimaryEmailAddress;
         ViewState["AccountId"]           = account.AccountId;
     }
     else
     {
         txtDisplayName.Text              = "";
         ViewState["AccountName"]         = null;
         ViewState["PrimaryEmailAddress"] = null;
         ViewState["AccountId"]           = null;
     }
 }
        private void BindData()
        {
            ExchangeMobileDevice device = ES.Services.ExchangeServer.GetMobileDevice(PanelRequest.ItemID,
                                                                                     PanelRequest.DeviceId);

            if (device != null)
            {
                lblStatus.Text = GetLocalizedString(device.Status.ToString());
                switch (device.Status)
                {
                case MobileDeviceStatus.PendingWipe:
                    lblStatus.ForeColor = Color.Red;
                    break;

                case MobileDeviceStatus.WipeSuccessful:
                    lblStatus.ForeColor = Color.Green;
                    break;

                default:
                    lblStatus.ForeColor = Color.Black;
                    break;
                }
                lblDeviceModel.Text           = device.DeviceModel;
                lblDeviceType.Text            = device.DeviceType;
                lblFirstSyncTime.Text         = DateTimeToString(device.FirstSyncTime);
                lblDeviceWipeRequestTime.Text = DateTimeToString(device.DeviceWipeRequestTime);
                lblDeviceAcnowledgeTime.Text  = DateTimeToString(device.DeviceWipeAckTime);
                lblLastSync.Text           = DateTimeToString(device.LastSyncAttemptTime);
                lblLastUpdate.Text         = DateTimeToString(device.LastPolicyUpdateTime);
                lblLastPing.Text           = device.LastPingHeartbeat == 0 ? string.Empty : device.LastPingHeartbeat.ToString();
                lblDeviceFriendlyName.Text = device.DeviceFriendlyName;
                lblDeviceId.Text           = device.DeviceID;
                lblDeviceUserAgent.Text    = device.DeviceUserAgent;
                lblDeviceOS.Text           = device.DeviceOS;
                lblDeviceOSLanguage.Text   = device.DeviceOSLanguage;
                lblDeviceIMEA.Text         = device.DeviceIMEI;
                lblDevicePassword.Text     = device.RecoveryPassword;

                UpdateButtons(device.Status);

                // form title
                ExchangeAccount account = ES.Services.ExchangeServer.GetAccount(PanelRequest.ItemID, PanelRequest.AccountID);
                litDisplayName.Text = account.DisplayName;
            }
        }
        public ActionResult Create([Bind(Include = "Name,Account,PasswordUnmasked,Url,EwsVersion")] ExchangeAccount ews)
        {
            Match lnk = _emailRgx.Match(ews.Account);

            ews.Account = lnk.Success ? lnk.Value : "";

            resolveAccount(ews);

            if (ModelState.IsValid)
            {
                db.ExchangeAccounts.Add(ews);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            FillVersionsSelectList(ews.EwsVersion);
            return(View(ews));
        }
        public ActionResult Edit([Bind(Include = "AccountId,Name,Account,PasswordUnmasked,Url,EwsVersion")] ExchangeAccount ews)
        {
            Match lnk = _emailRgx.Match(ews.Account);

            ews.Account = lnk.Success ? lnk.Value : "";

            resolveAccount(ews);

            if (ModelState.IsValid)
            {
                db.Entry(ews).State = EntityState.Modified;
                db.Entry(ews).Property(l => l.Password).IsModified = ews._passwordSet;
                //db.Entry(ews).Property(l => l.Url).IsModified = false;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            FillVersionsSelectList(ews.EwsVersion);
            return(View(ews));
        }
        // TODO: Add exchange account type from the user selection.
        public async Task Create(string userId, int accountTypeId)
        {
            var existingClient = await this.dbContext.Clients.FirstOrDefaultAsync(c => c.UserId == userId);

            if (existingClient == null)
            {
                return;
            }

            var exchangeAccountType = await this.dbContext.ExchangeAccountTypes.FirstOrDefaultAsync(eat => eat.Id == accountTypeId);

            if (exchangeAccountType == null)
            {
                return;
            }

            var exchangeAccount = new ExchangeAccount()
            {
                OwnerId   = existingClient.Id,
                CreatedAt = DateTime.UtcNow,
                IsActive  = true,
                Type      = exchangeAccountType
            };

            var identityNumber = this.identityNumberGenerator.Generate();

            var accountExists = this.dbContext.ExchangeAccounts.Any(ea => ea.IdentityNumber == identityNumber);

            while (accountExists)
            {
                identityNumber = this.identityNumberGenerator.Generate();

                accountExists = this.dbContext.ExchangeAccounts.Any(ea => ea.IdentityNumber == identityNumber);
            }

            exchangeAccount.IdentityNumber = identityNumber;

            this.dbContext.ExchangeAccounts.Add(exchangeAccount);

            await this.dbContext.SaveChangesAsync();
        }
Beispiel #27
0
        protected void gvPopupAccounts_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "SelectAccount")
            {
                string[]        parts   = e.CommandArgument.ToString().Split('^');
                ExchangeAccount account = new ExchangeAccount();
                account.AccountName         = parts[0];
                account.DisplayName         = parts[1];
                account.PrimaryEmailAddress = parts[2];
                account.AccountId           = Utils.ParseInt(parts[3]);


                // set account
                BindSelectedAccount(account);

                // hide popup
                SelectAccountsModal.Hide();

                // update parent panel
                MainUpdatePanel.Update();
            }
        }
Beispiel #28
0
        private void BindEmails()
        {
            EntServer.ExchangeEmailAddress[] emails = ES.Services.ExchangeServer.GetMailboxEmailAddresses(
                PanelRequest.ItemID, PanelRequest.AccountID);

            gvEmails.DataSource = emails;
            gvEmails.DataBind();

            lblTotal.Text = emails.Length.ToString();

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

            chkPmmAllowed.Checked = (account.MailboxManagerActions & MailboxManagerActions.EmailAddresses) > 0;

            litDisplayName.Text = account.DisplayName;

            //disable buttons if only one e-mail available, it is primary and cannot be deleted
            if (gvEmails.Rows.Count == 1)
            {
                btnDeleteAddresses.Enabled = false;
                btnSetAsPrimary.Enabled    = false;
            }
        }
Beispiel #29
0
        public async Task <CancelKey> AddOrderAsync(ExchangeAccount acct, TokenTradeOrder order)
        {
            order.CreatedTime = DateTime.Now;
            var item = new ExchangeOrder()
            {
                ExchangeAccountId = acct.Id,
                Order             = order,
                CanDeal           = true,
                State             = DealState.Placed,
                ClientIP          = null
            };
            await _queue.InsertOneAsync(item);

            OnNewOrder?.Invoke(this, new EventArgs());

            var key = new CancelKey()
            {
                State = OrderState.Placed,
                Key   = item.Id.ToString(),
                Order = order
            };

            return(key);
        }
Beispiel #30
0
        public async Task <ExchangeAccount> AddExchangeAccount(string assocaitedAccountId)
        {
            var findResult = await _exchangeAccounts.FindAsync(a => a.AssociatedToAccountId == assocaitedAccountId);

            var findAccount = await findResult.FirstOrDefaultAsync();

            if (findAccount != null)
            {
                return(findAccount);
            }

            var walletPrivateKey = Signatures.GenerateWallet().privateKey;
            var walletAccountId  = Signatures.GetAccountIdFromPrivateKey(walletPrivateKey);

            var account = new ExchangeAccount()
            {
                AssociatedToAccountId = assocaitedAccountId,
                AccountId             = walletAccountId,
                PrivateKey            = walletPrivateKey
            };
            await _exchangeAccounts.InsertOneAsync(account);

            return(account);
        }