WebAPI/Controllers/BarCodeController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Controllers/POOrderController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Controllers/WebAPIController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Controllers/Xt_grdAlignment_WMESController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Models/JsonResult.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Models/json.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Utility/HttpHelper.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/WebAPI.csproj | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
WebAPI/Controllers/BarCodeController.cs
@@ -1556,6 +1556,17 @@ //数量为0 跳过 if (oItemSub.HQty == 0) continue; //检验打印数量(HQTY)和未打印数量 string sql = $"select HQty -HBarcodeCount as HNotBarcodeCount ,* from Cg_POOrderBillSub where HEntryID = ={oItemSub.HSourceEntryID}"; DataSet ds = oCn.RunProcReturn(sql,"tables"); if (Convert.ToInt32(ds.Tables[0].Rows[0][0]) < oItemSub.HQty) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = $"物料编码{oItemSub.HMaterNumber},本次生成条码数量不能超出未生成条码数量"; objJsonResult.data = null; return objJsonResult; } if (ClsPub.isLong(oItemSub.HMaterID) != 0) { HNumber = oItemSub.HMaterID.ToString(); WebAPI/Controllers/POOrderController.cs
@@ -1,4 +1,5 @@ using DBUtility; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SQLHelper; using System; @@ -59,11 +60,19 @@ sql = "exec H_p_SRM_POOrderBillList '" + PcWhere + "'"; //LogService.WriteAsync(sql); ds = oCn.RunProcReturn("exec H_p_SRM_POOrderBillList '" + PcWhere + "'", "H_p_SRM_POOrderBillList"); //添加列名 List<object> columnNameList = new List<object>(); foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } objjson.code = "0"; objjson.count = 10000; objjson.Message = "获取成功"; objjson.data = ds.Tables[0]; objjson.list = columnNameList; return objjson; } WebAPI/Controllers/WebAPIController.cs
@@ -15,6 +15,7 @@ using System.Web.Http; using WebAPI.BLL; using WebAPI.Models; using WebAPI.Utility; namespace WebAPI.Controllers { @@ -845,6 +846,29 @@ return objjson; ; } #endregion #region[打印idSession] [Route("linteridSession")] [HttpPost] public object linteridSession([FromBody] JObject linterid) { var _linterid = linterid["linterid"].ToString(); var _huserName = linterid["HUserName"].ToString(); var postMesseege = _linterid + ";" + _huserName; //HttpHelper.PostData("http://localhost:8082/ZYMES/layuiAdmin.std-v1.2.1/src/views/SRM/Api/SRM_Web_PoBarCodeBillApi.ashx", postMesseege); HttpHelper.PostData("http://60.191.21.115:9090/layuiAdmin.std-v1.2.1/src/views/SRM/Api/SRM_Web_PoBarCodeBillApi.ashx", postMesseege); SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM(); string sql = $"Update Gy_BarCodeBill set HPrintQty=isnull(HPrintQty,0) + 1 where HItemID in ({_linterid})"; oCn.RunProc(sql); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = ""; objJsonResult.data = 1; return objJsonResult; //HttpContext.Current.Session["linterid"]; } #endregion } WebAPI/Controllers/Xt_grdAlignment_WMESController.cs
@@ -108,7 +108,7 @@ { var width = omdelsub[i].ColumnWidth; if (string.IsNullOrEmpty(width) || DBUtility.ClsPub.isLong(width) == 0) width = "120"; width = "80"; HGridString += $"{(i+1)}|{(omdelsub[i].IsHide == true ? 1 : 0)}|{omdelsub[i].Alignment}|{width},"; } HGridString = HGridString.Substring(0, HGridString.Length - 1); WebAPI/Models/JsonResult.cs
@@ -11,5 +11,7 @@ public int count { get; set; } public string Message { get; set; } public object data { get; set; } public List<object> list { get; set; } } } WebAPI/Models/json.cs
@@ -11,5 +11,7 @@ public int count { get; set; } public string Message { get; set; } public object data { get; set; } public List<object> list { get; set; } } } WebAPI/Utility/HttpHelper.cs
New file @@ -0,0 +1,134 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Text; using System.Threading.Tasks; namespace WebAPI.Utility { public class HttpHelper { public static string PostData(string url, string postData) { ASCIIEncoding encoding = new ASCIIEncoding(); byte[] data = Encoding.UTF8.GetBytes(postData); HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); myRequest.Method = "POST"; myRequest.ContentType = "application/x-www-form-urlencoded"; myRequest.ContentLength = data.Length; Stream newStream = myRequest.GetRequestStream(); newStream.Write(data, 0, data.Length); newStream.Close(); HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); string content = reader.ReadToEnd(); reader.Close(); return content; } public static string GetData(string url) { HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); myRequest.Method = "GET"; HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); string content = reader.ReadToEnd(); reader.Close(); return content; } /// <summary> /// FORM表单POST方式上传一个多媒体文件 /// </summary> /// <param name="url">API URL</param> /// <param name="typeName"></param> /// <param name="fileName"></param> /// <param name="fs"></param> /// <param name="encoding"></param> /// <returns></returns> public static string HttpRequestPost(string url, string typeName, string fileName, Stream fs, string encoding = "UTF-8") { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.Timeout = 10000; var postStream = new MemoryStream(); #region 处理Form表单文件上传 //通过表单上传文件 string boundary = "----" + DateTime.Now.Ticks.ToString("x"); string formdataTemplate = "\r\n--" + boundary + "\r\nContent-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: application/octet-stream\r\n\r\n"; try { var formdata = string.Format(formdataTemplate, typeName, fileName); var formdataBytes = Encoding.ASCII.GetBytes(postStream.Length == 0 ? formdata.Substring(2, formdata.Length - 2) : formdata);//第一行不需要换行 postStream.Write(formdataBytes, 0, formdataBytes.Length); //写入文件 byte[] buffer = new byte[1024]; int bytesRead = 0; while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0) { postStream.Write(buffer, 0, bytesRead); } } catch (Exception ex) { throw ex; } //结尾 var footer = Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n"); postStream.Write(footer, 0, footer.Length); request.ContentType = string.Format("multipart/form-data; boundary={0}", boundary); #endregion request.ContentLength = postStream != null ? postStream.Length : 0; request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; request.KeepAlive = true; request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36"; #region 输入二进制流 if (postStream != null) { postStream.Position = 0; //直接写入流 Stream requestStream = request.GetRequestStream(); byte[] buffer = new byte[1024]; int bytesRead = 0; while ((bytesRead = postStream.Read(buffer, 0, buffer.Length)) != 0) { requestStream.Write(buffer, 0, bytesRead); } postStream.Close();//关闭文件访问 } #endregion HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (Stream responseStream = response.GetResponseStream()) { using (StreamReader myStreamReader = new StreamReader(responseStream, Encoding.GetEncoding(encoding))) { string retString = myStreamReader.ReadToEnd(); return retString; } } } //public static string PostDataV2(string data, string url) //{ // WebClient wc = new WebClient(); // wc.Headers.Add("Content-Type", "application/json"); // byte[] postData = Encoding.ASCII.GetBytes(data); // byte[] responseData = wc.UploadData(url, "POST", postData); // return Encoding.UTF8.GetString(responseData); //} } } WebAPI/WebAPI.csproj
@@ -240,6 +240,7 @@ <Compile Include="MyHub.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Startup.cs" /> <Compile Include="Utility\HttpHelper.cs" /> <Compile Include="Utility\Util.cs" /> </ItemGroup> <ItemGroup>