Exemple #1
0
        private static NextStep LoadNextSteps(int acseriesId, atriumBE.CurrentFlow ap)
        {
            NextStep prevAc = null;

            foreach (atriumBE.NextStep ns in ap.NextSteps.Values)
            {
                if (ns.acs.ACSeriesId == acseriesId)
                {
                    return(ns);
                }
                if (ns.Children != null)
                {
                    prevAc = LoadNextSteps(acseriesId, ns.Children);
                }
            }
            return(prevAc);
        }
Exemple #2
0
        public NextStep SillyQuestion(NextStep ns, FileManager fmCurrent)
        {
            StepType st = (StepType)ns.acs.StepType;

            //check for silly question
            if (st == StepType.Decision && ns.acs.GetActivityFieldRows().Length > 0)
            {
                NextStep answer      = null;
                ACEngine sillyEngine = new ACEngine(fmCurrent);
                bool     isTrue      = sillyEngine.SillyQuestion(ns.acs);
                //find right path
                foreach (NextStep a1 in ns.Children.NextSteps.Values)
                {
                    if (isTrue && (a1.LinkText.StartsWith("Yes") || a1.LinkText.StartsWith("Oui")))
                    {
                        answer = a1;

                        break;
                    }
                    else if (!isTrue && (a1.LinkText.StartsWith("No") || a1.LinkText.StartsWith("Non")))
                    {
                        answer = a1;

                        break;
                    }
                }


                //follow it
                if (answer.Children != null)
                {
                    return(SillyQuestion(answer, fmCurrent));
                }
                else
                {
                    return(answer);
                }
            }
            return(ns);
        }
Exemple #3
0
        private void BuildOKToAdd(CurrentFlow ap)
        {
            foreach (NextStep ns1 in ap.NextSteps.Values)
            {
                NextStep ns = SillyQuestion(ns1);

                StepType st = (StepType)ns.acs.StepType;


                if (st == StepType.Activity)
                {
                    if (ns.Enabled)
                    {
                        FM.CurrentActivityProcess.AcSeriesOKToAdd.Add(ns.acs);
                    }
                }
                if (ns.Children != null)
                {
                    BuildOKToAdd(ns.Children);
                }
            }
        }
Exemple #4
0
        public NextStep SillyQuestion(NextStep ns)
        {
            return(SillyQuestion(ns, FM));

            //StepType st = (StepType)ns.acs.StepType;

            ////check for silly question
            //if (st == StepType.Decision && ns.acs.GetActivityFieldRows().Length > 0)
            //{
            //    NextStep answer = null;
            //    ACEngine sillyEngine = new ACEngine(FM);
            //    bool isTrue = sillyEngine.SillyQuestion(ns.acs);
            //    //find right path
            //    foreach (NextStep a1 in ns.Children.NextSteps.Values)
            //    {
            //        if (isTrue && (a1.LinkText.StartsWith("Yes") || a1.LinkText.StartsWith("Oui")))
            //        {
            //            answer = a1;

            //            break;
            //        }
            //        else if (!isTrue && (a1.LinkText.StartsWith("No") || a1.LinkText.StartsWith("Non")))
            //        {
            //            answer = a1;

            //            break;

            //        }
            //    }


            //    //follow it
            //    if (answer.Children != null)
            //        return SillyQuestion(answer);
            //    else
            //        return answer;
            //}
            //return ns;
        }
