Exemplo n.º 1
0
 private void SetAwardPhase(ArpsAward arpsAward, string button)
 {
     arpsAward.Phase =
         button == "Approve"
             ? GetAwardPhaseForApproval(arpsAward, button)
             : button == "Return"
                 ? AwardPhase.Initiator
                 : AwardPhase.End;
 }
Exemplo n.º 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));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
 }
Exemplo n.º 12
0
 private static bool IsNominatorPhase(ArpsAward arpsAward)
 {
     return(arpsAward != null && arpsAward.Phase == AwardPhase.Nominator);
 }
Exemplo n.º 13
0
 private static bool IsDdsmPhase(ArpsAward arpsAward)
 {
     return(arpsAward != null && arpsAward.Phase == AwardPhase.Ddsm);
 }
Exemplo n.º 14
0
 private static bool IsDivisionDirectorPhase(ArpsAward arpsAward)
 {
     return(arpsAward != null && arpsAward.Phase == AwardPhase.DivisionDirector);
 }
Exemplo n.º 15
0
 private string GetAwardPhaseForApproval(ArpsAward arpsAward, string button)
 {
     return(arpsAward.CashAmount > 5000.0m ?
            AwardPhase.Ddsm : AwardPhase.Ohr);
 }
Exemplo n.º 16
0
 public ActionResult Done(ArpsAward arpsAward)
 {
     return(View(@"~\Views\Shared\Done.cshtml", arpsAward));
 }
Exemplo n.º 17
0
 private static bool IsInitiatorPhase(ArpsAward arpsAward)
 {
     return(string.IsNullOrWhiteSpace(arpsAward.Phase) ||
            arpsAward.Phase == AwardPhase.Initiator);
 }