コード例 #1
0
        ///<summary>Returns true if the group the procedure belongs to is in process and the procedure status is set to "complete".
        ///If isAssumedComplete, then will pretend the procedure for procNum is complete regardless of current status.</summary>
        public static bool IsProcInProcess(long procNum, bool isAssumedComplete = false)
        {
            //No need to check RemotingRole; no call to db.
            ProcMultiVisit pmv = GetFirstOrDefault(x => x.ProcNum == procNum);

            //The existience of the procmultivisit in the cache means the procedure's group is In Process.
            if (pmv == null)
            {
                return(false);
            }
            //Now all we need to check is ProcStatus.
            if (isAssumedComplete)
            {
                List <ProcMultiVisit> listPmvs = GetWhere(x => x.GroupProcMultiVisitNum == pmv.GroupProcMultiVisitNum);            //Makes a deep copy.
                for (int i = 0; i < listPmvs.Count; i++)
                {
                    if (listPmvs[i].ProcNum == procNum)
                    {
                        listPmvs[i].ProcStatus = ProcStat.C;                      //We can safely change status directly, since GetWhere() returned a deep copy above.
                        break;
                    }
                }
                return(IsGroupInProcess(listPmvs));                  //Since are are assuming proc is complete, all we need to know is if the group would be in process or not.
            }
            return(pmv.IsInProcess && pmv.ProcStatus == ProcStat.C); //Part of an in process group and is complete.
        }
コード例 #2
0
 ///<summary>Does not send cache refresh signal.  Send the signal from calling code.</summary>
 public static long Insert(ProcMultiVisit procMultiVisit)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         procMultiVisit.ProcMultiVisitNum = Meth.GetLong(MethodBase.GetCurrentMethod(), procMultiVisit);
         return(procMultiVisit.ProcMultiVisitNum);
     }
     return(Crud.ProcMultiVisitCrud.Insert(procMultiVisit));
 }
コード例 #3
0
 ///<summary>Does not send cache refresh signal.  Send the signal from calling code.</summary>
 public static void Update(ProcMultiVisit procMultiVisit, ProcMultiVisit oldProcMultiVisit)
 {
     if (!Crud.ProcMultiVisitCrud.UpdateComparison(procMultiVisit, oldProcMultiVisit))
     {
         return;                //No changes.  Save middle tier call.
     }
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), procMultiVisit, oldProcMultiVisit);
         return;
     }
     Crud.ProcMultiVisitCrud.Update(procMultiVisit, oldProcMultiVisit);
 }
コード例 #4
0
        ///<summary>Responsible for updating procedures in the group to "In Process" or "Not In Process", depending on the stat passed in.
        ///Also sends signal to cause cache refresh.  Refreshes local cache for clients directly connected.</summary>
        public static void UpdateGroupForProc(long procNum, ProcStat stat)
        {
            //No need to check RemotingRole; no call to db.
            List <ProcMultiVisit> listPmvs = GetGroupsForProcsFromDb(procNum);
            ProcMultiVisit        pmv      = listPmvs.FirstOrDefault(x => x.ProcNum == procNum);

            if (pmv == null)
            {
                return;                //Rare edge case.  Might happen is someone deletes the procedure at the same time another person is updating it.
            }
            bool isGroupInProcessOld = IsGroupInProcess(listPmvs);

            if (stat == ProcStat.D)
            {
                //If the procedure is deleted, also delete the procvisitmulti to reduce clutter.
                listPmvs.Remove(pmv);                                                                 //Remove pmv from listpmvs.
                if (pmv.ProcMultiVisitNum == pmv.GroupProcMultiVisitNum && !listPmvs.IsNullOrEmpty()) //If the group points to the pmv to be removed and the group still exists.
                {
                    long replacementGPMVNum = listPmvs.First().ProcMultiVisitNum;
                    UpdateGroupProcMultiVisitNumForGroup(pmv.ProcMultiVisitNum, replacementGPMVNum);
                    foreach (ProcMultiVisit procMulti in listPmvs)                     //Replace all group numbers.
                    {
                        procMulti.GroupProcMultiVisitNum = replacementGPMVNum;
                    }
                }
                Delete(pmv.ProcMultiVisitNum);
            }
            else
            {
                ProcMultiVisit oldPmv = pmv.Copy();
                pmv.ProcStatus = stat;
                Update(pmv, oldPmv);
            }
            bool isGroupInProcess = IsGroupInProcess(listPmvs);

            if (isGroupInProcess != isGroupInProcessOld)
            {
                UpdateInProcessForGroup(pmv.GroupProcMultiVisitNum, isGroupInProcess);
            }
            //Always send a signal and refresh the cache in case someone else is going to edit the group soon.
            Signalods.SetInvalid(InvalidType.ProcMultiVisits);
            if (RemotingClient.RemotingRole == RemotingRole.ClientDirect)
            {
                RefreshCache();
            }
        }
コード例 #5
0
        ///<summary>Will not create a group if there are less than 2 items in listProcs.  Also sends signal and refreshes cache.</summary>
        public static void CreateGroup(List <Procedure> listProcs)
        {
            //No need to check RemotingRole; no call to db.
            if (listProcs.Count < 2)           //No reason to make a "group" with 0 or 1 items.
            {
                return;
            }
            List <ProcMultiVisit> listPmvs = new List <ProcMultiVisit>();

            for (int i = 0; i < listProcs.Count; i++)
            {
                ProcMultiVisit pmv = new ProcMultiVisit();
                pmv.ProcNum    = listProcs[i].ProcNum;
                pmv.ProcStatus = listProcs[i].ProcStatus;
                listPmvs.Add(pmv);
            }
            bool isGroupInProcess       = ProcMultiVisits.IsGroupInProcess(listPmvs);    //Could be in process if grouped procs which are different statuses via menu.
            long groupProcMultiVisitNum = 0;

            for (int i = 0; i < listPmvs.Count; i++)
            {
                ProcMultiVisit pmv = listPmvs[i];
                pmv.IsInProcess = isGroupInProcess;
                if (i == 0)
                {
                    groupProcMultiVisitNum = ProcMultiVisits.Insert(pmv);
                    ProcMultiVisit oldPmv = pmv.Copy();
                    pmv.GroupProcMultiVisitNum = groupProcMultiVisitNum;
                    ProcMultiVisits.Update(pmv, oldPmv);                   //Have to update after insert, or else we cannot know what the primary key is.
                }
                else
                {
                    pmv.GroupProcMultiVisitNum = groupProcMultiVisitNum;
                    ProcMultiVisits.Insert(pmv);
                }
            }
            Signalods.SetInvalid(InvalidType.ProcMultiVisits);
            RefreshCache();
        }