/// <summary> /// 提交推送信息 /// </summary> /// <param name="vguid"></param> /// <returns></returns> public bool SubmitDraftList(string vguid) { using (SqlSugarClient _dbMsSql = SugarDao_MsSql.GetInstance()) { bool result = false; Guid Vguid = Guid.Parse(vguid); try { _dbMsSql.BeginTran(); result = _dbMsSql.Update <Business_WeChatPush_Information>(new { Status = 2 }, i => i.VGUID == Vguid); Business_WeChatPush_Information weChatPushInfo = _dbMsSql.Queryable <Business_WeChatPush_Information>().Where(i => i.VGUID == Vguid).SingleOrDefault(); string weChatJson = JsonHelper.ModelToJson(weChatPushInfo); //存入操作日志表 _ll.SaveLog(8, 12, CurrentUser.GetCurrentUser().LoginName, weChatPushInfo.Title, weChatJson); _dbMsSql.CommitTran(); } catch (Exception ex) { _dbMsSql.RollbackTran(); LogHelper.WriteLog(ex.Message + "/n" + ex.ToString() + "/n" + ex.StackTrace); _ll.SaveLog(5, 12, CurrentUser.GetCurrentUser().LoginName, "提交推送信息", vguid); } return(result); } }
/// <summary> /// 批量删除推送信息 /// </summary> /// <param name="vguid"></param> /// <returns></returns> public bool DeletePushHistory(string vguid) { using (var db = SugarDao_MsSql.GetInstance()) { db.BeginTran(); try { Guid guid = Guid.Parse(vguid); Business_WeChatPush_Information weChatPushInfo = db.Queryable <Business_WeChatPush_Information>().Where(i => i.VGUID == guid).SingleOrDefault(); string weChatJson = JsonHelper.ModelToJson(weChatPushInfo); _ll.SaveLog(2, 37, CurrentUser.GetCurrentUser().LoginName, weChatPushInfo.Title, weChatJson); //存入操作日志表 db.Update <Business_WeChatPush_Information>(new { History = 0 }, c => c.VGUID == guid); //假删除 db.CommitTran(); return(true); } catch (Exception ex) { Common.LogHelper.LogHelper.WriteLog(ex.Message + "/n" + ex + "/n" + ex.StackTrace); _ll.SaveLog(5, 37, CurrentUser.GetCurrentUser().LoginName, "删除推送历史信息", vguid); db.RollbackTran(); return(false); } } }
public ActionResult CommitedDetail() { Business_WeChatPush_Information weChatMainModel = new Business_WeChatPush_Information(); bool isEdit = Boolean.Parse(Request.QueryString["isEdit"]); string vguid = Request.QueryString["Vguid"]; List <CS_Master_2> pushType = new List <CS_Master_2>(); pushType = _cl.GetPushTypeList(); ViewData["PushType"] = pushType; List <CS_Master_2> weChatPush = new List <CS_Master_2>(); weChatPush = _cl.GetWeChatPushType(); ViewData["WeChatPushType"] = weChatPush; List <Business_Exercises_Infomation> exerciseList = new List <Business_Exercises_Infomation>(); exerciseList = _cl.GetExerciseList(); ViewData["ExerciseList"] = exerciseList; ViewData["RevenueTypeList"] = _dl.GetRevenueType(); weChatMainModel = _cl.GetWeChatMainByVguid(vguid); Sys_Role_Module roleModuleModel = _al.GetRoleModulePermission(CurrentUser.GetCurrentUser().Role, ModuleVguid.SubmitListModule); ViewBag.CurrentModulePermission = roleModuleModel; var pushObject = _dl.GetPushObjectStr(vguid); ViewBag.WeChatModel = weChatMainModel; ViewBag.pushObject = pushObject; ViewBag.listCountersignType = _dl.GetMasterDataType(MasterVGUID.CountersignType); ViewBag.listRedPacketType = _dl.GetMasterDataType(MasterVGUID.RedPacketType); return(View()); }
/// <summary> /// 推送消息(定时/不定时) /// </summary> /// <param name="pushPersonList"></param> /// <returns></returns> public bool PushMsg(Business_WeChatPush_Information pushModel, List <Business_Personnel_Information> pushPersonList) { bool result = false; //PushFunction pf = new PushFunction(); return(result); }
/// <summary> /// 审核推送信息 /// </summary> /// <param name="vguid"></param> /// <returns></returns> public bool CheckSubmitList(string vguid) { using (SqlSugarClient _dbMsSql = SugarDao_MsSql.GetInstance()) { bool result = false; Guid Vguid = Guid.Parse(vguid); try { _dbMsSql.BeginTran(); result = _dbMsSql.Update <Business_WeChatPush_Information>(new { Status = 3 }, i => i.VGUID == Vguid); Business_WeChatPush_Information weChatPushModel = _dbMsSql.Queryable <Business_WeChatPush_Information>().Where(i => i.VGUID == Vguid).SingleOrDefault(); string jsonResult = JsonHelper.ModelToJson <Business_WeChatPush_Information>(weChatPushModel); //存入操作日志表 _ll.SaveLog(9, 16, Common.CurrentUser.GetCurrentUser().LoginName, weChatPushModel.Title, jsonResult); _dbMsSql.CommitTran(); } catch (Exception ex) { _dbMsSql.RollbackTran(); Common.LogHelper.LogHelper.WriteLog(ex.Message + "/n" + ex.ToString() + "/n" + ex.StackTrace); } finally { } return(result); } }
/// <summary> /// 给阅读消息历史并且没有答过题的人重新推送习题 /// </summary> /// <param name="businessPersonnelVguid"></param> /// <param name="wechatMainVguid"></param> /// <returns></returns> public bool ReWechatPushExercise(string businessPersonnelVguid, string wechatMainVguid) { Guid mainVguid = Guid.Parse(wechatMainVguid); Guid personnelVguid = Guid.Parse(businessPersonnelVguid); bool result = false; using (SqlSugarClient db = SugarDao_MsSql.GetInstance()) { try { db.BeginTran(); var wechatMainModel = db.Queryable <Business_WeChatPush_Information>().Where(i => i.VGUID == mainVguid).SingleOrDefault(); var currentUser = db.Queryable <Business_Personnel_Information>().Where(i => i.Vguid == personnelVguid).Select(i => i.UserID).SingleOrDefault(); DateTime?dateTime = null; var wechatMain = new Business_WeChatPush_Information() { PushType = 1, Title = wechatMainModel.Title, MessageType = 4, Timed = false, TimedSendTime = null, Important = wechatMainModel.PeriodOfValidity == null, PeriodOfValidity = wechatMainModel.PeriodOfValidity == null ? dateTime : DateTime.Now.AddMonths(1), Message = "从消息历史获取", PushPeople = wechatMainModel.PushPeople, Status = 3, CreatedDate = DateTime.Now, CreatedUser = wechatMainModel.CreatedUser, VGUID = Guid.NewGuid(), CoverImg = wechatMainModel.CoverImg, CoverDescption = wechatMainModel.CoverDescption, ExercisesVGUID = wechatMainModel.ExercisesVGUID, History = "0", Department_VGUID = Guid.Empty }; var wechatDetail = new Business_WeChatPushDetail_Information() { Type = "1", PushObject = currentUser, CreatedUser = wechatMainModel.CreatedUser, CreatedDate = DateTime.Now, Vguid = Guid.NewGuid(), Business_WeChatPushVguid = wechatMain.VGUID, ISRead = "0", }; string logdata = Extend.ModelToJson(wechatMain); _ll.SaveLog(10, 34, currentUser, "从消息历史获取习题", logdata); db.Insert(wechatDetail, false); db.Insert(wechatMain, false); db.CommitTran(); result = true; } catch (Exception ex) { db.RollbackTran(); LogHelper.WriteLog(ex.ToString()); } } return(result); }
/// <summary> /// 保存要发送的营收信息 /// </summary> /// <param name="phone"></param> /// <returns></returns> public bool SaveRevenueMsg(Business_WeChatPush_Information weChatPush, Business_WeChatPushDetail_Information weChatPushDetail) { using (SqlSugar.SqlSugarClient _dbMsSql = SugarDao.SugarDao_MsSql.GetInstance()) { bool result = false; try { _dbMsSql.BeginTran(); result = _dbMsSql.Insert <Business_WeChatPush_Information>(weChatPush, false) != DBNull.Value; if (result) { //短信接收者 result = _dbMsSql.Insert <Business_WeChatPushDetail_Information>(weChatPushDetail, false) != DBNull.Value; } _dbMsSql.CommitTran(); } catch (Exception ex) { Common.LogHelper.LogHelper.WriteLog(ex.Message); _dbMsSql.RollbackTran(); } finally { } return(result); } }
/// <summary> /// 获取推送用户信息列表(获取推送接收者信息列表)短信 /// </summary> /// <param name="id"></param> /// <returns></returns> public List <Business_Personnel_Information> GetPushUserSms(Business_WeChatPush_Information pushModel) { using (SqlSugar.SqlSugarClient _dbMsSql = SugarDao.SugarDao_MsSql.GetInstance()) { var queryable = _dbMsSql.Queryable <Business_Personnel_Information>() .JoinTable <Business_Personnel_Information, Business_WeChatPushDetail_Information>((c1, c2) => c1.UserID == c2.PushObject && c2.Business_WeChatPushVguid == pushModel.VGUID, JoinType.INNER); return(queryable.ToList()); } }
/// <summary> /// 通过vguid获取推送主表信息 /// </summary> /// <param name="vguid"></param> /// <returns></returns> public Business_WeChatPush_Information GetWeChatMainByVguid(string vguid) { using (SqlSugarClient _dbMsSql = SugarDao_MsSql.GetInstance()) { Guid Vguid = Guid.Parse(vguid); Business_WeChatPush_Information weChatMsgMain = new Business_WeChatPush_Information(); weChatMsgMain = _dbMsSql.Queryable <Business_WeChatPush_Information>().Where(i => i.VGUID == Vguid).SingleOrDefault(); //存入操作日志表 string logData = JsonHelper.ModelToJson <Business_WeChatPush_Information>(weChatMsgMain); _ll.SaveLog(3, 21, Common.CurrentUser.GetCurrentUser().LoginName, weChatMsgMain.Title, logData); return(weChatMsgMain); } }
/// <summary> /// 保存工资条推送消息 /// </summary> /// <param name="weChatMain">主表</param> /// <param name="weChatPushDetails">明细表</param> /// <param name="msg">明细表</param> /// <returns></returns> public bool SaveSalaryPush(Business_WeChatPush_Information weChatMain, List <Business_WeChatPushDetail_Information> weChatPushDetails, ref string msg) { using (var db = SugarDao_MsSql.GetInstance()) { try { db.BeginTran(); var salarys = db.Queryable <Business_Payroll_Information>().Where(it => it.PushVGUID == null).ToList(); var notExists = new List <NotExistPerson>(); foreach (var salary in salarys) { var personInfo = GetPersonnelInformation(string.Format(" IDNumber='{0}'", salary.IDCard)); if (personInfo != null) { continue; } var notExistPerson = new NotExistPerson(); notExistPerson.IDNumber = salary.IDCard; notExistPerson.Name = salary.Name; notExistPerson.MobilePhone = salary.JobNumber; notExists.Add(notExistPerson); } msg = "共计" + (weChatPushDetails.Count) + "条,成功推送" + (weChatPushDetails.Count - notExists.Count) + "条,失败" + notExists.Count + "条!"; //创建临时表存储推送失败人员 db.SqlQuery <string>("if exists(select * from sysobjects where name ='NotExistPerson') drop table NotExistPerson create table NotExistPerson(Name varchar(50) null,MobilePhone varchar(50) null,IDNumber varchar(50) null) "); db.Update <Business_Payroll_Information>(new { PushVGUID = weChatMain.VGUID }, it => it.PushVGUID == null); if (weChatPushDetails.Count > notExists.Count) { db.Insert(weChatMain, false); } db.SqlBulkCopy(notExists); weChatPushDetails = weChatPushDetails.Where(i => i.PushObject != null).ToList(); db.SqlBulkCopy(weChatPushDetails); db.CommitTran(); return(true); } catch (Exception ex) { LogHelper.WriteLog(ex.ToString()); db.RollbackTran(); return(false); } } }
/// <summary> /// 通过vguid获取推送信息 /// </summary> /// <param name="vguid"></param> /// <returns></returns> public Business_WeChatPush_Information GetPushDetail(string vguid) { using (SqlSugarClient _dbMsSql = SugarDao_MsSql.GetInstance()) { Business_WeChatPush_Information pushDetailModel = new Business_WeChatPush_Information(); Guid Vguid = Guid.Parse(vguid); pushDetailModel = _dbMsSql.Queryable <Business_WeChatPush_Information>().Where(i => i.VGUID == Vguid).SingleOrDefault(); if (pushDetailModel == null) { var moreGraphicModel = _dbMsSql.Queryable <Business_WeChatPush_MoreGraphic_Information>().Where(i => i.VGUID == Vguid).SingleOrDefault(); pushDetailModel = _dbMsSql.Queryable <Business_WeChatPush_Information>().Where(i => i.VGUID == moreGraphicModel.WeChatPushVguid).SingleOrDefault(); pushDetailModel.Title = moreGraphicModel.Title; pushDetailModel.Message = moreGraphicModel.Message; pushDetailModel.CoverImg = moreGraphicModel.CoverImg; pushDetailModel.CoverDescption = moreGraphicModel.CoverDescption; } return(pushDetailModel); } }
/// <summary> /// 保存多图文信息 /// </summary> /// <param name="weChatMain">主表</param> /// <param name="pushMoreGraphicList">多图文子表</param> /// <param name="weChatDetailList">推送人表</param> /// <param name="isEdit">是否编辑</param> /// <returns></returns> public bool SaveImagePushMsg(Business_WeChatPush_Information weChatMain, List <Business_WeChatPush_MoreGraphic_Information> pushMoreGraphicList, List <Business_WeChatPushDetail_Information> weChatDetailList, bool isEdit) { using (var db = SugarDao_MsSql.GetInstance()) { try { db.BeginTran(); if (isEdit) { //存入操作日志表 string logData = JsonHelper.ModelToJson(weChatMain); _ll.SaveLog(4, 14, weChatMain.ChangeUser, weChatMain.Title, logData); db.Delete <Business_WeChatPush_MoreGraphic_Information>(i => i.WeChatPushVguid == weChatMain.VGUID); db.InsertRange(pushMoreGraphicList); db.Delete <Business_WeChatPushDetail_Information>(i => i.Business_WeChatPushVguid == weChatMain.VGUID); db.SqlBulkCopy(weChatDetailList); db.Update(weChatMain); } else { //存入操作日志表 string logData = JsonHelper.ModelToJson(weChatMain); _ll.SaveLog(1, 15, weChatMain.ChangeUser, weChatMain.Title, logData); db.Insert(weChatMain); db.InsertRange(pushMoreGraphicList); db.SqlBulkCopy(weChatDetailList); } db.CommitTran(); return(true); } catch (Exception ex) { db.RollbackTran(); LogHelper.WriteLog(ex.Message + "/n" + ex + "/n" + ex.StackTrace); return(false); } } }
/// <summary> /// 保存 /// </summary> /// <param name="weChatMain"></param> /// <returns></returns> public PushAPIresult SavePushApi(Business_WeChatPush_Information weChatMain, string userid) { using (SqlSugarClient _dbMsSql = SugarDao_MsSql.GetInstance()) { PushAPIresult PushAPIresult = new PushAPIresult(); var result = false; try { _dbMsSql.BeginTran(); weChatMain.VGUID = Guid.NewGuid(); weChatMain.CreatedDate = DateTime.Now; weChatMain.CreatedUser = "******"; result = _dbMsSql.Insert <Business_WeChatPush_Information>(weChatMain, false) != DBNull.Value;//保存微信推送信息表 PushAPIresult.ErrorMessage = "ok"; PushAPIresult.Succeed = result.ToString(); Business_WeChatPushDetail_Information BusinessWeChatPushDetailInformation = new Business_WeChatPushDetail_Information(); BusinessWeChatPushDetailInformation.Type = "1"; BusinessWeChatPushDetailInformation.PushObject = userid; BusinessWeChatPushDetailInformation.CreatedDate = DateTime.Now; BusinessWeChatPushDetailInformation.CreatedUser = "******"; BusinessWeChatPushDetailInformation.Vguid = Guid.NewGuid(); BusinessWeChatPushDetailInformation.Business_WeChatPushVguid = weChatMain.VGUID; _dbMsSql.Insert <Business_WeChatPushDetail_Information>(BusinessWeChatPushDetailInformation, false);//保存微信推送详细信息表 _dbMsSql.CommitTran(); } catch (Exception ex) { LogHelper.WriteLog(ex.ToString() + ex.StackTrace); PushAPIresult.ErrorMessage = ex.ToString() + "\r\n" + ex.Source + "\r\n" + ex.StackTrace; PushAPIresult.Succeed = "false"; _dbMsSql.RollbackTran(); } return(PushAPIresult); } }
public ActionResult EtiquetteClass(string code) { //string knowledgeType = Request["knowledgeType"] ?? ""; string pushContentVguid = Request.QueryString["Vguid"] ?? ""; //"55ca3608-93d3-4245-b6f7-e4af76482edd";// if (!string.IsNullOrEmpty(pushContentVguid)) { var pushContentModel = new Business_WeChatPush_Information(); pushContentModel = _pl.GetPushDetail(pushContentVguid); bool isValidTime = false;//未过有效期 if (pushContentModel != null) { if (pushContentModel.PeriodOfValidity != null) { if (DateTime.Now > pushContentModel.PeriodOfValidity) { isValidTime = true;//已过有效期 } } } ViewBag.isValidTime = isValidTime; ViewData["PushContentModel"] = pushContentModel; ViewData["vguid"] = pushContentVguid; } U_WeChatUserID userInfo = new U_WeChatUserID(); string accessToken = Common.WeChatPush.WeChatTools.GetAccessoken(); string userInfoStr = Common.WeChatPush.WeChatTools.GetUserInfoByCode(accessToken, code); userInfo = Common.JsonHelper.JsonToModel <U_WeChatUserID>(userInfoStr); //用户ID //userInfo.UserId = "13524338060"; _pl.UpdateIsRead(userInfo.UserId, pushContentVguid); //更新用户是否阅读推送 Business_Personnel_Information personInfoModel = _wl.GetUserInfo(userInfo.UserId); //获取人员表信息 ViewBag.PersonInfo = personInfoModel; // ViewBag.KnowledgeType = knowledgeType; return(View()); }
/// <summary> /// 保存要发送的营收信息 /// </summary> /// <param name="paymentModel"></param> /// <param name="userID"></param> /// <returns></returns> public bool SaveRevenueMsg(API_PaymentMonthly paymentModel, string userID) { bool isZero = false; bool result = false; U_Revenue revenue = new U_Revenue(); var revenueQueryExceptionReply = _cs.GetConfigList()[12].ConfigValue; if (paymentModel == null) { revenue.HistoricalArrears = "0"; revenue.TheBalance = "0"; revenue.AmountDue = "0"; revenue.CurrentPayment = "0"; revenue.CurrentAccountBalance = "0"; isZero = true; } else if (paymentModel.DebtAmount == 0 && paymentModel.DueAmount == 0 && paymentModel.PaidAmount == 0) { isZero = true; } else { //if (paymentModel.DebtAmount > 0)//正值(欠款) //{ //revenue.TheBalance = (paymentModel.DebtAmount * -1).ToString("F2"); //revenue.HistoricalArrears = (paymentModel.DebtAmount * -1) >= 0 ? "0" : paymentModel.DebtAmount.ToString("F2"); ////} ////else//负值(结余) ////{ //// revenue.HistoricalArrears = (-paymentModel.DebtAmount).ToString("##.##"); //// revenue.TheBalance = paymentModel.DebtAmount.ToString("##.##"); ////} //revenue.AmountDue = paymentModel.DueAmount.ToString("F2"); //revenue.CurrentPayment = paymentModel.PaidAmount.ToString("F2"); //revenue.CurrentAccountBalance = (paymentModel.PaidAmount - paymentModel.DueAmount + (paymentModel.DebtAmount * -1)).ToString("F2"); revenue.TheBalance = paymentModel.DebtAmount.ToString("F2"); revenue.HistoricalArrears = paymentModel.DebtAmount >= 0 ? "0" : paymentModel.DebtAmount.ToString("F2"); //} //else//负值(结余) //{ // revenue.HistoricalArrears = (-paymentModel.DebtAmount).ToString("##.##"); // revenue.TheBalance = paymentModel.DebtAmount.ToString("##.##"); //} revenue.AmountDue = paymentModel.DueAmount.ToString("F2"); revenue.CurrentPayment = paymentModel.PaidAmount.ToString("F2"); revenue.CurrentAccountBalance = (paymentModel.PaidAmount - paymentModel.DueAmount + paymentModel.DebtAmount).ToString("F2"); } string isSmsPush = _ss.GetIsSmsPush(); string isWeChatPush = _ss.GetIsWeChatPush(); string isRevenuePush = _ss.GetIsRevenuePush(); string weChatRevenueTemp = ConfigSugar.GetAppString("WeChatRevenueTemp");//获取微信发送营收数据模板 //{"HistoricalArrears":"0","TheBalance":"0","AmountDue":"0","CurrentPayment":"0","CurrentAccountBalance":"0"} //只通过短信发送营收信息 if (isSmsPush == "1") { U_RevenueMonth revenueMonth = new U_RevenueMonth(); revenueMonth.AmountDue = revenue.AmountDue; revenueMonth.CurrentAccountBalance = revenue.CurrentAccountBalance; revenueMonth.CurrentPayment = revenue.CurrentPayment; revenueMonth.HistoricalArrears = revenue.HistoricalArrears; revenueMonth.TheBalance = revenue.TheBalance; revenueMonth.Month = DateTime.Now.Month.ToString(); Business_WeChatPush_Information weChatPush = new Business_WeChatPush_Information(); weChatPush.PushType = 2; weChatPush.Title = "营收短信"; weChatPush.MessageType = 8; weChatPush.Timed = false; weChatPush.TimedSendTime = null; weChatPush.Important = false; weChatPush.Message = Common.JsonHelper.ModelToJson <U_RevenueMonth>(revenueMonth); weChatPush.PeriodOfValidity = null; weChatPush.PushDate = DateTime.Now; weChatPush.Status = 3; weChatPush.CreatedDate = DateTime.Now; weChatPush.ChangeDate = DateTime.Now; weChatPush.VGUID = Guid.NewGuid(); //推送接收者 Business_WeChatPushDetail_Information weChatPushDetail = new Business_WeChatPushDetail_Information(); weChatPushDetail.PushObject = userID; weChatPushDetail.Vguid = Guid.NewGuid(); weChatPushDetail.CreatedDate = DateTime.Now; weChatPushDetail.ChangeDate = DateTime.Now; weChatPushDetail.Type = "短信营收"; weChatPushDetail.Business_WeChatPushVguid = weChatPush.VGUID; if (!isZero) { result = _ss.SaveRevenueMsg(weChatPush, weChatPushDetail); } } if (isWeChatPush == "1")//只通过微信发送营收信息 { Business_WeChatPush_Information weChatPush = new Business_WeChatPush_Information(); weChatPush.PushType = 1; weChatPush.Title = "营收微信"; weChatPush.MessageType = 1; weChatPush.Timed = false; weChatPush.TimedSendTime = null; weChatPush.Important = false; weChatPush.Message = isZero ? revenueQueryExceptionReply : string.Format(weChatRevenueTemp, revenue.HistoricalArrears, revenue.TheBalance, revenue.AmountDue, revenue.CurrentPayment, revenue.CurrentAccountBalance, DateTime.Now.Month); weChatPush.PeriodOfValidity = null; weChatPush.PushDate = null; weChatPush.Status = 3; weChatPush.CreatedDate = DateTime.Now; weChatPush.ChangeDate = DateTime.Now; weChatPush.VGUID = Guid.NewGuid(); //推送接收者 Business_WeChatPushDetail_Information weChatPushDetail = new Business_WeChatPushDetail_Information(); weChatPushDetail.PushObject = userID; weChatPushDetail.Vguid = Guid.NewGuid(); weChatPushDetail.CreatedDate = DateTime.Now; weChatPushDetail.ChangeDate = DateTime.Now; weChatPushDetail.Type = "微信营收"; weChatPushDetail.Business_WeChatPushVguid = weChatPush.VGUID; result = _ss.SaveRevenueMsg(weChatPush, weChatPushDetail); } if (isRevenuePush == "1")//只通过营收发送营收信息 { Business_WeChatPush_Information weChatPush = new Business_WeChatPush_Information(); weChatPush.PushType = 1; weChatPush.Title = "营收信息"; weChatPush.MessageType = 11; weChatPush.Timed = false; weChatPush.TimedSendTime = null; weChatPush.RevenueType = 2; DateTime now = DateTime.Now; //当前时间 DateTime d1 = new DateTime(now.Year, now.Month, 1); //当前月的第一天 DateTime d2 = d1.AddMonths(1).AddDays(-1); //当前月的最后一天 weChatPush.PeriodOfValidity = d2; weChatPush.CoverDescption = "个人营收账单明细"; weChatPush.CoverImg = "/_img/微信图片.jpg"; weChatPush.PushDate = DateTime.Now; weChatPush.Status = 3; weChatPush.CreatedDate = DateTime.Now; weChatPush.ChangeDate = DateTime.Now; weChatPush.VGUID = Guid.NewGuid(); //推送接收者 Business_WeChatPushDetail_Information weChatPushDetail = new Business_WeChatPushDetail_Information(); weChatPushDetail.PushObject = userID; weChatPushDetail.Vguid = Guid.NewGuid(); weChatPushDetail.CreatedDate = DateTime.Now; weChatPushDetail.ChangeDate = DateTime.Now; weChatPushDetail.Type = "营收发送"; weChatPushDetail.Business_WeChatPushVguid = weChatPush.VGUID; result = _ss.SaveRevenueMsg(weChatPush, weChatPushDetail); } //else if (isWeChatPush == "1" && isSmsPush == "1") //{ // Business_WeChatPush_Information weChatPush = new Business_WeChatPush_Information(); // weChatPush.PushType = 1; // weChatPush.Title = "营收微信"; // weChatPush.MessageType = 1; // weChatPush.Timed = false; // weChatPush.TimedSendTime = null; // weChatPush.Important = false; // weChatPush.Message = isZero ? revenueQueryExceptionReply : string.Format(weChatRevenueTemp, revenue.HistoricalArrears, revenue.TheBalance, revenue.AmountDue, revenue.CurrentPayment, revenue.CurrentAccountBalance, DateTime.Now.Month); // weChatPush.PeriodOfValidity = null; // weChatPush.PushDate = null; // weChatPush.Status = 3; // weChatPush.CreatedDate = DateTime.Now; // weChatPush.ChangeDate = DateTime.Now; // weChatPush.VGUID = Guid.NewGuid(); // //推送接收者 // Business_WeChatPushDetail_Information weChatPushDetail = new Business_WeChatPushDetail_Information(); // weChatPushDetail.PushObject = userID; // weChatPushDetail.Vguid = Guid.NewGuid(); // weChatPushDetail.CreatedDate = DateTime.Now; // weChatPushDetail.ChangeDate = DateTime.Now; // weChatPushDetail.Type = "微信营收"; // weChatPushDetail.Business_WeChatPushVguid = weChatPush.VGUID; // result = _ss.SaveRevenueMsg(weChatPush, weChatPushDetail); // if (result) // { // U_RevenueMonth revenueMonth = new U_RevenueMonth(); // revenueMonth.AmountDue = revenue.AmountDue; // revenueMonth.CurrentAccountBalance = revenue.CurrentAccountBalance; // revenueMonth.CurrentPayment = revenue.CurrentPayment; // revenueMonth.HistoricalArrears = revenue.HistoricalArrears; // revenueMonth.TheBalance = revenue.TheBalance; // revenueMonth.Month = DateTime.Now.Month.ToString(); // Business_WeChatPush_Information weChatPush1 = new Business_WeChatPush_Information(); // weChatPush1.PushType = 2; // weChatPush1.Title = "营收短信"; // weChatPush1.MessageType = 8; // weChatPush1.Timed = false; // weChatPush1.TimedSendTime = null; // weChatPush1.Important = false; // weChatPush1.Message = Common.JsonHelper.ModelToJson(revenueMonth); // weChatPush1.PeriodOfValidity = null; // weChatPush1.PushDate = DateTime.Now; // weChatPush1.Status = 3; // weChatPush1.CreatedDate = DateTime.Now; // weChatPush1.ChangeDate = DateTime.Now; // weChatPush1.VGUID = Guid.NewGuid(); // //推送接收者 // Business_WeChatPushDetail_Information weChatPushDetail1 = new Business_WeChatPushDetail_Information(); // weChatPushDetail1.PushObject = userID; // weChatPushDetail1.Vguid = Guid.NewGuid(); // weChatPushDetail1.CreatedDate = DateTime.Now; // weChatPushDetail1.ChangeDate = DateTime.Now; // weChatPushDetail1.Type = "短信营收"; // weChatPushDetail1.Business_WeChatPushVguid = weChatPush1.VGUID; // if (!isZero) // { // result = _ss.SaveRevenueMsg(weChatPush1, weChatPushDetail1); // } // } //} if (isWeChatPush == "0" && isSmsPush == "0" && isRevenuePush == "0") { var queryReply = _cs.GetConfigList()[15].ConfigValue; Business_WeChatPush_Information weChatPush = new Business_WeChatPush_Information(); weChatPush.PushType = 1; weChatPush.Title = "营收微信"; weChatPush.MessageType = 1; weChatPush.Timed = false; weChatPush.TimedSendTime = null; weChatPush.Important = false; weChatPush.Message = queryReply; weChatPush.PeriodOfValidity = null; weChatPush.PushDate = null; weChatPush.Status = 3; weChatPush.CreatedDate = DateTime.Now; weChatPush.ChangeDate = DateTime.Now; weChatPush.VGUID = Guid.NewGuid(); //推送接收者 Business_WeChatPushDetail_Information weChatPushDetail = new Business_WeChatPushDetail_Information(); weChatPushDetail.PushObject = userID; weChatPushDetail.Vguid = Guid.NewGuid(); weChatPushDetail.CreatedDate = DateTime.Now; weChatPushDetail.ChangeDate = DateTime.Now; weChatPushDetail.Type = "微信营收"; weChatPushDetail.Business_WeChatPushVguid = weChatPush.VGUID; result = _ss.SaveRevenueMsg(weChatPush, weChatPushDetail); } return(result); }
/// <summary> /// 保存推送信息(主信息,详细信息) /// </summary> /// <param name="weChatMain"></param> /// <param name="weChatDetailList"></param> /// <returns></returns> public bool SavePushMsg(Business_WeChatPush_Information weChatMain, List <Business_WeChatPushDetail_Information> weChatDetailList, bool isEdit) { using (SqlSugarClient _dbMsSql = SugarDao_MsSql.GetInstance()) { bool result = false; try { _dbMsSql.BeginTran(); if (isEdit) //编辑 { var model = new { Title = weChatMain.Title, RevenueType = weChatMain.RevenueType, CountersignType = weChatMain.CountersignType, Status = weChatMain.Status, Timed = weChatMain.Timed, TimedSendTime = weChatMain.TimedSendTime, Important = weChatMain.Important, Message = weChatMain.Message, History = weChatMain.History, PeriodOfValidity = weChatMain.PeriodOfValidity, ChangeDate = weChatMain.ChangeDate, ChangeUser = weChatMain.ChangeUser, CoverImg = weChatMain.CoverImg, CoverDescption = weChatMain.CoverDescption, ExercisesVGUID = weChatMain.ExercisesVGUID, //推送习题Vguid KnowledgeVGUID = weChatMain.KnowledgeVGUID, //推送知识库Vguid RedpacketMoney = weChatMain.RedpacketMoney, RedpacketMoneyFrom = weChatMain.RedpacketMoneyFrom, RedpacketMoneyTo = weChatMain.RedpacketMoneyTo }; if (model.PeriodOfValidity == null) //说明是永久有效,则加入知识库 { //先查询改知识是否存在 bool isExist = _dbMsSql.Queryable <Business_KnowledgeBase_Information>().Any(i => i.Title == model.Title); if (!isExist) { //不存在则插入 var knowledge = new Business_KnowledgeBase_Information() { Title = model.Title, Content = weChatMain.MessageType == 4 ? model.Message + " " + "4" : model.Message, Type = "1", Status = "1", Remark = "", CreatedDate = DateTime.Now, CreatedUser = CurrentUser.GetCurrentUser().LoginName, Vguid = Guid.NewGuid() }; _dbMsSql.Insert(knowledge, false); } else { //存在则更新 _dbMsSql.Update <Business_KnowledgeBase_Information>(new { //Title = model.Title, Content = model.Message, ChangeUser = CurrentUser.GetCurrentUser().LoginName, ChangeDate = DateTime.Now, }, i => i.Title == model.Title); } } result = _dbMsSql.Update <Business_WeChatPush_Information>(model, i => i.VGUID == weChatMain.VGUID); //存入操作日志表 string logData = JsonHelper.ModelToJson <Business_WeChatPush_Information>(weChatMain); _ll.SaveLog(4, 14, Common.CurrentUser.GetCurrentUser().LoginName, weChatMain.Title, logData); } else //新增 { if (weChatMain.PeriodOfValidity == null) { var knowledge = new Business_KnowledgeBase_Information() { Title = weChatMain.Title, Content = weChatMain.Message, Type = "1", Status = "1", Remark = "", CreatedDate = weChatMain.CreatedDate, CreatedUser = weChatMain.CreatedUser, Vguid = Guid.NewGuid() }; _dbMsSql.Insert(knowledge, false); } result = _dbMsSql.Insert(weChatMain, false) != DBNull.Value; //存入操作日志表 string logData = JsonHelper.ModelToJson(weChatMain); _ll.SaveLog(1, 13, weChatMain.CreatedUser, weChatMain.Title, logData); } _dbMsSql.Delete <Business_WeChatPushDetail_Information>(i => i.Business_WeChatPushVguid == weChatMain.VGUID); //存入操作日志表 string log = JsonHelper.ModelToJson(weChatDetailList); _ll.SaveLog(1, 15, weChatMain.CreatedUser, weChatMain.Title, log); _dbMsSql.SqlBulkCopy(weChatDetailList); _dbMsSql.CommitTran(); } catch (Exception ex) { _dbMsSql.RollbackTran(); LogHelper.WriteLog(ex.Message + "/n" + ex.ToString() + "/n" + ex.StackTrace); } return(result); } }
// // GET: /WeChatPush/PushAPI/ /// <summary> /// 微信纯文本推送 /// </summary> /// <param name="data"></param> /// <returns></returns> public ActionResult Push_WebChat_Message(string title, string message, string idcard) { PushAPIresult PushAPIresult = new PushAPIresult(); try { Business_WeChatPush_Information weChatMain = new Business_WeChatPush_Information(); if (string.IsNullOrEmpty(title))//标题不为空 { PushAPIresult.Succeed = "false"; PushAPIresult.ErrorMessage = "必填字段存在空数据,检查标题"; //返回为空的错误信息 return(Json(PushAPIresult, JsonRequestBehavior.AllowGet)); } else if (string.IsNullOrEmpty(message))//推送内容不为空 { PushAPIresult.Succeed = "false"; PushAPIresult.ErrorMessage = "必填字段存在空数据,检查推送内容"; //返回为空的错误信息 return(Json(PushAPIresult, JsonRequestBehavior.AllowGet)); } else if (string.IsNullOrEmpty(idcard))//接收者不能为空 { PushAPIresult.Succeed = "false"; PushAPIresult.ErrorMessage = "必填字段存在空数据,检查推送者"; //返回为空的错误信息 return(Json(PushAPIresult, JsonRequestBehavior.AllowGet)); } else if (!findAPIConfig()) { PushAPIresult.Succeed = "false"; PushAPIresult.ErrorMessage = "API发送已被关闭"; //返回为空的错误信息 return(Json(PushAPIresult, JsonRequestBehavior.AllowGet)); } else { var UserID = ""; UserID = findNonexistent(idcard); if (string.IsNullOrEmpty(UserID)) { //返回当前身份证不存在的错误信息 PushAPIresult.Succeed = "false"; PushAPIresult.ErrorMessage = "接收人员不存在"; return(Json(PushAPIresult, JsonRequestBehavior.AllowGet)); } weChatMain.Title = title; weChatMain.PushType = 1; weChatMain.Timed = false; //weChatMain.TimedSendTime = TimedSendTime; weChatMain.PushPeople = "SYSADMIN_API"; weChatMain.Important = false; weChatMain.PeriodOfValidity = DateTime.Now.AddMonths(1); weChatMain.MessageType = 1; weChatMain.Message = message; PushAPIresult = SavePushApi(weChatMain, UserID); } //var Title = title;//标题 必填 //var PushType = 1;//推送方式 必填 //var Timed = false;//是否定时发送 必填 //var TimedSendTime = timedsendtime;//发送时间 可空 //var pushPeople = pushpeople;//推送接收者 必填 //var Important = false;//是否永久 必填 //var PeriodOfValidity = periodofvalidity;//有效日期 必填 //var MessageType = 1;//微信推送类型 必填 //var Message = message;//推送内容 必填 } catch (Exception) { PushAPIresult.Succeed = "false"; PushAPIresult.ErrorMessage = "保存时报错"; } return(Json(PushAPIresult, JsonRequestBehavior.AllowGet)); }
public ActionResult DraftDetail() { Business_WeChatPush_Information weChatMainModel = new Business_WeChatPush_Information(); bool isEdit = Boolean.Parse(Request.QueryString["isEdit"]); string vguid = Request.QueryString["Vguid"]; List <CS_Master_2> pushType = new List <CS_Master_2>(); pushType = _dl.GetPushTypeList(); ViewData["PushType"] = pushType; List <CS_Master_2> weChatPushType = new List <CS_Master_2>(); weChatPushType = _dl.GetWeChatPushType(); ViewData["WeChatPushType"] = weChatPushType; List <Business_Exercises_Infomation> exerciseList = new List <Business_Exercises_Infomation>(); exerciseList = _dl.GetExerciseList(); ViewData["ExerciseList"] = exerciseList; List <Business_KnowledgeBase_Information> knowledgeList = new List <Business_KnowledgeBase_Information>(); knowledgeList = _dl.GetknowledgeList(); ViewData["KnowledgeList"] = knowledgeList; List <Business_Questionnaire> questionList = new List <Business_Questionnaire>(); questionList = _dl.GetQuestionList(); ViewData["QuestionList"] = questionList; ViewData["RevenueTypeList"] = _dl.GetRevenueType(); ViewData["LabelType"] = _dl.GetLabels(); string pushObject = string.Empty; string pushName = string.Empty; if (isEdit) //编辑 { weChatMainModel = _dl.GetWeChatMainByVguid(vguid); pushObject = _dl.GetPushObjectPhone(vguid); pushName = _dl.GetPushObjectStr(vguid); } Sys_Role_Module roleModuleModel = _al.GetRoleModulePermission(CurrentUser.GetCurrentUser().Role, ModuleVguid.DraftListModule); ViewData["currentUserDepartment"] = ""; if (!string.IsNullOrEmpty(CurrentUser.GetCurrentUser().Department)) { ViewData["currentUserDepartment"] = CurrentUser.GetCurrentUser().Department; } ViewBag.PushObject = pushObject; ViewBag.PushName = pushName; ViewBag.CurrentModulePermission = roleModuleModel; ViewBag.WeChatModel = weChatMainModel; ViewBag.isEdit = isEdit; ViewBag.listCountersignType = _dl.GetMasterDataType(MasterVGUID.CountersignType); ViewBag.listRedPacketType = _dl.GetMasterDataType(MasterVGUID.RedPacketType); return(View()); }