From 5dd7ff1128d7624b6315587461f3d198d3da3d59 Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期三, 24 四月 2024 10:04:36 +0800
Subject: [PATCH] 平板绑定
---
WebAPI/Controllers/PlateBindingController.cs | 123 +++++++++++++++++++++++++++++++++++++++++
WebAPI/WebAPI.csproj | 1
2 files changed, 124 insertions(+), 0 deletions(-)
diff --git a/WebAPI/Controllers/PlateBindingController.cs b/WebAPI/Controllers/PlateBindingController.cs
new file mode 100644
index 0000000..1821d54
--- /dev/null
+++ b/WebAPI/Controllers/PlateBindingController.cs
@@ -0,0 +1,123 @@
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Pub_Class;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Text;
+using System.Web.Http;
+using WebAPI.Models;
+
+namespace WebAPI.Controllers
+{
+ public class PlateBindingController : ApiController
+ {
+ private json objJsonResult = new json();
+ public DataSet ds = new DataSet();
+ SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+
+ /// <summary>
+ /// 淇濆瓨骞虫澘缁戝畾
+ /// </summary>
+ /// <param name="msg"></param>
+ /// <returns></returns>
+ [Route("Save/Xt_PlateBinding")]
+ [HttpPost]
+ public object Save([FromBody] JObject msg)
+ {
+ try
+ {
+ DataSet ds;
+ var _value = msg["msg"].ToString();
+ string msg3 = _value.ToString();
+ string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+ string msg1 = sArray[0].ToString();
+ string user = sArray[1].ToString();
+
+ string filePath = "Configuration";
+ bool isAppend = true;
+
+ filePath = $@"{filePath}\PlateBinding.txt";
+
+ filePath = "D:\\" + filePath;
+
+ if (!System.IO.Directory.Exists(Path.GetDirectoryName(filePath)))
+ {
+ System.IO.Directory.CreateDirectory(Path.GetDirectoryName(filePath));
+ }
+ //鍒ゆ柇鏄惁宸茬粡瀛樺湪骞虫澘缁戝畾鏂囦欢锛岃嫢宸插瓨鍦ㄥ垯鍒犻櫎锛岄噸鏂板垱寤�
+ bool fileExists = System.IO.File.Exists(filePath);
+
+ //瀛樺湪 鍒欏垹闄よ鏂囦欢
+ if (fileExists)
+ {
+ File.Delete(filePath);
+ }
+ //鍒涘缓鏂囦欢
+
+ using (StreamWriter writer = new StreamWriter(filePath, isAppend))
+ {
+ //瀛樺湪鐨勬椂鍊欐墠鍐欎竴琛�
+ if (fileExists && isAppend)
+ {
+ writer.WriteLine();
+ }
+
+ var content = msg1 is string ? msg1 : JsonConvert.SerializeObject(msg1);
+ writer.WriteLine($"{DateTime.Now}");
+ writer.WriteLine("");
+ msg1 = msg1.Replace("{","").Replace("}","").Replace("\"","");
+ string[] arr = msg1.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
+ for (int i = 0; i < arr.Length; i++)
+ {
+ writer.WriteLine(arr[i]);
+ }
+ }
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "骞虫澘缁戝畾淇℃伅鍐欏叆鎴愬姛锛�";
+ objJsonResult.data = "";
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍐欏叆骞虫澘缁戝畾淇℃伅杩囩▼涓彂鐢熷紓甯革紒";
+ objJsonResult.data = "";
+ return objJsonResult;
+ }
+ }
+
+ #region 鑾峰彇骞虫澘缁戝畾鏂囦欢鏁版嵁
+
+ [Route("Get/Xt_PlateBinding")]
+ [HttpGet]
+ public object Get(string user)
+ {
+ try
+ {
+ //鏍规嵁鎸囧畾璺緞锛岃鍙栨枃浠跺唴瀹癸紝杩斿洖鏁版嵁涓烘暟缁勬牸寮�
+ string[] ConfigFileInfo = File.ReadAllLines(@"D:\Configuration\PlateBinding.txt");
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = ConfigFileInfo;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ }
+}
diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj
index 70ecba5..72351ca 100644
--- a/WebAPI/WebAPI.csproj
+++ b/WebAPI/WebAPI.csproj
@@ -417,6 +417,7 @@
<Compile Include="Controllers\MJGL\Sc_MouldStatusChangeBillController.cs" />
<Compile Include="Controllers\MJGL\Sc_MouldUpperBillController.cs" />
<Compile Include="Controllers\Pay_ReportController.cs" />
+ <Compile Include="Controllers\PlateBindingController.cs" />
<Compile Include="Controllers\SBGL\Gy_FixCardChangeBillController.cs" />
<Compile Include="Controllers\SBGL\Gy_FixCardBillController.cs" />
<Compile Include="Controllers\SBGL\Sb_EquipConkBookBillController.cs" />
--
Gitblit v1.9.1