修改API 输出格式
This commit is contained in:
@@ -19,7 +19,7 @@ namespace NX.ERP.Model.Purchase
|
|||||||
public int Id { get => id; set => id = value; }
|
public int Id { get => id; set => id = value; }
|
||||||
public string ArrivalCode { get => arrivalCode; set => arrivalCode = value; }
|
public string ArrivalCode { get => arrivalCode; set => arrivalCode = value; }
|
||||||
public DateTime Date { get => _date; set => _date = value; }
|
public DateTime Date { get => _date; set => _date = value; }
|
||||||
public ICollection<ArrivalDetail> ArrivalDetails { get => arrivalDetails; set => arrivalDetails = value; }
|
public ICollection<ArrivalDetail> Details { get => arrivalDetails; set => arrivalDetails = value; }
|
||||||
public string SupplierCode { get => supplierCode; set => supplierCode = value; }
|
public string SupplierCode { get => supplierCode; set => supplierCode = value; }
|
||||||
public double ExchRate { get; set; }
|
public double ExchRate { get; set; }
|
||||||
public string ExchName { get; set; }
|
public string ExchName { get; set; }
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<appSettings>
|
<appSettings>
|
||||||
<!--修改账套请修改这里的配置-->
|
<!--修改账套请修改这里的配置-->
|
||||||
<add key="url" value="http://192.168.0.242/U8EAI/import.asp"/>
|
<add key="url" value="http://192.168.0.242/U8EAI/import.asp"/>
|
||||||
<add key="connStr" value="Server=192.168.0.242 ;DataBase=UFDATA_003_2019;Uid=sa;Pwd=!@#qwe123;"/>
|
<!--<add key="connStr" value="Server=192.168.0.242 ;DataBase=UFDATA_003_2019;Uid=sa;Pwd=!@#qwe123;"/>-->
|
||||||
<add key="ClientSettingsProvider.ServiceUri" value=""/>
|
<add key="ClientSettingsProvider.ServiceUri" value=""/>
|
||||||
</appSettings>
|
</appSettings>
|
||||||
<runtime>
|
<runtime>
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace U8AppMain
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string url = ConfigurationManager.AppSettings.Get("url");
|
private string url = ConfigurationManager.AppSettings.Get("url");
|
||||||
private string connStr = ConfigurationManager.AppSettings.Get("connStr");
|
// private string connStr = ConfigurationManager.AppSettings.Get("connStr");
|
||||||
private DataTable dataTable;
|
private DataTable dataTable;
|
||||||
|
|
||||||
|
|
||||||
@@ -288,8 +288,8 @@ namespace U8AppMain
|
|||||||
|
|
||||||
private void 登录ToolStripMenuItem_Click(object sender, EventArgs e)
|
private void 登录ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//u8LoginContext = new NX.ERP.U8.U8LoginContext();
|
//u8LoginContext = new NX.ERP.U8.U8LoginContext();
|
||||||
//u8LoginContext.Login(true);
|
//u8LoginContext.Login(true);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace NX.ERP.U8.Purchase
|
|||||||
arrival = _arrival;
|
arrival = _arrival;
|
||||||
}
|
}
|
||||||
|
|
||||||
arrival.ArrivalDetails.Add(ArrivalDetail);
|
arrival.Details.Add(ArrivalDetail);
|
||||||
return arrival;
|
return arrival;
|
||||||
}, param, null, true, "id", 10, System.Data.CommandType.Text);
|
}, param, null, true, "id", 10, System.Data.CommandType.Text);
|
||||||
return lookup.Values;
|
return lookup.Values;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace NX.ERP.U8.Store
|
|||||||
for (var n = 0; n < puStoreIn.Details.Count; n++)
|
for (var n = 0; n < puStoreIn.Details.Count; n++)
|
||||||
{
|
{
|
||||||
var detail = puStoreIn.Details[n];
|
var detail = puStoreIn.Details[n];
|
||||||
var arrivalDetail = Arrival.ArrivalDetails.First(m => { return m.Id == detail.SorceDetailId; });
|
var arrivalDetail = Arrival.Details.First(m => { return m.Id == detail.SorceDetailId; });
|
||||||
headXml.setAttribute("cordercode", arrivalDetail.OrderCode);
|
headXml.setAttribute("cordercode", arrivalDetail.OrderCode);
|
||||||
// headXml.setAttribute("ipurorderid", arrivalDetail.PoId);
|
// headXml.setAttribute("ipurorderid", arrivalDetail.PoId);
|
||||||
bodyXml = domBody.createElement("z:row");
|
bodyXml = domBody.createElement("z:row");
|
||||||
|
|||||||
@@ -78,18 +78,52 @@ namespace NX.ERP.U8
|
|||||||
{
|
{
|
||||||
if (uiLogin != null)
|
if (uiLogin != null)
|
||||||
{
|
{
|
||||||
uiLogin.SubLogout(AccID);
|
uiLogin.SubLogout(this._accid);
|
||||||
uiLogin.ShutDown();
|
uiLogin.ShutDown();
|
||||||
uiLogin = null;
|
uiLogin = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public string UserId { get; set; } = "003";
|
|
||||||
|
|
||||||
public string PassWord { get; set; } = "123456";
|
private string _userId = "";
|
||||||
|
|
||||||
public string Server { get; set; } = "192.168.0.250";
|
|
||||||
|
|
||||||
public string AccID { get; set; } = "(default)@001";
|
public string UserId
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._userId = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private string _password = "";
|
||||||
|
|
||||||
|
public string PassWord
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._password = value;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private string _server;
|
||||||
|
|
||||||
|
public string Server
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._server = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _accid;
|
||||||
|
public string AccID
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._accid = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string Serial { get; set; }
|
public string Serial { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -140,10 +174,24 @@ namespace NX.ERP.U8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool NeedUiLogin
|
||||||
public void Login(bool showlogin = false)
|
|
||||||
{
|
{
|
||||||
if (showlogin)
|
get
|
||||||
|
{
|
||||||
|
|
||||||
|
return string.IsNullOrEmpty(this._userId) ||
|
||||||
|
string.IsNullOrEmpty(this._password) ||
|
||||||
|
string.IsNullOrEmpty(this._server) ||
|
||||||
|
string.IsNullOrEmpty(this._accid);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Login()
|
||||||
|
{
|
||||||
|
if (NeedUiLogin)
|
||||||
{
|
{
|
||||||
if (!UiLogin.login("DP"))
|
if (!UiLogin.login("DP"))
|
||||||
{
|
{
|
||||||
@@ -152,8 +200,7 @@ namespace NX.ERP.U8
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (!UiLogin.login("DP", this._userId, this._password, this._server, DateTime.Today.ToString("yyyy-MM-dd"), this._accid, Serial))
|
||||||
if (!UiLogin.login("DP", "wx999", "!@#qwe123", "192.168.0.168", DateTime.Today.ToString("yyyy-MM-dd"), AccID, Serial))
|
|
||||||
{
|
{
|
||||||
throw new Exception(UiLogin.ErrDescript);
|
throw new Exception(UiLogin.ErrDescript);
|
||||||
}
|
}
|
||||||
@@ -175,9 +222,9 @@ namespace NX.ERP.U8
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ namespace NX.ERP.WebAPi
|
|||||||
// those comments into the generated docs and UI. You can enable this by providing the path to one or
|
// those comments into the generated docs and UI. You can enable this by providing the path to one or
|
||||||
// more Xml comment files.
|
// more Xml comment files.
|
||||||
//
|
//
|
||||||
c.IncludeXmlComments(string.Format("{0}/bin/NX.ERP.WebAPi.xml", System.AppDomain.CurrentDomain.BaseDirectory));
|
// c.IncludeXmlComments(string.Format("{0}/bin/NX.ERP.WebAPi.xml", System.AppDomain.CurrentDomain.BaseDirectory));
|
||||||
|
|
||||||
// Swashbuckle makes a best attempt at generating Swagger compliant JSON schemas for the various types
|
// Swashbuckle makes a best attempt at generating Swagger compliant JSON schemas for the various types
|
||||||
// exposed in your API. However, there may be occasions when more control of the output is needed.
|
// exposed in your API. However, there may be occasions when more control of the output is needed.
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace NX.ERP.WebAPi
|
|||||||
|
|
||||||
actionExecutedContext.Response.Content = new System.Net.Http.ObjectContent(typeof(ResultModel<string>),
|
actionExecutedContext.Response.Content = new System.Net.Http.ObjectContent(typeof(ResultModel<string>),
|
||||||
new ResultModel<string> { ErrCode = 500, ErrMsg = ex.Message, Data = null },
|
new ResultModel<string> { ErrCode = 500, ErrMsg = ex.Message, Data = null },
|
||||||
new JsonMediaTypeFormatter());
|
GlobalConfiguration.Configuration.Formatters.JsonFormatter);
|
||||||
|
|
||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
}
|
}
|
||||||
@@ -47,11 +47,11 @@ namespace NX.ERP.WebAPi
|
|||||||
result.Data = actionExecutedContext.ActionContext.Response.Content.ReadAsAsync<object>().Result;
|
result.Data = actionExecutedContext.ActionContext.Response.Content.ReadAsAsync<object>().Result;
|
||||||
|
|
||||||
//请求是否成功
|
//请求是否成功
|
||||||
// result.IsSuccess = actionExecutedContext.ActionContext.Response.IsSuccessStatusCode;
|
//result.IsSuccess = actionExecutedContext.ActionContext.Response.IsSuccessStatusCode;
|
||||||
//结果转为自定义消息格式
|
//结果转为自定义消息格式
|
||||||
HttpResponseMessage httpResponseMessage = new HttpResponseMessage() { Content = new ObjectContent<ResultModel<object>>(result, new JsonMediaTypeFormatter()) };
|
actionExecutedContext.Response.Content = new ObjectContent<ResultModel<object>>( result, GlobalConfiguration.Configuration.Formatters.JsonFormatter);
|
||||||
// 重新封装回传格式
|
// 重新封装回传格式
|
||||||
actionExecutedContext.Response = httpResponseMessage;
|
// actionExecutedContext.Response = httpResponseMessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,9 +80,16 @@ namespace NX.ERP.WebAPi
|
|||||||
{
|
{
|
||||||
public static void Register(HttpConfiguration config)
|
public static void Register(HttpConfiguration config)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
NX.ERP.U8.U8LoginContext.Instance.AccID = System.Configuration.ConfigurationManager.AppSettings["AccId"];
|
||||||
|
NX.ERP.U8.U8LoginContext.Instance.PassWord = System.Configuration.ConfigurationManager.AppSettings["Password"];
|
||||||
|
|
||||||
|
NX.ERP.U8.U8LoginContext.Instance.UserId = System.Configuration.ConfigurationManager.AppSettings["UserId"];
|
||||||
|
NX.ERP.U8.U8LoginContext.Instance.Server= System.Configuration.ConfigurationManager.AppSettings["Server"];
|
||||||
|
|
||||||
//System.Web.Http.Filters.IExceptionFilter
|
//System.Web.Http.Filters.IExceptionFilter
|
||||||
config.Filters.Add(new ExceptionFilter());
|
config.Filters.Add(new ExceptionFilter());
|
||||||
config.Filters.Add(new ApiResultAttribute());
|
//config.Filters.Add(new ApiResultAttribute());
|
||||||
Console.WriteLine(config.Filters.Count);
|
Console.WriteLine(config.Filters.Count);
|
||||||
// Web API 配置和服务
|
// Web API 配置和服务
|
||||||
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings
|
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings
|
||||||
@@ -92,11 +99,11 @@ namespace NX.ERP.WebAPi
|
|||||||
NullValueHandling = NullValueHandling.Ignore,
|
NullValueHandling = NullValueHandling.Ignore,
|
||||||
//Formatting = Newtonsoft.Json.Formatting.Indented,
|
//Formatting = Newtonsoft.Json.Formatting.Indented,
|
||||||
//小驼峰命名法
|
//小驼峰命名法
|
||||||
//ContractResolver = new DefaultContractResolver()
|
ContractResolver = new DefaultContractResolver()
|
||||||
//{
|
{
|
||||||
|
|
||||||
// NamingStrategy = new SnakeCaseNamingStrategy()
|
NamingStrategy = new SnakeCaseNamingStrategy()
|
||||||
//}
|
}
|
||||||
//格式化日期时间
|
//格式化日期时间
|
||||||
|
|
||||||
//空值处理
|
//空值处理
|
||||||
|
|||||||
@@ -37,7 +37,8 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
<DocumentationFile>bin\NX.ERP.WebAPi.xml</DocumentationFile>
|
<DocumentationFile>
|
||||||
|
</DocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
-->
|
-->
|
||||||
<configuration>
|
<configuration>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
|
<add key="server" value="192.168.0.168"/>
|
||||||
|
<add key="AccId" value="(default)@001"/>
|
||||||
|
<add key="UserId" value="wx999"/>
|
||||||
|
<add key="Password" value="!@#qwe123"/>
|
||||||
<add key="webpages:Version" value="3.0.0.0" />
|
<add key="webpages:Version" value="3.0.0.0" />
|
||||||
<add key="webpages:Enabled" value="false" />
|
<add key="webpages:Enabled" value="false" />
|
||||||
<add key="ClientValidationEnabled" value="true" />
|
<add key="ClientValidationEnabled" value="true" />
|
||||||
|
|||||||
Reference in New Issue
Block a user