示例#1
0
 public async Task <IHttpActionResult> ReplyTask(ReplyTaskModel model)
 {
     try
     {
         TaskMastApp app = new TaskMastApp();
         app.ReplyTask(model.taskId, User.Identity.GetUserId(), model.title, model.context, model.fileId, model.fileExt);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
示例#2
0
 public async Task <IHttpActionResult> ReadTask(string taskId)
 {
     try
     {
         TaskMastApp app = new TaskMastApp();
         app.readTask(taskId, User.Identity.GetUserId());
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
示例#3
0
        public async Task <IHttpActionResult> DeleteTask(string taskId)
        {
            try
            {
                TaskMastApp MastApp = new TaskMastApp();
                MastApp.deleteTask(taskId);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }



            return(Ok());
        }
示例#4
0
        public TaskModel CreateTask(TaskModel model)
        {
            try
            {
                String         userid   = User.Identity.GetUserId();
                String         taskId   = System.Guid.NewGuid().ToString();
                TaskMastApp    MastApp  = new TaskMastApp();
                marketSalesApp salesApp = new marketSalesApp();
                MastApp.createTask(new TaskMastEntity()
                {
                    id            = taskId,
                    alertType     = model.alertType,
                    createdUserId = userid,
                    CustomerCode  = model.CustomerCode,
                    CustomerName  = model.CustomerName,
                    desc          = model.desc,
                    endTime       = model.endTime,
                    freqType      = model.freqType,
                    importantType = model.importantType,
                    starTime      = model.starTime,
                    taskName      = model.taskName,
                    taskType      = model.taskType,
                    isAll         = model.isAll,
                    taskTypeName  = model.taskTypeName,
                    fileId        = model.fileId, createdTime = System.DateTime.Now, modifyTime = System.DateTime.Now,
                    taskSource    = salesApp.GetUserInfo(userid).Name,
                    fileName      = model.fileName,
                    fileExt       = model.fileExt, address = model.address, Location = model.Location
                });
                model.id = taskId;
                TaskPopApp popApp = new TaskPopApp();
                popApp.createTaskPop(new TaskPopEntity()
                {
                    id = System.Guid.NewGuid().ToString(), status = 2, taskId = taskId, UserId = userid, userType = 1
                });
                foreach (string pUserid in model.responsibilityUser)
                {
                    if (pUserid.Equals(userid))
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 2, taskId = taskId, UserId = pUserid, userType = 1
                        });
                    }
                    else
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 1, taskId = taskId, UserId = pUserid, userType = 1
                        });
                    }
                }
                foreach (string pUserid in model.participateUser)
                {
                    if (pUserid.Equals(userid))
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 2, taskId = taskId, UserId = pUserid, userType = 2
                        });
                    }
                    else
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 1, taskId = taskId, UserId = pUserid, userType = 2
                        });
                    }
                }
                return(model);
            }
            catch (Exception ex)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content      = new StringContent(ex.ToString()),
                    ReasonPhrase = "error"
                };
                throw new HttpResponseException(resp);
            }



            //return Ok();
        }
示例#5
0
        public async Task <IHttpActionResult> ModifyTask(TaskModel model)
        {
            try
            {
                String         userid   = User.Identity.GetUserId();
                marketSalesApp salesApp = new marketSalesApp();
                TaskMastApp    MastApp  = new TaskMastApp();
                MastApp.modifyTask(new TaskMastEntity()
                {
                    id            = model.id,
                    alertType     = model.alertType,
                    createdUserId = userid,
                    CustomerCode  = model.CustomerCode,
                    CustomerName  = model.CustomerName,
                    desc          = model.desc,
                    endTime       = model.endTime,
                    freqType      = model.freqType,
                    importantType = model.importantType,
                    starTime      = model.starTime,
                    taskName      = model.taskName,
                    taskType      = model.taskType,
                    taskTypeName  = model.taskTypeName,
                    fileId        = model.fileId,
                    isAll         = model.isAll,
                    modifyTime    = System.DateTime.Now, fileName = model.fileName, fileExt = model.fileExt,
                    taskSource    = salesApp.GetUserInfo(userid).Name, Location = model.Location, address = model.address
                });
                TaskPopApp popApp = new TaskPopApp();
                popApp.deletePop(model.id);
                popApp.createTaskPop(new TaskPopEntity()
                {
                    id = System.Guid.NewGuid().ToString(), status = 2, taskId = model.id, UserId = userid, userType = 1
                });
                foreach (string pUserid in model.responsibilityUser)
                {
                    if (pUserid.Equals(userid))
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 2, taskId = model.id, UserId = pUserid, userType = 1
                        });
                    }
                    else
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 1, taskId = model.id, UserId = pUserid, userType = 1
                        });
                    }
                }
                foreach (string pUserid in model.participateUser)
                {
                    if (pUserid.Equals(userid))
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 2, taskId = model.id, UserId = pUserid, userType = 2
                        });
                    }
                    else
                    {
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 1, taskId = model.id, UserId = pUserid, userType = 2
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }



            return(Ok());
        }
