public static void editTask(decimal id, String state, decimal userId)
 {
     try {
         TaskDAL.editTask(id, state, userId);
     } catch (Exception e) {
         throw e;
     }
 }
 public static void refuseTask(decimal id, String message, decimal userId)
 {
     try {
         TaskDAL.refuseTask(id, message, userId);
     } catch (Exception e) {
         throw e;
     }
 }
Example #3
0
        public TaskDAL ToDALConverter(TaskDTO task)
        {
            EmployeeDAL owner   = _employeeReposirory.Get(task.OwnerID);
            var         DALTask = new TaskDAL(task.Name, task.Description, task.State, task.OwnerID);

            DALTask.Logger = task.Logger;
            return(DALTask);
        }
        public void UpdateTask(TaskDTO taskDTO)
        {
            TaskDAL taskDAL = _mapper.Map <TaskDAL>(taskDTO);

            _unitOfWork.Tasks.Update(taskDAL);

            _unitOfWork.Save();
        }
 public static void assignTask(decimal id, decimal userId)
 {
     try {
         TaskDAL.assignTask(id, userId);
     } catch (Exception e) {
         throw e;
     }
 }
        public static List <Task> getTaskGreen(decimal id)
        {
            try {
                var list = TaskDAL.fetchAllByUnit(id).Select(x => new Task {
                    id           = long.Parse(x.id + ""),
                    name         = x.name,
                    description  = x.description,
                    dateStart    = x.date_start,
                    dateEnd      = x.date_end,
                    taskStatusId = x.task_status
                }).ToList();

                List <Task> newList = new List <Task>();
                var         alert   = ConfigTrafficLightDAL.fetch();
                foreach (Task task in list)
                {
                    var end  = (DateTime)task.dateEnd;
                    var now  = DateTime.Now;
                    var date = -(Math.Round((now - end).TotalDays));

                    if (date > double.Parse(alert.yellow + "") &&
                        task.taskStatusId != "2" && task.taskStatusId != "3")
                    {
                        User dUser = new User();
                        if (task.assingId != 0)
                        {
                            var user = UserDAL.fetchAll().Where(x => x.id == task.assingId).FirstOrDefault();
                            if (user != null)
                            {
                                dUser.id   = long.Parse(user.id + "");
                                dUser.name = user.name;
                            }
                            else
                            {
                                dUser.name = "Sin Asignar";
                            }
                        }
                        else
                        {
                            dUser.name = "Sin Asignar";
                        }
                        task.creatorUser = dUser;

                        if (task.dateEnd != null)
                        {
                            task.sDateEnd = ((DateTime)task.dateEnd).ToString("dd/MM/yyyy").Replace("-", "/");
                        }


                        newList.Add(task);
                    }
                }
                return(newList);
            } catch (Exception e) {
                throw e;
            }
        }
        public void FindTaskById()
        {
            TaskDAL pobj = new TaskDAL();
            var     p    = pobj.GetTaskById(2);

            Assert.AreEqual(p.Task_Id, 2);
            Assert.AreEqual(p.Task_Name, "Task 1");
            Assert.AreEqual(p.Project_Id, 1);
        }
        public void GetTaskById()
        {
            TaskDAL pobj = new TaskDAL();
            var     p    = pobj.GetTaskById(2);

            Assert.AreEqual(p.Task_Id, 2);
            Assert.AreEqual(p.Task_Name, "Cab Schedule");
            Assert.AreNotEqual(p.Project_Id, 2);
        }
Example #9
0
        public void ValidateTaskById()
        {
            TaskDAL pobj = new TaskDAL();
            var     p    = pobj.GetTaskById(2);

            Assert.AreEqual(p.Task_Id, 2);
            Assert.AreEqual(p.Task_Name, "Testing");
            Assert.AreEqual(p.Project_Id, 1);
        }
Example #10
0
 public TaskDTO(TaskDAL taskDAL)
 {
     Id          = taskDAL.Id;
     Name        = taskDAL.Name;
     Description = taskDAL.Description;
     State       = (TaskState)taskDAL.State;
     StaffId     = taskDAL.StaffId;
     Comment     = taskDAL.Comment;
 }
