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

                if (_POST["StartTime"] != null)
                {
                    OOF.StartTime = _POST["starttime"].ToString();
                }
                if (_POST["EndTime"] != null)
                {
                    OOF.EndTime = _POST["endtime"].ToString();
                }
                if (_POST["Internal"] != null)
                {
                    OOF.Internal = _POST["internal"].ToString();
                }
                if (_POST["External"] != null)
                {
                    OOF.External = _POST["external"].ToString();
                }
                ;

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

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

                CommonCAS.Stats("Mail/SetOOFMessage");

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

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