Exemple #5
0
        public Dictionary <int, CurrentFlow> AvailableProcesses()
        {
            //create collection of available Processes
            Dictionary <int, CurrentFlow> availableProcesses = new Dictionary <int, CurrentFlow>();

            fileProcesses.Clear();
            activeProcesses.Clear();
            foreach (atriumDB.ProcessRow pr in myFM.CurrentFile.GetProcessRows())
            {
                fileProcesses.Add(pr.ProcessId, pr.SeriesId);
                if (pr.Active)
                {
                    activeProcesses.Add(pr.ProcessId, pr.SeriesId);
                }
            }


            //go through series table
            //filter it based on file type

            foreach (ActivityConfig.SeriesRow sr in myFM.AtMng.acMng.DB.Series.Select("Obsolete=false", "SeriesDesc" + myFM.AppMan.Language))
            {
                bool add = true;
                //AvailableSeries availSeries = new AvailableSeries();
                //availSeries.Series = sr;
                CurrentFlow curFlow = new CurrentFlow();
                curFlow.Series = sr;

                //exclude processes that violate instance rules - onceperfile,singleinstanceperfile
                if (sr.OncePerFile & fileProcesses.ContainsValue(sr.SeriesId))
                {
                    add = false;
                }

                if (sr.SingleInstancePerFile & activeProcesses.ContainsValue(sr.SeriesId))
                {
                    add = false;
                }

                if (add)
                {
                    //look for sub series steps
                    //    ActivityConfig.ACSeriesRow[] acss = (ActivityConfig.ACSeriesRow[])FM.AtMng.acMng.DB.ACSeries.Select("Subseriesid=" + sr.SeriesId.ToString());
                    //verify that start activity is available
                    ActivityConfig.ACSeriesRow[] seriesSteps = (ActivityConfig.ACSeriesRow[])FM.AtMng.acMng.DB.ACSeries.Select("Seriesid=" + sr.SeriesId.ToString(), "seq,stepcode");
                    foreach (ActivityConfig.ACSeriesRow acsr in seriesSteps)
                    {
                        bool addstep = false;
                        if (acsr.Start)
                        {
                            if (sr.AlwaysAvailable)
                            {
                                addstep = true;
                            }

                            if (addstep)
                            {
                                //check filetype rule
                                //addstep = AllowForFileType(acsr,myFM);
                                addstep = Allowed(acsr, myFM.AtMng, myFM);
                            }

                            //if ok add
                            if (addstep)
                            {
                                NextStep ns = new NextStep();
                                ns.acs     = acsr;
                                ns.Enabled = IsEnabled(acsr);
                                ns.prevAc  = null;
                                curFlow.NextSteps.Add(acsr.ACSeriesId, ns);

                                //recurse check for next steps
                                if (acsr.StepType != (int)StepType.Activity && acsr.GetACDependencyRowsByNextSteps().Length > 0)
                                {
                                    CurrentFlow newFlow = new CurrentFlow();
                                    newFlow.Series = acsr.SeriesRow;
                                    ns.Children    = newFlow;
                                    NextSteps(newFlow, acsr, null);
                                }
                            }
                        }
                    }

                    if (curFlow.NextSteps.Count > 0)
                    {
                        availableProcesses.Add(sr.SeriesId, curFlow);
                    }
                }
            }
            foreach (CurrentFlow ap in availableProcesses.Values)
            {
                BuildOKToAdd(ap);
            }

            return(availableProcesses);
        }