Example #11
0
        public void CheckTaskById()
        {
            TaskDAL pobj = new TaskDAL();
            var     p    = pobj.GetTaskById(8);

            Assert.AreEqual(p.Task_Id, 8);
            Assert.AreEqual(p.Task_Name, "task1");
            Assert.AreEqual(p.Project_Id, 1);
        }
 public CRMService()
 {
     TaskDAL taskdal = new TaskDAL();
     UserDAL  userdal = new UserDAL();
     CustomerDAL customerdal = new CustomerDAL();
     container.RegisterInstance<TaskDAL>(taskdal);
     container.RegisterInstance<UserDAL>(userdal);
     container.RegisterInstance<CustomerDAL>(customerdal);
 }
Example #13
0
        public TaskDTO ToDTOConverter(TaskDAL task)
        {
            var DTOTask = new TaskDTO(task.Name, task.Description, task.State, task.OwnerID);

            DTOTask.State  = task.State;
            DTOTask.ID     = task.ID;
            DTOTask.Logger = task.Logger;
            return(DTOTask);
        }
 /// <summary>
 /// 删除指定ID的任务
 /// </summary>
 /// <param name="taskId"></param>
 private void DeleteTaskByTaskID(long taskId)
 {
     try
     {
         DataTable dtTasks = (DataTable)ViewState["dtTasks"];
         DataRow[] drs     = dtTasks.Select("TaskID=" + taskId);
         if (drs.Length > 0)
         {
             DataRow[] drChilds = dtTasks.Select("PID=" + taskId);
             if (drChilds.Length <= 0)//无子任务,可以删除
             {
                 DataRow dr = drs[0];
                 dr.BeginEdit();
                 dr["Flag"] = 0;//数据库逻辑删除,将标记置为0
                 TaskDAL.UpdateProjectTask(dr);
                 lbErr.Text = "任务删除成功!";
                 dr.EndEdit();
                 dtTasks.Rows.Remove(dr);//数据集中物理删除,将行删除
                 ViewState["dtTasks"] = dtTasks;
                 DataTable dtLTasks = TaskBLL.GetTasksWithLevel(dtTasks, "Title", "PID", false);
                 ViewState["dtLTasks"] = dtLTasks;
                 BindTasks(dtLTasks);
                 ////用户确认是否删除子任务
                 //if (isDelchildTask == 0)//不删除子任务,则将其升级到其上一级任务
                 //{
                 //    int pId = DAL.SystemDataExtension.GetInt16(dr, "PID");
                 //    foreach (DataRow drChild in drChilds)
                 //    {
                 //        drChild["PID"] = pId;
                 //        TaskDAL.UpdateProjectTask(drChild);
                 //    }
                 //}
                 //else//子任务一起删除
                 //{
                 //    foreach (DataRow drChild in drChilds)
                 //    {
                 //        drChild["Flag"] = 0;
                 //        TaskDAL.UpdateProjectTask(drChild);
                 //    }
                 //}
             }
             else
             {
                 lbErr.Text = "该任务有低级的子任务,无法删除!";//有子任务,不可删除
             }
         }
         else
         {
             lbErr.Text = "你删除的任务已不存在!";
         }
     }
     catch (Exception ex)
     {
         lbErr.Text = ex.ToString();
     }
 }
Example #15
0
        /// <summary>
        /// 更新Task对象到数据
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public int Update(Task task)
        {
            if (task == null)
            {
                return(0);
            }
            TaskDAL dal = new TaskDAL();
            int     ire = dal.Update(task);

            return(ire);
        }
