/// <summary> /// 提交草稿知识 /// </summary> /// <param name="vguid">主键</param> /// <returns></returns> public bool SubmitKnowledgeBase(Guid vguid) { using (SqlSugarClient db = SugarDao_MsSql.GetInstance()) { bool result = false; try { db.BeginTran(); result = db.Update <Business_KnowledgeBase_Information>( new { Status = 2, ChangeDate = DateTime.Now, ChangeUser = Common.CurrentUser.GetCurrentUser().LoginName }, i => i.Vguid == vguid); Business_KnowledgeBase_Information knowledgeInfo = db.Queryable <Business_KnowledgeBase_Information>() .Where(i => i.Vguid == vguid) .SingleOrDefault(); string knowledgeJson = JsonHelper.ModelToJson(knowledgeInfo); //存入操作日志表 _ll.SaveLog(8, 40, Common.CurrentUser.GetCurrentUser().LoginName, knowledgeInfo.Title, knowledgeJson); db.CommitTran(); } catch (Exception ex) { db.RollbackTran(); Common.LogHelper.LogHelper.WriteLog(ex.ToString()); _ll.SaveLog(5, 40, Common.CurrentUser.GetCurrentUser().LoginName, "", ex.ToString()); } return(result); } }
/// <summary> /// 判断是否存在相同的知识 /// </summary> /// <param name="knowledgeBaseInfo">知识信息实体</param> /// <param name="isEdit">是否编辑</param> /// <returns></returns> public bool IsExistKnowledge(Business_KnowledgeBase_Information knowledgeBaseInfo, bool isEdit) { using (var db = SugarDao_MsSql.GetInstance()) { return(isEdit ? db.Queryable <Business_KnowledgeBase_Information>() .Any(it => it.Title == knowledgeBaseInfo.Title && it.Vguid != knowledgeBaseInfo.Vguid) : db.Queryable <Business_KnowledgeBase_Information>().Any(it => it.Title == knowledgeBaseInfo.Title)); } }
/// <summary> /// 将DataTable内容绑定到知识详细信息列表 /// </summary> /// <param name="dt"></param> /// <param name="msg">返回其他信息</param> /// <returns></returns> public List <Business_KnowledgeBase_Information> DatatableToList(DataTable dt, ref string msg) { List <Business_KnowledgeBase_Information> listKnowledgeBaseInfo = new List <Business_KnowledgeBase_Information>(); try { if (dt != null && dt.Rows.Count > 0) { for (int i = 1; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; if (!string.IsNullOrEmpty(dr["column1"].ToString()) && !string.IsNullOrEmpty(dr["column2"].ToString())) { DataRow[] rows = dt.Select(string.Format("column1='{0}'", dr["column1"])); if (rows.Length > 1) { msg = "知识" + rows[0].ItemArray[0] + "存在重复!"; listKnowledgeBaseInfo.Clear(); break; } Business_KnowledgeBase_Information knowledgeInfo = new Business_KnowledgeBase_Information(); knowledgeInfo.Title = dr["column1"].ToString(); if (IsExistKnowledge(knowledgeInfo, false)) { i = i + 1; msg = "第" + i + "行知识已经存在!"; listKnowledgeBaseInfo.Clear(); break; } knowledgeInfo.Type = "2"; knowledgeInfo.Status = "1"; knowledgeInfo.Content = dr["column2"].ToString(); knowledgeInfo.CreatedUser = Common.CurrentUser.GetCurrentUser().LoginName; knowledgeInfo.CreatedDate = DateTime.Now; knowledgeInfo.Vguid = Guid.NewGuid(); listKnowledgeBaseInfo.Add(knowledgeInfo); } } } } catch (Exception ex) { listKnowledgeBaseInfo.Clear(); Common.LogHelper.LogHelper.WriteLog(ex.ToString()); _ll.SaveLog(5, 40, Common.CurrentUser.GetCurrentUser().LoginName, "", ex.ToString()); } return(listKnowledgeBaseInfo); }
/// <summary> /// 获取草稿知识库的列表信息 /// </summary> /// <param name="searchParam">搜索条件</param> /// <param name="para">分页信息</param> /// <returns></returns> public JsonResult GetKnowledgeListBySearch(Business_KnowledgeBase_Information searchParam, GridParams para) { if (para.sortdatafield == null) { para.sortdatafield = "CreatedDate"; para.sortorder = "desc"; } para.pagenum = para.pagenum + 1; var model = _formalLogic.GetKnowledgeListBySearch(searchParam, para); var result = new ConfigurableJsonResult { Data = model, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; // return Json(model, JsonRequestBehavior.AllowGet); return(result); }
public JsonResult SaveKnowledge(Business_KnowledgeBase_Information knowledgeBaseInfo, bool isEdit, string saveType) { var models = new ActionResultModel <string>() { isSuccess = false, respnseInfo = "0" }; if (_draftLogic.IsExistKnowledge(knowledgeBaseInfo, isEdit)) { models.respnseInfo = "2";//存在相同的 } else { models.isSuccess = _draftLogic.SaveKnowledge(knowledgeBaseInfo, isEdit, saveType); models.respnseInfo = models.isSuccess ? "1" : "0"; } return(Json(models)); }
public ActionResult DraftDetail() { bool isEdit = Boolean.Parse(Request.QueryString["isEdit"]); Guid vguid = Guid.Parse(Request.QueryString["Vguid"] ?? Guid.Empty.ToString()); Business_KnowledgeBase_Information knowledgeInfo = new Business_KnowledgeBase_Information(); if (isEdit) { knowledgeInfo = _draftLogic.GetKnowledgeBaseInfoByVguid(vguid); } else { knowledgeInfo.Vguid = Guid.NewGuid(); } ViewBag.knowledgeInfo = knowledgeInfo; Sys_Role_Module roleModuleModel = _al.GetRoleModulePermission(Common.CurrentUser.GetCurrentUser().Role, Common.Tools.ModuleVguid.KnowledgeDraftModule); ViewBag.CurrentModulePermission = roleModuleModel; ViewBag.isEdit = isEdit; return(View()); }
/// <summary> /// 保存新增或编辑的知识 /// </summary> /// <param name="knowledgeBaseInfo">知识信息实体</param> /// <param name="isEdit">是否编辑</param> /// <param name="saveType">保存类型 保存(1)还是提交(2)</param> /// <returns></returns> public bool SaveKnowledge(Business_KnowledgeBase_Information knowledgeBaseInfo, bool isEdit, string saveType) { using (var db = SugarDao_MsSql.GetInstance()) { try { knowledgeBaseInfo.Type = knowledgeBaseInfo.Type == "on" ? "2" : knowledgeBaseInfo.Type; if (isEdit) //编辑 { knowledgeBaseInfo.Status = saveType == "1" ? "1" : "2"; knowledgeBaseInfo.ChangeUser = CurrentUser.GetCurrentUser().LoginName; knowledgeBaseInfo.ChangeDate = DateTime.Now; db.DisableUpdateColumns = new[] { "CreatedUser", "CreatedDate", "Vguid" }; string knowledgeJson = JsonHelper.ModelToJson(knowledgeBaseInfo); _ll.SaveLog(saveType == "1" ? 1 : 8, 42, Common.CurrentUser.GetCurrentUser().LoginName, knowledgeBaseInfo.Title, knowledgeJson); db.Update <Business_KnowledgeBase_Information>(knowledgeBaseInfo, c => c.Vguid == knowledgeBaseInfo.Vguid); } else //新增 { knowledgeBaseInfo.Type = knowledgeBaseInfo.Type == "on" ? "2" : knowledgeBaseInfo.Type; knowledgeBaseInfo.Status = saveType == "1" ? "1" : "2"; knowledgeBaseInfo.Type = "1"; knowledgeBaseInfo.CreatedDate = DateTime.Now; knowledgeBaseInfo.CreatedUser = CurrentUser.GetCurrentUser().LoginName; knowledgeBaseInfo.Vguid = Guid.NewGuid(); string knowledgeJson = JsonHelper.ModelToJson(knowledgeBaseInfo); _ll.SaveLog(saveType == "1" ? 1 : 8, 41, Common.CurrentUser.GetCurrentUser().LoginName, knowledgeBaseInfo.Title, knowledgeJson); db.Insert(knowledgeBaseInfo, false); } return(true); } catch (Exception ex) { Common.LogHelper.LogHelper.WriteLog(ex.ToString()); _ll.SaveLog(5, isEdit ? 42 : 41, Common.CurrentUser.GetCurrentUser().LoginName, "", ex.ToString()); return(false); } } }
/// <summary> /// 获取草稿知识库的列表信息 /// </summary> /// <param name="searchParam">搜索条件</param> /// <param name="para">分页信息</param> /// <returns></returns> public JsonResultModel <V_Business_KnowledgeBase_Information> GetKnowledgeListBySearch(Business_KnowledgeBase_Information searchParam, GridParams para) { using (var db = SugarDao_MsSql.GetInstance()) { JsonResultModel <V_Business_KnowledgeBase_Information> jsonResult = new JsonResultModel <V_Business_KnowledgeBase_Information>(); var query = db.Queryable <V_Business_KnowledgeBase_Information>().Where(i => i.Status == "1"); if (!string.IsNullOrEmpty(searchParam.Title)) { query.Where(i => i.Title.Contains(searchParam.Title)); } if (!string.IsNullOrEmpty(searchParam.Remark)) { query.Where(i => i.Remark.Contains(searchParam.Remark)); } if (!string.IsNullOrEmpty(searchParam.Type)) { query.Where(i => i.Type.Contains(searchParam.Type)); } if (searchParam.CreatedDate != DateTime.MinValue) { query.Where(i => i.CreatedDate >= searchParam.CreatedDate); } query.OrderBy(para.sortdatafield + " " + para.sortorder); jsonResult.TotalRows = query.Count(); jsonResult.Rows = query.ToPageList(para.pagenum, para.pagesize); //存入操作日志表 string logData = JsonHelper.ModelToJson(jsonResult); _ll.SaveLog(3, 40, CurrentUser.GetCurrentUser().LoginName, "草稿列表", logData); return(jsonResult); } }
/// <summary> /// 判断是否存在相同的知识 /// </summary> /// <param name="knowledgeBaseInfo">知识信息实体</param> /// <param name="isEdit">是否编辑</param> /// <returns></returns> public bool IsExistKnowledge(Business_KnowledgeBase_Information knowledgeBaseInfo, bool isEdit) { return(_draftServer.IsExistKnowledge(knowledgeBaseInfo, isEdit)); }
/// <summary> /// 获取草稿知识库的列表信息 /// </summary> /// <param name="searchParam">搜索条件</param> /// <param name="para">分页信息</param> /// <returns></returns> public JsonResultModel <V_Business_KnowledgeBase_Information> GetKnowledgeListBySearch(Business_KnowledgeBase_Information searchParam, GridParams para) { return(_draftServer.GetKnowledgeListBySearch(searchParam, para)); }
/// <summary> /// 保存新增或编辑的知识 /// </summary> /// <param name="knowledgeBaseInfo">知识信息实体</param> /// <param name="isEdit">是否编辑</param> /// <param name="saveType">保存类型 保存(1)还是提交(2)</param> /// <returns></returns> public bool SaveKnowledge(Business_KnowledgeBase_Information knowledgeBaseInfo, bool isEdit, string saveType) { return(_draftServer.SaveKnowledge(knowledgeBaseInfo, isEdit, saveType)); }
/// <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); } }