using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.Mvc; using YTSoft.BaseCallCenter.Model; using YTSoft.BaseCallCenter.MVCWeb.Models; namespace YTSoft.BaseCallCenter.MVCWeb.Controllers { public class RepositoryCategoryController : BaseController { #region 知识库分类管理 BLL.T_RepositoryCategory reposcategoryBLL = new BLL.T_RepositoryCategory(); public ActionResult RepositoryCategoryList() { WorkOrderMyModel model = new WorkOrderMyModel(); return View(model); } ///通过dic编码获取dic值 /// /// /// public string GetrepositorycategoryJsonModel(int parentId) { return Newtonsoft.Json.JsonConvert.SerializeObject(reposcategoryBLL.GetRepositoryCategoryJsonModel(parentId)); } /// /// 获取知识库分类数据 /// /// 当前页码 /// 每页数据量 /// [ActionName("RepositoryCategoryDate")] [HttpGet] public string RepositoryCategoryDate(DateTime? NowDateTime, int page, int limit, int? parentId) { //数据结果集 ResponseData dataModel = new ResponseData(); string sql = " and F_DeleteFlag=0"; if (parentId != null) { sql += " and F_ParentId=" + parentId; } DataTable dt = new DataTable(); int recordCount = 0; Model.PageData pageModel = new Model.PageData(); dt = BLL.PagerBLL.GetListPager( "T_RepositoryCategory", "F_CategoryId", "*", sql, "ORDER BY F_Sort asc ", limit, page, true, out recordCount); dataModel.code = 0; dataModel.count = recordCount; dataModel.data = dt; return JsonConvert.SerializeObject(dataModel); } /// /// 编辑分类 /// /// 当前选中id /// 类型1、新增 2、修改 /// public ActionResult RepositoryCategoryEdit(int categoryId, int editType) { Model.T_RepositoryCategory viewModel = new Model.T_RepositoryCategory(); //当前对象实体 Model.T_RepositoryCategory categoryModel = reposcategoryBLL.GetModel(categoryId); if (editType == 1) { viewModel.F_ParentId = categoryModel.F_CategoryId; viewModel.F_Sort = 1; viewModel.F_CategoryType = categoryModel.F_CategoryType; } else { viewModel = categoryModel; } return View(viewModel); } /// /// 保存编辑 /// /// /// [AcceptVerbs(HttpVerbs.Post)] public bool SaveRepositoryCategoryData(T_RepositoryCategory categoryModel) { // 获取当前电脑名: string a = System.Net.Dns.GetHostName(); // 根据电脑名取出全部IP地址: System.Net.IPAddress[] addressList = System.Net.Dns.Resolve(a).AddressList; string b = Convert.ToString(addressList[0]); if (categoryModel.F_CategoryId > 0) { //int id = Common.CommonRequest.dtUserId; //string usercode = Common.CommonRequest.dtUserCode; //string pp = Common.DTRequest.GetIP(); return reposcategoryBLL.Update(categoryModel); } else { return reposcategoryBLL.Add(categoryModel) > 0; } } /// /// 删除数据 /// /// /// [AcceptVerbs(HttpVerbs.Get)] public bool DeleteCategoryData(int categoryId) { return reposcategoryBLL.Delete(categoryId); } #endregion #region 知识库内容管理 BLL.T_RepositoryInformation reposCategoryContentBLL = new BLL.T_RepositoryInformation(); public ActionResult RepositoryCategoryContentList(int dType) { WorkOrderMyModel model = new WorkOrderMyModel(); model.DType = dType; return View(model); } /// /// 获取知识库内容数据 /// /// 当前页码 /// 每页数据量 /// [ActionName("RepositoryCategoryContentDate")] [HttpGet] public string RepositoryCategoryContentDate(DateTime? NowDateTime, int page, int limit,int dType, int? parentId, string keyWord) { //数据结果集 ResponseData dataModel = new ResponseData(); string sql = " and t.F_DeleteFlag=0 "; //and F_CreateBy="+F_UserID+" if (!string.IsNullOrEmpty(keyWord)) { sql += " and ( t.F_Description like '%" + keyWord + "%' or F_Title like '%" + keyWord + "%')"; } if (parentId != null && parentId > 1) { sql += " and t.F_CategoryId=" + parentId; } string tableName = ""; if(dType>1) { tableName = " (SELECT m.* FROM T_RepositoryCategory t INNER JOIN T_RepositoryInformation m ON t.F_CategoryId=m.F_CategoryId WHERE t.F_DeleteFlag=0 and m.F_DeleteFlag=0 and t.F_CategoryType=" + dType + ") as t"; } else { tableName = " (SELECT m.* FROM T_RepositoryCategory t INNER JOIN T_RepositoryInformation m ON t.F_CategoryId=m.F_CategoryId WHERE t.F_DeleteFlag=0 and m.F_DeleteFlag=0 ) as t"; } DataTable dt = new DataTable(); int recordCount = 0; //Model.PageData pageModel = new Model.PageData(); dt = BLL.PagerBLL.GetListPager( tableName, "F_RepositoryId", "*", sql, "ORDER BY F_RepositoryId desc ", limit, page, true, out recordCount); dataModel.code = 0; dataModel.count = recordCount; dataModel.data = dt; return JsonConvert.SerializeObject(dataModel); } /// /// 编辑内容 /// /// 当前选中id /// 类型1、新增 2、修改 /// public ActionResult RepositoryCategoryContentEdit(int categoryContentId, int editType) { Model.T_RepositoryInformation viewModel = new Model.T_RepositoryInformation(); //当前对象实体 Model.T_RepositoryInformation categoryContentModel = reposCategoryContentBLL.GetModel(categoryContentId); if (editType == 1) { viewModel.F_CategoryId = categoryContentId; } else { viewModel = categoryContentModel; } return View(viewModel); } /// /// 查看内容 /// /// 当前选中id /// public ActionResult RepositoryCategoryContentView(int categoryContentId) { return View(reposCategoryContentBLL.GetModel(categoryContentId)); } /// /// 保存编辑 /// /// /// [AcceptVerbs(HttpVerbs.Post)] public bool SaveRepositoryCategoryContentData(T_RepositoryInformation categoryContentModel) { categoryContentModel.F_CreateBy = F_UserID; if (categoryContentModel.F_RepositoryId > 0) { return reposCategoryContentBLL.Update(categoryContentModel); } else { return reposCategoryContentBLL.Add(categoryContentModel) > 0; } } /// /// 删除数据 /// /// /// [AcceptVerbs(HttpVerbs.Get)] public bool DeleteCategoryContentData(int categoryContentId) { return reposCategoryContentBLL.Delete(categoryContentId); } #endregion } }