Нет описания

KnowledgeController.cs 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  1. using CallCenter.Utility;
  2. using CallCenterApi.DB;
  3. using CallCenterApi.Interface.Controllers.Base;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Net;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Web;
  12. using System.Web.Mvc;
  13. namespace CallCenterApi.Interface.Controllers.knowledge
  14. {
  15. [Authority]
  16. public class KnowledgeController : BaseController
  17. {
  18. BLL.T_RepositoryInformation infoBLL = new BLL.T_RepositoryInformation();
  19. private BLL.T_Sys_RoleInfo rolebll = new BLL.T_Sys_RoleInfo();
  20. // 获取知识库列表
  21. public ActionResult GetList(string title, string content,string keywords, string pid,int deptid=0)
  22. {
  23. string issub = RequestString.GetQueryString("issub");
  24. string ispass = RequestString.GetQueryString("ispass");
  25. DataTable dt = new DataTable();
  26. string strpageindex = RequestString.GetQueryString("page");
  27. int pageindex = 1;
  28. string strpagesize = RequestString.GetQueryString("pagesize");
  29. int pagesize = 10;
  30. string sql = "";
  31. if (!string.IsNullOrEmpty(issub))
  32. {//是否提交审核 0否,1是
  33. sql += " and isnull(F_ISSubmitAudit,0)=" + issub;
  34. }
  35. //else
  36. //{
  37. // sql += " and isnull(F_ISSubmitAudit,0)=1 ";
  38. //}
  39. if (!string.IsNullOrEmpty(ispass))
  40. {//是否审核通过 -1否,0未审核,1是
  41. sql += " and isnull(F_ISPass,0)=" + ispass;
  42. }
  43. else
  44. {
  45. sql += " and F_ISPass !=-1";
  46. }
  47. //else
  48. //{
  49. // sql += " and isnull(F_ISPass,0)=0 ";
  50. //}
  51. if (title != null && title.Trim() != "")
  52. {
  53. sql += " and F_Title like '%" + title.Trim() + "%'";
  54. }
  55. if (content != null && content.Trim() != "")
  56. {
  57. sql += " and F_Description like '%" + content.Trim() + "%'";
  58. }
  59. if (pid != null && pid.Trim() != "")
  60. {
  61. sql += " and F_CategoryId=" + pid.Trim();
  62. }
  63. if (keywords != null && keywords.Trim() != "")
  64. {
  65. sql += " and (F_Description like '%" + keywords.Trim() + "%' or F_Content like '%" + keywords.Trim() + "%' or F_Title like '%"
  66. + keywords.Trim() + "%' or F_KeyWords like '%" + keywords.Trim() + "%')";
  67. }
  68. if (deptid >0)
  69. {
  70. sql += "and F_CreateBy in( select F_UserId from T_Sys_UserAccount where F_DeptId ='" + deptid + "')";
  71. }
  72. if (User .F_RoleCode =="WLDW")
  73. {
  74. sql += "and F_CreateBy in( select F_UserId from T_Sys_UserAccount where F_DeptId ='" + User .F_DeptId + "')";
  75. }
  76. if (strpageindex.Trim() != "")
  77. {
  78. pageindex = Convert.ToInt32(strpageindex);
  79. }
  80. if (strpagesize.Trim() != "")
  81. {
  82. pagesize = Convert.ToInt32(strpagesize);
  83. }
  84. Model.T_Sys_RoleInfo role = rolebll.GetModel("WLDW");
  85. if ( pid==null&& User.F_RoleId == role.F_RoleId)
  86. {
  87. sql += " and F_CategoryId in ( select F_CategoryId from T_RepositoryCategory where F_CategoryName ='知识信息分类')";
  88. }
  89. int recordCount = 0;
  90. dt = BLL.PagerBLL.GetListPager(
  91. "T_RepositoryInformation a",
  92. "F_RepositoryId",
  93. "*,(select F_CategoryName from T_RepositoryCategory where F_CategoryId =a.F_CategoryId )as CategoryName" +
  94. ",dbo.GetDeptName(CONVERT (int ,(select F_DeptId from T_Sys_UserAccount where F_UserId = a.F_CreateBy)) ) DeptName ",
  95. sql,
  96. "ORDER BY F_RepositoryId desc",
  97. pagesize,
  98. pageindex,
  99. true,
  100. out recordCount);
  101. var obj = new
  102. {
  103. rows = dt,
  104. total = recordCount
  105. };
  106. return Content(obj.ToJson());
  107. }
  108. //获取知识库
  109. public ActionResult GetInfo(string infoid)
  110. {
  111. Model.T_RepositoryInformation dModel = infoBLL.GetModel(int.Parse(infoid.Trim()));
  112. BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
  113. Model.T_Sys_UserAccount User = new Model.T_Sys_UserAccount();
  114. if (dModel != null)
  115. {
  116. //获取信息更新点击量
  117. infoBLL.UpdateClick(int.Parse(infoid.Trim()));
  118. string cname = "";
  119. #region 类别
  120. if (dModel.F_CategoryId != null)
  121. {
  122. Model.T_RepositoryCategory cModel = new BLL.T_RepositoryCategory().GetModel(dModel.F_CategoryId.Value);
  123. if (cModel != null)
  124. cname = cModel.F_CategoryName;
  125. }
  126. #endregion
  127. string auditu = "";
  128. #region 审核人
  129. if (dModel.F_AuditID != null)
  130. {
  131. Model.T_RepositoryAudit auM = new BLL.T_RepositoryAudit().GetModel(dModel.F_AuditID.Value);
  132. if (auM != null && auM.F_AuditBy != null)
  133. {
  134. User = userBLL.GetModel(auM.F_AuditBy.Value);
  135. if (User != null)
  136. {
  137. auditu = User.F_UserName + "(" + User.F_UserCode + ")";
  138. }
  139. }
  140. }
  141. #endregion
  142. string creatu = "";
  143. #region 添加人
  144. if (dModel.F_CreateBy != null)
  145. {
  146. User = userBLL.GetModel(dModel.F_CreateBy.Value);
  147. if (User != null)
  148. {
  149. creatu = User.F_UserName + "(" + User.F_UserCode + ")";
  150. }
  151. }
  152. #endregion
  153. string KeyName = ""; int key1 = 0;
  154. if (dModel.F_Key != null)
  155. {
  156. var keyvalue = new BLL.T_Sys_DictionaryValue().GetModel(dModel.F_Key.Value);
  157. if (keyvalue != null)
  158. {
  159. KeyName = keyvalue.F_Value;
  160. if (keyvalue.F_PrentId != null)
  161. key1 = keyvalue.F_PrentId.Value;
  162. }
  163. }
  164. var obj = new
  165. {
  166. F_RepositoryId = dModel.F_RepositoryId,
  167. F_Title = dModel.F_Title,
  168. F_Content = dModel.F_Content,
  169. F_Description = dModel.F_Description,
  170. F_ISSubmitAudit = dModel.F_ISSubmitAudit,
  171. F_CreateOn = dModel.F_CreateOn,
  172. F_Category = cname,
  173. F_CategoryId = dModel.F_CategoryId,
  174. F_CreateBy = creatu,
  175. F_AuditBy = auditu,
  176. F_KeyWords = dModel.F_KeyWords ,
  177. KeyName,
  178. key1,
  179. F_Key = dModel.F_Key,
  180. };
  181. return Success("获取知识库信息成功", obj);
  182. }
  183. else
  184. {
  185. return Error("获取知识库信息失败");
  186. }
  187. }
  188. //获取审核列表
  189. public ActionResult GetAuditList()
  190. {
  191. DataTable dt = new DataTable();
  192. string action = RequestString.GetQueryString("action");
  193. string ispass = RequestString.GetQueryString("ispass");
  194. string strpageindex = RequestString.GetQueryString("page");
  195. int pageindex = 1;
  196. string strpagesize = RequestString.GetQueryString("pagesize");
  197. int pagesize = 10;
  198. string sql = ""; string sqlLog = "";
  199. if (!string.IsNullOrEmpty(ispass))
  200. {
  201. sql += " and isnull(F_ISPass,0)=" + ispass;
  202. if (ispass == "0")
  203. sql += " and F_RepositoryId in (select F_RepositoryId from T_RepositoryInformation where F_ISSubmitAudit=1)";
  204. }
  205. //else
  206. //{
  207. // sql += " and isnull(F_ISPass,0)=0 ";
  208. //}
  209. if (!string.IsNullOrEmpty(action))
  210. {
  211. sql += " and F_Action=" + action;
  212. sqlLog += " and F_Action=" + action;
  213. }
  214. if (strpageindex.Trim() != "")
  215. {
  216. pageindex = Convert.ToInt32(strpageindex);
  217. }
  218. if (strpagesize.Trim() != "")
  219. {
  220. pagesize = Convert.ToInt32(strpagesize);
  221. }
  222. int recordCount = 0;
  223. dt = BLL.PagerBLL.GetListPager(
  224. "T_RepositoryAudit",
  225. "F_AuditId",
  226. "*",
  227. sql,
  228. "ORDER BY F_AuditId desc",
  229. pagesize,
  230. pageindex,
  231. true,
  232. out recordCount);
  233. List<Model.T_RepositoryAudit> auditList = new BLL.T_RepositoryAudit().DataTableToList(dt);
  234. List<Model.T_RepositoryLog> logList = new BLL.T_RepositoryLog().GetModelList(" 1=1 and F_Action!=4 " + sqlLog);
  235. var obj = new
  236. {
  237. rows = auditList.Select(x =>
  238. {
  239. var preContent = ""; var afterContent = "";
  240. var predis = ""; var afterdis = "";
  241. var title = ""; var ptitle = ""; var atitle = "";
  242. if (x.F_PreLogID != null)
  243. {
  244. Model.T_RepositoryLog logModel = logList.Where(y => y.F_LogId == x.F_PreLogID.Value).FirstOrDefault();
  245. if (logModel != null)
  246. {
  247. preContent = logModel.F_Content;
  248. predis = logModel.F_Description;
  249. ptitle = logModel.F_Title;
  250. }
  251. }
  252. if (x.F_AfterLogID != null)
  253. {
  254. Model.T_RepositoryLog logModel = logList.Where(y => y.F_LogId == x.F_AfterLogID.Value).FirstOrDefault();
  255. if (logModel != null)
  256. {
  257. afterContent = logModel.F_Content;
  258. afterdis = logModel.F_Description;
  259. atitle = logModel.F_Title;
  260. }
  261. }
  262. if (ptitle != "")
  263. { title = ptitle; }
  264. else { title = atitle; }
  265. return new
  266. {
  267. F_AuditId = x.F_AuditId,
  268. F_Action = x.F_Action,
  269. F_Title = title,
  270. F_PreContent = preContent,
  271. F_PreDescription = predis,
  272. F_AfterContent = afterContent,
  273. F_AfterDescription = afterdis,
  274. F_ISPass = x.F_ISPass,
  275. F_AuditRemark = x.F_AuditRemark,
  276. };
  277. }),
  278. total = recordCount
  279. };
  280. return Content(obj.ToJson());
  281. }
  282. public ActionResult GetDeductLsit(int infoid = 0,int deptid=0)
  283. {
  284. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  285. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  286. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  287. string knowledgekey = HttpUtility.UrlDecode(RequestString.GetQueryString("knowledgekey"));
  288. DataTable dt = new DataTable();
  289. string strpageindex = RequestString.GetQueryString("page");
  290. int pageindex = 1;
  291. string strpagesize = RequestString.GetQueryString("pagesize");
  292. int pagesize = 10;
  293. string sql = "";
  294. if (infoid > 0)
  295. {
  296. sql += "and F_RepositoryId= '" + infoid + "'";
  297. }
  298. if (User.F_RoleCode == "WLDW")
  299. {
  300. sql += "and F_Expand1= '" + User.F_DeptId + "'";
  301. }
  302. else if (deptid>0)
  303. {
  304. sql += "and F_Expand1= '" + deptid + "'";
  305. }
  306. sql += "and F_Action= '" + 4 + "'";
  307. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  308. {
  309. sql += " and F_CreateOn >= '" + strstarttime + "'";
  310. }
  311. if (strendtime.Trim() != "" && strendtime != "undefined")
  312. {
  313. sql += " and F_CreateOn <= '" + strendtime + "'";
  314. }
  315. if (strkey.Trim() != "" && strkey != "undefined")
  316. {
  317. sql += " and F_Title like '%" + strkey + "%'";
  318. }
  319. if (knowledgekey.Trim() != "" && knowledgekey != "undefined")
  320. {
  321. sql += " and F_RepositoryId in (select F_RepositoryId from T_RepositoryInformation where F_Content like '%" + knowledgekey + "%') ";
  322. }
  323. if (strpageindex.Trim() != "")
  324. {
  325. pageindex = Convert.ToInt32(strpageindex);
  326. }
  327. if (strpagesize.Trim() != "")
  328. {
  329. pagesize = Convert.ToInt32(strpagesize);
  330. }
  331. int recordCount = 0;
  332. dt = BLL.PagerBLL.GetListPager(
  333. "T_RepositoryLog",
  334. "F_LogId",
  335. "*",
  336. sql,
  337. "ORDER BY F_LogId desc",
  338. pagesize,
  339. pageindex,
  340. true,
  341. out recordCount);
  342. var obj = new
  343. {
  344. rows = dt,
  345. total = recordCount
  346. };
  347. return Content(obj.ToJson());
  348. }
  349. [Authority]
  350. //扣除分值
  351. public ActionResult DeductInfo(int infoid = 0, int score = 0, string reason = "")
  352. {
  353. if (User.F_RoleCode == "GLY")
  354. {
  355. if (infoid <= 0)
  356. return Error("请选择知识库");
  357. if (score > 0)
  358. return Error("扣除分值不能大于0");
  359. if (string.IsNullOrEmpty(reason))
  360. return Error("请输入扣分原因");
  361. Model.T_RepositoryInformation dModel = infoBLL.GetModel(infoid);
  362. if (dModel.F_Score == null)
  363. dModel.F_Score = score;
  364. else
  365. dModel.F_Score = dModel.F_Score + score;
  366. dModel.F_Reason = reason;
  367. dModel.F_Description = User.F_UserCode;
  368. if (infoBLL.Update(dModel))
  369. {
  370. string content = $"{User.F_UserName}({User.F_UserCode })知识库{ dModel.F_Title}扣分{Math.Abs((float)score)}";
  371. string Operation = OperationLogController
  372. .AddOperationList(content, User.F_UserCode, Common.DTRequest.GetIP(), 3, 4594, dModel.F_RepositoryId );
  373. int logid = addLog(dModel, 4);
  374. return Success("扣分成功");
  375. }
  376. else
  377. {
  378. return Success("扣分失败");
  379. }
  380. }
  381. else
  382. {
  383. return Error("权限不足");
  384. }
  385. }
  386. public ActionResult GetExamineScore( int deptid = 0)
  387. {
  388. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  389. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  390. DataTable dt = new DataTable();
  391. string strpageindex = RequestString.GetQueryString("page");
  392. int pageindex = 1;
  393. string strpagesize = RequestString.GetQueryString("pagesize");
  394. int pagesize = 10;
  395. string sql = "";
  396. if (deptid > 0)
  397. {
  398. sql += "and F_Deptid= '" + deptid + "'";
  399. }
  400. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  401. {
  402. sql += " and F_CreateTime >= '" + strstarttime + "'";
  403. }
  404. if (strendtime.Trim() != "" && strendtime != "undefined")
  405. {
  406. sql += " and F_CreateTime <= '" + strendtime + "'";
  407. }
  408. if (strpageindex.Trim() != "")
  409. {
  410. pageindex = Convert.ToInt32(strpageindex);
  411. }
  412. if (strpagesize.Trim() != "")
  413. {
  414. pagesize = Convert.ToInt32(strpagesize);
  415. }
  416. int recordCount = 0;
  417. dt = BLL.PagerBLL.GetListPager(
  418. "T_Sys_ExamineScore a ",
  419. "F_ID",
  420. "*,dbo.GetDeptName(a.F_Deptid) DeptName",
  421. sql,
  422. "ORDER BY F_ID desc",
  423. pagesize,
  424. pageindex,
  425. true,
  426. out recordCount);
  427. var obj = new
  428. {
  429. rows = dt,
  430. total = recordCount
  431. };
  432. return Content(obj.ToJson());
  433. }
  434. [Authority]
  435. //扣除分值
  436. public ActionResult ExamineScore(string item,int deptid=0,int score=0,string reason="")
  437. {
  438. if (deptid<=0)
  439. return Error("请选择部门");
  440. if (string .IsNullOrEmpty (item))
  441. return Error("请选择加减分项");
  442. string strSql = string.Format(@"INSERT INTO T_Sys_ExamineScore
  443. ( [F_Item] ,[F_Score],[F_Reason] ,[F_Deptid],[F_CreateTime],[F_Month] ,[F_CreateUser])
  444. values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}') ;select @@IDENTITY ",
  445. item, score, reason, deptid, DateTime .Now , DateTime.Now.ToString ("yyyyMM"),
  446. User .F_UserCode );
  447. int rows = DbHelperSQL.ExecuteSql (strSql);
  448. if (rows > 0)
  449. {
  450. int logid = 0;
  451. Model.T_RepositoryLog logModel = new Model.T_RepositoryLog();
  452. logModel.F_Action = 4;
  453. logModel.F_Description = item;
  454. logModel.F_Title = item;
  455. if (score > 0)
  456. logModel.F_Content = User.F_UserCode + "加分" + Math.Abs((float)score) +
  457. ",加分原因:" + reason;
  458. else
  459. logModel.F_Content = User.F_UserCode + "扣分" + Math.Abs((float)score) +
  460. ",扣分原因:" + reason;
  461. logModel.F_Expand2 = item;
  462. var dapt = new BLL.T_Sys_Department().GetModel(deptid);
  463. if (dapt != null)
  464. {
  465. logModel.F_KeyWords = dapt.F_DeptName;
  466. logModel.F_Expand1 = dapt.F_DeptId.ToString();
  467. }
  468. logModel.F_CreateBy = User.F_UserId;
  469. logModel.F_CreateOn = DateTime.Now;
  470. logid = new BLL.T_RepositoryLog().Add(logModel);
  471. if (logid >0)
  472. {
  473. string content = "";
  474. if (score > 0)
  475. content = $"{User.F_UserName}({User.F_UserCode })知识库{ item}加分{Math.Abs((float)score)}";
  476. else
  477. content = $"{User.F_UserName}({User.F_UserCode })知识库{ item}扣分{Math.Abs((float)score)}";
  478. string Operation = OperationLogController
  479. .AddOperationList(content, User.F_UserCode, Common.DTRequest.GetIP(), 3, 4594,logid );
  480. }
  481. return Success ("添加成功");
  482. }
  483. else
  484. return Error("添加失败");
  485. }
  486. [Authority]
  487. //添加知识库
  488. public ActionResult AddInfo(string title, string con, string pid,string key, int issub=1, int keyid = 0,int demandsid=0)
  489. {
  490. Model.T_RepositoryInformation dModel = new Model.T_RepositoryInformation();
  491. if (string.IsNullOrEmpty(title))
  492. return Error("标题不能为空");
  493. if (string.IsNullOrEmpty(con))
  494. return Error("内容不能为空");
  495. dModel.F_Title = title.Trim();
  496. dModel.F_Content = WebHelper.UrlDecode(con.Trim());
  497. dModel.F_CategoryId = int.Parse(pid);
  498. dModel.F_Description = WebHelper.NoHtml(WebHelper.UrlDecode(con.Trim()));
  499. dModel.F_ISPass = 0;
  500. dModel.F_ISSubmitAudit = issub;
  501. dModel.F_CreateOn = DateTime.Now;
  502. dModel.F_CreateBy = User.F_UserId;
  503. dModel.F_KeyWords = key;
  504. dModel.F_Key = keyid;
  505. int b = infoBLL.Add(dModel);
  506. if (b > 0)
  507. {
  508. string content=$"{User.F_UserName}({User.F_UserCode })添加知识库{ dModel.F_Title }";
  509. string Operation = OperationLogController
  510. .AddOperationList(content, User.F_UserCode, Common.DTRequest.GetIP(), 0, 4594,b );
  511. if (demandsid > 0)
  512. {
  513. Model.T_Repository_List_Demands demandsModel = new BLL.T_Repository_List_Demands().GetModel(demandsid);
  514. if (demandsModel != null)
  515. {
  516. demandsModel.F_RepositoryId = b ;
  517. demandsModel.F_SubmitTime = DateTime.Now;
  518. demandsModel.F_SubmitUser = User.F_UserCode;
  519. new BLL.T_Repository_List_Demands().Update(demandsModel);
  520. }
  521. }
  522. dModel.F_RepositoryId = b;
  523. int logid = addLog(dModel, 1);
  524. int auditid = addaudit(b, 1, null, logid);
  525. new BLL.T_RepositoryInformation().UpdateAuditID(b, auditid);
  526. return Success("添加成功");
  527. }
  528. else
  529. {
  530. return Success("添加失败");
  531. }
  532. }
  533. [Authority]
  534. //编辑知识库
  535. public ActionResult EditInfo(string infoid, string title, string con, string pid,string key, int? issub, int keyid = 0)
  536. {
  537. Model.T_RepositoryInformation dModel = infoBLL.GetModel(int.Parse(infoid.Trim()));
  538. if (dModel != null)
  539. {
  540. if (keyid > 0)
  541. {
  542. dModel.F_Key = keyid;
  543. }
  544. if (title.Trim() != "")
  545. {
  546. dModel.F_Title = title.Trim();
  547. }
  548. if (con.Trim() != "")
  549. {
  550. dModel.F_Content = WebHelper.UrlDecode(con.Trim());
  551. dModel.F_Description = WebHelper.NoHtml(WebHelper.UrlDecode(con.Trim()));
  552. }
  553. if (pid != null)
  554. {
  555. dModel.F_CategoryId = int.Parse(pid);
  556. }
  557. if (issub != null)
  558. {
  559. dModel.F_ISSubmitAudit = issub;
  560. }
  561. dModel.F_KeyWords = key;
  562. Model.T_RepositoryAudit audModel = new Model.T_RepositoryAudit();
  563. if (dModel.F_AuditID != null)
  564. audModel = new BLL.T_RepositoryAudit().GetModel(dModel.F_AuditID.Value);
  565. int logid = addLog(dModel, 2);
  566. if (logid > 0)
  567. {
  568. string content = $"{User.F_UserName}({User.F_UserCode })编辑知识库{ dModel.F_Title }";
  569. string Operation = OperationLogController
  570. .AddOperationList(content, User.F_UserCode, Common.DTRequest.GetIP(), 1, 4594, dModel.F_RepositoryId);
  571. int auditid = addaudit(int.Parse(infoid.Trim()), 2, audModel.F_AfterLogID, logid);
  572. new BLL.T_RepositoryInformation().UpdateAuditID(int.Parse(infoid.Trim()), auditid);
  573. infoBLL.UpdateSubAudit(int.Parse(infoid.Trim()), 1);
  574. return Success("保存成功");
  575. }
  576. else
  577. {
  578. return Success("保存失败");
  579. }
  580. }
  581. else
  582. {
  583. return Error("请选择要编辑的知识库");
  584. }
  585. }
  586. [Authority]
  587. //删除知识库
  588. public ActionResult DelInfos(string[] ids)
  589. {
  590. if (ids != null && ids.Length > 0)
  591. {
  592. int c = 0;
  593. foreach (string str in ids)
  594. {
  595. Model.T_RepositoryInformation dModel = infoBLL.GetModel(int.Parse(str.Trim()));
  596. if (dModel != null)
  597. {
  598. Model.T_RepositoryAudit audModel = new Model.T_RepositoryAudit();
  599. if (dModel.F_AuditID != null)
  600. audModel = new BLL.T_RepositoryAudit().GetModel(dModel.F_AuditID.Value);
  601. int logid = addLog(dModel, 3);
  602. if (logid > 0)
  603. {
  604. string content = $"{User.F_UserName}({User.F_UserCode })删除知识库{ dModel.F_Title }";
  605. string Operation = OperationLogController
  606. .AddOperationList(content, User.F_UserCode, Common.DTRequest.GetIP(), 2, 4594, dModel.F_RepositoryId);
  607. int auditid = addaudit(int.Parse(str.Trim()), 3, audModel.F_AfterLogID, logid);
  608. infoBLL.UpdateSubAudit(int.Parse(str.Trim()), 1);
  609. infoBLL.UpdateAuditID(int.Parse(str.Trim()), auditid);
  610. c++;
  611. }
  612. }
  613. }
  614. if (c == ids.Length)
  615. return Success("已提交审核");
  616. else if (c < ids.Length && c > 0)
  617. return Success("部分审核完成,请查看未审核的内容!");
  618. else
  619. return Error("审核失败!");
  620. }
  621. else
  622. {
  623. return Error("获取参数失败");
  624. }
  625. }
  626. [Authority]
  627. //审核
  628. public ActionResult AuditR(int[] ids, string auditremark, int ispass)
  629. {
  630. int c = 0;
  631. foreach (int str in ids)
  632. {
  633. if (audit(str, auditremark, ispass))
  634. c++;
  635. }
  636. if (c >= ids.Length)
  637. return Success("审核完成!");
  638. else if (c < ids.Length && c > 0)
  639. return Success("部分审核完成,请查看未审核的内容!");
  640. else
  641. return Error("审核失败!");
  642. }
  643. [Authority]
  644. //提交审核
  645. public ActionResult SubAudit(int[] ids)
  646. {
  647. int c = 0;
  648. foreach (int str in ids)
  649. {
  650. if (infoBLL.UpdateSubAudit(str, 1))
  651. c++;
  652. }
  653. if (c >= ids.Length)
  654. return Success("提交成功!");
  655. else if (c < ids.Length && c > 0)
  656. return Success("部分提交完成,请查看未提交的内容!");
  657. else
  658. return Error("提交失败!");
  659. }
  660. //添加审核
  661. private int addaudit(int rid, int action, int? preid, int? afterid)
  662. {
  663. int auditid = 0;
  664. Model.T_RepositoryAudit auditModel = new Model.T_RepositoryAudit();
  665. auditModel.F_Action = action;
  666. auditModel.F_RepositoryId = rid;
  667. if (preid != null)
  668. {
  669. auditModel.F_PreLogID = preid;
  670. }
  671. if (afterid != null)
  672. {
  673. auditModel.F_AfterLogID = afterid;
  674. }
  675. auditModel.F_ISPass = 0;
  676. auditModel.F_CreateBy = User.F_UserId;
  677. auditModel.F_CreateOn = DateTime.Now;
  678. auditid = new BLL.T_RepositoryAudit().Add(auditModel);
  679. return auditid;
  680. }
  681. string FrontUrl = Configs.GetValue("FrontUrl");
  682. //审核
  683. private bool audit(int? auditid, string auditremark, int ispass)
  684. {
  685. BLL.T_RepositoryAudit auditBLL = new BLL.T_RepositoryAudit();
  686. if (auditid != null)
  687. {
  688. Model.T_RepositoryAudit auditModel = auditBLL.GetModel(auditid.Value);
  689. if (auditModel != null)
  690. {
  691. auditModel.F_AuditBy = User.F_UserId;
  692. auditModel.F_AuditOn = DateTime.Now;
  693. auditModel.F_AuditRemark = auditremark;
  694. auditModel.F_ISPass = ispass;
  695. bool r = auditBLL.Update(auditModel);
  696. if (r)
  697. {
  698. if (ispass == 1)
  699. {
  700. bool dd = infoBLL.UpdateAudit(auditModel.F_RepositoryId.Value, 1);
  701. if (auditModel.F_Action == 2)
  702. {
  703. Model.T_RepositoryLog logModel = new BLL.T_RepositoryLog().GetModel(auditModel.F_AfterLogID.Value);
  704. Model.T_RepositoryInformation infoModel = infoBLL.GetModel(auditModel.F_RepositoryId.Value);
  705. infoModel.F_Title = logModel.F_Title;
  706. infoModel.F_CategoryId = logModel.F_IntExpand1;
  707. infoModel.F_Description = logModel.F_Description;
  708. infoModel.F_Content = logModel.F_Content;
  709. infoModel.F_ISPass = ispass;
  710. infoModel.F_KeyWords = logModel.F_KeyWords;
  711. infoModel.F_Key = logModel.F_IntExpand2;
  712. string content = $"{User.F_UserName}({User.F_UserCode })审核通过了知识库{ infoModel.F_Title }修改";
  713. string Operation = OperationLogController
  714. .AddOperationList(content, User.F_UserCode, Common.DTRequest.GetIP(), 3, 4594,infoModel .F_RepositoryId);
  715. return infoBLL.Update(infoModel);
  716. }
  717. if (auditModel.F_Action == 3)
  718. {
  719. Model.T_RepositoryInformation infoModel = infoBLL.GetModel(auditModel.F_RepositoryId.Value);
  720. string content = $"{User.F_UserName}({User.F_UserCode })审核通过了知识库{ infoModel.F_Title }删除";
  721. string Operation = OperationLogController
  722. .AddOperationList(content, User.F_UserCode, Common.DTRequest.GetIP(), 3, 4594, infoModel .F_RepositoryId);
  723. return infoBLL.Delete(auditModel.F_RepositoryId.Value);
  724. }
  725. if (dd)
  726. {
  727. Task.Run(() =>
  728. {
  729. WebClient web = new WebClient();
  730. web.Encoding = Encoding.UTF8;
  731. if (auditModel.F_Action == 1)
  732. {
  733. string Dataurl = web.DownloadString(FrontUrl + "Affairs/kinfo_add?id=" + auditModel.F_RepositoryId.Value);
  734. }
  735. else if (auditModel.F_Action == 2)
  736. {
  737. string Dataurl = web.DownloadString(FrontUrl + "Affairs/kinfo_update?id=" + auditModel.F_RepositoryId.Value);
  738. }
  739. else if (auditModel.F_Action == 3)
  740. {
  741. string Dataurl = web.DownloadString(FrontUrl + "Affairs/kinfo_delete?id=" + auditModel.F_RepositoryId.Value + "&remark=" + auditremark);
  742. }
  743. }).ContinueWith(p =>
  744. {
  745. System.Diagnostics.Debug.WriteLine(DateTime.Now);
  746. });
  747. }
  748. return dd;
  749. }
  750. else
  751. {
  752. if (auditModel.F_Action == 1)
  753. {
  754. Model.T_RepositoryInformation infoModel = infoBLL.GetModel(auditModel.F_RepositoryId.Value);
  755. infoModel.F_ISPass = ispass;
  756. return infoBLL.Update(infoModel);
  757. }
  758. return r;
  759. }
  760. }
  761. }
  762. }
  763. return false;
  764. }
  765. //添加日志
  766. private int addLog(Model.T_RepositoryInformation rmodel, int action)
  767. {
  768. int logid = 0;
  769. Model.T_RepositoryLog logModel = new Model.T_RepositoryLog();
  770. logModel.F_Action = action;
  771. logModel.F_Description = rmodel.F_Description;
  772. logModel.F_IntExpand1 = rmodel.F_CategoryId;
  773. if(action==4)
  774. {
  775. logModel.F_Title = rmodel.F_Title;
  776. logModel.F_Content = User.F_UserCode +"扣分"+Math .Abs ((float )rmodel.F_Score )+
  777. ",扣分原因:"+ rmodel.F_Reason ;
  778. logModel.F_Expand2 = rmodel.F_Content;
  779. var demandsModel = new BLL.T_Repository_List_Demands().GetModelList
  780. ("F_RepositoryId='" + rmodel.F_RepositoryId + "' and F_IsDelete=0");
  781. try
  782. {
  783. if (demandsModel != null && demandsModel.Count > 0)
  784. {
  785. if (demandsModel.LastOrDefault().F_Deptid > 0)
  786. {
  787. var dapt = new BLL.T_Sys_Department().GetModel((int)demandsModel.LastOrDefault().F_Deptid);
  788. if (dapt != null)
  789. {
  790. logModel.F_KeyWords = dapt.F_DeptName;
  791. logModel.F_Expand1 = dapt.F_DeptId.ToString ();
  792. }
  793. }
  794. }
  795. else if (rmodel.F_CreateBy!=null&&rmodel.F_CreateBy>0)
  796. {
  797. var user = new BLL.T_Sys_UserAccount().GetModel(rmodel.F_CreateBy.Value);
  798. if (user !=null )
  799. {
  800. if (user .F_RoleId ==2 )
  801. {
  802. var dapt = new BLL.T_Sys_Department().GetModel(user.F_DeptId );
  803. if (dapt != null)
  804. {
  805. logModel.F_KeyWords = dapt.F_DeptName;
  806. logModel.F_Expand1 = dapt.F_DeptId.ToString();
  807. }
  808. }
  809. }
  810. }
  811. }
  812. catch
  813. {
  814. }
  815. }
  816. else
  817. {
  818. logModel.F_Title = rmodel.F_Title;
  819. logModel.F_Content = rmodel.F_Content;
  820. logModel.F_KeyWords = rmodel.F_KeyWords;
  821. }
  822. logModel.F_IntExpand2 = rmodel.F_Key;
  823. logModel.F_RepositoryId = rmodel.F_RepositoryId;
  824. logModel.F_Url = rmodel.F_Url;
  825. logModel.F_CreateBy = User.F_UserId;
  826. logModel.F_CreateOn = DateTime.Now;
  827. logid = new BLL.T_RepositoryLog().Add(logModel);
  828. return logid;
  829. }
  830. }
  831. }