示例#1
0
 public void SetupTest()
 {
     TaskListT.ClearTaskListTable();
     TaskT.ClearTaskTable();
     TaskSubscriptionT.ClearTaskSubscriptionTable();
     SignalodT.ClearSignalodTable();
     _taskListParent     = TaskListT.CreateTaskList(descript: "TaskListParent");
     _taskListChild      = TaskListT.CreateTaskList(descript: "TaskListChild", parent: _taskListParent.TaskListNum, parentDesc: _taskListParent.Descript);
     _taskListGrandchild = TaskListT.CreateTaskList(descript: "TaskListGrandchild", parent: _taskListChild.TaskListNum,
                                                    parentDesc: _taskListChild.Descript);
     _task = TaskT.CreateTask(_taskListGrandchild.TaskListNum, descript: "Test Task", fromNum: Security.CurUser.UserNum); //Starts in _taskListGrandchild
     Security.CurUser.TaskListInBox = _taskListParent.TaskListNum;                                                        //Set inbox for current user to _taskListParent.
     try {
         Userods.Update(Security.CurUser);
     }
     catch {
         Assert.Fail("Failed to update current user task list inbox.");                //Error updating user.
     }
     _userControlTasksInstance = new UserControlTasks();
     _userControlTasksAccessor = new PrivateObject(_userControlTasksInstance);
     //Artificially set that we are viewing _listTaskListParent.
     _userControlTasksAccessor.SetField("_listTaskListTreeHistory", new List <TaskList>()
     {
         _taskListParent
     });
     _userControlTasksAccessor.SetField("_dictTaskLists", new Dictionary <long, TaskList>());
 }
示例#2
0
文件: TaskAncestors.cs 项目: mnisl/OD
		/*
		///<summary></summary>
		public static void Update(TaskAncestor ancestor) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),ancestor);
				return;
			}
			Crud.TaskAncestorCrud.Update(ancestor);
		}*/

		public static void Synch(Task task){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),task);
				return;
			}
			string command="DELETE FROM taskancestor WHERE TaskNum="+POut.Long(task.TaskNum);
			Db.NonQ(command);
			long taskListNum=0;
			long parentNum=task.TaskListNum;
			DataTable table;
			TaskAncestor ancestor;
			while(true){
				if(parentNum==0){
					break;//no parent to mark
				}
				//get the parent
				command="SELECT TaskListNum,Parent FROM tasklist WHERE TaskListNum="+POut.Long(parentNum);
				table=Db.GetTable(command);
				if(table.Rows.Count==0){//in case of database inconsistency
					break;
				}
				taskListNum=PIn.Long(table.Rows[0]["TaskListNum"].ToString());
				parentNum=PIn.Long(table.Rows[0]["Parent"].ToString());
				ancestor=new TaskAncestor();
				ancestor.TaskNum=task.TaskNum;
				ancestor.TaskListNum=taskListNum;
				Insert(ancestor);
			}
		}
示例#3
0
		///<summary>Task gets inserted ahead of time, then frequently altered before passing in here.  The taskOld that is passed in should be the task as it is in the database.  When saving, taskOld will be compared with db to make sure no changes.</summary>
		public FormTaskEdit(Task taskCur,Task taskOld) {
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			TaskCur=taskCur;
			TaskOld=taskOld;
			TaskListCur=TaskLists.GetOne(taskCur.TaskListNum);
			Lan.F(this);
		}
示例#4
0
        ///<summary>Context menu right-click and select the "Done" option.</summary>
        public void UserControlTasks_Done_Clicked()
        {
            _userControlTasksAccessor.SetField("_clickedTask", _task);   //Directly set which task is clicked.
            _userControlTasksAccessor.Invoke("Done_Clicked");            //Context menu "Done" option click.
            List <Signalod> listSignals = SignalodT.GetAllSignalods();

            OpenDentBusiness.Task taskDb = Tasks.GetOne(_task.TaskNum);
            Assert.AreEqual(1, listSignals.Count);
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.Task && x.FKeyType == KeyType.Task && x.FKey == _task.TaskNum));
            Assert.AreEqual(TaskStatusEnum.Done, taskDb.TaskStatus);
        }
