Exemple #1
0
        /*
         * 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);
            }
        }
Exemple #2
0
 ///<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);
 }