Açıklama Yok

HomeController.cs 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. 
  2. using CallCenter.Utility;
  3. using CallCenterApi.Common;
  4. using CallCenterApi.Interface.Controllers.Base;
  5. using CallCenterApi.Interface.Models.Common;
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Data.SqlTypes;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading;
  14. using System.Web;
  15. using System.Web.Caching;
  16. using System.Web.Mvc;
  17. namespace CallCenterApi.Interface.Controllers
  18. {
  19. public class HomeController : BaseController
  20. {
  21. // GET: Home
  22. public ActionResult Index()
  23. {
  24. return Success("成功");
  25. }
  26. [Authorize]
  27. public JsonResult json1()
  28. {
  29. var person = new
  30. {
  31. Name = "张三",
  32. Age = 22,
  33. Sex = "男"
  34. };
  35. return Json(person, JsonRequestBehavior.AllowGet);
  36. }
  37. public string json2()
  38. {
  39. var person = new
  40. {
  41. Name = "张三",
  42. Age = 22,
  43. Sex = "男",
  44. Date = DateTime.Now
  45. };
  46. return person.ToJson();
  47. }
  48. public string json2_()
  49. {
  50. var tt = new
  51. {
  52. exp = 20,
  53. money = 12
  54. };
  55. var person = new
  56. {
  57. Name = "张三",
  58. Age = 22,
  59. Sex = "男",
  60. other = tt,
  61. Date = DateTime.Now
  62. };
  63. return person.ToJson();
  64. }
  65. /// <summary>
  66. /// 演示 查询出来datatable的数据进行展示
  67. /// </summary>
  68. /// <returns></returns>
  69. public string json3()
  70. {
  71. DataTable tblDatas = new DataTable("Datas");
  72. DataColumn dc = null;
  73. dc = tblDatas.Columns.Add("Product", Type.GetType("System.String"));
  74. dc = tblDatas.Columns.Add("Version", Type.GetType("System.String"));
  75. dc = tblDatas.Columns.Add("Description", Type.GetType("System.String"));
  76. DataRow newRow;
  77. newRow = tblDatas.NewRow();
  78. newRow["Product"] = "大话西游";
  79. newRow["Version"] = "2.0";
  80. newRow["Description"] = "我很喜欢";
  81. tblDatas.Rows.Add(newRow);
  82. newRow = tblDatas.NewRow();
  83. newRow["Product"] = "梦幻西游";
  84. newRow["Version"] = "3.0";
  85. newRow["Description"] = "比大话更幼稚";
  86. tblDatas.Rows.Add(newRow);
  87. return tblDatas.ToJson();
  88. }
  89. public ActionResult json3_()
  90. {
  91. DataTable tblDatas = new DataTable("Datas");
  92. DataColumn dc = null;
  93. dc = tblDatas.Columns.Add("Product", Type.GetType("System.String"));
  94. dc = tblDatas.Columns.Add("Version", Type.GetType("System.String"));
  95. dc = tblDatas.Columns.Add("Description", Type.GetType("System.String"));
  96. DataRow newRow;
  97. newRow = tblDatas.NewRow();
  98. newRow["Product"] = "大话西游";
  99. newRow["Version"] = "2.0";
  100. newRow["Description"] = "我很喜欢";
  101. tblDatas.Rows.Add(newRow);
  102. newRow = tblDatas.NewRow();
  103. newRow["Product"] = "梦幻西游";
  104. newRow["Version"] = "3.0";
  105. newRow["Description"] = "比大话更幼稚";
  106. tblDatas.Rows.Add(newRow);
  107. return Success("成功", tblDatas);
  108. }
  109. public ActionResult excel()
  110. {
  111. DataTable tblDatas = new DataTable("Datas");
  112. DataColumn dc = null;
  113. dc = tblDatas.Columns.Add("Product", Type.GetType("System.String"));
  114. dc = tblDatas.Columns.Add("Version", Type.GetType("System.String"));
  115. dc = tblDatas.Columns.Add("Description", Type.GetType("System.String"));
  116. DataRow newRow;
  117. newRow = tblDatas.NewRow();
  118. newRow["Product"] = "大话西游";
  119. newRow["Version"] = "2.0";
  120. newRow["Description"] = "我很喜欢";
  121. tblDatas.Rows.Add(newRow);
  122. newRow = tblDatas.NewRow();
  123. newRow["Product"] = "梦幻西游";
  124. newRow["Version"] = "3.0";
  125. newRow["Description"] = "比大话更幼稚";
  126. tblDatas.Rows.Add(newRow);
  127. NPOIHelper npoi = new NPOIHelper();
  128. string[] s = { "列1", "列2", "列3" };
  129. if (npoi.ToExcel(tblDatas, "test", null, "D:/2.xlsx", s))
  130. {
  131. return Success("成功", tblDatas);
  132. }
  133. else
  134. {
  135. return Error("导出失败");
  136. }
  137. }
  138. public ActionResult excel1()
  139. {
  140. DataTable tblDatas = new DataTable("Datas");
  141. DataColumn dc = null;
  142. dc = tblDatas.Columns.Add("Product", Type.GetType("System.String"));
  143. dc = tblDatas.Columns.Add("Version", Type.GetType("System.String"));
  144. dc = tblDatas.Columns.Add("Description", Type.GetType("System.String"));
  145. DataRow newRow;
  146. newRow = tblDatas.NewRow();
  147. newRow["Product"] = "大话西游";
  148. newRow["Version"] = "2.0";
  149. newRow["Description"] = "我很喜欢";
  150. tblDatas.Rows.Add(newRow);
  151. newRow = tblDatas.NewRow();
  152. newRow["Product"] = "梦幻西游";
  153. newRow["Version"] = "3.0";
  154. newRow["Description"] = "比大话更幼稚";
  155. tblDatas.Rows.Add(newRow);
  156. NPOIHelper npoi = new NPOIHelper();
  157. if (npoi.ExportToExcel("test", tblDatas) == "")
  158. {
  159. return Success("成功", tblDatas);
  160. }
  161. else
  162. {
  163. return Error("导出失败");
  164. }
  165. }
  166. public ActionResult error()
  167. {
  168. return Error("不具备权限");
  169. }
  170. public string ss()
  171. {
  172. return "ss";
  173. }
  174. public string tt(string name, string pass)
  175. {
  176. return "sss " + name + pass;
  177. }
  178. /// <summary>
  179. /// 抛出HTTP 500
  180. /// </summary>
  181. /// <returns></returns>
  182. public ActionResult ThrowHttp500()
  183. {
  184. throw new HttpException(500, "服务器错误");
  185. }
  186. /// <summary>
  187. /// 抛出HTTP 404
  188. /// </summary>
  189. /// <returns></returns>
  190. public ActionResult ThrowHttp404()
  191. {
  192. throw new HttpException(404, "页面未找到");
  193. }
  194. /// <summary>
  195. /// 抛出未引用对象异常
  196. /// ,此处单独使用HandleError特性
  197. /// ,并指定异常类型及响应视图
  198. /// </summary>
  199. /// <returns></returns>
  200. [HandleError(ExceptionType = typeof(NullReferenceException), View = "CustomError")]
  201. public ActionResult ThrowNullReferenceException()
  202. {
  203. throw new NullReferenceException();
  204. }
  205. /// <summary>
  206. /// 引发输入字符串的格式不正确异常
  207. /// ,此处指定了响应的错误页面
  208. /// ,由于是不同的控制器所以要完整的相对路径
  209. /// </summary>
  210. /// <returns></returns>
  211. [HandleError(View = "~/Views/Error/CustomHttpError.cshtml")]
  212. public ActionResult ThrowFormatException()
  213. {
  214. string str = "";
  215. int count = Convert.ToInt32(str);
  216. return View("Index");
  217. }
  218. public ActionResult GetRedisValue(string key)
  219. {
  220. return Success("成功", RedisHelper.StringGet(key));
  221. }
  222. public ActionResult GetRedis(string key)
  223. {
  224. List<object> caches = new List<object>();
  225. var keys = RedisHelper.GetKeyList(string.IsNullOrEmpty(key) ? "" : key);
  226. foreach (var k in keys)
  227. {
  228. caches.Add(new
  229. {
  230. key = k,
  231. value = RedisHelper.StringGet(k),
  232. outtime=RedisHelper.GetKeyOutTime(k)
  233. });
  234. }
  235. return Success("成功", caches);
  236. }
  237. public ActionResult UpdateRedis(string key, string value, int second = 10)
  238. {
  239. List<object> caches = new List<object>();
  240. var keys = RedisHelper.GetKeyList(string.IsNullOrEmpty(key) ? "" : key);
  241. foreach (var k in keys)
  242. {
  243. RedisHelper.StringSet(k, value, new TimeSpan(0, 0, second));
  244. }
  245. return Success("成功");
  246. }
  247. public ActionResult DeleteRedis(string key)
  248. {
  249. List<object> caches = new List<object>();
  250. var keys = RedisHelper.GetKeyList(string.IsNullOrEmpty(key) ? "" : key);
  251. long n = RedisHelper.KeysDelete(keys);
  252. return Success("成功", n);
  253. }
  254. public ActionResult GetAllCache()
  255. {
  256. System.Web.Caching.Cache cache = HttpRuntime.Cache;
  257. IDictionaryEnumerator cacheEnum = cache.GetEnumerator();
  258. List<cacheobj> caches = new List<cacheobj>();
  259. StringBuilder sb = new StringBuilder();
  260. while (cacheEnum.MoveNext())
  261. {
  262. Dictionary<string, string> dic = null;
  263. try
  264. {
  265. dic = (Dictionary<string, string>)cacheEnum.Value;
  266. }
  267. catch
  268. {
  269. continue;
  270. }
  271. sb.Append($"F_UserID={dic["F_UserID"]}, ");
  272. sb.Append($"F_UserCode={dic["F_UserCode"]}, ");
  273. sb.Append($"F_UserName={dic["F_UserName"]} ");
  274. caches.Add(new cacheobj
  275. {
  276. key = cacheEnum.Key.ToString().Substring(0, 20),
  277. value = sb.ToString()
  278. });
  279. sb.Clear();
  280. }
  281. return Success("", new
  282. {
  283. count = caches.Count(),
  284. });
  285. }
  286. //public ActionResult MakeCache()
  287. //{
  288. // while (true)
  289. // {
  290. // Dictionary<string, string> Dic = new Dictionary<string, string>();
  291. // Dic.Add("F_UserID", "1411");
  292. // Dic.Add("F_UserCode", "8000");
  293. // Dic.Add("F_DeptId", "1");
  294. // Dic.Add("F_UserName", "系统管理员");
  295. // Dic.Add("F_Telephone", "15537150907");
  296. // Dic.Add("F_RoleID", "1");
  297. // Dic.Add("F_SeatFlag", "1");
  298. // new CallCenterApi.BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  299. // {
  300. // F_LoginName = "8000",
  301. // F_LoginId = 1411,
  302. // F_Result = "登录成功",
  303. // F_LoginIP = Common.DTRequest.GetIP(),
  304. // F_Hostname = Common.DTRequest.GetIP(),
  305. // F_LoginDate = DateTime.Now,
  306. // F_Remark = "",
  307. // F_State = 0
  308. // });
  309. // var token = FormsPrincipal<Dictionary<string, string>>.GetCookieValue(Dic["F_UserCode"], Dic);
  310. // //放入缓存
  311. // CacheHelper.Insert(token, Dic, 2880, System.Web.Caching.CacheItemPriority.NotRemovable);
  312. // Response.Write(token.Substring(0, 20) + "</n>");
  313. // }
  314. //}
  315. public ActionResult TestCache()
  316. {
  317. int n = 0;
  318. while (n<100)
  319. {
  320. Dictionary<string, string> Dic = new Dictionary<string, string>();
  321. Dic.Add("F_UserID", (1000 + n).ToString());
  322. Dic.Add("F_UserCode", (8000+n).ToString());
  323. Dic.Add("F_DeptId", "1");
  324. Dic.Add("F_UserName", "系统管理员" + n);
  325. Dic.Add("F_Telephone", "15537150907");
  326. Dic.Add("F_RoleID", "1");
  327. Dic.Add("F_SeatFlag", "1");
  328. var token = FormsPrincipal<Dictionary<string, string>>.GetCookieValue(Dic["F_UserCode"], Dic);
  329. CacheItemRemovedCallback cacheItemRemovedCallback = new CacheItemRemovedCallback(onRemove);
  330. //放入缓存
  331. CacheHelper.Insert(token, Dic, 1, System.Web.Caching.CacheItemPriority.NotRemovable, cacheItemRemovedCallback);
  332. n++;
  333. }
  334. return Success(n.ToString());
  335. }
  336. /// <summary>
  337. /// 移除缓存后调用
  338. /// </summary>
  339. /// <param name="key"></param>
  340. /// <param name="val"></param>
  341. /// <param name="reason"></param>
  342. public void onRemove(string key, object val, CacheItemRemovedReason reason)
  343. {
  344. var obj = new
  345. {
  346. key = key,
  347. val = val,
  348. reason = reason
  349. };
  350. Error(obj.ToJson());
  351. }
  352. /// <summary>
  353. /// 测试日志
  354. /// </summary>
  355. /// <param name="message"></param>
  356. /// <returns></returns>
  357. public ActionResult LogTest(string message)
  358. {
  359. var log = LogFactory.GetLogger(this.GetType().ToString());
  360. log.Debug(message);
  361. log.Info(message);
  362. log.Warn(message);
  363. log.Error(message);
  364. return Success("");
  365. }
  366. /// <summary>
  367. /// 测试日志
  368. /// </summary>
  369. /// <param name="message"></param>
  370. /// <returns></returns>
  371. public ActionResult GetConfig(string key)
  372. {
  373. return Success(Configs.GetValue(key));
  374. }
  375. /// <summary>
  376. /// 导出
  377. /// </summary>
  378. /// <returns></returns>
  379. public ActionResult Export()
  380. {
  381. var aw = new AsposeWord();
  382. aw.OpenWithTemplate(Server.MapPath("/Upload/Word/热线工单模版.doc"));
  383. var bt = aw.ExportAs();
  384. Response.AppendHeader("Access-Control-Expose-Headers", "Content-Disposition");
  385. return File(bt, "application/msword", DateTime.Now.Ticks.ToString() + ".doc");
  386. }
  387. /// <summary>
  388. /// 导出
  389. /// </summary>
  390. /// <returns></returns>
  391. public ActionResult ExportWord(int id)
  392. {
  393. var aw = new AsposeWord();
  394. aw.OpenWithTemplate(Server.MapPath("/Upload/Word/政策专家库模板.doc"));
  395. var dt = DB.DbHelperSQL.Query("select * from T_Wiki_Professor where F_Id=" + id).Tables[0];
  396. aw.Builder();
  397. aw.CreateProfessorWord(dt);
  398. var bt = aw.ExportAs();
  399. Response.AppendHeader("Access-Control-Expose-Headers", "Content-Disposition");
  400. return File(bt, "application/msword", DateTime.Now.Ticks.ToString() + ".doc");
  401. }
  402. /// <summary>
  403. /// 发送短信
  404. /// </summary>
  405. /// <returns></returns>
  406. public ActionResult Send(string phones, string templateCode, string templateParam)
  407. {
  408. //string result=SmsHelper.Send("15838094023", "614915038222241792");
  409. string result = SmsHelper.Send(phones, templateCode, templateParam);
  410. return Success(result);
  411. }
  412. /// <summary>
  413. /// 发送短信
  414. /// </summary>
  415. /// <returns></returns>
  416. public ActionResult SendNew(string phones, string content)
  417. {
  418. string result = SmsNewHelper.Send(phones, content);
  419. return Success(result);
  420. }
  421. /// <summary>
  422. /// 办事指南
  423. /// </summary>
  424. /// <param name="id"></param>
  425. /// <returns></returns>
  426. public ActionResult ExportGuideWord(int id)
  427. {
  428. var aw = new AsposeWord();
  429. aw.OpenWithTemplate(Server.MapPath("/Upload/Word/办事指南模板.doc"));
  430. var dt = DB.DbHelperSQL.Query("select * from T_Wiki_LawGuide a where F_Id=" + id).Tables[0];
  431. dt.Columns.Add("fileurl");
  432. DataTable dtfile = new DataTable();
  433. string fileurl = "";
  434. string file = dt.Rows[0]["F_File"].ToString();
  435. if (!string.IsNullOrEmpty(file) )
  436. {
  437. dtfile = DB.DbHelperSQL.Query("select * from T_Sys_Accessories WITH(NOLOCK) where F_FileId in (" + file + ")").Tables[0];
  438. foreach (DataRow dr in dtfile.Rows)
  439. {
  440. fileurl+= dr["F_FileName"].ToString() +",";
  441. }
  442. }
  443. if (!string.IsNullOrEmpty(fileurl))
  444. {
  445. fileurl= fileurl.Substring(0, fileurl.Length - 1);
  446. }
  447. dt.Rows[0]["fileurl"] = fileurl;
  448. string F_key = dt.Rows[0]["F_key"].ToString();
  449. var dt2 = DB.DbHelperSQL.Query("SELECT * FROM View_KeysSplit WHERE id="+ F_key).Tables[0];
  450. aw.Builder();
  451. aw.CreateGuideWord(dt,dt2);
  452. var bt = aw.ExportAs();
  453. Response.AppendHeader("Access-Control-Expose-Headers", "Content-Disposition");
  454. return File(bt, "application/msword", DateTime.Now.Ticks.ToString() + ".doc");
  455. }
  456. /// <summary>
  457. /// 部门职能
  458. /// </summary>
  459. /// <param name="id"></param>
  460. /// <returns></returns>
  461. public ActionResult ExportDepartmentFunctionsWord(int id)
  462. {
  463. var aw = new AsposeWord();
  464. aw.OpenWithTemplate(Server.MapPath("/Upload/Word/部门职能模板.doc"));
  465. var dt = DB.DbHelperSQL.Query("select top 1 F_Id,F_FaBuDanWei,F_FaBuRen,F_HangYe,F_DiQu,F_ShengXiaoShiJian,F_ShiXiaoShiJian,F_FaBuShiJian,F_Key,F_FaWenWenHao,F_FaWenDanWei,F_BiaoShiBianMa,F_ZhiNengBuMen,F_File,F_WenJianMingCheng,F_WenJianNeiRong,F_DianJiLiang,F_CreateUser,F_CreateTime,F_IsDelete,F_DeleteUser,F_DeleteTime from T_Wiki_Functions a with(nolock) where F_Id=" + id).Tables[0];
  466. dt.Columns.Add("fileurl");
  467. DataTable dtfile = new DataTable();
  468. string fileurl = "";
  469. string file = dt.Rows[0]["F_File"].ToString();
  470. if (!string.IsNullOrEmpty(file))
  471. {
  472. dtfile = DB.DbHelperSQL.Query("select * from T_Sys_Accessories WITH(NOLOCK) where F_FileId in (" + file + ")").Tables[0];
  473. foreach (DataRow dr in dtfile.Rows)
  474. {
  475. fileurl += dr["F_FileName"].ToString() + ",";
  476. }
  477. }
  478. if (!string.IsNullOrEmpty(fileurl))
  479. {
  480. fileurl = fileurl.Substring(0, fileurl.Length - 1);
  481. }
  482. dt.Rows[0]["fileurl"] = fileurl;
  483. string F_key = dt.Rows[0]["F_key"].ToString();
  484. var dt2 = DB.DbHelperSQL.Query("SELECT * FROM View_KeysSplit WHERE id=" + F_key).Tables[0];
  485. aw.Builder();
  486. aw.CreateDepartmentFunctionsWord(dt,dt2);
  487. var bt = aw.ExportAs();
  488. Response.AppendHeader("Access-Control-Expose-Headers", "Content-Disposition");
  489. return File(bt, "application/msword", DateTime.Now.Ticks.ToString() + ".doc");
  490. }
  491. //政策法规
  492. public ActionResult ExportPolicyWord(int id)
  493. {
  494. var aw = new AsposeWord();
  495. aw.OpenWithTemplate(Server.MapPath("/Upload/Word/政策法规模板.doc"));
  496. var dt = DB.DbHelperSQL.Query("select top 1 F_Id,F_FaBuDanWei,F_FaBuRen,F_HangYe,F_DiQu,F_ShengXiaoShiJian,F_ShiXiaoShiJian,F_FaBuShiJian,F_Key,F_FaWenWenHao,F_FaWenDanWei,F_BiaoShiBianMa,F_ZhiNengBuMen,F_File,F_WenJianMingCheng,F_WenJianNeiRong,F_DianJiLiang,F_CreateUser,F_CreateTime,F_IsDelete,F_DeleteUser,F_DeleteTime from T_Wiki_Policy a with(nolock) where F_Id=" + id).Tables[0];
  497. dt.Columns.Add("fileurl");
  498. DataTable dtfile = new DataTable();
  499. string fileurl = "";
  500. string file = dt.Rows[0]["F_File"].ToString();
  501. if (!string.IsNullOrEmpty(file))
  502. {
  503. dtfile = DB.DbHelperSQL.Query("select * from T_Sys_Accessories WITH(NOLOCK) where F_FileId in (" + file + ")").Tables[0];
  504. foreach (DataRow dr in dtfile.Rows)
  505. {
  506. fileurl += dr["F_FileName"].ToString() + ",";
  507. }
  508. }
  509. if (!string.IsNullOrEmpty(fileurl))
  510. {
  511. fileurl = fileurl.Substring(0, fileurl.Length - 1);
  512. }
  513. dt.Rows[0]["fileurl"] = fileurl;
  514. aw.Builder();
  515. string F_key = dt.Rows[0]["F_key"].ToString();
  516. var dt2 = DB.DbHelperSQL.Query("SELECT * FROM View_KeysSplit WHERE id=" + F_key).Tables[0];
  517. aw.CreateDepartmentFunctionsWord(dt,dt2);
  518. var bt = aw.ExportAs();
  519. Response.AppendHeader("Access-Control-Expose-Headers", "Content-Disposition");
  520. return File(bt, "application/msword", DateTime.Now.Ticks.ToString() + ".doc");
  521. }
  522. //热点问da
  523. public ActionResult ExportHotSpotWord(int id)
  524. {
  525. var aw = new AsposeWord();
  526. aw.OpenWithTemplate(Server.MapPath("/Upload/Word/热点问答模板.doc"));
  527. var dt = DB.DbHelperSQL.Query("select top 1 F_Id,F_FaBuDanWei,F_FaBuRen,F_HangYe,F_DiQu,F_ShengXiaoShiJian,F_ShiXiaoShiJian,F_FaBuShiJian,F_Key,F_FaWenWenHao,F_FaWenDanWei,F_BiaoShiBianMa,F_JieDaDanWei,F_ZhengCeMingCi,F_File,F_ReDianWenTi,F_WenTiJieDa,F_DianJiLiang,F_CreateUser,F_CreateTime,F_IsDelete,F_DeleteUser,F_DeleteTime from T_Wiki_HotspotGlossary a with(nolock) where F_Id=" + id).Tables[0];
  528. dt.Columns.Add("fileurl");
  529. DataTable dtfile = new DataTable();
  530. string fileurl = "";
  531. string file = dt.Rows[0]["F_File"].ToString();
  532. if (!string.IsNullOrEmpty(file))
  533. {
  534. dtfile = DB.DbHelperSQL.Query("select * from T_Sys_Accessories WITH(NOLOCK) where F_FileId in (" + file + ")").Tables[0];
  535. foreach (DataRow dr in dtfile.Rows)
  536. {
  537. fileurl += dr["F_FileName"].ToString() + ",";
  538. }
  539. }
  540. if (!string.IsNullOrEmpty(fileurl))
  541. {
  542. fileurl = fileurl.Substring(0, fileurl.Length - 1);
  543. }
  544. dt.Rows[0]["fileurl"] = fileurl;
  545. string F_key = dt.Rows[0]["F_key"].ToString();
  546. var dt2 = DB.DbHelperSQL.Query("SELECT * FROM View_KeysSplit WHERE id=" + F_key).Tables[0];
  547. aw.Builder();
  548. aw.CreateHotSpotWord(dt,dt2);
  549. var bt = aw.ExportAs();
  550. Response.AppendHeader("Access-Control-Expose-Headers", "Content-Disposition");
  551. return File(bt, "application/msword", DateTime.Now.Ticks.ToString() + ".doc");
  552. }
  553. //名词解释 T_Wiki_NounInterpretation
  554. public ActionResult ExportNounInterpretationWord(int id)
  555. {
  556. var aw = new AsposeWord();
  557. aw.OpenWithTemplate(Server.MapPath("/Upload/Word/名词解释模板.doc"));
  558. var dt = DB.DbHelperSQL.Query("select top 1 F_Id,F_FaBuDanWei,F_FaBuRen,F_HangYe,F_DiQu,F_ShengXiaoShiJian,F_ShiXiaoShiJian,F_FaBuShiJian,F_Key,F_FaWenWenHao,F_FaWenDanWei,F_BiaoShiBianMa,F_JieDaDanWei,F_ZhengCeMingCi,F_File,F_ReDianWenTi,F_WenTiJieDa,F_DianJiLiang,F_CreateUser,F_CreateTime,F_IsDelete,F_DeleteUser,F_DeleteTime from T_Wiki_NounInterpretation a with(nolock) where F_Id=" + id).Tables[0];
  559. dt.Columns.Add("fileurl");
  560. DataTable dtfile = new DataTable();
  561. string fileurl = "";
  562. string file = dt.Rows[0]["F_File"].ToString();
  563. if (!string.IsNullOrEmpty(file))
  564. {
  565. dtfile = DB.DbHelperSQL.Query("select * from T_Sys_Accessories WITH(NOLOCK) where F_FileId in (" + file + ")").Tables[0];
  566. foreach (DataRow dr in dtfile.Rows)
  567. {
  568. fileurl += dr["F_FileName"].ToString() + ",";
  569. }
  570. }
  571. if (!string.IsNullOrEmpty(fileurl))
  572. {
  573. fileurl = fileurl.Substring(0, fileurl.Length - 1);
  574. }
  575. dt.Rows[0]["fileurl"] = fileurl;
  576. string F_key = dt.Rows[0]["F_key"].ToString();
  577. var dt2 = DB.DbHelperSQL.Query("SELECT * FROM View_KeysSplit WHERE id=" + F_key).Tables[0];
  578. aw.Builder();
  579. aw.CreateHotSpotWord(dt,dt2);
  580. var bt = aw.ExportAs();
  581. Response.AppendHeader("Access-Control-Expose-Headers", "Content-Disposition");
  582. return File(bt, "application/msword", DateTime.Now.Ticks.ToString() + ".doc");
  583. }
  584. }
  585. public class cacheobj
  586. {
  587. public string key { get; set; }
  588. public string value { get; set; }
  589. }
  590. }