纽威
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.

626 lines
16 KiB

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