Exemple #6
0
        public Dictionary <int, CurrentFlow> EnabledProcesses2()
        {
            //create collection of available Processes
            Dictionary <int, CurrentFlow> enabledProcesses = new Dictionary <int, CurrentFlow>();

            fileProcesses.Clear();
            activeProcesses.Clear();
            foreach (atriumDB.ProcessRow pr in myFM.CurrentFile.GetProcessRows())
            {
                fileProcesses.Add(pr.ProcessId, pr.SeriesId);
                if (pr.Active)
                {
                    activeProcesses.Add(pr.ProcessId, pr.SeriesId);
                }
            }


            //go through series table
            //filter it based on file type

            foreach (ActivityConfig.SeriesRow sr in myFM.AtMng.acMng.DB.Series.Select("Obsolete=false", "SeriesDesc" + myFM.AppMan.Language))
            {
                bool        add           = true;
                CurrentFlow enabledSeries = new CurrentFlow();
                enabledSeries.Series = sr;

                //exclude processes that violate instance rules - onceperfile,singleinstanceperfile
                if (sr.OncePerFile & fileProcesses.ContainsValue(sr.SeriesId))
                {
                    add = false;
                }

                if (sr.SingleInstancePerFile & activeProcesses.ContainsValue(sr.SeriesId))
                {
                    add = false;
                }

                if (add)
                {
                    //look for sub series steps
                    ActivityConfig.ACSeriesRow[] acss = (ActivityConfig.ACSeriesRow[])FM.AtMng.acMng.DB.ACSeries.Select("Subseriesid=" + sr.SeriesId.ToString());
                    //verify that start activity is available
                    foreach (ActivityConfig.ACSeriesRow acsr in sr.GetACSeriesRows())
                    {
                        atriumDB.ActivityRow arp = null;
                        bool addstep             = false;
                        if (acsr.Start)
                        {
                            //check dependencies for each sub series step
                            foreach (ActivityConfig.ACSeriesRow acsrs in acss)
                            {
                                foreach (ActivityConfig.ACDependencyRow acdr in acsrs.GetACDependencyRowsByPreviousSteps())
                                {
                                    //see if the previous activity has been done
                                    bool isDone = myFM.DB.Activity.Select("ACSeriesID=" + acdr.CurrentStepId.ToString()).Length > 0;
                                    //check enable link
                                    if (acdr.LinkType == (int)ConnectorType.Enable & isDone)
                                    {
                                        //need to track parent process here
                                        addstep = true;
                                    }

                                    //check transfer link - only if it is working as  enable
                                    //TODO need to check whether enabling activity was in an active process
                                    if (acdr.LinkType == (int)ConnectorType.Transfer & isDone)
                                    {
                                        //need to track parent process here
                                        arp = (atriumDB.ActivityRow)myFM.DB.Activity.Select("ACSeriesID=" + acdr.CurrentStepId.ToString())[0];
                                        if (!activeProcesses.ContainsKey(arp.ProcessId))
                                        {
                                            arp = null;
                                        }
                                        addstep = true;
                                    }
                                    //check disable link
                                    if (acdr.LinkType == (int)ConnectorType.Disable & isDone)
                                    {
                                        addstep = false;
                                    }
                                }
                            }

                            if (addstep)
                            {
                                //check filetype rule
                                //addstep = AllowForFileType(acsr,myFM);
                                addstep = Allowed(acsr, myFM.AtMng, myFM);
                            }

                            //if ok add
                            if (addstep)
                            {
                                NextStep ns = new NextStep();
                                ns.acs = acsr;
                                if (arp == null)
                                {
                                    ns.prevAc = null;
                                }
                                else
                                {
                                    ns.prevAc = arp;
                                }

                                enabledSeries.NextSteps.Add(acsr.ACSeriesId, ns);

                                //recurse check for next steps
                                if (acsr.StepType != (int)StepType.Activity && acsr.GetACDependencyRowsByNextSteps().Length > 0)
                                {
                                    CurrentFlow newFlow = new CurrentFlow();
                                    newFlow.Series = acsr.SeriesRow;
                                    ns.Children    = newFlow;
                                    NextSteps(newFlow, acsr, arp);
                                }
                            }
                        }
                    }

                    if (enabledSeries.NextSteps.Count > 0)
                    {
                        enabledProcesses.Add(sr.SeriesId, enabledSeries);
                    }
                }
            }
            return(enabledProcesses);
        }
