コード例 #1
0
        public ActionResult RemoveOOFMessage(FormCollection _POST)
        {
            try
            {
                CustomOOF OOF = new CustomOOF()
                {
                    Organization      = _POST["organization"].ToString(),
                    UserPrincipalName = _POST["userprincipalname"].ToString()
                };

                CommonCAS.Log(string.Format("has run Mail/RemoveOOFMessage() for organization {0} and mailbox {1}", OOF.Organization, OOF.UserPrincipalName));

                // execute powershell script and dispose powershell object
                using (MyPowerShell ps = new MyPowerShell())
                {
                    ps.RemoveOOFMessage(OOF);
                    var result = ps.Invoke();
                }

                CommonCAS.Stats("Mail/RemoveOOFMessage");

                model.OKMessage.Add(string.Format("'{0}' OOF has been removed...", OOF.UserPrincipalName));

                return(View("RemoveOOFMessage", model));
            }
            catch (Exception exc)
            {
                CommonCAS.Log("Exception: " + exc.Message);
                model.ActionFailed = true;
                model.Message      = exc.Message;
                return(View(model));
            }
        }