Ejemplo n.º 1
0
        /// <summary>
        /// This method triggered based on given time interval(i.e MyDailyScheduleForMissingUpdates)
        /// This method will verifies whether any userbackend(s)/Request(s) missed update or not
        /// if any user(s)/Request(s) misses update then keep the messages into update trigger input queue in UpdateTriggerMsg Format.
        /// </summary>
        public static void CollectMissingUpdates([TimerTrigger(typeof(MyDailyScheduleForMissingUpdates))] TimerInfo timerInfo, TextWriter log)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                // InsightLogger.TrackStartEvent(callerMethodName);
                //foreach backend
                NextUserCollectingTimeDAL objnextcollectingTime = new NextUserCollectingTimeDAL();
                //get all the userbackends needs to update
                List <NextUserCollectingTimeEntity> lstbackends = objnextcollectingTime.GetBackendsNeedsUpdate();

                DateTime currentTimestampForMissedUpdates = DateTime.Now;
                Parallel.ForEach <NextUserCollectingTimeEntity>(lstbackends, backend =>
                {
                    InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: collect missing updates : start() , Response :: Backend Name : " + backend.BackendID);
                    //getting minutes difference between currenttime and Missing Update Next CollectingTime
                    TimeSpan tspan     = backend.MissingUpdateNextCollectingTime.Subtract(currentTimestampForMissedUpdates);
                    int waitingMinutes = tspan.Minutes;
                    //if minutes difference is with in RegularChecksWaitingTimeInMinutes(>=-8 and <=0) then invoke MissedUpdatesWaitingTimeInMinutes method()
                    if (waitingMinutes >= -(Convert.ToInt32(ConfigurationManager.AppSettings["MissedUpdatesWaitingTimeInMinutes"])) && waitingMinutes <= 0)
                    {
                        UserBackendDAL objUserBackendDAL = new UserBackendDAL();
                        //collects the missed update userbackends,Requests and convert into update trigger message format and put into UT input queue
                        objUserBackendDAL.CollectUsersMissedUpdatesByBackend(backend.BackendID, currentTimestampForMissedUpdates);
                        //update the backend entity with new missing update collecting time[i.e MissingUpdateLastCollectingTime= MissingUpdateNextCollectingTime and MissingUpdateNextCollectingTime=Max(]
                        objnextcollectingTime.UpdateMisseduserBackendNextCollectingTime(backend.BackendID, backend.MissingUpdateNextCollectingTime, DateTime.Now);
                        InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: collect missing updates : End() , Response :: Success, Backend Name : " + backend.BackendID);
                    }
                    else
                    {
                        InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: collect missing updates : End(), Response ::  next missing update collecting time of the backend [ " + backend.BackendID + " ] is greater-than to current time.");
                    }
                });
            }
            catch (BusinessLogicException balexception)
            {
                //write exception message to web job dashboard logs
                //log.WriteLine(balexception.Message);
                //write Business Logic Exception into application insights
                InsightLogger.Exception(balexception.Message, balexception, callerMethodName);
            }
            catch (DataAccessException dalexception)
            {
                //write exception message to web job dashboard logs
                //log.WriteLine(dalexception.Message);
                //write Data layer logic Exception into application insights
                InsightLogger.Exception(dalexception.Message, dalexception, callerMethodName);
            }
            catch (Exception exception)
            {
                // log.WriteLine("Error in adidas.clb.job.UpdateTriggering :: Functions :: RegularChecksforUserbackendLostsUpdate() :: Exception Message=" + exception.Message);
                //write  Exception into application insights
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method triggered based on given time interval(i.e MyDailyScheduleForRegularUpdates)
        /// This method will verifies whether the userbackends needs update or not based on UT RUle ,if it requires update then it will update the userbackend
        /// if any user needs update then  keep the messages into update trigger input queue in UpdateTriggerMsg Format.
        /// </summary>
        public static void CollectUsersNeedsUpdate([TimerTrigger(typeof(MyDailyScheduleForRegularUpdates))] TimerInfo timerInfo, TextWriter log)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();

                NextUserCollectingTimeDAL objnextcollentingTime = new NextUserCollectingTimeDAL();
                //get all the userbackends needs to update
                List <NextUserCollectingTimeEntity> lstbackends = objnextcollentingTime.GetBackendsNeedsUpdate();
                //foreach backend
                DateTime currentTimestamp = DateTime.Now;
                Parallel.ForEach <NextUserCollectingTimeEntity>(lstbackends, backend =>
                {
                    InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: collect users needing update : start(), Response :: Backend Name : " + backend.BackendID);
                    //getting minutes difference between currenttime and Regular Update Next CollectingTime
                    TimeSpan span = backend.RegularUpdateNextCollectingTime.Subtract(currentTimestamp);
                    int minutes   = span.Minutes;
                    //if minutes difference is with in RegularChecksWaitingTimeInMinutes(>=-5 and <=0) then invoke CollectUsersNeedUpdateByBackend method()
                    if (minutes >= -(Convert.ToInt32(ConfigurationManager.AppSettings["RegularChecksWaitingTimeInMinutes"])) && minutes <= 0)
                    {
                        UserBackendDAL objdal = new UserBackendDAL();
                        //collect the users needing update and keep the messages in update trigger input queue
                        objdal.CollectUsersNeedUpdateByBackend(backend.BackendID, currentTimestamp);
                        //update the backend entity with new collecting time[i.e LastCollectingTime= NextCollectingTime and NextCollectingTime=NextCollectingTime+(Backend MinimumusersUpdateFrequency)/2 ]
                        objnextcollentingTime.UpdateBackendRegularNextCollectingTime(backend.BackendID, backend.MinimumUpdateFrequency, backend.RegularUpdateNextCollectingTime);
                        InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: collect users needing update : End(), Response :: Success,  Backend Name : " + backend.BackendID);
                    }
                    else
                    {
                        InsightLogger.TrackEvent("UpdateTriggering, Action :: for each backend :: collect users needing update : End(), Response :: next collecting time of the backend [ " + backend.BackendID + " ] is greater-than to current time.");
                    }
                });
            }
            catch (BusinessLogicException balexception)
            {
                //write exception message to web job dashboard logs
                // log.WriteLine(balexception.Message);
                //write (Business Logic Exception into application insights
                InsightLogger.Exception(balexception.Message, balexception, callerMethodName);
            }
            catch (DataAccessException dalexception)
            {
                //write exception message to web job dashboard logs
                //log.WriteLine(dalexception.Message);
                //write Data Access Exception into application insights
                InsightLogger.Exception(dalexception.Message, dalexception, callerMethodName);
            }
            catch (Exception exception)
            {
                //  log.WriteLine("Error in adidas.clb.job.UpdateTriggering :: Functions :: RegularChecksforBackendNeedsUpdate() :: Exception Message=" + exception.Message);
                //write exception into application insights
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
            }
        }