///<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();
        }
Beispiel #2
0
        ///<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);
        }
Beispiel #3
0
        ///<summary>Process all Signals and Acks Since a given DateTime.  Only to be used by OpenDentalWebService.
        ///Returns latest valid signal Date/Time and the list of InvalidTypes that were refreshed.
        ///Can throw exception.</summary>
        public static List <InvalidType> RefreshForWeb()
        {
            int defaultProcessSigsIntervalInSecs = 7;

            ODException.SwallowAnyException(() => defaultProcessSigsIntervalInSecs = PrefC.GetInt(PrefName.ProcessSigsIntervalInSecs));
            if (DateTime.Now.Subtract(_signalLastRefreshedWeb) <= TimeSpan.FromSeconds(defaultProcessSigsIntervalInSecs))
            {
                return(new List <InvalidType>());
            }
            InvalidType[] arrayInvalidTypes = new InvalidType[0];
            //No need to check RemotingRole; no call to db.
            try {
                if (_signalLastRefreshedWeb.Year < 1880)
                {
                    _signalLastRefreshedWeb = MiscData.GetNowDateTime();
                }
                arrayInvalidTypes = Signalods.GetInvalidTypesForWeb(Signalods.RefreshTimed(_signalLastRefreshedWeb));
                //Get all invalid types since given time and refresh the cache for those given invalid types.
                Cache.Refresh(arrayInvalidTypes);
            }
            catch (Exception e) {
                //Most likely cause for an exception here would be a thread collision between 2 consumers trying to refresh the cache at the exact same instant.
                //There is a chance that performing as subsequent refresh here would cause yet another collision but it's the best we can do without redesigning the entire cache pattern.
                Cache.Refresh(InvalidType.AllLocal);
                throw new Exception("Server cache may be invalid. Please try again. Error: " + e.Message);
            }
            finally {
                DateTime dateTimeNow = DateTime.Now;
                try {
                    dateTimeNow = OpenDentBusiness.MiscData.GetNowDateTime();
                }
                catch (Exception) { }
                _signalLastRefreshedWeb = dateTimeNow;
            }
            return(arrayInvalidTypes.ToList());
        }
