Beispiel #1
0
            public static void WorkErrored( ref SchedulerClient objSchedulerClient, ref Exception objException )
            {
                try
                {
                    ScheduleHistoryItem objScheduleHistoryItem;
                    objScheduleHistoryItem = objSchedulerClient.ScheduleHistoryItem;
                    ///'''''''''''''''''''''''''''''''''''''''''''''''
                    //Remove the object in the ScheduleInProgress collection
                    ///'''''''''''''''''''''''''''''''''''''''''''''''
                    RemoveFromScheduleInProgress( objScheduleHistoryItem );

                    ///''''''''''''''''''''''''''''''''''''''''''''''''
                    //A SchedulerClient is notifying us that their
                    //process has errored.  Decrease our ActiveThreadCount
                    ///''''''''''''''''''''''''''''''''''''''''''''''''
                    Interlocked.Decrement( ref ActiveThreadCount );

                    Exceptions.Exceptions.ProcessSchedulerException( objException );

                    ///'''''''''''''''''''''''''''''''''''''''''''''''
                    //Update the schedule item object property
                    //to note the end time and next start
                    ///'''''''''''''''''''''''''''''''''''''''''''''''
                    objScheduleHistoryItem.EndDate = DateTime.Now;
                    if( objScheduleHistoryItem.ScheduleSource == ScheduleSource.STARTED_FROM_EVENT )
                    {
                        objScheduleHistoryItem.NextStart = Null.NullDate;
                    }
                    else if( objScheduleHistoryItem.RetryTimeLapse != Null.NullInteger )
                    {
                        switch( objScheduleHistoryItem.RetryTimeLapseMeasurement )
                        {
                            case "s":

                                objScheduleHistoryItem.NextStart = objScheduleHistoryItem.StartDate.AddSeconds( objScheduleHistoryItem.RetryTimeLapse );
                                break;
                            case "m":

                                objScheduleHistoryItem.NextStart = objScheduleHistoryItem.StartDate.AddMinutes( objScheduleHistoryItem.RetryTimeLapse );
                                break;
                            case "h":

                                objScheduleHistoryItem.NextStart = objScheduleHistoryItem.StartDate.AddHours( objScheduleHistoryItem.RetryTimeLapse );
                                break;
                            case "d":

                                objScheduleHistoryItem.NextStart = objScheduleHistoryItem.StartDate.AddDays( objScheduleHistoryItem.RetryTimeLapse );
                                break;
                        }
                    }
                    ///''''''''''''''''''''''''''''''''''''''''''''''''
                    //Update the ScheduleHistory in the database
                    ///''''''''''''''''''''''''''''''''''''''''''''''''
                    UpdateScheduleHistory( objScheduleHistoryItem );

                    if( objScheduleHistoryItem.NextStart != Null.NullDate && objScheduleHistoryItem.RetryTimeLapse != Null.NullInteger )
                    {
                        ///''''''''''''''''''''''''''''''''''''''''''''''''
                        //Put the object back into the ScheduleQueue
                        //collection with the new NextStart date.
                        ///''''''''''''''''''''''''''''''''''''''''''''''''
                        objScheduleHistoryItem.StartDate = Null.NullDate;
                        objScheduleHistoryItem.EndDate = Null.NullDate;
                        objScheduleHistoryItem.LogNotes = "";
                        objScheduleHistoryItem.ProcessGroup = - 1;
                        AddToScheduleQueue( objScheduleHistoryItem );
                    }

                    if( objSchedulerClient.ScheduleHistoryItem.RetainHistoryNum > 0 )
                    {
                        ///''''''''''''''''''''''''''''''''''''''''''''''''
                        //Write out the log entry for this event
                        ///''''''''''''''''''''''''''''''''''''''''''''''''
                        EventLogController objEventLog = new EventLogController();
                        LogInfo objEventLogInfo = new LogInfo();
                        objEventLogInfo.AddProperty( "THREAD ID", Thread.CurrentThread.GetHashCode().ToString() );
                        objEventLogInfo.AddProperty( "TYPE", objSchedulerClient.GetType().FullName );
                        if( objException != null )
                        {
                            objEventLogInfo.AddProperty( "EXCEPTION", objException.Message );
                        }
                        objEventLogInfo.AddProperty( "RESCHEDULED FOR", Convert.ToString( objScheduleHistoryItem.NextStart ) );
                        objEventLogInfo.AddProperty( "SOURCE", objSchedulerClient.ScheduleHistoryItem.ScheduleSource.ToString() );
                        objEventLogInfo.AddProperty( "ACTIVE THREADS", ActiveThreadCount.ToString() );
                        objEventLogInfo.AddProperty( "FREE THREADS", FreeThreads.ToString() );
                        objEventLogInfo.AddProperty( "READER TIMEOUTS", ReaderTimeouts.ToString() );
                        objEventLogInfo.AddProperty( "WRITER TIMEOUTS", WriterTimeouts.ToString() );
                        objEventLogInfo.AddProperty( "IN PROGRESS", GetScheduleInProgressCount().ToString() );
                        objEventLogInfo.AddProperty( "IN QUEUE", GetScheduleQueueCount().ToString() );
                        objEventLogInfo.LogTypeKey = "SCHEDULER_EVENT_FAILURE";
                        objEventLog.AddLog( objEventLogInfo );
                    }
                }
                catch( Exception exc )
                {
                    Exceptions.Exceptions.ProcessSchedulerException( exc );
                }
            }
