using Nancy; using System.Text; namespace SiaSun.LMS.Implement { public class SampleModule : NancyModule { private static S_ERPService ERPService = new S_ERPService(); public SampleModule() { Get["/"] = _ => "Siasun Warehouse Manage System"; Post["/API/ECWorkInstruction/BatteryCapacityRuleSet"] = _ => { var body = this.Request.Body; int length = (int)body.Length; byte[] data = new byte[length]; body.Read(data, 0, length); string jsonStr = Encoding.UTF8.GetString(data); string responseJson = string.Empty; ERPService.PartionParam(jsonStr, out responseJson); byte[] responseData = Encoding.UTF8.GetBytes(responseJson); return new Response() { Contents = stream => { stream.Write(responseData, 0, responseData.Length); }, StatusCode = HttpStatusCode.OK }; }; Post["/API/ECWorkInstruction/CapacityParameterGet"] = _ => { var body = this.Request.Body; int length = (int)body.Length; byte[] data = new byte[length]; body.Read(data, 0, length); string jsonStr = Encoding.UTF8.GetString(data); string responseJson = ERPService.ParaMapping(jsonStr); byte[] responseData = Encoding.UTF8.GetBytes(responseJson); return new Response() { Contents = stream => { stream.Write(responseData, 0, responseData.Length); }, StatusCode = HttpStatusCode.OK }; }; Post["/API/ECWorkInstruction/PartionInfoGet"] = _ => { var body = this.Request.Body; int length = (int)body.Length; byte[] data = new byte[length]; body.Read(data, 0, length); string jsonStr = Encoding.UTF8.GetString(data); string responseJson = ERPService.PartionInfoGet(jsonStr); byte[] responseData = Encoding.UTF8.GetBytes(responseJson); return new Response() { Contents = stream => { stream.Write(responseData, 0, responseData.Length); }, StatusCode = HttpStatusCode.OK }; }; Post["/API/ECWorkInstruction/PoorPack"] = _ => { var body = this.Request.Body; int length = (int)body.Length; byte[] data = new byte[length]; body.Read(data, 0, length); string jsonStr = Encoding.UTF8.GetString(data); string responseJson = string.Empty; ERPService.PoorPack(jsonStr, out responseJson); byte[] responseData = Encoding.UTF8.GetBytes(responseJson); return new Response() { Contents = stream => { stream.Write(responseData, 0, responseData.Length); }, StatusCode = HttpStatusCode.OK }; }; } } }