Exemple #7
0
        public Dictionary <int, CurrentFlow> EnabledProcesses()
        {
            //create collection of available Processes
            Dictionary <int, CurrentFlow> enabledProcesses = new Dictionary <int, CurrentFlow>();

            fileProcesses.Clear();
            activeProcesses.Clear();
            foreach (atriumDB.ProcessRow pr in myFM.CurrentFile.GetProcessRows())
            {
                fileProcesses.Add(pr.ProcessId, pr.SeriesId);
                if (pr.Active)
                {
                    activeProcesses.Add(pr.ProcessId, pr.SeriesId);
                }
            }


            //go through activities on file in seq
            foreach (atriumDB.ActivityRow ar in FM.DB.Activity.Select("", "ActivityID"))
            {
                ActivityConfig.ACSeriesRow acs = FM.GetActivity().GetACSeriesRow(ar);

                //go through this acseries next steps to see if they enable or disable a process
                foreach (ActivityConfig.ACDependencyRow acdr in acs.GetACDependencyRowsByNextSteps())
                {
                    if (acdr.ACSeriesRowByPreviousSteps.StepType == (int)StepType.Subseries && (acdr.LinkType == (int)ConnectorType.Enable | acdr.LinkType == (int)ConnectorType.Transfer | acdr.LinkType == (int)ConnectorType.Disable))
                    {
                        //the link is to a subprocess
                        bool add = true;
                        ActivityConfig.SeriesRow sr = FM.AtMng.acMng.DB.Series.FindBySeriesId(acdr.ACSeriesRowByPreviousSteps.SubseriesId);

                        CurrentFlow enabledSeries;
                        if (enabledProcesses.ContainsKey(sr.SeriesId))
                        {
                            enabledSeries = enabledProcesses[sr.SeriesId];
                        }
                        else
                        {
                            enabledSeries = new CurrentFlow();

                            enabledSeries.Series = sr;
                        }

                        //exclude processes that violate instance rules - onceperfile,singleinstanceperfile
                        if (sr.OncePerFile & fileProcesses.ContainsValue(sr.SeriesId))
                        {
                            add = false;
                        }

                        if (sr.SingleInstancePerFile & activeProcesses.ContainsValue(sr.SeriesId))
                        {
                            add = false;
                        }

                        if (add)
                        {
                            ActivityConfig.ACSeriesRow[] seriesSteps = (ActivityConfig.ACSeriesRow[])FM.AtMng.acMng.DB.ACSeries.Select("Seriesid=" + sr.SeriesId.ToString(), "seq,stepcode");
                            foreach (ActivityConfig.ACSeriesRow acsr in seriesSteps)
                            {
                                atriumDB.ActivityRow arp = null;
                                bool addstep             = false;
                                if (acsr.Start)
                                {
                                    if (acdr.LinkType == (int)ConnectorType.Enable)
                                    {
                                        //need to track parent process here
                                        addstep = true;
                                    }
                                    if (acdr.LinkType == (int)ConnectorType.Transfer)
                                    {
                                        //need to track parent process here
                                        addstep = true;
                                        arp     = ar;
                                        if (!fileProcesses.ContainsKey(arp.ProcessId))
                                        {
                                            arp = null;
                                        }
                                    }
                                    if (acdr.LinkType == (int)ConnectorType.Disable)
                                    {
                                        //need to track parent process here
                                        addstep = false;

                                        //remove next step
                                        if (enabledSeries.NextSteps.ContainsKey(acsr.ACSeriesId))
                                        {
                                            enabledSeries.NextSteps.Remove(acsr.ACSeriesId);
                                        }
                                        //remove series
                                        if (enabledProcesses.ContainsKey(sr.SeriesId))
                                        {
                                            enabledProcesses.Remove(sr.SeriesId);
                                        }
                                    }
                                    if (addstep)
                                    {
                                        //check filetype rule
                                        //addstep = AllowForFileType(acsr,myFM);
                                        addstep = Allowed(acsr, myFM.AtMng, myFM);
                                    }

                                    //if ok add
                                    if (addstep && !enabledSeries.NextSteps.ContainsKey(acsr.ACSeriesId))
                                    {
                                        NextStep ns = new NextStep();
                                        ns.acs     = acsr;
                                        ns.Enabled = IsEnabled(acsr);
                                        if (arp == null)
                                        {
                                            ns.prevAc = null;
                                        }
                                        else
                                        {
                                            ns.prevAc = arp;
                                        }

                                        enabledSeries.NextSteps.Add(acsr.ACSeriesId, ns);

                                        //recurse check for next steps
                                        if (acsr.StepType != (int)StepType.Activity && acsr.GetACDependencyRowsByNextSteps().Length > 0)
                                        {
                                            CurrentFlow newFlow = new CurrentFlow();
                                            newFlow.Series = acsr.SeriesRow;
                                            ns.Children    = newFlow;
                                            NextSteps(newFlow, acsr, arp);
                                        }
                                    }
                                }
                            }
                        }
                        if (enabledSeries.NextSteps.Count > 0 && !enabledProcesses.ContainsKey(sr.SeriesId))
                        {
                            enabledProcesses.Add(sr.SeriesId, enabledSeries);
                        }
                    }
                }
            }
            foreach (CurrentFlow ap in enabledProcesses.Values)
            {
                BuildOKToAdd(ap);
            }
            return(enabledProcesses);
        }