Example #16
0
 public Func <int, bool> GetSave()
 {
     if (!this.Legal)
     {
         Logger.Log.Error("did not save task id: " + this.ID + " becuse it is illegal.  title: '" + this.Title + "'; desciption: '" + this.Description + "'; dueDate: " + this.DueDate.Date + "; creationDate: " + this.CreationDate.Date);
         AlmogException kipod = new AlmogException();
         kipod.Value = "did not save task because it's illegal";
         throw kipod;
     }
     return((Cid) => { TaskDAL.SaveTask(this.toStruct(), Cid); return true; });
 }
        public static List <ListReportProcess> getReportProcess(decimal id)
        {
            try {
                List <ListReportProcess> processList = new List <ListReportProcess>();

                var dProcess = ProcessDAL.fetchAllByUnit(id);

                foreach (process p in dProcess)
                {
                    ListReportProcess response = new ListReportProcess();
                    response.processId   = int.Parse(p.id + "");
                    response.processName = p.name;

                    var list = TaskDAL.fetchByProcess(p.id).Select(x => new Task {
                        id           = long.Parse(x.id + ""),
                        name         = x.name,
                        taskStatusId = x.task_status,
                    }).ToList();

                    response.taskList = list;

                    int ready   = 0;
                    int working = 0;
                    int pending = 0;

                    foreach (Task task in list)
                    {
                        if (task.taskStatusId == "0")
                        {
                            pending++;
                        }
                        else if (task.taskStatusId == "2")
                        {
                            ready++;
                        }
                        else if (task.taskStatusId == "4")
                        {
                            working++;
                        }
                    }

                    response.tasks   = list.Count();
                    response.done    = ready;
                    response.working = working;
                    response.pending = pending;

                    processList.Add(response);
                }

                return(processList);
            } catch (Exception e) {
                throw e;
            }
        }
Example #18
0
        public List <Task> GetAllTasks()
        {
            List <Task> tasks = TaskDAL.GetAllTasks();

            foreach (Task t in tasks)
            {
                CheckOverdue(t);
            }

            return(tasks);
        }
Example #19
0
        /// <summary>
        /// 页面加载与控件事件绑定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //btnSetAction.Click += BtnSetActions_Click;//设计计划的操作
            btnSubmit.Click    += BtnSubmit_Click;//提交计划保存
            btnCancel.Click    += BtnCancel_Click;
            btnAddSingle.Click += BtnAddSingle_Click;
            btnAddMulti.Click  += BtnAddMulti_Click;
            ddlPlanAction.SelectedIndexChanged += DdlPlanAction_SelectedIndexChanged;
            //btnSaveToPlan.Click += BtnSaveToPlan_Click;
            btnSaveToList.Click    += BtnSaveToList_Click;
            btnCancelToList.Click  += BtnCancelToList_Click;
            gvPlans.RowDataBound   += GvPlans_RowDataBound;
            gvActions.RowDataBound += GvActions_RowDataBound;
            gvPlans.RowCommand     += GvPlans_RowCommand;
            if (!IsPostBack)
            {
                int userId = VSDLL.Common.Users.UserID;
                if (userId == 0)
                {
                    divList.Visible   = false;
                    divPlan.Visible   = false;
                    divAction.Visible = false;
                    lbPTitle.Visible  = false;
                    lbErr.Text        = "你尚未登录,无法管理个人计划!";
                }
                else
                {
                    lbPTitle.Visible = true;
                    lbErr.Text       = "";
                    try
                    {
                        //获取计划列表
                        DataSet   dsPlans = TaskDAL.GetDailyTask(userId);
                        DataTable dtPlans = dsPlans.Tables[0];
                        ViewState["dtPlans"] = dtPlans;
                        //获取操作列表
                        DataSet   dsActions = ActionDAL.GetAllActions(0);
                        DataTable dtActions = dsActions.Tables[0];
                        ViewState["dtActions"] = dtActions;
                        //获取操作关系列表
                        DataSet   dsRelations = ActionDAL.GetActionRelation();
                        DataTable dtRelations = dsRelations.Tables[0];
                        ViewState["dtRelations"] = dtRelations;

                        //绑定计划列表
                        BindgvPlans(dtPlans);
                    }
                    catch (Exception ex)
                    {
                        lbErr.Text = ex.ToString();
                    }
                }
            }
        }
Example #20
0
        /// <summary>
        /// 所有任务的一个列表
        /// eg
        /// ABREQUEST-1111-说明说明
        /// </summary>
        /// <returns></returns>
        public IList <string> TaskList()
        {
            IList <string> tasks = new List <string>();
            TaskDAL        dal   = new TaskDAL();
            DataTable      dtb   = dal.GetTaskTable();

            foreach (DataRow dr in dtb.Rows)
            {
                tasks.Add(dr[1].ToString());
            }
            return(tasks);
        }
