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.

72 lines
2.1 KiB

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. try
  41. {
  42. do
  43. {
  44. var db = SugarBase.DB;
  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. LogService.MailSend(ex.Message, ex, "", "", nameof(WebService), "", nameof(GetOrgs), "", "", "");
  54. sMsg = ex.Message;
  55. }
  56. if (sMsg != null)
  57. {
  58. dicResult["MSG"] = $"查詢資料異常,請聯繫IT人員 ,ERROR MSG:{ sMsg }";
  59. }
  60. return ServiceBase.JsonToString(dicResult);
  61. }
  62. #endregion QueryList
  63. }
  64. }