示例#6
0
        public List <QueryTaskModel> GetTasks(int queryType, string startDay, string endDay)
        {
            try
            {
                DateTime startTime            = DateTime.ParseExact(startDay + " 00:00:00", "yyyyMMdd HH:mm:ss", CultureInfo.CurrentCulture);
                DateTime endTime              = DateTime.ParseExact(endDay + " 23:59:59", "yyyyMMdd HH:mm:ss", CultureInfo.CurrentCulture);
                String   userid               = User.Identity.GetUserId();
                List <QueryTaskModel> models  = new List <QueryTaskModel>();
                TaskMastApp           mastApp = new TaskMastApp();
                var tempMastEnt               = mastApp.getTask(userid, startTime.ToString("yyyy-MM-dd"),
                                                                endTime.ToString("yyyy-MM-dd"), queryType);
                var mastEnts = tempMastEnt.Distinct();
                SubTaskStatusApp statusApp = new SubTaskStatusApp();
                var        statusEnts      = statusApp.getTaskStatus(startTime.ToString("yyyy-MM-dd HH:mm:ss"), endTime.ToString("yyyy-MM-dd HH:mm:ss"), userid);
                TaskPopApp popApp          = new TaskPopApp();
                var        mastStatusList  = popApp.getTaskStatusList(startTime.ToString("yyyy-MM-dd"),
                                                                      endTime.ToString("yyyy-MM-dd"), userid);


                foreach (var mastEnt in mastEnts)
                {
                    int mastStatus = 2;
                    var list       = mastStatusList.Where(p => p.taskId.Equals(mastEnt.id));
                    if (list != null && list.Count() > 0)
                    {
                        mastStatus = list.First().status.Value;
                    }
                    //int mastStatus= mastStatusList.Where(p=>p.taskId.Equals(mastEnt.id))   //popApp.getTaskStatus(mastEnt.id, userid);
                    string patch = mastEnt.createdTime.Value.ToString("yyyyMM");
                    // 1 = 一次
                    if (mastEnt.freqType == 1)
                    {
                        models.Add(this.markTasks(mastStatus, mastEnt, statusEnts, patch, mastEnt.starTime.Value));
                    }
                    //4 = 每日
                    else if (mastEnt.freqType == 4)
                    {
                        TimeSpan ts        = endTime - startTime;
                        DateTime temptime  = DateTime.ParseExact(startTime.ToString("yyyy-MM-dd") + mastEnt.starTime.Value.ToString(" HH:mm:ss"), "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture);
                        DateTime temptime2 = DateTime.ParseExact(startTime.ToString("yyyy-MM-dd") + mastEnt.endTime.Value.ToString(" HH:mm:ss"), "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture);
                        for (int i = 0; i <= ts.Days; i++)
                        {
                            if (DateTime.Compare(temptime, mastEnt.starTime.Value) >= 0 && DateTime.Compare(mastEnt.endTime.Value, temptime2) >= 0)
                            {
                                models.Add(this.markTasks(mastStatus, mastEnt, statusEnts, patch, temptime));
                            }
                            temptime  = temptime.AddDays(1);
                            temptime2 = temptime2.AddDays(1);
                        }
                    }
                    //8 = 每周
                    else if (mastEnt.freqType == 8)
                    {
                        TimeSpan ts        = endTime - startTime;
                        DateTime temptime  = DateTime.ParseExact(startTime.ToString("yyyy-MM-dd") + mastEnt.starTime.Value.ToString(" HH:mm:ss"), "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture);
                        DateTime temptime2 = DateTime.ParseExact(startTime.ToString("yyyy-MM-dd") + mastEnt.endTime.Value.ToString(" HH:mm:ss"), "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture);

                        for (int i = 0; i <= ts.Days; i++)
                        {
                            //DateTime tempDate = mastEnt.starTime.Value.AddDays(i);
                            if (DateTime.Compare(temptime, mastEnt.starTime.Value) >= 0 && DateTime.Compare(mastEnt.endTime.Value, temptime2) >= 0 && temptime.DayOfWeek == mastEnt.starTime.Value.DayOfWeek)
                            {
                                models.Add(this.markTasks(mastStatus, mastEnt, statusEnts, patch, temptime));
                            }
                            temptime  = temptime.AddDays(1);
                            temptime2 = temptime2.AddDays(1);
                        }
                    }
                    //16 = 每月
                    else if (mastEnt.freqType == 16)
                    {
                        TimeSpan ts        = endTime - startTime;
                        DateTime temptime  = DateTime.ParseExact(startTime.ToString("yyyy-MM-dd") + mastEnt.starTime.Value.ToString(" HH:mm:ss"), "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture);
                        DateTime temptime2 = DateTime.ParseExact(startTime.ToString("yyyy-MM-dd") + mastEnt.endTime.Value.ToString(" HH:mm:ss"), "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture);

                        for (int i = 0; i <= ts.Days; i++)
                        {
                            //DateTime tempDate = mastEnt.starTime.Value.AddDays(i);
                            if (DateTime.Compare(temptime, mastEnt.starTime.Value) >= 0 && DateTime.Compare(mastEnt.endTime.Value, temptime2) >= 0 && temptime.Day == mastEnt.starTime.Value.Day)
                            {
                                models.Add(this.markTasks(mastStatus, mastEnt, statusEnts, patch, temptime));
                            }
                            temptime  = temptime.AddDays(1);
                            temptime2 = temptime2.AddDays(1);
                        }
                    }
                }

                return(models.OrderByDescending(p => p.starTime).ToList());
            }
            catch (Exception ex)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content      = new StringContent(ex.ToString()),
                    ReasonPhrase = "error"
                };
                throw new HttpResponseException(resp);
            }
        }