Ejemplo n.º 1
0
        /// <summary>
        /// Tasks the clerk engine start.
        /// </summary>
        public override void StartEngine()
        {
            base.StartEngine();

            DateTime lastShutdown = (DateTime)SettingsProvider.Get("LastStopEngine", DateTime.MinValue);

            if (lastShutdown != DateTime.MinValue)
            {
                ForcedShutDownDetected(lastShutdown);
            }

            this.HeartBeat += AppContext_HeartBeat;

            bool startTaskActivity = (bool)SettingsProvider.Get("StartTaskEnabled", false);

            if (startTaskActivity == true)
            {
                TaskDescription taskDescription =
                    (TaskDescription)SettingsProvider.Get("StartTaskDescription", TaskDescription.Empty);
                if (taskDescription.IsNotEmpty())
                {
                    HandleNewTaskActivity(taskDescription, DateTime.Now);
                }

                taskDescription =
                    SettingsProvider.Get("StartTaskDescription2", TaskDescription.Empty) as TaskDescription;
                if (taskDescription != null && taskDescription.IsNotEmpty())
                {
                    HandleNewTaskActivity(taskDescription, DateTime.Now);
                }
            }

            BackupData();

            Trace.TraceInformation(
                "AppContext:TaskClerkEngineStart[TaskClerk has successfully started and is ready for user input.]");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tasks the clerk engine end.
        /// </summary>
        public override void StopEngine()
        {
            base.StopEngine();

            SettingsProvider.Set("AppEndTime", DateTime.Now, PersistHint.AcrossSessions);
            bool stopTaskActivity = (bool)SettingsProvider.Get("StopTaskEnabled", false);

            if (stopTaskActivity == true)
            {
                TaskDescription taskDescription =
                    (TaskDescription)SettingsProvider.Get("StopTaskDescription", TaskDescription.Empty);
                if (taskDescription.IsNotEmpty())
                {
                    HandleNewTaskActivity(taskDescription, DateTime.Now);
                }
            }
            Trace.TraceInformation("AppContext:TaskClerkEngineEnd[TaskClerk has successfully shutdown.]");
            Application.Exit();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Provides the business logic for handling a new TaskActivity
        /// </summary>
        /// <param name="taskDescription">The task description.</param>
        /// <param name="crossTabTaskDescription">The task description for cross tab.</param>
        /// <param name="effectiveDateTime">The effective date time.</param>
        public void HandleNewTaskActivity(TaskDescription taskDescription, TaskDescription crossTabTaskDescription, 
            DateTime effectiveDateTime)
        {
            if (taskDescription == null)
            {
                throw new ArgumentNullException("taskDescription");
            }

            if (taskDescription.IsNotEmpty())
            {
                // update SelectedTaskDescription
                SettingsProvider.Set(STRING_SELECTEDTASKDESCRIPTION, taskDescription, PersistHint.AcrossSessions);

                // Close off the current activity
                TaskActivity currentActivity =
                    (TaskActivity)SettingsProvider.Get(STRING_CURRENTTASK, TaskActivity.Empty);
                if (currentActivity.IsNotEmpty())
                {
                    if (currentActivity.EndDate == DateTime.MinValue)
                    {
                        currentActivity.EndDate = effectiveDateTime;
                        currentActivity.UserId = IdentityProvider.Principal.Identity.Name;
                        TaskActivitiesProvider.CompleteActivity(currentActivity);
                    }
                    SettingsProvider.Set(STRING_PREVIOUSTASK, currentActivity, PersistHint.AcrossSessions);
                }

                // create a new task activity
                TaskActivity newActivity = new TaskActivity(taskDescription, IdentityProvider.Principal.Identity.Name);
                newActivity.StartDate = effectiveDateTime;
                if(crossTabTaskDescription != null)
                    newActivity.CrosstabTaskDescription = crossTabTaskDescription;
                SettingsProvider.Set(STRING_CURRENTTASK, newActivity, PersistHint.AcrossSessions);
                TaskActivitiesProvider.BeginActivity(newActivity);

                if (taskDescription.IsEvent)
                {
                    // because the selected event is an event also close it off
                    newActivity.EndDate = newActivity.StartDate.AddSeconds(1);
                    newActivity.UserId = IdentityProvider.Principal.Identity.Name;
                    TaskActivitiesProvider.CompleteActivity(newActivity);
                    // now set the current activity to null
                    SettingsProvider.Set(STRING_CURRENTTASK, TaskActivity.Empty, PersistHint.AcrossSessions);
                }
                Trace.TraceInformation("AppContext:HandleNewTaskActivity");
            }
        }