示例#5
0
        ///<summary>Correct signals are sent when user deletes a Task using "Delete" button, and Task is no longer in database.</summary>
        public void FormTaskEdit_butDelete_Click()
        {
            _formTaskEditAccessor.SetField("IsNew", true);           //Causes butDelete_Click to skip UI interaction.
            _formTaskEditAccessor.Invoke("butDelete_Click", new object(), new EventArgs());
            List <Signalod> listSignals = SignalodT.GetAllSignalods();

            Assert.AreEqual(2, listSignals.Count);
            OpenDentBusiness.Task task = Tasks.GetOne(_task.TaskNum);
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskList && x.FKeyType == KeyType.Undefined && x.FKey == _task.TaskListNum));
            Assert.IsNull(task);
        }
示例#6
0
 public static List<Task> GetListTasksContainingCR()
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         return Meth.GetObject<List<Task>>(MethodBase.GetCurrentMethod());
     }
     Task task=new Task();
     //			task.Descript="Line1";
     task.Descript="Line1\r\nLine2";
     List<Task> retVal=new List<Task>();
     retVal.Add(task);
     return retVal;
 }
示例#7
0
        ///<summary>Context menu right-click and select the "Mark Read" with TaskNewTrackedByUser preference turned off.</summary>
        public void UserControlTasks_MarkRead()
        {
            Prefs.UpdateBool(PrefName.TasksNewTrackedByUser, false);           //TaskNewTrackedByUser=false;
            _userControlTasksAccessor.Invoke("MarkRead", _task);
            List <Signalod> listSignals = SignalodT.GetAllSignalods();

            Assert.AreEqual(1, listSignals.Count);
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.Task && x.FKeyType == KeyType.Task &&
                                             x.FKey == _task.TaskNum));//Signal for _task.
            OpenDentBusiness.Task taskDb = Tasks.GetOne(_task.TaskNum);
            Assert.AreEqual(TaskStatusEnum.Viewed, taskDb.TaskStatus);
        }
示例#8
0
        ///<summary>Context menu right-click and select the "Send to Me" option.</summary>
        public void UserControlTasks_SendToMe_Clicked()
        {
            _userControlTasksAccessor.SetField("_clickedTask", _task);
            _userControlTasksAccessor.Invoke("SendToMe_Clicked", false);
            List <Signalod> listSignals = SignalodT.GetAllSignalods();

            Assert.AreEqual(3, listSignals.Count);
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskList && x.FKeyType == KeyType.Undefined &&
                                             x.FKey == _taskListGrandchild.TaskListNum)); //Signal for source taskList.
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskList && x.FKeyType == KeyType.Undefined &&
                                             x.FKey == _taskListParent.TaskListNum));     //Signal for destination taskList.
            OpenDentBusiness.Task taskDb = Tasks.GetOne(_task.TaskNum);
            Assert.AreEqual(taskDb.TaskListNum, _taskListParent.TaskListNum);             //Db was properly updated with new taskListNum on _task.
        }
示例#9
0
        ///<summary>Correct signals are sent when user clicks "Reply" button (without having added a TaskNote), and Task.TaskListNum is correctly updated in database.</summary>
        public void FormTaskEdit_OnNoteEditComplete_Reply()
        {
            long oldTaskListNum = _task.TaskListNum;

            _formTaskEditAccessor.SetField("_replyToUserNum", Security.CurUser.UserNum);           //User we are replying to.
            _formTaskEditAccessor.Invoke("OnNoteEditComplete_Reply", new object());
            List <Signalod> listSignals = SignalodT.GetAllSignalods();

            Assert.AreEqual(4, listSignals.Count);
            OpenDentBusiness.Task task = Tasks.GetOne(_task.TaskNum);
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskList && x.FKeyType == KeyType.Undefined && x.FKey == oldTaskListNum));      //Old TL
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskList && x.FKeyType == KeyType.Undefined && x.FKey == _task.TaskListNum));   //New TL
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskPopup && x.FKeyType == KeyType.Task && x.FKey == _task.TaskNum));
            Assert.AreEqual(_task.TaskListNum, task.TaskListNum);
        }