Beispiel #2
0
            public static void WorkStarted( ref SchedulerClient objSchedulerClient )
            {
                bool ActiveThreadCountIncremented = false;
                try
                {
                    objSchedulerClient.ScheduleHistoryItem.ThreadID = Thread.CurrentThread.GetHashCode();

                    ///''''''''''''''''''''''''''''''''''''''''''''''''
                    //Put the object in the ScheduleInProgress collection
                    //and remove it from the ScheduleQueue
                    ///''''''''''''''''''''''''''''''''''''''''''''''''
                    RemoveFromScheduleQueue( objSchedulerClient.ScheduleHistoryItem );
                    AddToScheduleInProgress( objSchedulerClient.ScheduleHistoryItem );

                    ///''''''''''''''''''''''''''''''''''''''''''''''''
                    //A SchedulerClient is notifying us that their
                    //process has started.  Increase our ActiveThreadCount
                    ///''''''''''''''''''''''''''''''''''''''''''''''''
                    Interlocked.Increment( ref ActiveThreadCount );
                    ActiveThreadCountIncremented = true;

                    ///''''''''''''''''''''''''''''''''''''''''''''''''
                    //Update the schedule item
                    //object property to note the start time.
                    ///''''''''''''''''''''''''''''''''''''''''''''''''
                    objSchedulerClient.ScheduleHistoryItem.StartDate = DateTime.Now;
                    AddScheduleHistory( objSchedulerClient.ScheduleHistoryItem );

                    if( objSchedulerClient.ScheduleHistoryItem.RetainHistoryNum > 0 )
                    {
                        ///''''''''''''''''''''''''''''''''''''''''''''''''
                        //Write out the log entry for this event
                        ///''''''''''''''''''''''''''''''''''''''''''''''''
                        EventLogController objEventLog = new EventLogController();
                        LogInfo objEventLogInfo = new LogInfo();
                        objEventLogInfo.AddProperty( "THREAD ID", Thread.CurrentThread.GetHashCode().ToString() );
                        objEventLogInfo.AddProperty( "TYPE", objSchedulerClient.GetType().FullName );
                        objEventLogInfo.AddProperty( "SOURCE", objSchedulerClient.ScheduleHistoryItem.ScheduleSource.ToString() );
                        objEventLogInfo.AddProperty( "ACTIVE THREADS", ActiveThreadCount.ToString() );
                        objEventLogInfo.AddProperty( "FREE THREADS", FreeThreads.ToString() );
                        objEventLogInfo.AddProperty( "READER TIMEOUTS", ReaderTimeouts.ToString() );
                        objEventLogInfo.AddProperty( "WRITER TIMEOUTS", WriterTimeouts.ToString() );
                        objEventLogInfo.AddProperty( "IN PROGRESS", GetScheduleInProgressCount().ToString() );
                        objEventLogInfo.AddProperty( "IN QUEUE", GetScheduleQueueCount().ToString() );
                        objEventLogInfo.LogTypeKey = "SCHEDULER_EVENT_STARTED";
                        objEventLog.AddLog( objEventLogInfo );
                    }
                }
                catch( Exception exc )
                {
                    //Decrement the ActiveThreadCount because
                    //otherwise the number of active threads
                    //will appear to be climbing when in fact
                    //no tasks are being executed.
                    if( ActiveThreadCountIncremented )
                    {
                        Interlocked.Decrement( ref ActiveThreadCount );
                    }
                    Exceptions.Exceptions.ProcessSchedulerException( exc );
                }
            }