Example #21
0
        /// <summary>
        /// 更新任务
        /// </summary>
        /// <param name="myTask">DairyTask</param>
        public bool UpdateTask(DairyTask myTask)
        {
            bool    isSuccessful = false;
            TaskDAL dal          = new TaskDAL();
            int     i            = dal.UpdateTask(myTask);

            if (i == 1)
            {
                isSuccessful = true;
            }
            return(isSuccessful);
        }
        public TaskDTO GetTask(int id)
        {
            TaskDAL taskDAL = _unitOfWork.Tasks.GetByID(id);

            if (taskDAL == null)
            {
                return(null);
            }
            TaskDTO taskDTO = _mapper.Map <TaskDTO>(taskDAL);

            return(taskDTO);
        }
        public static List <Alert> getRejectionTasksByCreator(decimal id)
        {
            try {
                List <Alert> list   = new List <Alert>();
                var          dTasks = TaskDAL.getCreationTasksByUser(id).ToList();

                foreach (tasks item in dTasks)
                {
                    var dAlert = AlertDAL.fetchByTaskId(long.Parse(item.id + ""));
                    if (dAlert != null)
                    {
                        Task task = new Task();
                        task.id          = long.Parse(item.id + "");
                        task.name        = item.name;
                        task.description = item.description;
                        task.dateEnd     = item.date_end;
                        task.sDateEnd    = ((DateTime)item.date_end).ToString("dd/MM/yyyy").Replace("-", "/");

                        if (item.process_id != null)
                        {
                            var     process  = ProcessDAL.getById(Decimal.Parse(item.process_id + ""));
                            Process dProcess = new Process();
                            dProcess.name        = process.name;
                            dProcess.description = process.description;
                            dProcess.id          = long.Parse(process.id + "");
                            task.process         = dProcess;
                        }

                        var user = UserDAL.fetchAll().Where(x => x.id == item.assing_id).FirstOrDefault();

                        User mUser = new User();
                        mUser.id   = long.Parse(user.id + "");
                        mUser.name = user.name;

                        task.creatorUser = mUser;

                        Alert alert = new Alert();

                        alert.id      = dAlert.id;
                        alert.message = dAlert.message;
                        alert.state   = int.Parse(dAlert.state + "");
                        alert.task    = task;

                        list.Add(alert);
                    }
                }


                return(list);
            } catch (Exception e) {
                throw e;
            }
        }
        public static List <ListReportUnit> getReportUnit(decimal id)
        {
            try {
                List <ListReportUnit> processList = new List <ListReportUnit>();

                var dUnit = UnitDAL.fetchAll().Where(x => x.id == id).FirstOrDefault();

                var dUnits = UnitDAL.fetchAll().Where(x => x.enterprise_id == dUnit.enterprise_id).ToList();

                foreach (units u in dUnits)
                {
                    ListReportUnit response = new ListReportUnit();
                    response.unitId   = int.Parse(u.id + "");
                    response.unitName = u.name;

                    var list = TaskDAL.fetchAllByUnit(u.id).Select(x => new Task {
                        id           = long.Parse(x.id + ""),
                        name         = x.name,
                        taskStatusId = x.task_status,
                    }).ToList();

                    int ready   = 0;
                    int working = 0;
                    int pending = 0;

                    foreach (Task task in list)
                    {
                        if (task.taskStatusId == "0")
                        {
                            pending++;
                        }
                        else if (task.taskStatusId == "2")
                        {
                            ready++;
                        }
                        else if (task.taskStatusId == "4")
                        {
                            working++;
                        }
                    }

                    response.done    = ready;
                    response.working = working;
                    response.pending = pending;

                    processList.Add(response);
                }
                return(processList);
            } catch (Exception e) {
                throw e;
            }
        }