Exemple #8
0
        private void NextSteps(ActivityConfig.ACSeriesRow nextStep, CurrentFlow ap, atriumDB.ActivityRow prevAc, ActivityConfig.ACDependencyRow acdr)
        {
            bool add = true;

            bool pause = false;

            //do not add step if it is not a next step or answer
            if (acdr.LinkType != (int)ConnectorType.NextStep & acdr.LinkType != (int)ConnectorType.Answer)
            {
                add = false;
            }

            //check filetype rule

            if (!AllowForFileType(nextStep, myFM))
            {
                add = false;
            }
            //}

            //do not add step if it is a disable link
            //if (acdr.LinkType==(int)ConnectorType.Disable)
            //    add = false;


            //if ((StepType)nextStep.StepType == StepType.Activity)
            //{
            //check role
            bool enable = IsEnabled(nextStep);

            if (acdr.LinkType == (int)ConnectorType.Enable)
            {
                //exclude processes that violate instance rules - onceperfile,singleinstanceperfile
                ActivityConfig.SeriesRow sr = nextStep.SeriesRow;
                if (sr.OncePerFile & fileProcesses.ContainsValue(sr.SeriesId))
                {
                    add = false;
                }

                if (sr.SingleInstancePerFile & activeProcesses.ContainsValue(sr.SeriesId))
                {
                    add = false;
                }
            }

            //do not add steps from an exclusive switch if we have taken one path
            //this gets handled by the bf rule if there is a bf
            //do not add step if bf to it is completed
            //
            if (prevAc != null && !acdr.IsACBFIdNull())
            {
                atriumDB.ActivityBFRow[] abfr = (atriumDB.ActivityBFRow[])myFM.DB.ActivityBF.Select("Activityid=" + prevAc.ActivityId.ToString() + "and ACDepId=" + acdr.ACDependencyId + " and ACBFId=" + acdr.ACBFId.ToString());

                if (abfr.Length > 0)
                {
                    if (abfr[0].Completed)
                    {
                        add = false;
                    }
//need to find a better more flexible mechanism than '100 days'
//                    else if (abfr[0].BFDate > DateTime.Today.AddDays(100))
//                        add = false;
                }
                else
                {
                    //TFS#54408 CJW 2013-09-16 don't add next step if precursor bf is not on file
                    //TODO: maybe we don't need this here after all?
                    //may be we do!!!!!!!!!!!!!!!!!!
                    add = false;
                }
            }

            //check to see if process is paused
            if (prevAc != null && prevAc.ProcessRow.Paused)
            {
                pause = true;
            }

            //?do not add step if it is unique in process and has been done already?
            if (ap.Process != null && nextStep.OnceOnly & myFM.DB.Activity.Select("ProcessID=" + ap.Process.ProcessId.ToString() + " and ACSeriesID=" + acdr.NextStepId.ToString()).Length > 0)
            {
                add = false;
            }

            if (add)
            {
                NextStep ns = new NextStep();

                if (!acdr.IsDescEngNull())
                {
                    //if it is the first step in a subprocess don't add the link text
                    if (!nextStep.Start)
                    {
                        ns.LinkText = acdr["Desc" + myFM.AppMan.Language] + ": ";
                    }
                }
                ns.acs     = nextStep;
                ns.prevAc  = prevAc;
                ns.Enabled = enable;
                ns.Paused  = pause;
                if (ns.Paused)
                {
                    ns.Enabled = false;
                }
                if (flowQ != null)
                {
                    ns.FlowQ = new Stack <ParentChildStep>(flowQ);
                }

                bool merged = false;
                if (ap.NextSteps.ContainsKey(ns.acs.ACSeriesId))
                {
                    currentAP = topAP;
                    merged    = true;
                }
                else
                {
                    ap.NextSteps.Add(ns.acs.ACSeriesId, ns);
                }

                if (ap.NextSteps.Count == 1)
                {
                    ap.Series = ns.acs.SeriesRow;
                }

                if (ap.Process != null && ap.Process.SeriesId != ap.Series.SeriesId)
                {
                    ap.NewSeries = true;
                }

                if ((StepType)ns.acs.StepType != StepType.Activity)
                {
                    CurrentFlow apNew = new CurrentFlow();
                    apNew.Process = ap.Process;
                    ns.Children   = apNew;
                    if (nextStep.StepType == (int)StepType.Branch)
                    {
                        currentAP = apNew;
                    }

                    if ((StepType)ns.acs.StepType == StepType.Subseries)
                    {
                        if (flowQ == null)
                        {
                            flowQ = new Stack <ParentChildStep>();
                        }
                        //apNew.Process = null;

                        //drill into sub process
                        //find start ac series
                        //
                        lmDatasets.ActivityConfig.ACSeriesRow subStart = null;

                        //CJW 2013-6-18 added obsolete = false see PITS#41039
                        subStart = (lmDatasets.ActivityConfig.ACSeriesRow)FM.AtMng.acMng.DB.ACSeries.Select("Start = true and obsolete= false and SeriesID=" + ns.acs.SubseriesId.ToString())[0];

                        ParentChildStep pcs = new ParentChildStep();
                        pcs.ParentStep = ns.acs;
                        pcs.ChildStep  = subStart.SeriesRow;

                        flowQ.Push(pcs);

                        NextSteps(subStart, apNew, prevAc, acdr);

                        flowQ.Pop();

                        if (apNew.NextSteps.Count == 0)
                        {
                            //sub process is complete
                            //goto next step from subseries
                            NextSteps(apNew, nextStep, prevAc);
                        }
                        else
                        {
                            //sub process is active
                        }
                    }
                    else
                    {
                        //drilldown thru flow-tree
                        if (ns.acs.StepType == (int)StepType.Merge)
                        {
                            //check to see if the merge condition is met
                            if (merged)
                            {
                                ap.NextSteps.Clear();

                                NextSteps(ap, nextStep, prevAc);
                            }
                        }
                        else
                        {
                            NextSteps(apNew, nextStep, prevAc);
                            currentAP = topAP;
                        }
                    }
                }
            }
        }