示例#10
0
        ///<summary>Context menu right-click and drill down in the "Set Priority" option, selecting one of the priority options.</summary>
        public void UserControlTasks_menuTaskPriority_Click()
        {
            Def newDef = new Def()
            {
                DefNum = 5
            };

            _userControlTasksAccessor.Invoke("menuTaskPriority_Click", _task, newDef);
            List <Signalod> listSignals = SignalodT.GetAllSignalods();

            Assert.AreEqual(1, listSignals.Count);
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.Task && x.FKeyType == KeyType.Task &&
                                             x.FKey == _task.TaskNum));//Signal for _task.
            OpenDentBusiness.Task taskDb = Tasks.GetOne(_task.TaskNum);
            Assert.AreEqual(newDef.DefNum, taskDb.PriorityDefNum);
        }
示例#11
0
        ///<summary>Correct signals are sent when user clicks "Reply" button, and Task.TaskListNum is correctly updated in database.</summary>
        public void FormTaskEdit_butReply_Click()
        {
            long oldTaskListNum = _task.TaskListNum;

            _formTaskEditAccessor.SetField("_replyToUserNum", Security.CurUser.UserNum); //User we are replying to.
            _formTaskEditAccessor.SetField("NotesChanged", true);                        //Causes butReply_Click to skip UI interaction.
            _formTaskEditAccessor.Invoke("butReply_Click", new object(), new EventArgs());
            List <Signalod> listSignals = SignalodT.GetAllSignalods();

            OpenDentBusiness.Task task = Tasks.GetOne(_task.TaskNum);
            Assert.AreEqual(4, listSignals.Count);
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskList && x.FKeyType == KeyType.Undefined && x.FKey == oldTaskListNum));      //Old TL
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskList && x.FKeyType == KeyType.Undefined && x.FKey == _task.TaskListNum));   //New TL
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskPopup && x.FKeyType == KeyType.Task && x.FKey == _task.TaskNum));
            Assert.AreEqual(_task.TaskListNum, task.TaskListNum);
        }
示例#12
0
        ///<summary>User clicks "OK" after having changed the Description.</summary>
        public void FormTaskEdit_butOK_Click_DescriptionChanged()
        {
            _formTaskEditAccessor.SetField("_taskCur", _task);
            _formTaskEditAccessor.SetField("_taskOld", _task.Copy());
            string    newDescript  = "new" + _task.Descript;
            ODtextBox textDescript = (ODtextBox)_formTaskEditAccessor.GetField("textDescript");

            textDescript.Text = newDescript;
            _formTaskEditAccessor.SetField("textDescript", textDescript);
            _formTaskEditAccessor.Invoke("butOK_Click", new object(), new EventArgs());
            List <Signalod> listSignals = SignalodT.GetAllSignalods();

            Assert.AreEqual(2, listSignals.Count);
            OpenDentBusiness.Task task = Tasks.GetOne(_task.TaskNum);
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskList && x.FKeyType == KeyType.Undefined && x.FKey == _task.TaskListNum));      //New TL
            Assert.AreEqual(newDescript, task.Descript);
        }
示例#13
0
        ///<summary>Context menu right-click and select the "Paste" option with a cut Task on the clipboard.</summary>
        public void UserControlTasks_Paste_Clicked_Task_Cut()
        {
            _userControlTasksAccessor.SetField("_wasCut", true);          //task is cut, not copied.
            //Destination task list is the root node (item 0) from _listTaskListTreeHistory which was initialized in SetupTest().
            _userControlTasksAccessor.SetField("_clipTask", _task);       //Directly set which task is cut.
            _userControlTasksAccessor.Invoke("Paste_Clicked");            //Context menu "Paste" option click.
            List <Signalod> listSignals = SignalodT.GetAllSignalods();

            Assert.AreEqual(4, listSignals.Count);
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskList && x.FKeyType == KeyType.Undefined &&
                                             x.FKey == _taskListGrandchild.TaskListNum)); //Signal for source taskList.
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskList && x.FKeyType == KeyType.Undefined &&
                                             x.FKey == _taskListParent.TaskListNum));     //Signal for destination taskList.
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskPopup && x.FKeyType == KeyType.Task &&
                                             x.FKey == _task.TaskNum));                   //Signal for Task Popup.
            OpenDentBusiness.Task taskDb = Tasks.GetOne(_task.TaskNum);
            Assert.AreEqual(_taskListParent.TaskListNum, taskDb.TaskListNum);             //Db was properly updated with new taskListNum on _task.
        }
