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.

638 lines
17 KiB

  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. FormatSql = HttpUtility.UrlDecode(FormatSql);
  212. App.SetDataSource(SysDataSourceFlag, FormatSql, DbId, MenuID, DbParameters, SourceID, TempName, XCol);
  213. return Content("操作成功");
  214. }
  215. catch (Exception ex)
  216. {
  217. return Content(ex.ToString());
  218. }
  219. }
  220. [HttpPost]
  221. public ActionResult SetDataSourceText(string SysDataSourceFlag, string FormatSql, string DbId, string DbParameters, string TempName, string XCol)
  222. {
  223. try
  224. {
  225. FormatSql = HttpUtility.UrlDecode(FormatSql);
  226. App.SetDataSourceText(SysDataSourceFlag, FormatSql, DbId, DbParameters, TempName, XCol);
  227. return Content("OK");
  228. }
  229. catch (Exception ex)
  230. {
  231. return Content(ex.ToString());
  232. }
  233. }
  234. //获取过滤数据
  235. [HttpGet]
  236. [HandlerAjaxOnly]
  237. public ActionResult GetFilter(Pagination pagination, string SourceID)
  238. {
  239. DataTable data = App.GetFilter(SourceID);
  240. var JsonData = new
  241. {
  242. total = pagination.total,
  243. page = pagination.page,
  244. records = pagination.records,
  245. rows = data
  246. };
  247. return Content(JsonData.ToJson());
  248. }
  249. //获取过滤条件详情
  250. [HttpGet]
  251. [HandlerAjaxOnly]
  252. public ActionResult GetCondition(Pagination pagination, string SourceID)
  253. {
  254. DataTable data = App.GetCondition(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. [HttpPost]
  266. [HandlerAjaxOnly]
  267. public ActionResult SetCondition(string SourceID, string List_Condition)
  268. {
  269. try
  270. {
  271. App.SetCondition(SourceID, List_Condition);
  272. return Content("操作成功。");
  273. }
  274. catch (Exception ex)
  275. {
  276. return Content(ex.ToString());
  277. }
  278. }
  279. //记录账号的过滤条件
  280. [HttpPost]
  281. [HandlerAjaxOnly]
  282. public ActionResult SetDefaultRecord(string SourceID, string List_Record)
  283. {
  284. try
  285. {
  286. App.SetDefaultRecord(SourceID, List_Record);
  287. return Content("操作成功。");
  288. }
  289. catch (Exception ex)
  290. {
  291. return Content(ex.ToString());
  292. }
  293. }
  294. //获取列设置信息
  295. [HttpGet]
  296. [HandlerAjaxOnly]
  297. public ActionResult GetCols(Pagination pagination, string SourceID)
  298. {
  299. DataTable data = App.GetCols(SourceID);
  300. var JsonData = new
  301. {
  302. total = pagination.total,
  303. page = pagination.page,
  304. records = pagination.records,
  305. rows = data
  306. };
  307. return Content(JsonData.ToJson());
  308. }
  309. //获取个性化信息
  310. [HttpGet]
  311. [HandlerAjaxOnly]
  312. public ActionResult GetGridFormat(Pagination pagination, string ColId)
  313. {
  314. DataTable data = App.GetGridFormat(ColId);
  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. [HttpPost]
  326. [HandlerAjaxOnly]
  327. public ActionResult SetGridFormat(string ColId, string List_GridFormat)
  328. {
  329. try
  330. {
  331. App.SetGridFormat(ColId, List_GridFormat);
  332. return Content("保存成功。");
  333. }
  334. catch (Exception ex)
  335. {
  336. return Content(ex.ToString());
  337. }
  338. }
  339. [HttpPost]
  340. [HandlerAjaxOnly]
  341. public ActionResult ClearAll(string MenuID)
  342. {
  343. try
  344. {
  345. App.ClearAll(MenuID);
  346. return Content("清空成功");
  347. }
  348. catch (Exception ex)
  349. {
  350. return Content(ex.ToString());
  351. }
  352. }
  353. //重置列
  354. [HttpPost]
  355. [HandlerAjaxOnly]
  356. public ActionResult ReSetCols(string MenuID)
  357. {
  358. try
  359. {
  360. App.ReSetCols(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 SetCols(string SourceID, string List_Cols)
  372. {
  373. try
  374. {
  375. App.SetCols(SourceID, List_Cols);
  376. return Content("操作成功。");
  377. }
  378. catch (Exception ex)
  379. {
  380. return Content(ex.ToString());
  381. }
  382. }
  383. [HttpGet]
  384. public ActionResult GetColsVisible(Pagination pagination, string MenuID, string Roles, string Cols)
  385. {
  386. try
  387. {
  388. DataTable dt = App.GetColsVisible(MenuID, Roles, Cols, ref pagination);
  389. var data = new
  390. {
  391. rows = dt,
  392. total = pagination.total,
  393. page = pagination.page,
  394. records = pagination.records
  395. };
  396. return Content(data.ToJson());
  397. }
  398. catch (Exception ex)
  399. {
  400. return Error(ex.ToString());
  401. }
  402. }
  403. [HttpGet]
  404. public ActionResult GetRoles()
  405. {
  406. try
  407. {
  408. DataTable data = App.GetRoles();
  409. return Content(data.ToJson());
  410. }
  411. catch (Exception ex)
  412. {
  413. return Error(ex.ToString());
  414. }
  415. }
  416. [HttpGet]
  417. public ActionResult GetColsFiledName(string MenuID)
  418. {
  419. try
  420. {
  421. DataTable data = App.GetColsFiledName(MenuID);
  422. return Content(data.ToJson());
  423. }
  424. catch (Exception ex)
  425. {
  426. return Error(ex.ToString());
  427. }
  428. }
  429. [HttpPost]
  430. [HandlerAjaxOnly]
  431. public ActionResult SetColsVisibleALL(string Cols, string IsCommon, string MenuID)
  432. {
  433. try
  434. {
  435. App.SetColsVisibleALL(Cols, IsCommon, MenuID);
  436. return Content("操作成功。");
  437. }
  438. catch (Exception ex)
  439. {
  440. return Content(ex.ToString());
  441. }
  442. }
  443. [HttpPost]
  444. [HandlerAjaxOnly]
  445. public ActionResult SetColsVisibleAdd(string Cols, string Roles, string MenuID)
  446. {
  447. try
  448. {
  449. App.SetColsVisibleAdd(Cols, Roles, MenuID);
  450. return Content("操作成功。");
  451. }
  452. catch (Exception ex)
  453. {
  454. return Content(ex.ToString());
  455. }
  456. }
  457. [HttpPost]
  458. [HandlerAjaxOnly]
  459. public ActionResult SetColsVisibleDel(string MenuID, string IDList)
  460. {
  461. try
  462. {
  463. App.SetColsVisibleDel(MenuID, IDList);
  464. return Content("操作成功。");
  465. }
  466. catch (Exception ex)
  467. {
  468. return Content(ex.ToString());
  469. }
  470. }
  471. [HttpGet]
  472. public ActionResult GetHiddenCols(string MenuID, string Cols)
  473. {
  474. try
  475. {
  476. DataTable data = App.GetHiddenCols(MenuID, Cols);
  477. return Content(data.ToJson());
  478. }
  479. catch (Exception ex)
  480. {
  481. return Error(ex.ToString());
  482. }
  483. }
  484. [HttpGet]
  485. public ActionResult Filter()
  486. {
  487. return View();
  488. }
  489. [HttpGet]
  490. public ActionResult DataSource()
  491. {
  492. return View();
  493. }
  494. [HttpGet]
  495. public ActionResult Cols()
  496. {
  497. return View();
  498. }
  499. [HttpGet]
  500. public ActionResult Condition()
  501. {
  502. return View();
  503. }
  504. [HttpGet]
  505. public ActionResult ColsSelect()
  506. {
  507. return View();
  508. }
  509. [HttpGet]
  510. public ActionResult GridHeader()
  511. {
  512. return View();
  513. }
  514. [HttpGet]
  515. public ActionResult GridFormat()
  516. {
  517. return View();
  518. }
  519. [HttpGet]
  520. public ActionResult WatchPanel()
  521. {
  522. return View();
  523. }
  524. [HttpGet]
  525. public ActionResult ColsVisible()
  526. {
  527. return View();
  528. }
  529. public ActionResult WatchPanel2()
  530. {
  531. return View();
  532. }
  533. public ActionResult WatchPanelSet()
  534. {
  535. return View();
  536. }
  537. public ActionResult WatchPanelWhite()
  538. {
  539. return View();
  540. }
  541. }
  542. }