| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- 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值
- /// </summary>
- /// <param name="fid"></param>
- /// <returns></returns>
- public string GetrepositorycategoryJsonModel(int parentId)
- {
- return Newtonsoft.Json.JsonConvert.SerializeObject(reposcategoryBLL.GetRepositoryCategoryJsonModel(parentId));
- }
- /// <summary>
- /// 获取知识库分类数据
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <returns></returns>
- [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<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
- 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);
- }
- /// <summary>
- /// 编辑分类
- /// </summary>
- /// <param name="F_WorkOrderTypeId">当前选中id</param>
- /// <param name="editType">类型1、新增 2、修改</param>
- /// <returns></returns>
- 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);
- }
- /// <summary>
- /// 保存编辑
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [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;
- }
- }
- /// <summary>
- /// 删除数据
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [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);
- }
- /// <summary>
- /// 获取知识库内容数据
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <returns></returns>
- [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<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
- 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);
- }
- /// <summary>
- /// 编辑内容
- /// </summary>
- /// <param name="F_WorkOrderTypeId">当前选中id</param>
- /// <param name="editType">类型1、新增 2、修改</param>
- /// <returns></returns>
- 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);
- }
- /// <summary>
- /// 查看内容
- /// </summary>
- /// <param name="F_WorkOrderTypeId">当前选中id</param>
- /// <returns></returns>
- public ActionResult RepositoryCategoryContentView(int categoryContentId)
- {
- return View(reposCategoryContentBLL.GetModel(categoryContentId));
- }
- /// <summary>
- /// 保存编辑
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [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;
- }
- }
- /// <summary>
- /// 删除数据
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteCategoryContentData(int categoryContentId)
- {
- return reposCategoryContentBLL.Delete(categoryContentId);
- }
- #endregion
- }
- }
|