修改API 输出格式
This commit is contained in:
@@ -19,7 +19,7 @@ namespace NX.ERP.Model.Purchase
|
||||
public int Id { get => id; set => id = value; }
|
||||
public string ArrivalCode { get => arrivalCode; set => arrivalCode = 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 double ExchRate { get; set; }
|
||||
public string ExchName { get; set; }
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<appSettings>
|
||||
<!--修改账套请修改这里的配置-->
|
||||
<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=""/>
|
||||
</appSettings>
|
||||
<runtime>
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace U8AppMain
|
||||
}
|
||||
|
||||
private string url = ConfigurationManager.AppSettings.Get("url");
|
||||
private string connStr = ConfigurationManager.AppSettings.Get("connStr");
|
||||
// private string connStr = ConfigurationManager.AppSettings.Get("connStr");
|
||||
private DataTable dataTable;
|
||||
|
||||
|
||||
@@ -288,8 +288,8 @@ namespace U8AppMain
|
||||
|
||||
private void 登录ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//u8LoginContext = new NX.ERP.U8.U8LoginContext();
|
||||
//u8LoginContext.Login(true);
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace NX.ERP.U8.Purchase
|
||||
arrival = _arrival;
|
||||
}
|
||||
|
||||
arrival.ArrivalDetails.Add(ArrivalDetail);
|
||||
arrival.Details.Add(ArrivalDetail);
|
||||
return arrival;
|
||||
}, param, null, true, "id", 10, System.Data.CommandType.Text);
|
||||
return lookup.Values;
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace NX.ERP.U8.Store
|
||||
for (var n = 0; n < puStoreIn.Details.Count; 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("ipurorderid", arrivalDetail.PoId);
|
||||
bodyXml = domBody.createElement("z:row");
|
||||
|
||||
@@ -78,18 +78,52 @@ namespace NX.ERP.U8
|
||||
{
|
||||
if (uiLogin != null)
|
||||
{
|
||||
uiLogin.SubLogout(AccID);
|
||||
uiLogin.SubLogout(this._accid);
|
||||
uiLogin.ShutDown();
|
||||
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; }
|
||||
/// <summary>
|
||||
@@ -140,10 +174,24 @@ namespace NX.ERP.U8
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Login(bool showlogin = false)
|
||||
public bool NeedUiLogin
|
||||
{
|
||||
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"))
|
||||
{
|
||||
@@ -152,8 +200,7 @@ namespace NX.ERP.U8
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (!UiLogin.login("DP", "wx999", "!@#qwe123", "192.168.0.168", DateTime.Today.ToString("yyyy-MM-dd"), AccID, Serial))
|
||||
if (!UiLogin.login("DP", this._userId, this._password, this._server, DateTime.Today.ToString("yyyy-MM-dd"), this._accid, Serial))
|
||||
{
|
||||
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
|
||||
// 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
|
||||
// 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>),
|
||||
new ResultModel<string> { ErrCode = 500, ErrMsg = ex.Message, Data = null },
|
||||
new JsonMediaTypeFormatter());
|
||||
GlobalConfiguration.Configuration.Formatters.JsonFormatter);
|
||||
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
@@ -47,11 +47,11 @@ namespace NX.ERP.WebAPi
|
||||
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)
|
||||
{
|
||||
|
||||
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
|
||||
config.Filters.Add(new ExceptionFilter());
|
||||
config.Filters.Add(new ApiResultAttribute());
|
||||
//config.Filters.Add(new ApiResultAttribute());
|
||||
Console.WriteLine(config.Filters.Count);
|
||||
// Web API 配置和服务
|
||||
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings
|
||||
@@ -92,11 +99,11 @@ namespace NX.ERP.WebAPi
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
//Formatting = Newtonsoft.Json.Formatting.Indented,
|
||||
//小驼峰命名法
|
||||
//ContractResolver = new DefaultContractResolver()
|
||||
//{
|
||||
ContractResolver = new DefaultContractResolver()
|
||||
{
|
||||
|
||||
// NamingStrategy = new SnakeCaseNamingStrategy()
|
||||
//}
|
||||
NamingStrategy = new SnakeCaseNamingStrategy()
|
||||
}
|
||||
//格式化日期时间
|
||||
|
||||
//空值处理
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<DocumentationFile>bin\NX.ERP.WebAPi.xml</DocumentationFile>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
-->
|
||||
<configuration>
|
||||
<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:Enabled" value="false" />
|
||||
<add key="ClientValidationEnabled" value="true" />
|
||||
|
||||
Reference in New Issue
Block a user