Example #25
0
        public Func <int, bool> GetUpdate(string title, string description, DateTime?dueDate)
        {
            Func <int, bool> ans = (Cid) =>
            {
                this.Legal = true;
                String validTitle = title;
                if (title == null)
                {
                    validTitle = this.Title;
                }
                String validDescription = description;
                if (description == null)
                {
                    validDescription = this.Description;
                }
                DateTime validduedate = this.DueDate;
                if (dueDate != null)
                {
                    validduedate = (DateTime)dueDate;
                }

                validTask(validTitle, validDescription, validduedate);

                if (!this.Legal)
                {
                    Logger.Log.Error("did not update task id: " + this.ID + " becuse it is still illegal/  title: '" + validTitle + "'; desciption: '" + validDescription + "'; dueDate: " + validduedate.Date + "; creationDate: " + this.CreationDate.Date);
                    // Console.WriteLine("did not update task because it's illegal");
                    AlmogException kipod = new AlmogException();
                    kipod.Value = "did not update task because it's illegal";
                    throw kipod;
                }
                else
                {
                    if (title != null)
                    {
                        this.Title = title;
                    }
                    if (description != null)
                    {
                        this.Description = description;
                    }
                    if (dueDate != null)
                    {
                        this.DueDate = (DateTime)dueDate;
                    }
                    TaskDAL.UpdateTask(this.toStruct(), Cid);
                    return(true);
                }
            };

            return(ans);
        }
        public static ListReportAlerts getReportAlerts(decimal id)
        {
            try {
                var list = TaskDAL.fetchAllByUser(id).Select(x => new Task {
                    id           = long.Parse(x.id + ""),
                    name         = x.name,
                    description  = x.description,
                    dateStart    = x.date_start,
                    dateEnd      = x.date_end,
                    taskStatusId = x.task_status
                }).ToList();

                ListReportAlerts response = new ListReportAlerts();

                var alert = ConfigTrafficLightDAL.fetch();

                int red    = 0;
                int yellow = 0;
                int green  = 0;

                foreach (Task task in list)
                {
                    var end  = (DateTime)task.dateEnd;
                    var now  = DateTime.Now;
                    var date = -(Math.Round((now - end).TotalDays));

                    if (date <= double.Parse(alert.red + "") && task.taskStatusId != "2" && task.taskStatusId != "3")
                    {
                        red++;
                    }
                    else
                    if (date <= double.Parse(alert.yellow + "") &&
                        task.taskStatusId != "2" && task.taskStatusId != "3")
                    {
                        yellow++;
                    }
                    else if (date > double.Parse(alert.green + "") &&
                             task.taskStatusId != "2" && task.taskStatusId != "3")
                    {
                        green++;
                    }
                }

                response.red    = red;
                response.yellow = yellow;
                response.green  = green;
                return(response);
            } catch (Exception e) {
                throw e;
            }
        }
Example #27
0
        /// <summary>
        /// Inserts a task to the db
        /// </summary>
        /// <param name="dalObject"></param>
        /// <returns>The id generated by the database</returns>
        public override long Insert(DalObject dalObject)
        {
            using (var connection = new SQLiteConnection(_connectionString))
            {
                TaskDAL          task       = (TaskDAL)dalObject;
                long             output     = -1;
                SQLiteCommand    command    = new SQLiteCommand(null, connection);
                SQLiteDataReader dataReader = null;
                try
                {
                    connection.Open();
                    command.CommandText = $"INSERT INTO {tasksTable} ({TaskDAL.TaskTitleColumn} ,{TaskDAL.TaskCreationTimeColumn} ,{TaskDAL.TaskDueDateColumn} ,{TaskDAL.TaskDescriptionColumn},{TaskDAL.TaskColumnIdColumn},{TaskDAL.TaskAssigneeColumn}) " +
                                          $"VALUES (@TitleVal,@CreationVal,@DueVal,@DescVal,@colIdVal,@assigneeIdVal); SELECT {DalController.seqCol} FROM {DalController.SqlSeq} WHERE {DalController.seqName}='{tasksTable}';";

                    SQLiteParameter TitleParam    = new SQLiteParameter(@"TitleVal", task.Title);
                    SQLiteParameter CreationParam = new SQLiteParameter(@"CreationVal", task.CreationTime);
                    SQLiteParameter DueDateParam  = new SQLiteParameter(@"DueVal", task.DueDate);
                    SQLiteParameter DescParam     = new SQLiteParameter(@"DescVal", task.Description);
                    SQLiteParameter colIdParam    = new SQLiteParameter(@"colIdVal", task.ColumnID);
                    SQLiteParameter assigneeParam = new SQLiteParameter(@"assigneeIdVal", task.AssigneeID);


                    command.Parameters.Add(TitleParam);
                    command.Parameters.Add(CreationParam);
                    command.Parameters.Add(DueDateParam);
                    command.Parameters.Add(DescParam);
                    command.Parameters.Add(colIdParam);
                    command.Parameters.Add(assigneeParam);
                    dataReader = command.ExecuteReader();

                    if (dataReader.Read())
                    {
                        output = (long)dataReader.GetValue(0);
                    }
                }
                catch (Exception e)
                {
                    log.Error($"Failed to insert task to database{task.Title}", e);
                }
                finally
                {
                    if (dataReader != null)
                    {
                        dataReader.Close();
                    }
                    command.Dispose();
                    connection.Close();
                }
                return(output);
            }
        }