Exemple #9
0
        public void CreateAC(int acseriesId, DateTime acDate, string ctxTable, int ctxId, int revId, ACEngine.RevType revType)
        {
            //get context process
            atriumDB.ProcessRow pr = null;
            if (ctxTable != null)
            {
                foreach (atriumDB.ProcessContextRow pcr in FM.DB.ProcessContext)
                {
                    if (pcr.LinkTable == ctxTable && pcr.LinkId == ctxId)
                    {
                        pr = pcr.ProcessRow;
                        break;
                    }
                }
            }
            ActivityConfig.ACSeriesRow acsr = FM.AtMng.acMng.DB.ACSeries.FindByACSeriesId(acseriesId);

            AcSeriesOKToAdd.Clear();
            Dictionary <int, atriumBE.CurrentFlow> activeProcesses = this.Workflow.NextSteps();

            Workflow.EnabledProcesses();
            Workflow.AvailableProcesses();

            if (AcSeriesOKToAdd.Contains(acsr))
            {
                //atriumDB.ActivityRow prevAc = null;
                NextStep ns = null;
                foreach (atriumBE.CurrentFlow ap in activeProcesses.Values)
                {
                    ns = LoadNextSteps(acseriesId, ap);
                    //test for process match
                    if (ns != null)
                    {
                        bool match = TestForProcessMatch(pr, ns.prevAc);

                        if (ns != null && ns.prevAc != null && match)
                        {
                            break;
                        }
                    }
                }

                if (ns == null || ns.prevAc == null)
                {
                    activeProcesses = this.Workflow.EnabledProcesses();
                    foreach (atriumBE.CurrentFlow ap in activeProcesses.Values)
                    {
                        ns = LoadNextSteps(acseriesId, ap);
                        if (ns != null)
                        {
                            bool match = TestForProcessMatch(pr, ns.prevAc);
                            if (ns != null && ns.prevAc != null && match)
                            {
                                break;
                            }
                        }
                    }
                }

                this.DoAutoAC(ns, acsr, revId, revType, acDate);
            }
            else
            {
                throw new AtriumException("You cannot perform this activity on this file");
            }
        }
Exemple #10
0
 //TFS#54543 BY 2013-8-29
 //made the function overloading so that we can set the activitydate
 public void DoAutoAC(NextStep ns, ActivityConfig.ACSeriesRow asr, int revId, ACEngine.RevType revType)
 {
     DoAutoAC(ns, asr, revId, revType, DateTime.Today);
 }