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; //using YTSoft.Common; //using CallCenter.Utility; 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 string ToExcel() //{ // NPOIHelper npoi = new NPOIHelper(); // DataTable dt = new DataTable(); // dt.Columns.Add("标题", typeof(string));//一列 // dt.Columns.Add("内容", typeof(string));//二列 // npoi.ExportToExcel("导出模板",dt); // return Success("导出成功"); //} //public string importKnowledgeBase() //{ // // int userId = Utils.StrToInt(User.UserData["F_UserID"], 0); // HttpPostedFile _upfile = RequestString.GetFile("upFile"); // int headrow = 0; // NPOIHelper npoi = new NPOIHelper(); // DataTable dt = npoi.ExcelToTable(_upfile, headrow); // foreach (DataRow dr in dt.Rows) // { // headrow = headrow + 1; // if (dr[0].ToString() != "" && dr[1].ToString() != "") // { // Model.T_Cus_CustomerBase model = new Model.T_Cus_CustomerBase(); // model.F_CustomerName = dr[0].ToString(); //客户姓名 // //model.F_CustomerEName = dr[1].ToString(); //联系人 // model.F_Sex = dr[1].ToString(); //性别 // model.F_Mobile = dr[2].ToString(); //手机号码 // model.F_Telephone = dr[3].ToString(); //单位电话 // model.F_ChargeTelephone = dr[4].ToString(); //其它号码 // model.F_PostCode = dr[5].ToString(); //邮编 // model.F_Email = dr[6].ToString(); //Email // model.F_ChargeDept = dr[7].ToString(); //所在单位 // model.F_ServiceDept = dr[8].ToString(); //部门 // model.F_CustomerIndustry = dr[9].ToString(); //职务 // model.F_CreateBy = userId; // model.F_CreatedOn = DateTime.Now; // model.F_DeleteFlag = 0; // if (new BLL.T_Cus_CustomerBase().Add(model) <= 0) // { // return Error("第" + headrow + "行,导入失败!"); // } // } // else // { // return Error("第" + headrow + "行,第1,2列信息不能为空,未导入"); // } // } // return Success("导入成功"); //} 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 } }