示例#14
0
        ///<summary>When sending a Task to multiple TaskLists, copies of the Task are made for the extra TaskLists. Verifies correct signals and Tasks are actually copied.</summary>
        public void FormTaskEdit_SaveCopy_OtherUserInbox()
        {
            _formTaskEditAccessor.SetField("_taskCur", _task);
            _formTaskEditAccessor.SetField("_listTaskNotes", new List <TaskNote>());
            List <long> listTaskListNums = new List <long>()
            {
                _taskListChild.TaskListNum
            };                                                                                      //Not current user's inbox, but still subscribed.

            _formTaskEditAccessor.Invoke("SaveCopy", listTaskListNums);
            List <Signalod> listSignals = SignalodT.GetAllSignalods();

            Assert.AreEqual(2, listSignals.Count);           //One popup signal, one tasklist signal.
            List <OpenDentBusiness.Task> listAllTasks = Tasks.GetNewTasksThisUser(Security.CurUser.UserNum, Clinics.ClinicNum);

            OpenDentBusiness.Task task = listAllTasks.FirstOrDefault(x => x.TaskListNum == _taskListChild.TaskListNum); //copied task.
            Assert.IsNotNull(task);                                                                                     //Task was copied correctly.
            //popup signal for copied task.
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskPopup && x.FKeyType == KeyType.Task && x.FKey == task.TaskNum));
            Assert.AreEqual(_taskListChild.TaskListNum, task.TaskListNum);           //Correct tasklist.
        }
示例#15
0
        ///<summary>Context menu right-click and select the "Paste" option with a copied Task on the clipboard.</summary>
        public void UserControlTasks_Paste_Clicked_Task_Copied()
        {
            _userControlTasksAccessor.SetField("_wasCut", false);         //task is copied.
            //Destination task list is the root node (item 0) from _listTaskListTreeHistory which was initialized in SetupTest().
            _userControlTasksAccessor.SetField("_clipTask", _task);       //Directly set which task is cut.
            _userControlTasksAccessor.Invoke("Paste_Clicked");            //Context menu "Paste" option click.
            List <Signalod> listSignals = SignalodT.GetAllSignalods();

            Assert.AreEqual(3, listSignals.Count);
            Assert.IsTrue(!listSignals.Exists(x => x.IType == InvalidType.TaskList && x.FKeyType == KeyType.Undefined &&
                                              x.FKey == _taskListGrandchild.TaskListNum)); //Should not have signal for source taskList.
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskList && x.FKeyType == KeyType.Undefined &&
                                             x.FKey == _taskListParent.TaskListNum));      //Signal for destination taskList.
            //Signal for Task Popup. Don't know the primary key for this.
            Assert.IsTrue(listSignals.Exists(x => x.IType == InvalidType.TaskPopup && x.FKeyType == KeyType.Task));
            long pastedTaskPK = listSignals.FirstOrDefault(x => x.IType == InvalidType.TaskPopup)?.FKey ?? 0; //Only way to get new key is by reading the associated signal.

            OpenDentBusiness.Task taskCopiedDb = Tasks.GetOne(_task.TaskNum);                                 //Copied task.
            OpenDentBusiness.Task taskPastedDb = Tasks.GetOne(pastedTaskPK);                                  //Pasted task.
            Assert.AreEqual(_taskListGrandchild.TaskListNum, taskCopiedDb.TaskListNum);                       //Db did not change on copied task.
            Assert.AreEqual(_taskListParent.TaskListNum, taskPastedDb.TaskListNum);                           //Db has pasted task in the correct tasklist.
        }
 public void TaskSubscriptions_TrySubscList_MarkOldRemindersRead()
 {
     TaskSubscriptionT.CreateTaskSubscription(_userNum, taskListChild.TaskListNum);           //Subscribed to TaskListChild (and by extension, TaskListGrandchild).
     #region Create Unread Past Due Reminders
     OpenDentBusiness.Task taskParent = TaskT.CreateTask(taskListParent.TaskListNum, descript: "ParentReminder", isUnread: true, reminderGroupId: "1"
                                                         , dateTimeEntry: DateTime.Now.AddSeconds(-1), reminderType: TaskReminderType.Once);
     OpenDentBusiness.Task taskChild = TaskT.CreateTask(taskListChild.TaskListNum, descript: "ChildReminder", isUnread: true, reminderGroupId: "1"
                                                        , dateTimeEntry: DateTime.Now.AddSeconds(-1), reminderType: TaskReminderType.Once);
     OpenDentBusiness.Task taskGrandchild = TaskT.CreateTask(taskListGrandchild.TaskListNum, descript: "GrandchildReminder", isUnread: true
                                                             , dateTimeEntry: DateTime.Now.AddSeconds(-1), reminderGroupId: "1", reminderType: TaskReminderType.Once);
     TaskAncestors.SynchAll();
     TaskUnreads.SetUnread(_userNum, taskParent);
     TaskUnreads.SetUnread(_userNum, taskChild);
     TaskUnreads.SetUnread(_userNum, taskGrandchild);
     #endregion
     bool isSuccess = TaskSubscriptions.TrySubscList(taskListParent.TaskListNum, _userNum);
     OpenDentBusiness.Task taskParentDb     = Tasks.GetOne(taskParent.TaskNum);
     OpenDentBusiness.Task taskChildDb      = Tasks.GetOne(taskChild.TaskNum);
     OpenDentBusiness.Task taskGrandchildDb = Tasks.GetOne(taskGrandchild.TaskNum);
     Assert.IsTrue(isSuccess);
     Assert.IsFalse(TaskUnreads.IsUnread(_userNum, taskParentDb));         //Only the task in taskListParent should be Read.
     Assert.IsTrue(TaskUnreads.IsUnread(_userNum, taskChildDb));           //The task in taskListChild should still be Unread.
     Assert.IsTrue(TaskUnreads.IsUnread(_userNum, taskGrandchildDb));      //The task in taskListGrandchild should still be Unread.
 }
