You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

660 lines
17 KiB

3 weeks ago
  1. using NFine.Application;
  2. using NFine.Application.SystemManage;
  3. using NFine.Code;
  4. using NFine.Domain.Entity.SystemManage;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. namespace NFine.Web.Areas.SystemManage.Controllers
  13. {
  14. public class CommonReportController : ControllerBase
  15. {
  16. private CommonReportApp App = new CommonReportApp();
  17. [HttpGet]
  18. [HandlerAjaxOnly]
  19. public ActionResult GetGridJson(Pagination pagination, string sqlTxt, string DBName, string TempName)
  20. {
  21. DataTable dt = new DataTable();
  22. try
  23. {
  24. dt = App.GetGridJson(sqlTxt, DBName, TempName, ref pagination);
  25. }
  26. catch (Exception ex)
  27. {
  28. dt = null;
  29. return Error(ex.ToString());
  30. }
  31. var data = new
  32. {
  33. rows = dt,
  34. total = pagination.total,
  35. page = pagination.page,
  36. records = pagination.records
  37. };
  38. return Content(data.ToJson());
  39. }
  40. [HttpGet]
  41. [HandlerAjaxOnly]
  42. public ActionResult GetGridJsonNew(Pagination pagination, string MenuID, string sqlTxt_Condition, string DBName, string TempName)
  43. {
  44. DataTable dt = new DataTable();
  45. try
  46. {
  47. dt = App.GetGridJsonNew(MenuID, sqlTxt_Condition, DBName, TempName, ref pagination);
  48. }
  49. catch (Exception ex)
  50. {
  51. dt = null;
  52. return Error(ex.ToString());
  53. }
  54. var data = new
  55. {
  56. rows = dt,
  57. total = pagination.total,
  58. page = pagination.page,
  59. records = pagination.records
  60. };
  61. return Content(data.ToJson());
  62. }
  63. //导出
  64. [HttpPost]
  65. public void ExportAll(string sqlTxt, string DBName, string TempName, string MenuID)
  66. {
  67. sqlTxt = HttpUtility.UrlDecode(sqlTxt);
  68. DataTable data = App.ExportAll(sqlTxt, DBName, TempName, MenuID);
  69. if (data != null && data.Rows.Count > 0)
  70. {
  71. AsposeCell.Export(data);
  72. }
  73. }
  74. //导出
  75. [HttpPost]
  76. public void ExportAllNew(string sqlTxt, string DBName, string TempName, string MenuID, string XCol)
  77. {
  78. try
  79. {
  80. sqlTxt = HttpUtility.UrlDecode(sqlTxt);
  81. DataTable data = App.ExportAllNew(sqlTxt, DBName, TempName, MenuID, XCol);
  82. if (data != null && data.Rows.Count > 0)
  83. {
  84. AsposeCell.Export(data);
  85. }
  86. }
  87. catch (Exception ex)
  88. {
  89. throw new Exception(ex.Message);
  90. }
  91. }
  92. //导出
  93. [HttpPost]
  94. public void ExportLocation(string sqlTxt, string DBName, string TempName, string MenuID, string XCol)
  95. {
  96. DataTable data = App.ExportLocation();
  97. if (data != null && data.Rows.Count > 0)
  98. {
  99. AsposeCell.Export(data);
  100. }
  101. }
  102. //获取数据源DB
  103. [HttpGet]
  104. public ActionResult GetAllDataBase()
  105. {
  106. try
  107. {
  108. DataTable data = App.GetAllDataBase();
  109. return Content(data.ToJson());
  110. }
  111. catch (Exception ex)
  112. {
  113. return Error(ex.ToString());
  114. }
  115. }
  116. //获取菜单Name
  117. [HttpGet]
  118. public ActionResult GetMenuID(string MenuTag)
  119. {
  120. try
  121. {
  122. DataTable data = App.GetMenuID(MenuTag);
  123. return Content(data.ToJson());
  124. }
  125. catch (Exception ex)
  126. {
  127. return Content(ex.ToString());
  128. }
  129. }
  130. //获取数据源DB
  131. [HttpGet]
  132. public ActionResult GetMenu(string MenuID)
  133. {
  134. try
  135. {
  136. DataTable Menu = App.GetMenuSQL(MenuID);
  137. if (Menu != null && Menu.Rows.Count > 0)
  138. {
  139. string MenuCols = App.GetMenuColsNew(Menu.Rows[0]["SourceID"].ToString());
  140. DataTable formatcols = App.Getformatcols(Menu.Rows[0]["SourceID"].ToString());
  141. string UnVisiblecols = App.UnVisiblecols(Menu.Rows[0]["SourceID"].ToString());
  142. String[] Mergercols = { };
  143. if (!string.IsNullOrEmpty(Menu.Rows[0]["Mergercols"].ToString()))
  144. {
  145. Mergercols = Menu.Rows[0]["Mergercols"].ToString().Split(',').ToArray();
  146. }
  147. String[] footercols = { };
  148. if (!string.IsNullOrEmpty(Menu.Rows[0]["footercols"].ToString()))
  149. {
  150. footercols = Menu.Rows[0]["footercols"].ToString().Split(',').ToArray();
  151. }
  152. var data = new
  153. {
  154. sqlTxt = Menu.Rows[0]["sqlTxt"].ToString(),
  155. MenuID = Menu.Rows[0]["MenuID"].ToString(),
  156. Cols = MenuCols,
  157. HiddenCols = UnVisiblecols,
  158. ReportName = Menu.Rows[0]["ReportName"].ToString(),
  159. Mergercols = Mergercols,
  160. XCol = Menu.Rows[0]["XCol"].ToString(),
  161. footercols = footercols,
  162. TempName = Menu.Rows[0]["TempName"].ToString(),
  163. formatcols = formatcols,
  164. footerrow = Menu.Rows[0]["footerrow"].ToString().ToBool(),
  165. IsExistsDataSource = Menu.Rows[0]["IsExistsDataSource"].ToString(),
  166. DBName = Menu.Rows[0]["DBName"].ToString(),
  167. SourceID = Menu.Rows[0]["SourceID"].ToString(),
  168. };
  169. return Content(data.ToJson());
  170. }
  171. else
  172. {
  173. return Content("无菜单数据");
  174. }
  175. }
  176. catch (Exception ex)
  177. {
  178. return Content(ex.ToString());
  179. }
  180. }
  181. //获取栏位的栏位筛选信息
  182. [HttpGet]
  183. public ActionResult GetColsSelectGrid(string SourceID, string ColsName, string InputKey)
  184. {
  185. try
  186. {
  187. DataTable dt = App.GetColsSelectData(SourceID, ColsName, InputKey);
  188. if (dt != null && dt.Rows.Count > 0)
  189. {
  190. string Cols = App.GetColsSelectCols(dt);
  191. var data = new
  192. {
  193. cols = Cols,
  194. gridData = dt,
  195. };
  196. return Content(data.ToJson());
  197. }
  198. else
  199. {
  200. return Content("无菜单数据");
  201. }
  202. }
  203. catch (Exception ex)
  204. {
  205. return Content(ex.ToString());
  206. }
  207. }
  208. //获取数据源sql等数据
  209. [HttpGet]
  210. public ActionResult GetMenuSQL(string MenuID)
  211. {
  212. try
  213. {
  214. DataTable data = App.GetMenuSQL(MenuID);
  215. return Content(data.ToJson());
  216. }
  217. catch (Exception ex)
  218. {
  219. return Error(ex.ToString());
  220. }
  221. }
  222. //提交数据源信息
  223. [HttpPost]
  224. public ActionResult SetDataSource(string SysDataSourceFlag, string FormatSql, string DbId, string MenuID, string DbParameters, string SourceID, string TempName, string XCol)
  225. {
  226. try
  227. {
  228. App.SetDataSource(SysDataSourceFlag, FormatSql, DbId, MenuID, DbParameters, SourceID, TempName, XCol);
  229. return Content("操作成功");
  230. }
  231. catch (Exception ex)
  232. {
  233. return Content(ex.ToString());
  234. }
  235. }
  236. [HttpPost]
  237. public ActionResult SetDataSourceText(string SysDataSourceFlag, string FormatSql, string DbId, string DbParameters, string TempName, string XCol)
  238. {
  239. try
  240. {
  241. App.SetDataSourceText(SysDataSourceFlag, FormatSql, DbId, DbParameters, TempName, XCol);
  242. return Content("OK");
  243. }
  244. catch (Exception ex)
  245. {
  246. return Content(ex.ToString());
  247. }
  248. }
  249. //获取过滤数据
  250. [HttpGet]
  251. [HandlerAjaxOnly]
  252. public ActionResult GetFilter(Pagination pagination, string SourceID)
  253. {
  254. DataTable data = App.GetFilter(SourceID);
  255. var JsonData = new
  256. {
  257. total = pagination.total,
  258. page = pagination.page,
  259. records = pagination.records,
  260. rows = data
  261. };
  262. return Content(JsonData.ToJson());
  263. }
  264. //获取过滤条件详情
  265. [HttpGet]
  266. [HandlerAjaxOnly]
  267. public ActionResult GetCondition(Pagination pagination, string SourceID)
  268. {
  269. DataTable data = App.GetCondition(SourceID);
  270. var JsonData = new
  271. {
  272. total = pagination.total,
  273. page = pagination.page,
  274. records = pagination.records,
  275. rows = data
  276. };
  277. return Content(JsonData.ToJson());
  278. }
  279. //设置过滤条件
  280. [HttpPost]
  281. [HandlerAjaxOnly]
  282. public ActionResult SetCondition(string SourceID, string List_Condition)
  283. {
  284. try
  285. {
  286. App.SetCondition(SourceID, List_Condition);
  287. return Content("操作成功。");
  288. }
  289. catch (Exception ex)
  290. {
  291. return Content(ex.ToString());
  292. }
  293. }
  294. //记录账号的过滤条件
  295. [HttpPost]
  296. [HandlerAjaxOnly]
  297. public ActionResult SetDefaultRecord(string SourceID, string List_Record)
  298. {
  299. try
  300. {
  301. App.SetDefaultRecord(SourceID, List_Record);
  302. return Content("操作成功。");
  303. }
  304. catch (Exception ex)
  305. {
  306. return Content(ex.ToString());
  307. }
  308. }
  309. //获取列设置信息
  310. [HttpGet]
  311. [HandlerAjaxOnly]
  312. public ActionResult GetCols(Pagination pagination, string SourceID)
  313. {
  314. DataTable data = App.GetCols(SourceID);
  315. var JsonData = new
  316. {
  317. total = pagination.total,
  318. page = pagination.page,
  319. records = pagination.records,
  320. rows = data
  321. };
  322. return Content(JsonData.ToJson());
  323. }
  324. //获取个性化信息
  325. [HttpGet]
  326. [HandlerAjaxOnly]
  327. public ActionResult GetGridFormat(Pagination pagination, string ColId)
  328. {
  329. DataTable data = App.GetGridFormat(ColId);
  330. var JsonData = new
  331. {
  332. total = pagination.total,
  333. page = pagination.page,
  334. records = pagination.records,
  335. rows = data
  336. };
  337. return Content(JsonData.ToJson());
  338. }
  339. //保存个性化设置
  340. [HttpPost]
  341. [HandlerAjaxOnly]
  342. public ActionResult SetGridFormat(string ColId, string List_GridFormat)
  343. {
  344. try
  345. {
  346. App.SetGridFormat(ColId, List_GridFormat);
  347. return Content("保存成功。");
  348. }
  349. catch (Exception ex)
  350. {
  351. return Content(ex.ToString());
  352. }
  353. }
  354. [HttpPost]
  355. [HandlerAjaxOnly]
  356. public ActionResult ClearAll(string MenuID)
  357. {
  358. try
  359. {
  360. App.ClearAll(MenuID);
  361. return Content("清空成功");
  362. }
  363. catch (Exception ex)
  364. {
  365. return Content(ex.ToString());
  366. }
  367. }
  368. //重置列
  369. [HttpPost]
  370. [HandlerAjaxOnly]
  371. public ActionResult ReSetCols(string MenuID)
  372. {
  373. try
  374. {
  375. App.ReSetCols(MenuID);
  376. return Content("操作成功。");
  377. }
  378. catch (Exception ex)
  379. {
  380. return Content(ex.ToString());
  381. }
  382. }
  383. //保存列设置
  384. [HttpPost]
  385. [HandlerAjaxOnly]
  386. public ActionResult SetCols(string SourceID, string List_Cols)
  387. {
  388. try
  389. {
  390. App.SetCols(SourceID, List_Cols);
  391. return Content("操作成功。");
  392. }
  393. catch (Exception ex)
  394. {
  395. return Content(ex.ToString());
  396. }
  397. }
  398. [HttpGet]
  399. public ActionResult GetColsVisible(Pagination pagination, string MenuID, string Roles, string Cols)
  400. {
  401. try
  402. {
  403. DataTable dt = App.GetColsVisible(MenuID, Roles, Cols, ref pagination);
  404. var data = new
  405. {
  406. rows = dt,
  407. total = pagination.total,
  408. page = pagination.page,
  409. records = pagination.records
  410. };
  411. return Content(data.ToJson());
  412. }
  413. catch (Exception ex)
  414. {
  415. return Error(ex.ToString());
  416. }
  417. }
  418. [HttpGet]
  419. public ActionResult GetRoles()
  420. {
  421. try
  422. {
  423. DataTable data = App.GetRoles();
  424. return Content(data.ToJson());
  425. }
  426. catch (Exception ex)
  427. {
  428. return Error(ex.ToString());
  429. }
  430. }
  431. [HttpGet]
  432. public ActionResult GetColsFiledName(string MenuID)
  433. {
  434. try
  435. {
  436. DataTable data = App.GetColsFiledName(MenuID);
  437. return Content(data.ToJson());
  438. }
  439. catch (Exception ex)
  440. {
  441. return Error(ex.ToString());
  442. }
  443. }
  444. [HttpPost]
  445. [HandlerAjaxOnly]
  446. public ActionResult SetColsVisibleALL(string Cols, string IsCommon, string MenuID)
  447. {
  448. try
  449. {
  450. App.SetColsVisibleALL(Cols, IsCommon, MenuID);
  451. return Content("操作成功。");
  452. }
  453. catch (Exception ex)
  454. {
  455. return Content(ex.ToString());
  456. }
  457. }
  458. [HttpPost]
  459. [HandlerAjaxOnly]
  460. public ActionResult SetColsVisibleAdd(string Cols, string Roles, string MenuID)
  461. {
  462. try
  463. {
  464. App.SetColsVisibleAdd(Cols, Roles, MenuID);
  465. return Content("操作成功。");
  466. }
  467. catch (Exception ex)
  468. {
  469. return Content(ex.ToString());
  470. }
  471. }
  472. [HttpPost]
  473. [HandlerAjaxOnly]
  474. public ActionResult SetColsVisibleDel(string MenuID, string IDList)
  475. {
  476. try
  477. {
  478. App.SetColsVisibleDel(MenuID, IDList);
  479. return Content("操作成功。");
  480. }
  481. catch (Exception ex)
  482. {
  483. return Content(ex.ToString());
  484. }
  485. }
  486. [HttpGet]
  487. public ActionResult GetHiddenCols(string MenuID, string Cols)
  488. {
  489. try
  490. {
  491. DataTable data = App.GetHiddenCols(MenuID, Cols);
  492. return Content(data.ToJson());
  493. }
  494. catch (Exception ex)
  495. {
  496. return Error(ex.ToString());
  497. }
  498. }
  499. [HttpGet]
  500. public ActionResult Filter()
  501. {
  502. return View();
  503. }
  504. [HttpGet]
  505. public ActionResult DataSource()
  506. {
  507. return View();
  508. }
  509. [HttpGet]
  510. public ActionResult Cols()
  511. {
  512. return View();
  513. }
  514. [HttpGet]
  515. public ActionResult Condition()
  516. {
  517. return View();
  518. }
  519. [HttpGet]
  520. public ActionResult ColsSelect()
  521. {
  522. return View();
  523. }
  524. [HttpGet]
  525. public ActionResult GridHeader()
  526. {
  527. return View();
  528. }
  529. [HttpGet]
  530. public ActionResult GridFormat()
  531. {
  532. return View();
  533. }
  534. [HttpGet]
  535. public ActionResult WatchPanel()
  536. {
  537. return View();
  538. }
  539. [HttpGet]
  540. public ActionResult ColsVisible()
  541. {
  542. return View();
  543. }
  544. [HttpGet]
  545. [HandlerAjaxOnly]
  546. public ActionResult GetFilePath()
  547. {
  548. string _FilePath = App.GetFilePath();
  549. var JsonData = new
  550. {
  551. FilePath = _FilePath
  552. };
  553. return Content(JsonData.ToJson());
  554. }
  555. }
  556. }