Beispiel #3
0
 public static void WorkProgressing( ref SchedulerClient objSchedulerClient )
 {
     try
     {
         ///''''''''''''''''''''''''''''''''''''''''''''''''
         //A SchedulerClient is notifying us that their
         //process is in progress.  Informational only.
         ///''''''''''''''''''''''''''''''''''''''''''''''''
         if( objSchedulerClient.ScheduleHistoryItem.RetainHistoryNum > 0 )
         {
             ///''''''''''''''''''''''''''''''''''''''''''''''''
             //Write out the log entry for this event
             ///''''''''''''''''''''''''''''''''''''''''''''''''
             EventLogController objEventLog = new EventLogController();
             LogInfo objEventLogInfo = new LogInfo();
             objEventLogInfo.AddProperty( "THREAD ID", Thread.CurrentThread.GetHashCode().ToString() );
             objEventLogInfo.AddProperty( "TYPE", objSchedulerClient.GetType().FullName );
             objEventLogInfo.AddProperty( "SOURCE", objSchedulerClient.ScheduleHistoryItem.ScheduleSource.ToString() );
             objEventLogInfo.AddProperty( "ACTIVE THREADS", ActiveThreadCount.ToString() );
             objEventLogInfo.AddProperty( "FREE THREADS", FreeThreads.ToString() );
             objEventLogInfo.AddProperty( "READER TIMEOUTS", ReaderTimeouts.ToString() );
             objEventLogInfo.AddProperty( "WRITER TIMEOUTS", WriterTimeouts.ToString() );
             objEventLogInfo.AddProperty( "IN PROGRESS", GetScheduleInProgressCount().ToString() );
             objEventLogInfo.AddProperty( "IN QUEUE", GetScheduleQueueCount().ToString() );
             objEventLogInfo.LogTypeKey = "SCHEDULER_EVENT_PROGRESSING";
             objEventLog.AddLog( objEventLogInfo );
         }
     }
     catch( Exception exc )
     {
         Exceptions.Exceptions.ProcessSchedulerException( exc );
     }
 }