示例#17
0
 public void SetupTest()
 {
     TaskListT.ClearTaskListTable();
     TaskT.ClearTaskTable();
     TaskSubscriptionT.ClearTaskSubscriptionTable();
     SignalodT.ClearSignalodTable();
     _taskListParent     = TaskListT.CreateTaskList(descript: "TaskListParent");
     _taskListChild      = TaskListT.CreateTaskList(descript: "TaskListChild", parent: _taskListParent.TaskListNum, parentDesc: _taskListParent.Descript);
     _taskListGrandchild = TaskListT.CreateTaskList(descript: "TaskListGrandchild", parent: _taskListChild.TaskListNum,
                                                    parentDesc: _taskListChild.Descript);
     _task = TaskT.CreateTask(_taskListGrandchild.TaskListNum, descript: "Test Task", fromNum: Security.CurUser.UserNum, priorityDefNum: 1); //Starts in _taskListGrandchild
     TaskSubscriptionT.CreateTaskSubscription(Security.CurUser.UserNum, _taskListParent.TaskListNum);                                        //current user subscribes to top level tasklist.
     Security.CurUser.TaskListInBox = _taskListParent.TaskListNum;                                                                           //Set inbox for current user to _taskListParent.
     try {
         Userods.Update(Security.CurUser);
         Userods.RefreshCache();
     }
     catch {
         Assert.Fail("Failed to update current user task list inbox.");                //Error updating user.
     }
     _formTaskEditInstance = new FormTaskEdit(_task);
     _formTaskEditAccessor = new PrivateObject(_formTaskEditInstance);
     _formTaskEditAccessor.Invoke("LoadTask");
 }
示例#18
0
 public void MiddleTier_GetListTasksContainingCR()
 {
     OpenDentBusiness.Task t = WebServiceTests.GetListTasksContainingCR()[0];
     Assert.IsTrue(t != null && t.Descript == WebServiceTests.NewLineString);
 }
