public void insertTaskMember(List <TaskMemberDataEntity> ents, string bid) { LogApp logApp = new LogApp(); foreach (var ent in ents) { rep.Insert(ent); } /*logApp.WriteDbLog(new LogEntity() * { * F_Account = "", * F_CreatorTime = System.DateTime.Now, * F_Date = System.DateTime.Now, * F_CreatorUserId = "", * F_Description = "StartSend", * F_Id = System.Guid.NewGuid().ToString(), * F_ModuleId = "SendMessage", * F_ModuleName = "SendMessage", * * * }); */ try { var shops = ents.GroupBy(p => p.shopCode); foreach (var shop in shops) { string ShopCode = shop.Key; var salesApp = new marketSalesApp(); var users = salesApp.getGuidManByShop(ShopCode); foreach (var user in users) { var userinfo = salesApp.getUserInfoBySalesNo(user.sales_No); string taskId = System.Guid.NewGuid().ToString(); TaskMastEntity ent = new TaskMastEntity() { id = taskId, alertType = 1, createdTime = System.DateTime.Now, createdUserId = userinfo.id, MESSAGE_BILL_NO = bid, MESSAGE_SUB_NO = 0, MESSAGE_REPLY_TYPE_CODE = "001", MESSAGE_REPLY_TYPE_NAME = "不需回复", RECEIVE_EMPLOYEE_CODE = user.sales_No, RECEIVE_EMPLOYEE_NAME = user.sales_Name, desc = "有会员进店,请接待", freqType = 1, taskName = "有会员进店,请接待", starTime = System.DateTime.Now, endTime = System.DateTime.Now.AddMinutes(5), importantType = 1, isAll = 1, isRead = 0, isReply = 0, taskType = "009", taskTypeName = "会员到店通知", URGENCY_TYPE_CODE = "002", URGENCY_TYPE_NAME = "紧急", taskSource = "系统", isDelete = 0, taskUrl = "{'shopCode':'" + ShopCode + "','bid':'" + bid + "'}" }; taskRep.Insert(ent); TaskPopApp popApp = new TaskPopApp(); popApp.createTaskPop(new TaskPopEntity() { id = System.Guid.NewGuid().ToString(), status = 2, taskId = taskId, UserId = userinfo.id, userType = 1 }); string AndroIdDevice = getDeviceTokens(userinfo.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); foreach (var memberEnt in ents) { postJson = new AndroidPostJson(); payload = new AndroidPayload(); postJson.type = CastType.unicast; 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; dic = new Dictionary <string, string>(); dic.Add("messageId", System.Guid.NewGuid().ToString()); dic.Add("mfMemberId", memberEnt.mfMemberId); dic.Add("bid", bid); payload.extra = dic; postJson.payload = payload; postJson.policy = new AndroidPolicy(); postJson.policy.expire_time = DateTime.Now.AddMinutes(5).ToString("yyyy-MM-dd HH:mm:ss"); UMengMessagePush <AndroidPostJson> uMAndroidPush2 = new UMengMessagePush <AndroidPostJson>("5b3ae2eaf43e4808f6000112", "gljoyn3tebkcchaeyvksvp0itjagynqr"); ReturnJsonClass resu2 = uMAndroidPush2.SendMessage(postJson); /*logApp.WriteDbLog(new LogEntity() * { * F_Account = user.sales_No, * F_CreatorTime = System.DateTime.Now, * F_Date = System.DateTime.Now, * F_CreatorUserId = user.sales_No, * F_Description = resu2.ret, * F_Id = System.Guid.NewGuid().ToString(), * F_ModuleId = "SendMessage", * F_ModuleName = "SendMessage", * * });*/ } System.Console.WriteLine(resu.ret); } string IOSDevice = getDeviceTokens(userinfo.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); } } } } catch (Exception ex) { logApp.WriteDbLog(new LogEntity() { F_Account = "", F_CreatorTime = System.DateTime.Now, F_Date = System.DateTime.Now, F_CreatorUserId = "", F_Description = ex.Message, F_Id = System.Guid.NewGuid().ToString(), F_ModuleId = "SendMessage", F_ModuleName = "SendMessage", }); } }
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("时间范围错误!"); //} }