private void BuildTree(TaskDescription parent, TreeNode rootNode) { foreach (TaskDescription child in parent.Children) { TreeNode node = new TreeNode(child.Name); node.Tag = child; node.ToolTipText = child.Description; if (comboboxScheme.SelectedIndex == 0) { node.Checked = !child.IsPrivate; } if (comboboxScheme.SelectedIndex == 2) { node.Checked = true; } if (node.Checked) { _taskDescriptions.Add(child); } rootNode.Nodes.Add(node); if (child.Children.Count > 0) { BuildTree(child, node); } } }
private void RemoveItemFromList(TaskDescription taskDescription) { if (_taskDescriptions.Contains(taskDescription)) { _taskDescriptions.Remove(taskDescription); } labelTaskDescriptionsCount.Text = string.Format("{0} TaskDescriptions selected.", _taskDescriptions.Count); }
private void InsertItemInList(TaskDescription taskDescription) { if (!_taskDescriptions.Contains(taskDescription)) { _taskDescriptions.Add(taskDescription); } labelTaskDescriptionsCount.Text = string.Format("{0} TaskDescriptions selected.", _taskDescriptions.Count); }
/// <summary> /// Initializes a new instance of the <see cref="T:TaskActivity"/> class. /// </summary> /// <param name="taskDescription">The task description.</param> /// <param name="userId">The user id.</param> public TaskActivity(TaskDescription taskDescription, string userId) { id = Guid.NewGuid(); this.taskDescription = taskDescription; startDate = DateTime.Now; endDate = DateTime.MinValue; originalDate = DateTime.Now; UserId = userId; sourceMachine = Environment.MachineName; }
/// <summary> /// Initializes a new instance of the <see cref="T:TaskActivity"/> class. /// </summary> /// <param name="taskDescription">The task description.</param> /// <param name="userId">The user id.</param> public TaskActivity(TaskDescription taskDescription, string userId) { id = Guid.NewGuid(); this.taskDescription = taskDescription; startDate = DateTime.Now; endDate = DateTime.MinValue; originalDate = DateTime.Now; UserId = userId; sourceMachine = Environment.MachineName; }
/// <summary> /// Initializes a new instance of the <see cref="TaskDescriptionEventArgs"/> class. /// </summary> /// <param name="item">The item.</param> /// <param name="parent">The parent.</param> public TaskDescriptionEventArgs(TaskDescription item, TaskDescription parent) { if (item == null) { throw new InvalidOperationException(Resources.DescriptionCannotBeSetToNull); } _item = item; _parent = parent; }
/// <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(); }
/// <summary> /// Handles the Checked event on a TaskDescriptionNode in the tree. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.TreeViewEventArgs"/> instance containing the event data.</param> private void TaskDescriptionNode_Checked(object sender, TreeViewEventArgs e) { if (e.Node.Tag.GetType() == typeof(TaskDescription)) { comboboxScheme.SelectedIndex = 1; TaskDescription taskDescription = e.Node.Tag as TaskDescription; if (taskDescription != null) { if (e.Node.Checked == true) { InsertItemInList(taskDescription); } else { RemoveItemFromList(taskDescription); } CheckChildren(e.Node); } //CheckParents(e.Node); } }
private void CheckChildren(TreeNode parent) { foreach (TreeNode child in parent.Nodes) { if (child.Checked != parent.Checked) { child.Checked = parent.Checked; TaskDescription taskDescription = child.Tag as TaskDescription; if (child.Checked) { InsertItemInList(taskDescription); } else { RemoveItemFromList(taskDescription); } } if (child.Nodes != null) { CheckChildren(child); } } }
/// <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.]"); }
/// <summary> /// Initializes a new instance of the <see cref="TaskDescriptionEventArgs"/> class. /// </summary> /// <param name="item">The item.</param> public TaskDescriptionEventArgs(TaskDescription item) : this(item, null) { }
private void RemoveItemFromList(TaskDescription taskDescription) { if (_taskDescriptions.Contains(taskDescription)) { _taskDescriptions.Remove(taskDescription); } labelTaskDescriptionsCount.Text = string.Format("{0} TaskDescriptions selected.", _taskDescriptions.Count); }
private void InsertItemInList(TaskDescription taskDescription) { if (!_taskDescriptions.Contains(taskDescription)) { _taskDescriptions.Add(taskDescription); } labelTaskDescriptionsCount.Text = string.Format("{0} TaskDescriptions selected.", _taskDescriptions.Count); }
private void BuildTree(TaskDescription parent, TreeNode rootNode) { foreach (TaskDescription child in parent.Children) { TreeNode node = new TreeNode(child.Name); node.Tag = child; node.ToolTipText = child.Description; if (comboboxScheme.SelectedIndex == 0) { node.Checked = !child.IsPrivate; } if (comboboxScheme.SelectedIndex == 2) { node.Checked = true; } if (node.Checked) { _taskDescriptions.Add(child); } rootNode.Nodes.Add(node); if (child.Children.Count > 0) { BuildTree(child, node); } } }
/// <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"); } }
/// <summary> /// Provides the business logic for handling a new TaskActivity /// </summary> /// <param name="taskDescription">The task description.</param> /// <param name="effectiveDateTime">The effective date time.</param> public void HandleNewTaskActivity(TaskDescription taskDescription, DateTime effectiveDateTime) { HandleNewTaskActivity(taskDescription, null, effectiveDateTime); }
/// <summary> /// part of the menu builder tasks /// </summary> /// <param name="parent"></param> /// <param name="parentMenu"></param> private void MenuBuilder(TaskDescription parent, MenuItem parentMenu) { int menubreak = 0; if (parent.Children != null) { foreach (TaskDescription child in parent.Children) { if (child != null) { MenuItem menuItem = new MenuItem(child.Name); menuItem.Tag = child; menuItem.Enabled = child.IsValid(); if (child.IsEvent) { menuItem.Text = "[" + child.Name + "]"; } menuItem.Click += new EventHandler(ChangeTask); if (menubreak != child.MenuColumn) { menuItem.BarBreak = true; menubreak = child.MenuColumn; } parentMenu.MenuItems.Add(menuItem); MenuBuilder(child, menuItem); } } } }
/// <summary> /// Initializes a new instance of the <see cref="TaskDescriptionEventArgs"/> class. /// </summary> /// <param name="item">The item.</param> /// <param name="parent">The parent.</param> public TaskDescriptionEventArgs(TaskDescription item, TaskDescription parent) { _item = item ?? throw new InvalidOperationException(Resources.DescriptionCannotBeSetToNull); _parent = parent; }
/// <summary> /// Initializes a new instance of the <see cref="TaskDescriptionEventArgs"/> class. /// </summary> /// <param name="item">The item.</param> public TaskDescriptionEventArgs(TaskDescription item) : this(item, null) { }
/// <summary> /// Compares the task description on sequence. /// </summary> /// <param name="taskDescriptionA">The task description A.</param> /// <param name="taskDescriptionB">The task description B.</param> /// <returns></returns> public static int CompareTaskDescriptionOnSequence(TaskDescription taskDescriptionA, TaskDescription taskDescriptionB) { if (taskDescriptionA == null) { throw new ArgumentNullException("taskDescriptionA"); } if (taskDescriptionB == null) { throw new ArgumentNullException("taskDescriptionB"); } return taskDescriptionA.Sequence.CompareTo(taskDescriptionB.Sequence); }