Beispiel #4
0
        ///<summary>Upserts the InvalidType.SmsTextMsgReceivedUnreadCount signal which tells all client machines to update the received unread SMS
        ///message count.  There should only be max one of this signal IType in the database.</summary>
        public static List <SmsFromMobiles.SmsNotification> UpsertSmsNotification()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <SmsFromMobiles.SmsNotification> >(MethodBase.GetCurrentMethod()));
            }
            string command = "SELECT ClinicNum,COUNT(*) AS CountUnread FROM smsfrommobile WHERE SmsStatus=0 AND IsHidden=0 GROUP BY ClinicNum "
                             + "ORDER BY ClinicNum";
            List <SmsFromMobiles.SmsNotification> ret = Db.GetTable(command).AsEnumerable()
                                                        .Select(x => new SmsFromMobiles.SmsNotification()
            {
                ClinicNum = PIn.Long(x["ClinicNum"].ToString()),
                Count     = PIn.Int(x["CountUnread"].ToString()),
            }).ToList();
            //Insert as structured data signal so all workstations won't have to query the db to get the counts. They will get it directly from Signalod.MsgValue.
            string json = SmsFromMobiles.SmsNotification.GetJsonFromList(ret);

            //FKeyType SmsMsgUnreadCount is written to db as a string.
            command = "SELECT * FROM signalod WHERE IType=" + POut.Int((int)InvalidType.SmsTextMsgReceivedUnreadCount)
                      + " AND FKeyType='" + POut.String(KeyType.SmsMsgUnreadCount.ToString()) + "' ORDER BY SigDateTime DESC LIMIT 1";
            DataTable table = Db.GetTable(command);
            Signalod  sig   = Crud.SignalodCrud.TableToList(table).FirstOrDefault();

            if (sig != null && sig.MsgValue == json) //No changes, not need to insert a new signal.
            {
                return(ret);                         //Return the list of notifications, but do not update the existing signal.
            }
            Signalods.Insert(new Signalod()
            {
                IType      = InvalidType.SmsTextMsgReceivedUnreadCount,
                FKeyType   = KeyType.SmsMsgUnreadCount,
                MsgValue   = json,
                RemoteRole = RemotingClient.RemotingRole
            });
            return(ret);
        }
        ///<summary>Called by local practice db to query HQ for EService setup info. Must remain very lite and versionless. Will be used by signup portal.
        ///If HasClinics==true then any SignupOut.EServices entries where ClinicNum==0 are invalid and should be ignored.
        ///If HasClinics==false then SignupOut.EServices should only pay attention items where ClinicNum==0.
        ///This list is kept completely unfiltered by ClinicNum for forward compatibility reasons.
        ///The ClinicNum 0 items are always used by the Signup portal to determine default signup preferences.
        ///However, these items are only used for validation and billing in the case where HasClinics==true.</summary>
        public static EServiceSetup.SignupOut GetEServiceSetupFull(SignupPortalPermission permission, bool isSwitchClinicPref = false)
        {
            //Clinics will be stored in this order at HQ to allow signup portal to display them in proper order.
            List <Clinic> clinics = Clinics.GetDeepCopy().OrderBy(x => x.ItemOrder).ToList();

            if (PrefC.GetBool(PrefName.ClinicListIsAlphabetical))
            {
                clinics = clinics.OrderBy(x => x.Abbr).ToList();
            }
#if DEBUG
            bool isMockChanged = false;
            if (WebServiceMainHQProxy.MockWebServiceMainHQ == null)
            {
                WebServiceMainHQProxy.MockWebServiceMainHQ = new WebServiceMainHQMockDemo();
                isMockChanged = true;
            }
#endif
            EServiceSetup.SignupOut signupOut = ReadXml <EServiceSetup.SignupOut>
                                                (
                WebSerializer.DeserializePrimitiveOrThrow <string>
                (
                    GetWebServiceMainHQInstance().EServiceSetup
                    (
                        CreateWebServiceHQPayload
                        (
                            WriteXml(new EServiceSetup.SignupIn()
            {
                MethodNameInt = (int)EServiceSetup.SetupMethod.GetSignupOutFull,
                HasClinics    = PrefC.HasClinicsEnabled,
                //ClinicNum is not currently used as input.
                ClinicNum                 = 0,
                ProgramVersionStr         = PrefC.GetString(PrefName.ProgramVersion),
                SignupPortalPermissionInt = (int)permission,
                Clinics = clinics
                          .Select(x => new EServiceSetup.SignupIn.ClinicLiteIn()
                {
                    ClinicNum   = x.ClinicNum,
                    ClinicTitle = x.Abbr,
                    IsHidden    = x.IsHidden,
                }).ToList(),
                IsSwitchClinicPref = isSwitchClinicPref,
            }), eServiceCode.Undefined
                        )
                    )
                )
                                                );
#if DEBUG
            if (isMockChanged)
            {
                WebServiceMainHQProxy.MockWebServiceMainHQ = null;
            }
#endif
            //We just got the latest sync info from HQ so update the local db to reflect what HQ says is true.
            #region Reconcile Phones
            List <SmsPhone> listPhonesHQ = signupOut.Phones.Select(x => new SmsPhone()
            {
                ClinicNum        = x.ClinicNum,
                CountryCode      = x.CountryCode,
                DateTimeActive   = x.DateTimeActive,
                DateTimeInactive = x.DateTimeInactive,
                InactiveCode     = x.InactiveCode,
                PhoneNumber      = x.PhoneNumber,
            }).ToList();
            SmsPhones.UpdateOrInsertFromList(listPhonesHQ);
            #endregion
            #region Reconcile practice and clinics
            List <EServiceSetup.SignupOut.SignupOutSms> smsSignups = GetSignups <EServiceSetup.SignupOut.SignupOutSms>(signupOut, eServiceCode.IntegratedTexting);
            bool isCacheInvalid = false;
            bool isSmsEnabled   = false;
            if (PrefC.HasClinicsEnabled)              //Clinics are ON so loop through all clinics and reconcile with HQ.
            {
                List <Clinic> listClinicsAll = Clinics.GetDeepCopy();
                foreach (Clinic clinicDb in listClinicsAll)
                {
                    WebServiceMainHQProxy.EServiceSetup.SignupOut.SignupOutSms clinicSignup =
                        smsSignups.FirstOrDefault(x => x.ClinicNum == clinicDb.ClinicNum) ?? new WebServiceMainHQProxy.EServiceSetup.SignupOut.SignupOutSms()
                    {
                        //Not found so turn it off.
                        SmsContractDate = DateTime.MinValue,
                        MonthlySmsLimit = 0,
                        IsEnabled       = false,
                    };
                    Clinic clinicNew = clinicDb.Copy();
                    clinicNew.SmsContractDate = clinicSignup.SmsContractDate;
                    clinicNew.SmsMonthlyLimit = clinicSignup.MonthlySmsLimit;
                    isCacheInvalid           |= Clinics.Update(clinicNew, clinicDb);
                    isSmsEnabled |= clinicSignup.IsEnabled;
                }
            }
            else               //Clinics are off so ClinicNum 0 is the practice clinic.
            {
                WebServiceMainHQProxy.EServiceSetup.SignupOut.SignupOutSms practiceSignup =
                    smsSignups.FirstOrDefault(x => x.ClinicNum == 0) ?? new WebServiceMainHQProxy.EServiceSetup.SignupOut.SignupOutSms()
                {
                    //Not found so turn it off.
                    SmsContractDate = DateTime.MinValue,
                    MonthlySmsLimit = 0,
                    IsEnabled       = false,
                };
                isCacheInvalid
                    |= Prefs.UpdateDateT(PrefName.SmsContractDate, practiceSignup.SmsContractDate)
                       | Prefs.UpdateLong(PrefName.TextingDefaultClinicNum, 0)
                       | Prefs.UpdateDouble(PrefName.SmsMonthlyLimit, practiceSignup.MonthlySmsLimit);
                isSmsEnabled |= practiceSignup.IsEnabled;
            }
            #endregion
            #region Reconcile CallFire
            //Turn off CallFire if SMS has been activated.
            //This only happens the first time SMS is turned on and CallFire is still activated.
            if (isSmsEnabled && Programs.IsEnabled(ProgramName.CallFire))
            {
                Program callfire = Programs.GetCur(ProgramName.CallFire);
                if (callfire != null)
                {
                    callfire.Enabled = false;
                    Programs.Update(callfire);
                    Signalods.Insert(new Signalod()
                    {
                        IType = InvalidType.Providers
                    });
                    signupOut.Prompts.Add("Call Fire has been disabled. Cancel Integrated Texting and access program properties to retain Call Fire.");
                }
            }
            #endregion
            #region eConfirmations
            if (Prefs.UpdateBool(PrefName.ApptConfirmAutoSignedUp, IsEServiceActive(signupOut, eServiceCode.ConfirmationRequest)))
            {
                //HQ does not match the local pref. Make it match with HQ.
                isCacheInvalid = true;
                SecurityLogs.MakeLogEntry(Permissions.Setup, 0, "Automated appointment eConfirmations automatically changed by HQ.  Local pref set to "
                                          + IsEServiceActive(signupOut, eServiceCode.ConfirmationRequest).ToString() + ".");
            }
            #endregion
            if (isCacheInvalid)              //Something changed in the db. Alert other workstations and change this workstation immediately.
            {
                Signalods.Insert(new Signalod()
                {
                    IType = InvalidType.Prefs
                });
                Prefs.RefreshCache();
                Signalods.Insert(new Signalod()
                {
                    IType = InvalidType.Providers
                });
                Providers.RefreshCache();
                Clinics.RefreshCache();
            }
            return(signupOut);
        }
Beispiel #6
0
        ///<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);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
 ///<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);
 }