Example #1
0
        public ActionResult Index(BackupModel model)
        {
            if (ModelState.IsValid)
            {

                model.Index++;
                if (model.Index == 3)
                    return Run(model);

                if (model.Index == 1)
                {
                    IEwsAdapter mailboxOper = CatalogFactory.Instance.NewEwsAdapter();
                    EwsServiceArgument argument = new EwsServiceArgument();
                    var password = RSAUtil.AsymmetricDecrypt(model.EncryptPassword);
                    argument.ServiceCredential = new System.Net.NetworkCredential(model.BackupUserMailAddress, password);
                    argument.UseDefaultCredentials = false;
                    argument.SetConnectMailbox(model.BackupUserMailAddress);
                    mailboxOper.ConnectMailbox(argument, model.BackupUserMailAddress);
                    return Json(model);
                }
            }

            return Json(model);
        }
Example #2
0
 public string ConnectMailbox(EwsServiceArgument argument, string connectMailAddress)
 {
     argument.SetConnectMailbox(connectMailAddress);
     MailboxPrincipalAddress = connectMailAddress;
     var url = _ewsOperator.NewExchangeService(connectMailAddress, argument);
     CreatedFolders = new Dictionary<string, FolderId>();
     return url;
 }
Example #3
0
 public void ConnectMailbox(EwsServiceArgument argument, string connectMailAddress)
 {
     argument.SetConnectMailbox(connectMailAddress);
     MailboxPrincipalAddress = connectMailAddress;
     CurrentExchangeService = EwsProxyFactory.CreateExchangeService(argument, MailboxPrincipalAddress);
 }
Example #4
0
        public JsonResult TestConnect(SettingViewModel model)
        {
            if (ModelState.IsValid)
            {
                IEwsAdapter mailboxOper = CatalogFactory.Instance.NewEwsAdapter();
                EwsServiceArgument argument = new EwsServiceArgument();
                var password = RSAUtil.AsymmetricDecrypt(model.EncryptPassword);
                argument.ServiceCredential = new System.Net.NetworkCredential(model.AdminUserName, password);
                argument.UseDefaultCredentials = false;
                argument.SetConnectMailbox(model.AdminUserName);
                try {
                    var url = mailboxOper.ConnectMailbox(argument, model.AdminUserName);

                    if (url == model.EwsConnectUrl)
                        return Json(new { Success = true, IsChangeUrl = false });
                    else
                        return Json(new { Success = true, IsChangeUrl = true, Url = url });
                }
                catch(Exception e)
                {
                    System.Diagnostics.Trace.TraceError(e.GetExceptionDetail());
                    return Json(new { Success = false});
                }
            }
            return Json(model);
        }