private void FillGridTasks() { gridTasks.BeginUpdate(); gridTasks.Columns.Clear(); gridTasks.Columns.Add(new ODGridColumn("Date", -1)); gridTasks.Columns.Add(new ODGridColumn("TaskList", -1)); gridTasks.Columns.Add(new ODGridColumn("Done", 40) { TextAlign = HorizontalAlignment.Center }); gridTasks.Columns.Add(new ODGridColumn("Unlink", 40, HorizontalAlignment.Center)); gridTasks.NoteSpanStart = 0; gridTasks.NoteSpanStop = 3; gridTasks.Rows.Clear(); List <Task> listTasks = _listJobLinks.FindAll(x => x.LinkType == JobLinkType.Task) .Select(x => Tasks.GetOne(x.FKey)) .Where(x => x != null) .OrderBy(x => x.DateTimeEntry).ToList(); foreach (Task task in listTasks) { ODGridRow row = new ODGridRow() { Tag = task.TaskNum }; //taskNum row.Cells.Add(task.DateTimeEntry.ToShortDateString()); row.Cells.Add(TaskLists.GetOne(task.TaskListNum)?.Descript ?? "<TaskListNum:" + task.TaskListNum + ">"); row.Cells.Add(task.TaskStatus == TaskStatusEnum.Done?"X":""); row.Cells.Add("X"); row.Note = task.Descript.Left(100, true).Trim(); gridTasks.Rows.Add(row); } gridTasks.EndUpdate(); }
private void LoadUnfilteredTaskLists() { switch (OType) { case TaskObjectType.Patient: _listUnfilteredTaskList = TaskLists.GetForObjectType(OType, false); break; case TaskObjectType.Appointment: _listUnfilteredTaskList = TaskLists.GetForObjectType(OType, false); _listUnfilteredTaskList.AddRange( GetUserInboxTaskLists().FindAll(x => x.ObjectType != TaskObjectType.Appointment) ); _listUnfilteredTaskList.Sort(SortTaskListByDescript); break; case TaskObjectType.None: _listUnfilteredTaskList = GetUserInboxTaskLists(); this.Text = Lan.g(this, "Task Send User"); //Form title assumes tasklist. break; default: //Just in case _listUnfilteredTaskList = new List <TaskList>(); break; } }
private void butOK_Click(object sender, System.EventArgs e) { if (textDateTL.errorProvider1.GetError(textDateTL) != "" ) { MessageBox.Show(Lan.g(this, "Please fix data entry errors first.")); return; } Cur.Descript = textDescript.Text; Cur.DateTL = PIn.Date(textDateTL.Text); Cur.DateType = (TaskDateType)listDateType.SelectedIndex; if (!checkFromNum.Checked) //user unchecked the box { Cur.FromNum = 0; } Cur.ObjectType = (TaskObjectType)listObjectType.SelectedIndex; try{ if (IsNew) { TaskLists.Insert(Cur); SecurityLogs.MakeLogEntry(Permissions.TaskListCreate, 0, Cur.Descript + " " + Lan.g(this, "added")); } else { TaskLists.Update(Cur); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } DialogResult = DialogResult.OK; }
private void RefreshMainLists(int parent, DateTime date) { if (this.DesignMode) { TaskListsList = new TaskList[0]; TasksList = new Task[0]; return; } if (tabContr.SelectedIndex == 0) //main { TaskListsList = TaskLists.Refresh(parent, DateTime.MinValue, TaskDateType.None, false); TasksList = Tasks.Refresh(parent, DateTime.MinValue, TaskDateType.None, false); } else if (tabContr.SelectedIndex == 1) //repeating { TaskListsList = TaskLists.Refresh(parent, DateTime.MinValue, TaskDateType.None, true); TasksList = Tasks.Refresh(parent, DateTime.MinValue, TaskDateType.None, true); } else if (tabContr.SelectedIndex == 2) //date { TaskListsList = TaskLists.Refresh(parent, date, TaskDateType.Day, false); TasksList = Tasks.Refresh(parent, date, TaskDateType.Day, false); } else if (tabContr.SelectedIndex == 3) //week { TaskListsList = TaskLists.Refresh(parent, date, TaskDateType.Week, false); TasksList = Tasks.Refresh(parent, date, TaskDateType.Week, false); } else if (tabContr.SelectedIndex == 4) //month { TaskListsList = TaskLists.Refresh(parent, date, TaskDateType.Month, false); TasksList = Tasks.Refresh(parent, date, TaskDateType.Month, false); } }
private void butOK_Click(object sender, System.EventArgs e) { if (textDateTL.errorProvider1.GetError(textDateTL) != "" ) { MessageBox.Show(Lan.g(this, "Please fix data entry errors first.")); return; } Cur.Descript = textDescript.Text; Cur.DateTL = PIn.PDate(textDateTL.Text); Cur.DateType = (TaskDateType)listDateType.SelectedIndex; if (!checkFromNum.Checked) //user unchecked the box { Cur.FromNum = 0; } Cur.ObjectType = (TaskObjectType)listObjectType.SelectedIndex; try{ TaskLists.InsertOrUpdate(Cur, IsNew); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } DialogResult = DialogResult.OK; }
private void RefreshTable() { long priority = 0; if (comboPriority.SelectedIndex != 0) { priority = _listTaskPriorities[comboPriority.SelectedIndex - 1].DefNum; } long userNum = 0; if (comboUsers.SelectedIndex == 1) //Me { userNum = Security.CurUser.UserNum; } else if (comboUsers.SelectedIndex != 0) { userNum = _listUsers[comboUsers.SelectedIndex - 2].UserNum; //1(All) + 1(Me)= 2 } List <long> listTaskListNums = new List <long>(); if (textTaskList.Text != "") { listTaskListNums = TaskLists.GetNumsByDescription(textTaskList.Text, checkReportServer.Checked); if (listTaskListNums.Count == 0) { MsgBox.Show(this, "Task List not found."); return; } } List <long> listTaskNums = new List <long>() { }; if (textTaskNum.Text != "") { try { listTaskNums = textTaskNum.Text.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => PIn.Long(x)).ToList(); } catch { MsgBox.Show(this, "Invalid Task Num format."); return; } } long patNum = 0; if (textPatNum.Text != "") { try { patNum = PIn.Long(textPatNum.Text); } catch { MsgBox.Show(this, "Invalid PatNum format."); return; } } _tableTasks = Tasks.GetDataSet(userNum, listTaskListNums, listTaskNums, dateCreatedFrom.Text, dateCreatedTo.Text, dateCompletedFrom.Text, dateCompletedTo.Text, textDescription.Text, priority, patNum, checkBoxIncludesTaskNotes.Checked, checkBoxIncludeCompleted.Checked, checkLimit.Checked, checkReportServer.Checked); }
private void FormTaskListSelect_Load(object sender, System.EventArgs e) { TaskListList = TaskLists.GetForObjectType(OType); for (int i = 0; i < TaskListList.Length; i++) { listMain.Items.Add(TaskListList[i].Descript); } }
///<summary>Fetches the subscriptions that the user is currently subscribed too ad adds them to the treeview.</summary> private void InitializeTree() { treeSubscriptions.Nodes.Clear(); List <TaskList> listTaskListSubs = TaskLists.RefreshUserTrunk(Security.CurUser.UserNum); BuildTaskListTree(listTaskListSubs); treeSubscriptions.ExpandAll(); }
private void FormTaskListBlock_Load(object sender, EventArgs e) { _dictAllTaskLists = TaskLists.GetAll().ToDictionary(x => x.TaskListNum);//Used so we don't need to acces the database multiple times _listUserOdPrefTaskListBlocks = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.TaskListBlock); //We pull the list then save it so the sync moethod is able to run correctly. //This correctly fixes users having duplicate task list preferences in the databse. _listUserDBPrefs = _listUserOdPrefTaskListBlocks.Select(x => x.Clone()).ToList(); _listUserOdPrefTaskListBlocks = _listUserOdPrefTaskListBlocks.GroupBy(x => x.Fkey).Select(x => x.First()).ToList(); InitializeTree(); }
///<summary>Fetches the subscriptions that the user is currently subscribed too ad adds them to the treeview.</summary> private void InitializeTree() { treeSubscriptions.Nodes.Clear(); List <TaskList> listTaskListSubs = TaskLists.RefreshUserTrunk(Security.CurUser.UserNum); //Only want active task lists that have no archived ancestors or no ancestors at all. listTaskListSubs.RemoveAll(x => x.TaskListStatus == TaskListStatusEnum.Archived || TaskLists.IsAncestorTaskListArchived(ref _dictAllTaskLists, x)); BuildTaskListTree(listTaskListSubs); treeSubscriptions.ExpandAll(); }
private void FormTaskInboxSetup_Load(object sender, EventArgs e) { UserList = Userods.GetDeepCopy(true); UserListOld = Userods.GetDeepCopy(true); TrunkList = TaskLists.RefreshMainTrunk(Security.CurUser.UserNum, TaskType.All); listMain.Items.Add(Lan.g(this, "none")); for (int i = 0; i < TrunkList.Count; i++) { listMain.Items.Add(TrunkList[i].Descript); } FillGrid(); }
private void FormTaskListSelect_Load(object sender, System.EventArgs e) { SetLabelText(); _userCurTaskListInbox = TaskLists.GetOne(Security.CurUser.TaskListInBox); if (_userCurTaskListInbox != null) { _userCurTaskListInbox.Descript = Lan.g(this, "My Inbox") + ": " + _userCurTaskListInbox.Descript; } else { //Is null when the current user does not have an inbox set up //or if OType is TaskObjectType.Patient and the current users inbox is not of ObjectType Patient. } FillList(); }
private void FormTaskListSelect_Load(object sender, System.EventArgs e) { _taskListList = TaskLists.GetForObjectType(OType); if (OType == TaskObjectType.Appointment) { List <TaskList> TrunkList = TaskLists.RefreshMainTrunk(Security.CurUser.UserNum, TaskType.All) .FindAll(x => x.ObjectType != TaskObjectType.Appointment);//TaskListList already contains all appt type tasklists List <long> listUserInboxNums = Userods.GetDeepCopy(true).Select(x => x.TaskListInBox).ToList(); _taskListList.AddRange(TrunkList.FindAll(x => listUserInboxNums.Contains(x.TaskListNum))); } for (int i = 0; i < _taskListList.Count; i++) { listMain.Items.Add(_taskListList[i].Descript); } }
///<summary>A recursive function that duplicates an entire existing TaskList. For the initial loop, make changes to the original taskList before passing it in. That way, Date and type are only set in initial loop. All children preserve original dates and types. The isRepeating value will be applied in all loops. Also, make sure to change the parent num to the new one before calling this function. The taskListNum will always change, because we are inserting new record into database.</summary> private void DuplicateExistingList(TaskList newList, bool isInMain) { //get all children: TaskList[] childLists = TaskLists.Refresh(newList.TaskListNum, DateTime.MinValue, TaskDateType.None, newList.IsRepeating); Task[] childTasks = Tasks.Refresh(newList.TaskListNum, DateTime.MinValue, TaskDateType.None, newList.IsRepeating); TaskLists.InsertOrUpdate(newList, true); //now we have a new taskListNum to work with for (int i = 0; i < childLists.Length; i++) { childLists[i].Parent = newList.TaskListNum; if (newList.IsRepeating) { childLists[i].IsRepeating = true; childLists[i].DateTL = DateTime.MinValue; //never a date } else { childLists[i].IsRepeating = false; } childLists[i].FromNum = 0; if (!isInMain) { childLists[i].DateTL = DateTime.MinValue; childLists[i].DateType = TaskDateType.None; } DuplicateExistingList(childLists[i], isInMain); } for (int i = 0; i < childTasks.Length; i++) { childTasks[i].TaskListNum = newList.TaskListNum; if (newList.IsRepeating) { childTasks[i].IsRepeating = true; childTasks[i].DateTask = DateTime.MinValue; //never a date } else { childTasks[i].IsRepeating = false; } childTasks[i].FromNum = 0; if (!isInMain) { childTasks[i].DateTask = DateTime.MinValue; childTasks[i].DateType = TaskDateType.None; } Tasks.InsertOrUpdate(childTasks[i], true); } }
/// <summary>Fills listMain with all tasklists with DateType.None. Each task list will also list out it's children lists. /// Items will be filtered the same way as FillListUser (based on textFilter).</summary> private void FillListSubTasks() { List <TaskList> listAllTaskLists = TaskLists.GetForDateType(TaskDateType.None, false); //Convert to dictionary for faster lookups Dictionary <long, TaskList> dictAllTaskLists = listAllTaskLists.ToDictionary(x => x.TaskListNum); //This will hold the final list of task lists, which will have different descriptions than normal. List <TaskList> listFilteredTaskLists = new List <TaskList>(); TaskList tempTaskList; StringBuilder itemName = new StringBuilder(); //String builder because we want speeeed foreach (TaskList tList in listAllTaskLists) { itemName.Clear(); TaskList tempList = tList.Copy(); //Copy so we don't modify the original in case it's another list's parent. long listParent = tList.Parent; itemName.Append(tList.Descript); while (listParent != 0) //When listParent is 0, is means the current item doesn't have a parent or we can't find the parent. { if (dictAllTaskLists.TryGetValue(listParent, out tempTaskList)) { listParent = tempTaskList.Parent; itemName.Insert(0, tempTaskList.Descript + "/"); //Add the parent name to the beginning of the description } else { //If we can't find the parent, it'll be listed by itself. listParent = 0; } } tempList.Descript = itemName.ToString(); //Store task list with extended name in our final list of tasklists listFilteredTaskLists.Add(tempList); } //If the user has typed in a filter term, check it now. //We wait until the entire description is created because one task might be filtered, but it's parent isn't listFilteredTaskLists = FilterList(textFilter.Text, listFilteredTaskLists).OrderBy(x => x.Descript).ToList(); //Add the user's primary inbox to the top if (_userCurTaskListInbox != null && _userCurTaskListInbox.Descript.Contains(textFilter.Text)) { listFilteredTaskLists.Insert(0, _userCurTaskListInbox); } listMain.SetItems(listFilteredTaskLists, x => x.Descript); }
///<summary>A recursive function that deletes the specified list and all children.</summary> private void DeleteEntireList(TaskList list) { //get all children: TaskList[] childLists = TaskLists.Refresh(list.TaskListNum, DateTime.MinValue, TaskDateType.None, list.IsRepeating); Task[] childTasks = Tasks.Refresh(list.TaskListNum, DateTime.MinValue, TaskDateType.None, list.IsRepeating); for (int i = 0; i < childLists.Length; i++) { DeleteEntireList(childLists[i]); } for (int i = 0; i < childTasks.Length; i++) { Tasks.Delete(childTasks[i]); } try { TaskLists.Delete(list); } catch (Exception e) { MessageBox.Show(e.Message); } }
///<summary>A recursive function that checks every child in a list IsFromRepeating. If any are marked complete, then it returns true, signifying that this list should be immune from being deleted since it's already in use.</summary> private bool AnyAreMarkedComplete(TaskList list) { //get all children: TaskList[] childLists = TaskLists.Refresh(list.TaskListNum, DateTime.MinValue, TaskDateType.None, false); Task[] childTasks = Tasks.Refresh(list.TaskListNum, DateTime.MinValue, TaskDateType.None, false); for (int i = 0; i < childLists.Length; i++) { if (AnyAreMarkedComplete(childLists[i])) { return(true); } } for (int i = 0; i < childTasks.Length; i++) { if (childTasks[i].TaskStatus) { return(true); } } return(false); }
private void FormTaskSendUser_Load(object sender, EventArgs e) { List <Userod> UserList = Userods.GetDeepCopy(true); List <TaskList> TrunkList = TaskLists.RefreshMainTrunk(Security.CurUser.UserNum, TaskType.All); FilteredList = new List <TaskList>(); for (int i = 0; i < UserList.Count; i++) { if (UserList[i].TaskListInBox == 0) { continue; } for (int t = 0; t < TrunkList.Count; t++) { if (TrunkList[t].TaskListNum == UserList[i].TaskListInBox) { FilteredList.Add(TrunkList[t]); listMain.Items.Add(TrunkList[t].Descript); } } } }
///<summary>Recursively returns a list of all leaf nodes down stream from the given parent taskListNode.</summary> private List <TaskList> GetLeafSubsFromTask(TaskList taskListNode, List <TaskList> listTaskListSubs) { List <TaskList> children = TaskLists.RefreshChildren(taskListNode.TaskListNum, Security.CurUser.UserNum, Security.CurUser.TaskListInBox, TaskType.All); if (children.Count == 0) //base case: is a leaf { return(new List <TaskList>() { taskListNode }); } List <TaskList> listLeaves = new List <TaskList>(); foreach (TaskList child in children) { if (listTaskListSubs.Contains(child)) //This node is already in our list of tasklist subscriptions { continue; //Avoid traversing the same route down the tree twice, reduces Db calls. } listLeaves.AddRange(GetLeafSubsFromTask(child, listTaskListSubs)); } return(listLeaves); }
private void FillMain() { int parent; DateTime date; if (TreeHistory.Count > 0) //not on main trunk { parent = ((TaskList)TreeHistory[TreeHistory.Count - 1]).TaskListNum; date = DateTime.MinValue; } else //one of the main trunks { parent = 0; date = cal.SelectionStart; } RefreshMainLists(parent, date); if (TreeHistory.Count == 0 && //main trunk (tabContr.SelectedIndex == 2 || tabContr.SelectedIndex == 3 || tabContr.SelectedIndex == 4)) //any of the dated groups { //clear any lists which are derived from a repeating list and which do not have any itmes checked off bool changeMade = false; for (int i = 0; i < TaskListsList.Length; i++) { if (TaskListsList[i].FromNum == 0) //ignore because not derived from a repeating list { continue; } if (!AnyAreMarkedComplete(TaskListsList[i])) { DeleteEntireList(TaskListsList[i]); changeMade = true; } } //clear any tasks which are derived from a repeating tast and which are not checked off for (int i = 0; i < TasksList.Length; i++) { if (TasksList[i].FromNum == 0) { continue; } if (!TasksList[i].TaskStatus) { Tasks.Delete(TasksList[i]); changeMade = true; } } if (changeMade) { RefreshMainLists(parent, date); } //now add back any repeating lists and tasks that meet the criteria //Get lists of all repeating lists and tasks of one type. We will pick items from these two lists. TaskList[] repeatingLists = new TaskList[0]; Task[] repeatingTasks = new Task[0]; switch (tabContr.SelectedIndex) { case 2: repeatingLists = TaskLists.Refresh(-1, DateTime.MinValue, TaskDateType.Day, true); repeatingTasks = Tasks.Refresh(-1, DateTime.MinValue, TaskDateType.Day, true); break; case 3: repeatingLists = TaskLists.Refresh(-1, DateTime.MinValue, TaskDateType.Week, true); repeatingTasks = Tasks.Refresh(-1, DateTime.MinValue, TaskDateType.Week, true); break; case 4: repeatingLists = TaskLists.Refresh(-1, DateTime.MinValue, TaskDateType.Month, true); repeatingTasks = Tasks.Refresh(-1, DateTime.MinValue, TaskDateType.Month, true); break; } //loop through list and add back any that meet criteria. changeMade = false; bool alreadyExists; for (int i = 0; i < repeatingLists.Length; i++) { //if already exists, skip alreadyExists = false; for (int j = 0; j < TaskListsList.Length; j++) //loop through Main list { if (TaskListsList[j].FromNum == repeatingLists[i].TaskListNum) { alreadyExists = true; break; } } if (alreadyExists) { continue; } //otherwise, duplicate the list repeatingLists[i].DateTL = date; repeatingLists[i].FromNum = repeatingLists[i].TaskListNum; repeatingLists[i].IsRepeating = false; repeatingLists[i].Parent = 0; repeatingLists[i].ObjectType = 0; //user will have to set explicitly DuplicateExistingList(repeatingLists[i], true); changeMade = true; } for (int i = 0; i < repeatingTasks.Length; i++) { //if already exists, skip alreadyExists = false; for (int j = 0; j < TasksList.Length; j++) //loop through Main list { if (TasksList[j].FromNum == repeatingTasks[i].TaskNum) { alreadyExists = true; break; } } if (alreadyExists) { continue; } //otherwise, duplicate the task repeatingTasks[i].DateTask = date; repeatingTasks[i].FromNum = repeatingTasks[i].TaskNum; repeatingTasks[i].IsRepeating = false; repeatingTasks[i].TaskListNum = 0; Tasks.InsertOrUpdate(repeatingTasks[i], true); changeMade = true; } if (changeMade) { RefreshMainLists(parent, date); } } //if main trunk on dated group listMain.Items.Clear(); ListViewItem item; string dateStr = ""; for (int i = 0; i < TaskListsList.Length; i++) { dateStr = ""; if (TaskListsList[i].DateTL.Year > 1880 && tabContr.SelectedIndex == 0) //main { //dateStr=TaskListsList[i].DateTL.ToShortDateString()+" - "; if (TaskListsList[i].DateType == TaskDateType.Day) { dateStr = TaskListsList[i].DateTL.ToShortDateString() + " - "; } else if (TaskListsList[i].DateType == TaskDateType.Week) { dateStr = Lan.g(this, "Week of") + " " + TaskListsList[i].DateTL.ToShortDateString() + " - "; } else if (TaskListsList[i].DateType == TaskDateType.Month) { dateStr = TaskListsList[i].DateTL.ToString("MMMM") + " - "; } } item = new ListViewItem(dateStr + TaskListsList[i].Descript, 0); item.ToolTipText = item.Text; listMain.Items.Add(item); } string objDesc = ""; for (int i = 0; i < TasksList.Length; i++) { //checked=1, unchecked=2 dateStr = ""; if (tabContr.SelectedIndex == 0) //main { if (TasksList[i].DateTask.Year > 1880) { if (TasksList[i].DateType == TaskDateType.Day) { dateStr = TasksList[i].DateTask.ToShortDateString() + " - "; } else if (TasksList[i].DateType == TaskDateType.Week) { dateStr = Lan.g(this, "Week of") + " " + TasksList[i].DateTask.ToShortDateString() + " - "; } else if (TasksList[i].DateType == TaskDateType.Month) { dateStr = TasksList[i].DateTask.ToString("MMMM") + " - "; } } else if (TasksList[i].DateTimeEntry.Year > 1880) { dateStr = TasksList[i].DateTimeEntry.ToShortDateString() + " - "; } } objDesc = ""; if (TasksList[i].ObjectType == TaskObjectType.Patient) { if (TasksList[i].KeyNum != 0) { objDesc = Patients.GetPat(TasksList[i].KeyNum).GetNameLF() + " - "; } } else if (TasksList[i].ObjectType == TaskObjectType.Appointment) { if (TasksList[i].KeyNum != 0) { Appointment AptCur = Appointments.GetOneApt(TasksList[i].KeyNum); if (AptCur != null) { objDesc = Patients.GetPat(AptCur.PatNum).GetNameLF() + " " + AptCur.AptDateTime.ToString() + " " + AptCur.ProcDescript + " " + AptCur.Note + " - "; } } } if (TasksList[i].TaskStatus) //complete { item = new ListViewItem(dateStr + objDesc + TasksList[i].Descript, 1); } else { item = new ListViewItem(dateStr + objDesc + TasksList[i].Descript, 2); } item.ToolTipText = item.Text; listMain.Items.Add(item); } }
///<summary>Returns a list of TaskList inboxes for non hidden users with an inbox setup.</summary> private List <TaskList> GetUserInboxTaskLists() { List <TaskList> listUserInboxTaskLists = TaskLists.GetMany(Userods.GetDeepCopy(true).Select(x => x.TaskListInBox).ToList()); return(listUserInboxTaskLists.OrderBy(x => x.Descript).ThenBy(x => x.DateTimeEntry).ToList()); }