示例#19
0
文件: Tasks.cs 项目: nampn/ODental
 ///<summary></summary>
 public static long Insert(Task task)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         task.TaskNum=Meth.GetLong(MethodBase.GetCurrentMethod(),task);
         return task.TaskNum;
     }
     if(task.IsRepeating && task.DateTask.Year>1880) {
         throw new Exception(Lans.g("Tasks","Task cannot be tagged repeating and also have a date."));
     }
     if(task.IsRepeating && task.TaskStatus!=TaskStatusEnum.New) {//and any status but new
         throw new Exception(Lans.g("Tasks","Tasks that are repeating must have a status of New."));
     }
     if(task.IsRepeating && task.TaskListNum!=0 && task.DateType!=TaskDateType.None) {//In repeating, children not allowed to repeat.
         throw new Exception(Lans.g("Tasks","In repeating tasks, only the main parents can have a task status."));
     }
     Crud.TaskCrud.Insert(task);
     TaskAncestors.Synch(task);
     return task.TaskNum;
 }
示例#20
0
		private void Copy_Clicked() {
			if(clickedI < TaskListsList.Count) {//is list
				ClipTaskList=TaskListsList[clickedI].Copy();
				ClipTask=null;
			}
			else {//task
				ClipTaskList=null;
				ClipTask=TasksList[clickedI-TaskListsList.Count].Copy();
			}
			WasCut=false;
		}
示例#21
0
文件: Tasks.cs 项目: nampn/ODental
 /*
 public static List<Task> RefreshAndFill(DataTable table){
     //No need to check RemotingRole; no call to db.
     List<Task> retVal=new List<Task>();
     Task task;
     for(int i=0;i<table.Rows.Count;i++) {
         task=new Task();
         task.TaskNum        = PIn.Long(table.Rows[i][0].ToString());
         task.TaskListNum    = PIn.Long(table.Rows[i][1].ToString());
         task.DateTask       = PIn.Date(table.Rows[i][2].ToString());
         task.KeyNum         = PIn.Long(table.Rows[i][3].ToString());
         task.Descript       = PIn.String(table.Rows[i][4].ToString());
         task.TaskStatus     = (TaskStatusEnum)PIn.Long(table.Rows[i][5].ToString());
         task.IsRepeating    = PIn.Bool(table.Rows[i][6].ToString());
         task.DateType       = (TaskDateType)PIn.Long(table.Rows[i][7].ToString());
         task.FromNum        = PIn.Long(table.Rows[i][8].ToString());
         task.ObjectType     = (TaskObjectType)PIn.Long(table.Rows[i][9].ToString());
         task.DateTimeEntry  = PIn.DateT(table.Rows[i][10].ToString());
         task.UserNum        = PIn.Long(table.Rows[i][11].ToString());
         task.DateTimeFinished= PIn.DateT(table.Rows[i][12].ToString());
         retVal.Add(task);
     }
     return retVal;
 }*/
 ///<summary>Must supply the supposedly unaltered oldTask.  The update will fail if oldTask does not exactly match the database state.  Keeps users from overwriting each other's changes.</summary>
 public static void Update(Task task,Task oldTask)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         Meth.GetVoid(MethodBase.GetCurrentMethod(),task,oldTask);
         return;
     }
     if(task.IsRepeating && task.DateTask.Year>1880) {
         throw new Exception(Lans.g("Tasks","Task cannot be tagged repeating and also have a date."));
     }
     if(task.IsRepeating && task.TaskStatus!=TaskStatusEnum.New) {//and any status but new
         throw new Exception(Lans.g("Tasks","Tasks that are repeating must have a status of New."));
     }
     if(task.IsRepeating && task.TaskListNum!=0 && task.DateType!=TaskDateType.None) {//In repeating, children not allowed to repeat.
         throw new Exception(Lans.g("Tasks","In repeating tasks, only the main parents can have a task status."));
     }
     if(WasTaskAltered(oldTask)){
         throw new Exception(Lans.g("Tasks","Not allowed to save changes because the task has been altered by someone else."));
     }
     Crud.TaskCrud.Update(task);
     if(task.TaskListNum!=oldTask.TaskListNum) {
         TaskAncestors.Synch(task);
     }
 }
