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.

78 lines
2.3 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. using EasyBL;
  2. using Entity.Sugar;
  3. using SqlSugar.Base;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Web.Script.Services;
  7. using System.Web.Services;
  8. namespace WebApp.WS
  9. {
  10. /// <summary>
  11. ///WebService 的摘要描述
  12. /// </summary>
  13. [WebService(Namespace = "http://tempuri.org/")]
  14. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  15. [System.ComponentModel.ToolboxItem(false)]
  16. // 若要允許使用 ASP.NET AJAX 從指令碼呼叫此 Web 服務,請取消註解下列一行。
  17. [ScriptService]
  18. public class WebService : System.Web.Services.WebService
  19. {
  20. public WebService()
  21. {
  22. //如果使用設計的元件,請取消註解下列一行
  23. //InitializeComponent();
  24. }
  25. #region QueryList
  26. /// <summary>
  27. /// 資料查詢List
  28. /// </summary>
  29. [WebMethod]
  30. [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  31. public string GetOrgs()
  32. {
  33. string sMsg = null;
  34. Dictionary<string, object> dicResult = new Dictionary<string, object>
  35. {
  36. { "RESULT", 0 },
  37. { "DATA" , null },
  38. { "MSG", string.Empty }
  39. };
  40. var db = SugarBase.DB;
  41. try
  42. {
  43. do
  44. {
  45. var saOrgs = db.Queryable<OTB_SYS_Organization>().Where(x => x.Effective == "Y").OrderBy(x => x.CreateDate)
  46. .Select(x => new { x.OrgID, x.OrgName }).ToList();
  47. dicResult["RESULT"] = 1;
  48. dicResult["DATA"] = saOrgs;
  49. } while (false);
  50. }
  51. catch (Exception ex)
  52. {
  53. db.Dispose();
  54. LogService.MailSend(ex.Message, ex, "TG", "", nameof(WebService), "", nameof(GetOrgs), "", "", "");
  55. sMsg = ex.Message;
  56. }
  57. finally
  58. {
  59. //釋放掉資源
  60. db.Dispose();
  61. }
  62. if (sMsg != null)
  63. {
  64. dicResult["MSG"] = $"查詢資料異常,請聯繫IT人員 ,ERROR MSG:{ sMsg }";
  65. }
  66. return ServiceBase.JsonToString(dicResult);
  67. }
  68. #endregion QueryList
  69. }
  70. }