Beispiel #1
0
 private void SetAwardPhase(ArpsAward arpsAward, string button)
 {
     arpsAward.Phase =
         button == "Approve"
             ? GetAwardPhaseForApproval(arpsAward, button)
             : button == "Return"
                 ? AwardPhase.Initiator
                 : AwardPhase.End;
 }
Beispiel #2
0
        public ActionResult Post(ArpsAward arpsAward)
        {
            // GetName getname = new GetName();
            var arpsAwardFromSession = SessionHelper.ArpsAward;

            arpsAward.Phase = arpsAwardFromSession.Phase;
            var viewName = WorkflowHelper.GetViewName(arpsAward);

            return(View(viewName, arpsAward));
        }
        public static string GetViewName(ArpsAward arpsAward)
        {
            var viewName   = string.Empty;
            var dictionary = new Dictionary <string, Object>();

            dictionary.Add("ArpsAward", arpsAward);

            var wfApplication = new WorkflowApplication(new ArpsWF(), dictionary);

            var idleEvent = new AutoResetEvent(false);

            wfApplication.Idle += eventArgs => idleEvent.Set();

            var syncEvent = new AutoResetEvent(false);

            wfApplication.Completed += delegate(WorkflowApplicationCompletedEventArgs args)
            {
                if (args.CompletionState == ActivityInstanceState.Closed)
                {
                    try
                    {
                        // Accessing the output arguments dictionary
                        // might throw a KeyNotFoundException or
                        // InvalidCastException
                        viewName = arpsAward.ViewName;
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    finally
                    {
                        // Must be sure to unblock the main thread
                        syncEvent.Set();
                    }
                }
            };
            try
            {
                wfApplication.Run();
            }
            catch (Exception)
            {
                throw;
            }

            syncEvent.WaitOne();
            SessionHelper.ArpsAward = arpsAward;
            return(viewName);
        }
Beispiel #4
0
        public ActionResult Post(ArpsAward arpsAward, string button)
        {
            var arpsAwardFromSession = SessionHelper.ArpsAward;

            if (!IsDivisionDirectorPhase(arpsAwardFromSession))
            {
                return(new HttpUnauthorizedResult());
            }

            SetAwardPhase(arpsAward, button);

            SessionHelper.ArpsAward = arpsAward;

            return(RedirectToAction("Done", arpsAward));
        }
Beispiel #5
0
        public ActionResult Post(ArpsAward arpsAward)
        {
            var arpsAwardFromSession = SessionHelper.ArpsAward;

            if (arpsAwardFromSession.Phase != AwardPhase.Initiator)
            {
                return(new HttpUnauthorizedResult());
            }

            arpsAward = arpsAward.RunRuleSet <ArpsAward>(new InitiatorRuleSet());

            SessionHelper.ArpsAward = arpsAward;

            return(RedirectToAction(arpsAward.ViewName, arpsAward));
        }
Beispiel #6
0
        public ActionResult Post(ArpsAward arpsAward, string button)
        {
            var arpsAwardFromSession = SessionHelper.ArpsAward;

            if (arpsAwardFromSession == null || arpsAwardFromSession.Phase != DemoArps_Common.AwardPhase.ServicingAo)
            {
                throw new Exception();
            }

            arpsAward.Phase         = arpsAwardFromSession.Phase;
            arpsAward.UserSelection = button;

            var viewName = WorkflowHelper.GetViewName(arpsAward);

            return(View(viewName, arpsAward));
        }
        public ActionResult Post(ArpsAward arpsAward, string button)
        {
            arpsAward.Phase = SessionHelper.ArpsAward.Phase;

            if (arpsAward.Phase != AwardPhase.DivisionDirector)
            {
                return(new HttpUnauthorizedResult());
            }

            arpsAward.UserSelection = button;
            arpsAward = arpsAward.RunRuleSet <ArpsAward>(new DivisionDirectorRuleSet());

            SessionHelper.ArpsAward = arpsAward;

            return(RedirectToAction(arpsAward.ViewName, arpsAward));
        }
Beispiel #8
0
        public ActionResult Post(ArpsAward arpsAward)
        {
            var arpsAwardFromSession = SessionHelper.ArpsAward;

            if (arpsAwardFromSession.Phase != AwardPhase.Initiator)
            {
                return(new HttpUnauthorizedResult());
            }

            arpsAward.Phase = (arpsAward.InitiatorSso == arpsAward.NominatorSso)
                ? AwardPhase.ServicingAo : AwardPhase.Nominator;

            SessionHelper.ArpsAward = arpsAward;

            return(RedirectToAction("Done", arpsAward));
        }
Beispiel #9
0
        public ActionResult Post(ArpsAward arpsAward, string button)
        {
            arpsAward.Phase = SessionHelper.ArpsAward.Phase;

            if (arpsAward.Phase != AwardPhase.ServicingAo)
            {
                return(new HttpUnauthorizedResult());
            }

            arpsAward.UserSelection = button;
            arpsAward.ApplyRule <ArpsAward>(new ServicingAoSelectionRule());

            SessionHelper.ArpsAward = arpsAward;

            return(RedirectToAction(arpsAward.ViewName, arpsAward));
        }
        public ActionResult Post(ArpsAward arpsAward, string button)
        {
            var arpsAwardFromSession = SessionHelper.ArpsAward;

            if (!IsServicingAoPhase(arpsAwardFromSession))
            {
                return(new HttpUnauthorizedResult());
            }

            arpsAward.Phase = button == "Approve" ? AwardPhase.DivisionDirector :
                              button == "Return" ? AwardPhase.Initiator :
                              AwardPhase.End;

            SessionHelper.ArpsAward = arpsAward;

            return(RedirectToAction("Done", arpsAward));
        }
 private static bool IsServicingAoPhase(ArpsAward arpsAward)
 {
     return(arpsAward != null && arpsAward.Phase == AwardPhase.ServicingAo);
 }
Beispiel #12
0
 private static bool IsNominatorPhase(ArpsAward arpsAward)
 {
     return(arpsAward != null && arpsAward.Phase == AwardPhase.Nominator);
 }
Beispiel #13
0
 private static bool IsDdsmPhase(ArpsAward arpsAward)
 {
     return(arpsAward != null && arpsAward.Phase == AwardPhase.Ddsm);
 }
Beispiel #14
0
 private static bool IsDivisionDirectorPhase(ArpsAward arpsAward)
 {
     return(arpsAward != null && arpsAward.Phase == AwardPhase.DivisionDirector);
 }
Beispiel #15
0
 private string GetAwardPhaseForApproval(ArpsAward arpsAward, string button)
 {
     return(arpsAward.CashAmount > 5000.0m ?
            AwardPhase.Ddsm : AwardPhase.Ohr);
 }
Beispiel #16
0
 public ActionResult Done(ArpsAward arpsAward)
 {
     return(View(@"~\Views\Shared\Done.cshtml", arpsAward));
 }
Beispiel #17
0
 private static bool IsInitiatorPhase(ArpsAward arpsAward)
 {
     return(string.IsNullOrWhiteSpace(arpsAward.Phase) ||
            arpsAward.Phase == AwardPhase.Initiator);
 }