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.
 
 
 
 
 

79 lines
2.3 KiB

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
{
/// <summary>
///WebService 的摘要描述
/// </summary>
[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
/// <summary>
/// 資料查詢List
/// </summary>
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetOrgs()
{
string sMsg = null;
Dictionary<string, object> dicResult = new Dictionary<string, object>
{
{ "RESULT", 0 },
{ "DATA" , null },
{ "MSG", string.Empty }
};
var db = SugarBase.DB;
try
{
do
{
var saOrgs = db.Queryable<OTB_SYS_Organization>().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)
{
db.Dispose();
LogService.MailSend(ex.Message, ex, "TG", "", nameof(WebService), "", nameof(GetOrgs), "", "", "");
sMsg = ex.Message;
}
finally
{
//釋放掉資源
db.Dispose();
}
if (sMsg != null)
{
dicResult["MSG"] = $"查詢資料異常,請聯繫IT人員 ,ERROR MSG:{ sMsg }";
}
return ServiceBase.JsonToString(dicResult);
}
#endregion QueryList
}
}