using EasyBL; using Entity.Sugar; using SqlSugar.Base; using System; using System.Collections.Generic; using System.Web.Script.Services; using System.Web.Services; namespace WebApp.WS { /// ///WebService 的摘要描述 /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // 若要允許使用 ASP.NET AJAX 從指令碼呼叫此 Web 服務,請取消註解下列一行。 [ScriptService] public class WebService : System.Web.Services.WebService { public WebService() { //如果使用設計的元件,請取消註解下列一行 //InitializeComponent(); } #region QueryList /// /// 資料查詢List /// [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string GetOrgs() { string sMsg = null; Dictionary dicResult = new Dictionary { { "RESULT", 0 }, { "DATA" , null }, { "MSG", string.Empty } }; try { do { var db = SugarBase.DB; var saOrgs = db.Queryable().Where(x => x.Effective == "Y").OrderBy(x => x.CreateDate) .Select(x => new { x.OrgID, x.OrgName }).ToList(); dicResult["RESULT"] = 1; dicResult["DATA"] = saOrgs; } while (false); } catch (Exception ex) { LogService.MailSend(ex.Message, ex, "", "", nameof(WebService), "", nameof(GetOrgs), "", "", ""); sMsg = ex.Message; } if (sMsg != null) { dicResult["MSG"] = $"查詢資料異常,請聯繫IT人員 ,ERROR MSG:{ sMsg }"; } return ServiceBase.JsonToString(dicResult); } #endregion QueryList } }