Example #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCreateTask_Click(object sender, EventArgs e)
        {
            lblCreateTaskResults.Text = "";

            if (Page.IsValid)
            {
                // Make sure the user selected a team
                if (ddlCreateTaskTeam.SelectedValue.Equals("") || ddlCreateTaskTeam.SelectedValue.Equals("0") ||
                    ddlCreateTaskTeam.SelectedValue == null)
                {
                    lblCreateTaskResults.ForeColor = Color.Red;
                    lblCreateTaskResults.Text      = "You must select a team. ";
                    return;
                }

                // Make sure name and description are not empty
                if (tbxCreateTaskName.Text.Equals("") || tbxCreateDescription.Equals(""))
                {
                    lblCreateTaskResults.ForeColor = Color.Red;
                    lblCreateTaskResults.Text      = "Must complete all fields. ";
                    return;
                }

                // Make sure current user is the admin of the selected team
                // First make sure the current user is the admin of the selected team
                Team team = TeamDAL.GetTeamById(Convert.ToInt64(ddlCreateTaskTeam.SelectedValue));

                // If the user is NOT the team admin...
                if (currentUser.ID != team.TeamOwner)
                {
                    lblCreateTaskResults.ForeColor = Color.Red;
                    lblCreateTaskResults.Text     += "Cannot add tasks to a team that you are not the admin of. ";
                    return;
                }

                // Now all data is valid... so create task
                Int64 newTaskID = TaskDAL.CreateNewTask(tbxCreateTaskName.Text, cdlCreateCalendar.SelectedDate,
                                                        tbxCreateDescription.Text, Convert.ToInt64(ddlCreateTaskTeam.SelectedValue));
                lblCreateTaskResults.ForeColor = Color.Blue;
                lblCreateTaskResults.Text      = "Successfully created task. ";

                // Now refresh all of the drop down lists on the page
                this.RefreshAllDropDownLists();

                // Clear the fields in the Create Task View
                tbxCreateTaskName.Text         = "";
                tbxCreateDescription.Text      = "";
                cdlCreateCalendar.SelectedDate = DateTime.Now;
            }
        }
Example #29
0
        public virtual void Create(TaskDataModel task)
        {
            if (task.fileTemplate != null)
            {
                string filePath = FileManager.SaveFile(task.fileTemplate);
                if (!String.IsNullOrEmpty(filePath))
                {
                    task.Template = filePath;
                }
                ;
            }

            TaskDAL.Create(task);
        }
        public IActionResult TaskChange(int id, byte f, byte v)
        {
            ViewBag.taskList = TaskDAL.refreshTasks(new TaskConfigurationModel {
                id             = id,
                allowDocuments = f,
                state          = v
            });
            int response = 1;

            return(RedirectToAction("Index", new
            {
                response
            }));
        }
Example #31
0
        public void Update(TaskDTO task, int employeeID, int ToChangeTaskId)
        {
            if (Get(ToChangeTaskId).State == TaskState.Resolved)
            {
                throw new ResolvedTask();
            }
            var     discriptionLog = $"Update : task.Name = {task.Name} task.ownerID = {task.OwnerID}, task.description = {task.Description}, task.state = {task.State}";
            var     log            = new Triad <DateTime, int, string> (DateTime.Now, employeeID, discriptionLog);
            TaskDAL DALTask        = _taskReposirory.GetAll().Find(t => t.ID.Equals(ToChangeTaskId));

            task.Logger.AddRange(DALTask.Logger);
            task.Logger.Add(log);
            _taskReposirory.Update(ToDALConverter(task), ToChangeTaskId);
        }