///<summary>When user clicks on a colored light, they intend to ack it to turn it off. This acks all sigmessages with the specified index. ///This is in case multiple sigmessages have been created from different workstations. This acks them all in one shot. ///Must specify a time because you only want to ack sigmessages earlier than the last time this workstation was refreshed. ///A newer sigmessage would not get acked. If this seems slow, then I will need to check to make sure all these tables are properly indexed. ///Inserts a signal for every SigMessageNum that was updated.</summary> public static void AckButton(int buttonIndex, DateTime time) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), buttonIndex, time); return; } List <long> listSigMessageNums = new List <long>(); string command = "SELECT DISTINCT sigmessage.SigMessageNum FROM sigmessage " + "INNER JOIN sigelementdef ON (sigmessage.SigElementDefNumUser=sigelementdef.SigElementDefNum " + "OR sigmessage.SigElementDefNumExtra=sigelementdef.SigElementDefNum " + "OR sigmessage.SigElementDefNumMsg=sigelementdef.SigElementDefNum) " + "WHERE sigmessage.AckDateTime < " + POut.Date(new DateTime(1880, 1, 1), true) + " " + "AND MessageDateTime <= " + POut.DateT(time) + " " + "AND sigelementdef.LightRow=" + POut.Long(buttonIndex); DataTable table = Db.GetTable(command); if (table.Rows.Count == 0) { return; } listSigMessageNums = table.Select().Select(x => PIn.Long(x["SigMessageNum"].ToString())).ToList(); command = "UPDATE sigmessage SET AckDateTime = " + DbHelper.Now() + " " + "WHERE SigMessageNum IN (" + string.Join(",", listSigMessageNums) + ")"; Db.NonQ(command); listSigMessageNums.ForEach(x => Signalods.SetInvalid(InvalidType.SigMessages, KeyType.SigMessage, x)); }
///<summary>If there is nothing in _queueFeeUdpates, reset _hasTransStarted to false and return. ///If all items in _queueFeeUpdates are Inserts, do a bulk insert to save time. ///If all items in _queueFeeUpdates are Deletes, do a bulk delete to save time. ///Otherwise, we need to loop through the list of updates and save them to the db, as order matters for these operations. ///Set signalods invalid for each distinct fee schedule represented in _queueFeeUpdates and re-initialize the static cache used by the Fees class. ///Finally, set _hasTransStarted back to false and clear _queueFeeUpdates.</summary> public void SaveToDb() { if (_queueFeeUpdates == null || _queueFeeUpdates.Count == 0) { _hasTransStarted = false; return; } List <long> listFeeScheds = new List <long>(); if (_queueFeeUpdates.All(x => x.UpdateType == FeeUpdateType.Add)) //all updates are inserts, so do bulk insert { listFeeScheds = _queueFeeUpdates.Select(x => x.Fee.FeeSched).Distinct().ToList(); Fees.InsertMany(_queueFeeUpdates.Select(x => (Fee)x.Fee).ToList()); } else if (_queueFeeUpdates.All(x => x.UpdateType == FeeUpdateType.Remove)) //all updates are removes, so do bulk delete { listFeeScheds = _queueFeeUpdates.Select(x => x.Fee.FeeSched).Distinct().ToList(); Fees.DeleteMany(_queueFeeUpdates.Select(x => x.Fee.FeeNum).ToList()); } else //There is a mixture of Add, Removes, and Updates { listFeeScheds = Fees.UpdateFromCache(_queueFeeUpdates.ToList()); } foreach (long feeSched in listFeeScheds) { Signalods.SetInvalid(InvalidType.Fees, KeyType.FeeSched, feeSched); } Fees.InvalidateFeeSchedules(listFeeScheds); _hasTransStarted = false; _queueFeeUpdates = new ConcurrentQueue <FeeUpdate>(); //clear the list of updates }
public static void Update(MobileAppDevice device) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), device); return; } Crud.MobileAppDeviceCrud.Update(device); Signalods.SetInvalid(InvalidType.EClipboard); }
public static void Delete(long mobileAppDeviceNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), mobileAppDeviceNum); return; } WebTypes.PushNotificationUtils.CI_IsAllowedChanged(mobileAppDeviceNum, false); //deleting so always false Crud.MobileAppDeviceCrud.Delete(mobileAppDeviceNum); Signalods.SetInvalid(InvalidType.EClipboard); }
///<summary>Syncs the two lists in the database.</summary> public static void Sync(List <MobileAppDevice> listDevicesNew, List <MobileAppDevice> listDevicesDb) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), listDevicesNew, listDevicesDb); return; } if (Crud.MobileAppDeviceCrud.Sync(listDevicesNew, listDevicesDb)) { Signalods.SetInvalid(InvalidType.EClipboard); } }
///<summary>Keeps MobileAppDevice table current so we know which patient is on which device and for how long.</summary> public static void SetPatNum(long mobileAppDeviceNum, long patNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), mobileAppDeviceNum, patNum); return; } string command = "UPDATE mobileappdevice SET PatNum=" + POut.Long(patNum) + ",LastCheckInActivity=" + POut.DateT(DateTime.Now) + " WHERE MobileAppDeviceNum=" + POut.Long(mobileAppDeviceNum); Db.NonQ(command); Signalods.SetInvalid(InvalidType.EClipboard); }
///<summary>Also sets primary key and DateTcreated.</summary> public static long Insert(WebChatSession webChatSession) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { webChatSession.WebChatSessionNum = Meth.GetLong(MethodBase.GetCurrentMethod(), webChatSession); return(webChatSession.WebChatSessionNum); } WebChatMisc.DbAction(delegate() { Crud.WebChatSessionCrud.Insert(webChatSession); }); WebChatMisc.DbAction(delegate() { Signalods.SetInvalid(InvalidType.WebChatSessions); //Signal OD HQ to refresh sessions. }, false); return(webChatSession.WebChatSessionNum); }
public static void SetQueueForExtension(int extension, AsteriskQueues asteriskQueue) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), extension, asteriskQueue); return; } //Update the phone table so that the PhoneTrackingServer knows what queue to put this extension into. string command = "UPDATE phone SET RingGroups=" + POut.Int((int)asteriskQueue) + " " + "WHERE Extension=" + POut.Int(extension); Db.NonQ(command); //Create a custom signalod so that the queue system (new way of doing ring groups) knows how to handle this extension. Signalods.SetInvalid(InvalidType.PhoneAsteriskReload, KeyType.PhoneExtension, (long)extension); }
///<summary>Used to set the patient for a kiosk, to either load a patient or pass in patNum==0 to clear a patient. Does nothing if termNum is not ///a valid TerminalActiveNum.</summary> public static void SetPatNum(long termNum, long patNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), termNum, patNum); return; } if (termNum < 1) { return; //invalid TerminalActiveNum, just return } string command = "UPDATE terminalactive SET PatNum=" + POut.Long(patNum) + " WHERE TerminalActiveNum=" + POut.Long(termNum); Db.NonQ(command); Signalods.SetInvalid(InvalidType.EClipboard); }
public static void Update(WebChatSession webChatSession, WebChatSession oldWebChatSession, bool hasSignal = true) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), webChatSession, oldWebChatSession, hasSignal); return; } WebChatMisc.DbAction(delegate() { Crud.WebChatSessionCrud.Update(webChatSession, oldWebChatSession); }); if (hasSignal) { WebChatMisc.DbAction(delegate() { Signalods.SetInvalid(InvalidType.WebChatSessions); //Signal OD HQ to refresh sessions. }, false); } }
///<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(); } }
///<summary>DateType and ObjectType to None, the TaskListStatus to 1 - Archived, ///and set all Task List Inboxes that reference this Task List to 0.</summary> public static void Archive(TaskList taskList) { //No need to check RemotingRole; no call to db. if (taskList.TaskListStatus != TaskListStatusEnum.Active) { return; } TaskList taskListOld = taskList.Copy(); taskList.DateType = TaskDateType.None; taskList.DateTL = DateTime.MinValue; taskList.ObjectType = TaskObjectType.None; taskList.TaskListStatus = TaskListStatusEnum.Archived; Update(taskList, taskListOld); Userods.DisassociateTaskListInBox(taskList.TaskListNum); Signalods.SetInvalid(InvalidType.Security); //Send a signal in case any userod was associated to the task list. }
///<summary>This can be used to delete a specific terminalactive by computer name, session ID and process ID, e.g. when the terminal window closes ///or when the delete button is pressed in the terminal manager window. Also used to clear any left over terminalactives when starting a terminal ///for a specific computer and session, in which case you can supply a process ID to exclude so the current terminal won't be deleted but all ///others for the computer and session will be. ComputerName is case-insensitive.</summary> public static void DeleteForCmptrSessionAndId(string computerName, int sessionId, int processId = 0, int excludeId = 0) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), computerName, sessionId, processId, excludeId); return; } string command = "DELETE FROM terminalactive WHERE ComputerName='" + POut.String(computerName) + "' AND SessionId=" + POut.Int(sessionId); if (processId > 0) { command += " AND ProcessId=" + POut.Int(processId); } if (excludeId > 0) { command += " AND ProcessId!=" + POut.Int(excludeId); } Db.NonQ(command); Signalods.SetInvalid(InvalidType.EClipboard); }
///<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(); }
///<summary>If carrierName is blank (empty string) this will throw an ApplicationException. If a carrier is not found with the exact name, ///including capitalization, a new carrier is created, inserted in the database, and returned.</summary> public static Carrier GetByNameAndPhone(string carrierName, string phone, bool updateCacheIfNew = false) { //No need to check RemotingRole; no call to db. if (string.IsNullOrEmpty(carrierName)) { throw new ApplicationException("Carrier cannot be blank"); } Carrier carrier = GetFirstOrDefault(x => x.CarrierName == carrierName && x.Phone == phone); if (carrier == null) { carrier = new Carrier(); carrier.CarrierName = carrierName; carrier.Phone = phone; Insert(carrier); //Insert function takes care of logging. if (updateCacheIfNew) { Signalods.SetInvalid(InvalidType.Carriers); RefreshCache(); } } return(carrier); }
///<summary>Kicks all of the occupants within the passed in conference room.</summary> public static void KickConfRoom(long confRoomExtension) { //No need to check RemotingRole; no call to db. Signalods.SetInvalid(InvalidType.PhoneAsteriskReload, KeyType.ConfKick, confRoomExtension); }
///<summary>Updates writeoff estimated for claimprocs for the passed in clinics. Called only in FormFeeSchedTools, located here to allow unit ///testing. Requires an ODProgressExtended to display UI updates. If clinics are enabled and the user is not clinic restricted and chooses to run ///for all clinics, set doUpdatePrevClinicPref to true so that the ClinicNums will be stored in the preference table as they are finished to allow ///for pausing/resuming the process.</summary> public static long GlobalUpdateWriteoffs(List <long> listWriteoffClinicNums, ODProgressExtended progress, bool doUpdatePrevClinicPref = false) { //No need to check RemotingRole; no call to db. long totalWriteoffsUpdated = 0; List <Fee> listFeesHQ = Fees.GetByClinicNum(0);//All HQ fees Dictionary <long, List <Procedure> > dictPatProcs; List <FamProc> listFamProcs; Dictionary <long, List <ClaimProc> > dictClaimProcs; List <Fee> listFeesHQandClinic; Lookup <FeeKey2, Fee> lookupFeesByCodeAndSched; List <InsSub> listInsSubs; List <InsPlan> listInsPlans; List <PatPlan> listPatPlans; List <Benefit> listBenefits; List <Action> listActions; //Get all objects needed to check if procedures are linked to an orthocase here to avoid querying in loops. List <OrthoProcLink> listOrthoProcLinksAll = new List <OrthoProcLink>(); Dictionary <long, OrthoProcLink> dictOrthoProcLinksAll = new Dictionary <long, OrthoProcLink>(); Dictionary <long, OrthoCase> dictOrthoCases = new Dictionary <long, OrthoCase>(); Dictionary <long, OrthoSchedule> dictOrthoSchedules = new Dictionary <long, OrthoSchedule>(); OrthoCases.GetDataForAllProcLinks(ref listOrthoProcLinksAll, ref dictOrthoProcLinksAll, ref dictOrthoCases, ref dictOrthoSchedules); OrthoProcLink orthoProcLink = null; OrthoCase orthoCase = null; OrthoSchedule orthoSchedule = null; List <OrthoProcLink> listOrthoProcLinksForOrthoCase = null; foreach (long clinicNumCur in listWriteoffClinicNums) { progress.Fire(ODEventType.FeeSched, new ProgressBarHelper(Clinics.GetAbbr(clinicNumCur), "0%", 0, 100, ProgBarStyle.Blocks, "WriteoffProgress")); long rowCurIndex = 0; //reset for each clinic. object lockObj = new object(); //used to lock rowCurIndex so the threads will correctly increment the count progress.Fire(ODEventType.FeeSched, new ProgressBarHelper(Lans.g("FeeSchedEvent", "Getting list to update writeoffs..."), progressBarEventType: ProgBarEventType.TextMsg)); listFeesHQandClinic = Fees.GetByClinicNum(clinicNumCur); //could be empty for some clinics that don't use overrides listFeesHQandClinic.AddRange(listFeesHQ); lookupFeesByCodeAndSched = (Lookup <FeeKey2, Fee>)listFeesHQandClinic.ToLookup(x => new FeeKey2(x.CodeNum, x.FeeSched)); dictPatProcs = Procedures.GetAllTp(clinicNumCur) .GroupBy(x => x.PatNum) .ToDictionary(x => x.Key, x => Procedures.SortListByTreatPlanPriority(x.ToList()).ToList()); #region Has Paused or Cancelled while (progress.IsPaused) { progress.AllowResume(); if (progress.IsCanceled) { break; } } if (progress.IsCanceled) { break; } #endregion Has Paused or Cancelled if (dictPatProcs.Count == 0) { continue; } int procCount = dictPatProcs.Sum(x => x.Value.Count); listFamProcs = Patients.GetFamilies(dictPatProcs.Keys.ToList()).Where(x => x.Guarantor != null) .Select(x => new FamProc { GuarNum = x.Guarantor.PatNum, ListPatProcs = x.ListPats.Select(y => new PatProc { PatNum = y.PatNum, Age = y.Age, ListProcs = dictPatProcs.TryGetValue(y.PatNum, out List <Procedure> listProcsCurr)?listProcsCurr:new List <Procedure>() }).ToList() }).ToList(); listPatPlans = PatPlans.GetPatPlansForPats(dictPatProcs.Keys.ToList()); listInsSubs = InsSubs.GetListInsSubs(dictPatProcs.Keys.ToList()); List <long> listInsSubNums = listInsSubs.Select(x => x.InsSubNum).ToList(); listInsSubs.AddRange(InsSubs.GetMany(listPatPlans.Select(x => x.InsSubNum).Distinct().Where(x => !listInsSubNums.Contains(x)).ToList())); listInsSubs = listInsSubs.DistinctBy(x => x.InsSubNum).ToList(); listInsPlans = InsPlans.RefreshForSubList(listInsSubs); listBenefits = Benefits.GetAllForPatPlans(listPatPlans, listInsSubs); #region Has Paused or Cancelled while (progress.IsPaused) { progress.AllowResume(); if (progress.IsCanceled) { break; } } if (progress.IsCanceled) { break; } #endregion Has Paused or Cancelled //dictionary of key=PatNum, value=list of claimprocs, i.e. a dictionary linking each PatNum to a list of claimprocs for the given procs dictClaimProcs = ClaimProcs.GetForProcs(dictPatProcs.SelectMany(x => x.Value.Select(y => y.ProcNum)).ToList(), useDataReader: true) .GroupBy(x => x.PatNum) .ToDictionary(x => x.Key, x => x.ToList()); #region Has Paused or Cancelled while (progress.IsPaused) { progress.AllowResume(); if (progress.IsCanceled) { break; } } if (progress.IsCanceled) { break; } #endregion Has Paused or Cancelled progress.Fire(ODEventType.FeeSched, new ProgressBarHelper(Lans.g("FeeSchedEvent", "Updating writeoff estimates for patients..."), progressBarEventType: ProgBarEventType.TextMsg)); listActions = listFamProcs.Select(x => new Action(() => { #region Has Cancelled if (progress.IsCanceled) { return; } #endregion Has Cancelled List <long> listPatNums = x.ListPatProcs.Select(y => y.PatNum).ToList(); List <long> listInsSubNumsPatPlanCur = listPatPlans.Where(y => y.PatNum.In(listPatNums)).Select(y => y.InsSubNum).ToList(); List <InsSub> listInsSubsCur = listInsSubs.FindAll(y => listPatNums.Contains(y.Subscriber) || y.InsSubNum.In(listInsSubNumsPatPlanCur)); List <long> listInsSubPlanNumsCur = listInsSubsCur.Select(y => y.PlanNum).ToList(); List <InsPlan> listInsPlansCur = listInsPlans.FindAll(y => listInsSubPlanNumsCur.Contains(y.PlanNum)); List <SubstitutionLink> listSubstitutionLinks = SubstitutionLinks.GetAllForPlans(listInsPlansCur); List <PatPlan> listPatPlansCur; List <Benefit> listBenefitsCur; foreach (PatProc patProc in x.ListPatProcs) //foreach patient in the family { if (patProc.ListProcs.IsNullOrEmpty()) { continue; } listPatPlansCur = listPatPlans.FindAll(y => y.PatNum == patProc.PatNum); List <long> listInsPlanNumsCur = listInsPlansCur.Select(y => y.PlanNum).ToList(); List <long> listPatPlanNumsCur = listPatPlansCur.Select(y => y.PatPlanNum).ToList(); listBenefitsCur = listBenefits .FindAll(y => listInsPlanNumsCur.Contains(y.PlanNum) || listPatPlanNumsCur.Contains(y.PatPlanNum)); listBenefitsCur.Sort(Benefits.SortBenefits); if (!dictClaimProcs.TryGetValue(patProc.PatNum, out List <ClaimProc> listClaimProcsCur)) { listClaimProcsCur = new List <ClaimProc>(); } foreach (Procedure procCur in patProc.ListProcs) //foreach proc for this patient { OrthoCases.FillOrthoCaseObjectsForProc(procCur.ProcNum, ref orthoProcLink, ref orthoCase, ref orthoSchedule , ref listOrthoProcLinksForOrthoCase, dictOrthoProcLinksAll, dictOrthoCases, dictOrthoSchedules, listOrthoProcLinksAll); Procedures.ComputeEstimates(procCur, patProc.PatNum, ref listClaimProcsCur, false, listInsPlansCur, listPatPlansCur, listBenefitsCur, null, null, true, patProc.Age, listInsSubsCur, listSubstLinks: listSubstitutionLinks, lookupFees: lookupFeesByCodeAndSched, orthoProcLink: orthoProcLink, orthoCase: orthoCase, orthoSchedule: orthoSchedule, listOrthoProcLinksForOrthoCase: listOrthoProcLinksForOrthoCase); double percentage = 0; lock (lockObj) { percentage = Math.Ceiling(((double)(++rowCurIndex) / procCount) * 100); } progress.Fire(ODEventType.FeeSched, new ProgressBarHelper(Clinics.GetAbbr(clinicNumCur), (int)percentage + "%", (int)percentage, 100, ProgBarStyle.Blocks, "WriteoffProgress")); } } })).ToList(); ODThread.RunParallel(listActions, TimeSpan.FromHours(3), onException: new ODThread.ExceptionDelegate((ex) => { //Notify the user what went wrong via the text box. progress.Fire(ODEventType.FeeSched, new ProgressBarHelper("Error updating writeoffs: " + ex.Message, progressBarEventType: ProgBarEventType.TextMsg)); }) ); if (listWriteoffClinicNums.Count > 1) //only show if more than one clinic { progress.Fire(ODEventType.FeeSched, new ProgressBarHelper(rowCurIndex + " " + Lans.g("FeeSchedTools", "procedures processed from") + " " + Clinics.GetAbbr(clinicNumCur), progressBarEventType: ProgBarEventType.TextMsg)); } totalWriteoffsUpdated += rowCurIndex; if (doUpdatePrevClinicPref && rowCurIndex == procCount) { //if storing previously completed clinic and we actually completed this clinic's procs, update the pref if (listWriteoffClinicNums.Last() == clinicNumCur) { //if this is the last clinic in the list, clear the last clinic pref so the next time it will run for all clinics Prefs.UpdateString(PrefName.GlobalUpdateWriteOffLastClinicCompleted, ""); } else { Prefs.UpdateString(PrefName.GlobalUpdateWriteOffLastClinicCompleted, POut.Long(clinicNumCur)); } Signalods.SetInvalid(InvalidType.Prefs); } #region Has Cancelled if (progress.IsCanceled) { break; } #endregion Has Cancelled } progress.OnProgressDone(); progress.Fire(ODEventType.FeeSched, new ProgressBarHelper("Writeoffs updated. " + totalWriteoffsUpdated + " procedures processed.\r\nDone.", progressBarEventType: ProgBarEventType.TextMsg)); return(totalWriteoffsUpdated); }
public static void SetRingGroups(int extension, AsteriskRingGroups ringGroups) { DataConnection dcon = new DataConnection("192.168.0.197", "asterisk", "opendental", "secret", DatabaseType.MySql); string command = "SELECT grpnum,grplist FROM ringgroups WHERE grpnum = '601' OR grpnum = '609'"; DataTable table = null; try { table = dcon.GetTable(command); } catch { //if remotely connecting from home return; } string rawExtensions601 = ""; string rawExtensions609 = ""; string[] arrayExtensions601 = new string[0]; string[] arrayExtensions609 = new string[0]; for (int i = 0; i < table.Rows.Count; i++) { if (table.Rows[i]["grpnum"].ToString() == "601") //there should always be exactly one { rawExtensions601 = table.Rows[i]["grplist"].ToString(); arrayExtensions601 = rawExtensions601.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); } if (table.Rows[i]["grpnum"].ToString() == "609") //there should always be exactly one { rawExtensions609 = table.Rows[i]["grplist"].ToString(); arrayExtensions609 = rawExtensions609.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); } } List <string> listExtension601 = new List <string>(); bool isIn601 = false; for (int i = 0; i < arrayExtensions601.Length; i++) { //we won't test to make sure each item is a pure number. listExtension601.Add(arrayExtensions601[i]); if (arrayExtensions601[i] == extension.ToString()) { isIn601 = true; } } List <string> listExtension609 = new List <string>(); bool isIn609 = false; for (int i = 0; i < arrayExtensions609.Length; i++) { //we won't test to make sure each item is a pure number. listExtension609.Add(arrayExtensions609[i]); if (arrayExtensions609[i] == extension.ToString()) { isIn609 = true; } } if (ringGroups == AsteriskRingGroups.All) { if (!isIn601) { AddToRingGroup("601", extension.ToString(), rawExtensions601); } if (!isIn609) { AddToRingGroup("609", extension.ToString(), rawExtensions609); } } if (ringGroups == AsteriskRingGroups.None) { if (isIn601) { RemoveFromRingGroup("601", extension.ToString(), listExtension601, rawExtensions601); } if (isIn609) { RemoveFromRingGroup("609", extension.ToString(), listExtension609, rawExtensions609); } } if (ringGroups == AsteriskRingGroups.Backup) { if (isIn601) { RemoveFromRingGroup("601", extension.ToString(), listExtension601, rawExtensions601); } if (!isIn609) { AddToRingGroup("609", extension.ToString(), rawExtensions609); } } Signalods.SetInvalid(InvalidType.PhoneAsteriskReload); }