public List <TaskUser> GetUsers(int page, string queryString) { try { List <TaskUser> users = new List <TaskUser>(); TaskPopApp popApp = new TaskPopApp(); if (queryString == null) { queryString = ""; } var orgEnts = popApp.getAllOrg(); var ents = popApp.getAllOrgUser(); foreach (var ent in ents) { users.Add(new TaskUser() { GroupName = "ALL", userId = ent.id, userName = ent.EMPLOYEE_NAME, JobName = ent.Job_NAME, Desc = getOrgDesc(ent.ORG_ID, orgEnts) }); } return(users); } catch (Exception ex) { var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(ex.ToString()), ReasonPhrase = "error" }; throw new HttpResponseException(resp); } }
public async Task <IHttpActionResult> AllowTask(string taskId, int allowType) { try { String userid = User.Identity.GetUserId(); TaskPopApp popApp = new TaskPopApp(); popApp.AllowTask(taskId, userid, 0, allowType); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }
public TaskUsers GetTaskUsers(string taskId) { try { TaskUsers users = new TaskUsers(); users.participateUser = new List <TaskUser>(); users.responsibilityUser = new List <TaskUser>(); marketSalesApp salesApp = new marketSalesApp(); TaskPopApp popApp = new TaskPopApp(); var ents = popApp.getTaskPop(taskId); foreach (var ent in ents) { if (ent.userType == 1) { users.responsibilityUser.Add(new TaskUser() { userId = ent.UserId, userName = salesApp.GetUserInfo(ent.UserId).Name }); } else { users.participateUser.Add(new TaskUser() { userId = ent.UserId, userName = salesApp.GetUserInfo(ent.UserId).Name }); } } return(users); } catch (Exception ex) { var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(ex.ToString()), ReasonPhrase = "error" }; throw new HttpResponseException(resp); } }
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(); }
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()); }
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); } }
public salesActualChangeRes leave(user_leaveEntity entity) { if (getLeaveByDate2(entity.userid, entity.StartDateTime.Value.ToString("yyyy-MM-dd"), entity.EndDateTime.Value.ToString("yyyy-MM-dd")).Count > 0) { return(new salesActualChangeRes() { errorCode = "101", errorMessage = "请假失败,日期范围内请假记录已经存在!", isOk = false }); } var res = service.leave(entity); string auser = null; if (res.isOk) { var shopApp = new marketShopApp(); var shops = shopApp.getShopByUserId(entity.userid); foreach (var shop in shops) { //发送签核消息 var salesapp = new marketSalesApp(); var user = salesapp.getAdminExecutiveById(shop.ORG_ID); var userinfo = salesapp.GetUserInfo(entity.userid); var ApUsers = salesapp.getPOrgUserInfo(userinfo.SalesNo); var ApUserinfo = salesapp.getUserInfoBySalesNo(user.EMPLOYEE_CODE); auser = ApUserinfo.id; string taskId = System.Guid.NewGuid().ToString(); TaskMastEntity ent = new TaskMastEntity() { id = taskId, alertType = 1, createdTime = System.DateTime.Now, createdUserId = ApUserinfo.id, MESSAGE_BILL_NO = entity.id, MESSAGE_SUB_NO = 0, MESSAGE_REPLY_TYPE_CODE = "001", MESSAGE_REPLY_TYPE_NAME = "不需回复", RECEIVE_EMPLOYEE_CODE = ApUserinfo.SalesNo, RECEIVE_EMPLOYEE_NAME = ApUserinfo.Name, desc = userinfo.Name + "的请假签核", freqType = 1, taskName = userinfo.Name + "的请假签核", starTime = System.DateTime.Now, endTime = System.DateTime.Now.AddMinutes(5), importantType = 1, isAll = 1, isRead = 0, isReply = 0, taskType = "001", taskTypeName = "一般通知", URGENCY_TYPE_CODE = "002", URGENCY_TYPE_NAME = "紧急", taskSource = "系统", isDelete = 0, taskUrl = "https://iretailerapp.flnet.com/QJ/QJAllowIndex?id=" + entity.id + "&userId=" + ApUserinfo.id }; taskRep.Insert(ent); TaskPopApp popApp = new TaskPopApp(); popApp.createTaskPop(new TaskPopEntity() { id = System.Guid.NewGuid().ToString(), status = 2, taskId = taskId, UserId = ApUserinfo.id, userType = 1 }); string AndroIdDevice = getDeviceTokens(ApUserinfo.id, "Android"); if (AndroIdDevice.Length > 0) { AndroidPostJson postJson = new AndroidPostJson(); var payload = new AndroidPayload(); postJson.type = CastType.listcast; postJson.device_tokens = AndroIdDevice; payload.display_type = "notification"; payload.body = new ContentBody(); payload.body.ticker = ent.taskName; payload.body.title = ent.taskName; payload.body.icon = "appicon"; payload.body.play_lights = "true"; payload.body.play_sound = "true"; payload.body.play_vibrate = "true"; payload.body.text = ent.taskName; payload.body.after_open = AfterOpenAction.go_app; //payload.body.custom = "comment-notify"; var dic = new Dictionary <string, string>(); dic.Add("messageId", System.Guid.NewGuid().ToString()); payload.extra = dic; postJson.payload = payload; postJson.description = ent.taskName; UMengMessagePush <AndroidPostJson> uMAndroidPush = new UMengMessagePush <AndroidPostJson>("59550725677baa17ce0003fe", "grpqx0ayqc1ovn45iqczlrovqrdtvujf"); ReturnJsonClass resu = uMAndroidPush.SendMessage(postJson); System.Console.WriteLine(resu.ret); } string IOSDevice = getDeviceTokens(ApUserinfo.id, "IOS"); if (IOSDevice.Length > 0) { IOSPostJson postJson = new IOSPostJson(); postJson.type = CastType.unicast; var aps = new Aps() { alert = "msg", sound = "default" }; var payload = new IOSPayload(aps); JObject jo = JObject.FromObject(payload); var extra = new Dictionary <string, string>(); //用户自定义内容,"d","p"为友盟保留字段,key不可以是"d","p" extra.Add("open", "list"); extra.ToList().ForEach(x => jo.Add(x.Key, x.Value)); postJson.payload = jo; postJson.description = ent.taskName; postJson.device_tokens = IOSDevice; postJson.production_mode = "true"; UMengMessagePush <IOSPostJson> uMAndroidPush = new UMengMessagePush <IOSPostJson>("596791cbb27b0a673700001f", "siy2v7u9uzishzimgnslzdukyqkeofhp"); ReturnJsonClass resu = uMAndroidPush.SendMessage(postJson); System.Console.WriteLine(resu.ret); } } //var ApUserinfo = salesapp.GetUserInfo(entity.userid); } var ent2 = service.FindEntity(entity.id); ent2.auser = auser; service.Update(ent2); return(res); //DateTime startTime = System.Convert.ToDateTime(entity.day.Value.ToString("yyyy-MM-dd 00:00:00")); //DateTime EndTime = System.Convert.ToDateTime(entity.day.Value.ToString("yyyy-MM-dd 23:59:59")); //entity.id = Common.GuId(); //service.Insert(entity); //if (entity.day_type.Equals("1")) //{ // if (service.FindEntity(p => p.day >= startTime && p.day <= EndTime && (p.day_type.Equals("1") || p.day_type.Equals("2") || p.day_type.Equals("3"))) == null) // { // entity.id = Common.GuId(); // service.Insert(entity); // } // else // { // throw new Exception("请假记录已存在!"); // } //} //else if (entity.day_type.Equals("2")) //{ // if (service.FindEntity(p => p.day >= startTime && p.day <= EndTime && (p.day_type.Equals("1") || p.day_type.Equals("2"))) == null) // { // entity.id = Common.GuId(); // service.Insert(entity); // } // else // { // throw new Exception("请假记录已存在!"); // } //} //else if (entity.day_type.Equals("3")) //{ // if (service.FindEntity(p => p.day >= startTime && p.day <= EndTime && (p.day_type.Equals("1") || p.day_type.Equals("3"))) == null) // { // entity.id = Common.GuId(); // service.Insert(entity); // } // else // { // throw new Exception("请假记录已存在!"); // } //} //else //{ // throw new Exception("时间范围错误!"); //} }