示例#22
0
文件: Tasks.cs 项目: nampn/ODental
 ///<summary></summary>
 public static bool WasTaskAltered(Task task)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         return Meth.GetBool(MethodBase.GetCurrentMethod(),task);
     }
     string command="SELECT * FROM task WHERE TaskNum="+POut.Long(task.TaskNum);
     Task oldtask=Crud.TaskCrud.SelectOne(command);
     if(oldtask==null
         || oldtask.DateTask!=task.DateTask
         || oldtask.DateType!=task.DateType
         || oldtask.Descript!=task.Descript
         || oldtask.FromNum!=task.FromNum
         || oldtask.IsRepeating!=task.IsRepeating
         || oldtask.KeyNum!=task.KeyNum
         || oldtask.ObjectType!=task.ObjectType
         || oldtask.TaskListNum!=task.TaskListNum
         || oldtask.TaskStatus!=task.TaskStatus
         || oldtask.UserNum!=task.UserNum
         || oldtask.DateTimeEntry!=task.DateTimeEntry
         || oldtask.DateTimeFinished!=task.DateTimeFinished)
     {
         return true;
     }
     return false;
 }
示例#23
0
		private void butTask_Click(object sender,EventArgs e) {
			if(!UpdateToDB()) {
				return;
			}
			FormTaskListSelect FormT=new FormTaskListSelect(TaskObjectType.Appointment);//,AptCur.AptNum);
			FormT.ShowDialog();
			if(FormT.DialogResult!=DialogResult.OK) {
				return;
			}
			Task task=new Task();
			task.TaskListNum=-1;//don't show it in any list yet.
			Tasks.Insert(task);
			Task taskOld=task.Copy();
			task.KeyNum=AptCur.AptNum;
			task.ObjectType=TaskObjectType.Appointment;
			task.TaskListNum=FormT.SelectedTaskListNum;
			task.UserNum=Security.CurUser.UserNum;
			FormTaskEdit FormTE=new FormTaskEdit(task,taskOld);
			FormTE.IsNew=true;
			FormTE.ShowDialog();
		}
示例#24
0
		private void AddTask_Clicked() {
			if(Plugins.HookMethod(this,"UserControlTasks.AddTask_Clicked")) {
				return;
			}
			//if(tabContr.SelectedTab==tabUser && TreeHistory.Count==0) {//trunk of user tab
			//	MsgBox.Show(this,"Not allowed to add a task to the trunk of the user tab.  Add it to a child list instead.");
			//	return;
			//}
			//if(tabContr.SelectedTab==tabNew) {//new tab
			//	MsgBox.Show(this,"Not allowed to add items to the 'New' tab.");
			//	return;
			//}
			Task task=new Task();
			task.TaskListNum=-1;//don't show it in any list yet.
			Tasks.Insert(task);
			Task taskOld=task.Copy();
			//if this is a child of any taskList
			if(TreeHistory.Count>0) {
				task.TaskListNum=TreeHistory[TreeHistory.Count-1].TaskListNum;
			}
			else if(tabContr.SelectedTab==tabNew) {//new tab
				task.TaskListNum=-1;
			}
			else if(tabContr.SelectedTab==tabUser && TreeHistory.Count==0) {//trunk of user tab
				task.TaskListNum=-1;
			}
			else {
				task.TaskListNum=0;
				if(tabContr.SelectedTab==tabDate) {
					task.DateTask=cal.SelectionStart;
					task.DateType=TaskDateType.Day;
				}
				else if(tabContr.SelectedTab==tabWeek) {
					task.DateTask=cal.SelectionStart;
					task.DateType=TaskDateType.Week;
				}
				else if(tabContr.SelectedTab==tabMonth) {
					task.DateTask=cal.SelectionStart;
					task.DateType=TaskDateType.Month;
				}
			}
			if(tabContr.SelectedTab==tabRepeating) {
				task.IsRepeating=true;
			}
			task.UserNum=Security.CurUser.UserNum;
			FormTaskEdit FormT=new FormTaskEdit(task,taskOld);
			FormT.IsNew=true;
			FormT.Closing+=new CancelEventHandler(TaskGoToEvent);
			FormT.Show();//non-modal
		}