Beispiel #1
0
 ///<summary>Process all Signals and Acks Since a given DateTime.  Only to be used by OpenDentalWebService.  Returns latest valid signal Date/Time.  Can throw exception.</summary>
 public static void RefreshForWeb(ref DateTime sinceDateT)
 {
     //No need to check RemotingRole; no call to db.
     try {
         if (sinceDateT.Year < 1880)
         {
             sinceDateT = MiscData.GetNowDateTime();
         }
         //Get all invalid types since given time.
         List <int> itypes = Signalods.GetInvalidTypes(Signalods.RefreshTimed(sinceDateT));
         if (itypes.Count <= 0)
         {
             return;
         }
         string itypesStr = "";
         for (int i = 0; i < itypes.Count; i++)
         {
             if (i > 0)
             {
                 itypesStr += ",";
             }
             itypesStr += ((int)itypes[i]).ToString();
         }
         //Refresh the cache for the given invalid types.
         Cache.RefreshCache(itypesStr);
         sinceDateT = OpenDentBusiness.MiscData.GetNowDateTime();
     }
     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);
     }
 }
Beispiel #2
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()
        {
            InvalidTypeHistory.InitIfNecessary();
            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.
            List <Signalod> listSignals = new List <Signalod>();

            try {
                if (SignalLastRefreshedWeb.Year < 1880)                //First signals for this session so go back in time a bit.
                {
                    SignalLastRefreshedWeb = MiscData.GetNowDateTime().AddSeconds(-1);
                }
                listSignals = Signalods.RefreshTimed(SignalLastRefreshedWeb);
                if (listSignals.Count > 0)                  //Next lower bound is current upper bound.
                {
                    SignalLastRefreshedWeb = listSignals.Max(x => x.SigDateTime);
                }
                arrayInvalidTypes = Signalods.GetInvalidTypesForWeb(listSignals);
                //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);
                //Reset the last signal process time.
                DateTime dateTimeNow = DateTime.Now;
                ODException.SwallowAnyException(() => dateTimeNow = OpenDentBusiness.MiscData.GetNowDateTime());
                SignalLastRefreshedWeb = dateTimeNow;
                throw new Exception("Server cache may be invalid. Please try again. Error: " + e.Message);
            }
            InvalidTypeHistory.UpdateStatus(SignalLastRefreshedWeb, listSignals, arrayInvalidTypes);
            return(arrayInvalidTypes.ToList());
        }
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());
        }