Beispiel #4
0
            public static void WorkCompleted(SchedulerClient schedulerClient)
            {
                try
                {
                    ScheduleHistoryItem scheduleHistoryItem = schedulerClient.ScheduleHistoryItem;

                    //Remove the object in the ScheduleInProgress collection
                    RemoveFromScheduleInProgress(scheduleHistoryItem);

                    //A SchedulerClient is notifying us that their
                    //process has completed.  Decrease our ActiveThreadCount
                    Interlocked.Decrement(ref _activeThreadCount);

                    //Update the schedule item object property
                    //to note the end time and next start
                    scheduleHistoryItem.EndDate = DateTime.Now;

                    if (scheduleHistoryItem.ScheduleSource == ScheduleSource.STARTED_FROM_EVENT)
                    {
                        scheduleHistoryItem.NextStart = Null.NullDate;
                    }
                    else
                    {
                        if (scheduleHistoryItem.CatchUpEnabled)
                        {
                            switch (scheduleHistoryItem.TimeLapseMeasurement)
                            {
                                case "s":
                                    scheduleHistoryItem.NextStart = scheduleHistoryItem.NextStart.AddSeconds(scheduleHistoryItem.TimeLapse);
                                    break;
                                case "m":
                                    scheduleHistoryItem.NextStart = scheduleHistoryItem.NextStart.AddMinutes(scheduleHistoryItem.TimeLapse);
                                    break;
                                case "h":
                                    scheduleHistoryItem.NextStart = scheduleHistoryItem.NextStart.AddHours(scheduleHistoryItem.TimeLapse);
                                    break;
                                case "d":
                                    scheduleHistoryItem.NextStart = scheduleHistoryItem.NextStart.AddDays(scheduleHistoryItem.TimeLapse);
                                    break;
                            }
                        }
                        else
                        {
                            switch (scheduleHistoryItem.TimeLapseMeasurement)
                            {
                                case "s":
                                    scheduleHistoryItem.NextStart = scheduleHistoryItem.StartDate.AddSeconds(scheduleHistoryItem.TimeLapse);
                                    break;
                                case "m":
                                    scheduleHistoryItem.NextStart = scheduleHistoryItem.StartDate.AddMinutes(scheduleHistoryItem.TimeLapse);
                                    break;
                                case "h":
                                    scheduleHistoryItem.NextStart = scheduleHistoryItem.StartDate.AddHours(scheduleHistoryItem.TimeLapse);
                                    break;
                                case "d":
                                    scheduleHistoryItem.NextStart = scheduleHistoryItem.StartDate.AddDays(scheduleHistoryItem.TimeLapse);
                                    break;
                            }
                        }
                    }

                    //Update the ScheduleHistory in the database
                    UpdateScheduleHistory(scheduleHistoryItem);
                    var eventLogInfo = new LogInfo();

                    if (scheduleHistoryItem.NextStart != Null.NullDate)
                    {
                        //Put the object back into the ScheduleQueue
                        //collection with the new NextStart date.
                        scheduleHistoryItem.StartDate = Null.NullDate;
                        scheduleHistoryItem.EndDate = Null.NullDate;
                        scheduleHistoryItem.LogNotes = "";
                        scheduleHistoryItem.ProcessGroup = -1;
                        AddToScheduleQueue(scheduleHistoryItem);
                    }


                    if (schedulerClient.ScheduleHistoryItem.RetainHistoryNum > 0)
                    {
                        //Write out the log entry for this event
                        var objEventLog = new EventLogController();

                        eventLogInfo.AddProperty("TYPE", schedulerClient.GetType().FullName);
                        eventLogInfo.AddProperty("THREAD ID", Thread.CurrentThread.GetHashCode().ToString());
                        eventLogInfo.AddProperty("NEXT START", Convert.ToString(scheduleHistoryItem.NextStart));
                        eventLogInfo.AddProperty("SOURCE", schedulerClient.ScheduleHistoryItem.ScheduleSource.ToString());
                        eventLogInfo.AddProperty("ACTIVE THREADS", _activeThreadCount.ToString());
                        eventLogInfo.AddProperty("FREE THREADS", FreeThreads.ToString());
                        eventLogInfo.AddProperty("READER TIMEOUTS", _readerTimeouts.ToString());
                        eventLogInfo.AddProperty("WRITER TIMEOUTS", _writerTimeouts.ToString());
                        eventLogInfo.AddProperty("IN PROGRESS", GetScheduleInProgressCount().ToString());
                        eventLogInfo.AddProperty("IN QUEUE", GetScheduleQueueCount().ToString());
                        eventLogInfo.LogTypeKey = "SCHEDULER_EVENT_COMPLETED";
                        objEventLog.AddLog(eventLogInfo);
                    }
                }
                catch (Exception exc)
                {
                    Exceptions.Exceptions.ProcessSchedulerException(exc);
                }
            }