From 7e3c795134fce3544a938928c1b43e6aca49609c Mon Sep 17 00:00:00 2001 From: jhz <jinghz@oceic.com> Date: 星期二, 21 六月 2022 02:49:48 +0800 Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API --- WebAPI/Controllers/SCGL/日计划管理/Sc_WorkDemandPlanBillController.cs | 53 +++++++ WebAPI/Controllers/博日自动扫码线/ScanlineAPIController.cs | 11 WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs | 2 WebAPI/Config/kdapi.config | 9 + WebAPI/Controllers/Sc_ProcessMangementController.cs | 196 +++++++++++++++++++++++++++ WebAPI/InvokeHelper.cs | 17 +- WebAPI/Utility/Util.cs | 124 +++++++++++++++++ WebAPI/WebAPI.csproj | 2 WebAPI/Controllers/生产管理/报工台工序/Sc_MESBeginStepWorkBillController.cs | 5 9 files changed, 399 insertions(+), 20 deletions(-) diff --git a/WebAPI/Config/kdapi.config b/WebAPI/Config/kdapi.config new file mode 100644 index 0000000..c18615b --- /dev/null +++ b/WebAPI/Config/kdapi.config @@ -0,0 +1,9 @@ +锘�<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <appSettings> + <add key="DbId" value="5f9258a311401c"></add> + <add key="UserName" value="Administrator"></add> + <add key="PassWord" value="qaz!@#123"></add> + <add key="KDApiUrl" value="http://localhost/K3Cloud/"></add> + </appSettings> +</configuration> \ No newline at end of file diff --git a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs index ac6d135..2e16b55 100644 --- a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs +++ b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs @@ -1149,5 +1149,7 @@ } #endregion + + } } \ No newline at end of file diff --git "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_WorkDemandPlanBillController.cs" "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_WorkDemandPlanBillController.cs" index d9e3f4f..d4f2e1f 100644 --- "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_WorkDemandPlanBillController.cs" +++ "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_WorkDemandPlanBillController.cs" @@ -1,4 +1,5 @@ -锘縰sing Newtonsoft.Json.Linq; +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; @@ -91,7 +92,7 @@ string user = sArray[3].ToString(); try { - if (!DBUtility.ClsPub.Security_Log("Cg_PODemandPlanBill_Edit", 1, false, user)) + if (!DBUtility.ClsPub.Security_Log("Sc_WorkDemandPlanBill_Edit", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; @@ -318,6 +319,52 @@ } } #endregion - + + #region 瑕佹枡璁″垝鍗� 瑕佹枡璁″垝鎶ヨ〃 + public class ReportWorkDemandPlanBill + { + public int? HORGID; + public DateTime HBEGINDATE; + public DateTime HENDDATE; + public int? HMATERIALID; + public int? HDeptID; + } + [Route("Sc_WorkDemandPlanBill/ReportWorkDemandPlanBillList")] + [HttpGet] + public object ReportWorkDemandPlanBillList(string sWhere, string user) + { + try + { + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("Sc_WorkDemandPlanBill_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + ReportWorkDemandPlanBill Report = JsonConvert.DeserializeObject<ReportWorkDemandPlanBill>(sWhere); + + ds = oCN.RunProcReturn($"exec h_p_JIT_Sc_WorkDemandPlanBill_ReportList {Report.HORGID},'{Report.HBEGINDATE}','{Report.HENDDATE}',{Report.HMATERIALID},{Report.HDeptID} ", "h_p_JIT_Sc_WorkDemandPlanBill_ReportList"); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + } } \ No newline at end of file diff --git a/WebAPI/Controllers/Sc_ProcessMangementController.cs b/WebAPI/Controllers/Sc_ProcessMangementController.cs index b0a8e5a..ef0324d 100644 --- a/WebAPI/Controllers/Sc_ProcessMangementController.cs +++ b/WebAPI/Controllers/Sc_ProcessMangementController.cs @@ -1,4 +1,5 @@ -锘縰sing Newtonsoft.Json.Linq; +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Pub_Class; using System; using System.Collections; @@ -97,6 +98,199 @@ return objJsonResult; } + #region 宸ュ簭姹囨姤鍏ュ簱 + /// <summary> + /// 鑾峰彇宸ュ簭姹囨姤鍏ュ簱鍗曞垪琛� + /// </summary> + /// <param name="sWhere"></param> + /// <param name="user"></param> + /// <returns></returns> + [Route("Sc_ProcessMangement/Get_ProcessReportOverList")] + [HttpGet] + public object Get_ProcessReportOverList(string sWhere, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄� + if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡璇㈡潈闄�!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (sWhere == null || sWhere.Equals("")) + { + ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList_LastProc order by hmainid desc", "h_v_MES_StationOutBillList_LastProc"); + } + else + { + string sql1 = "select * from h_v_MES_StationOutBillList_LastProc where 1 = 1 "; + string sql = sql1 + sWhere + " order by hmainid desc"; + ds = oCN.RunProcReturn(sql, "h_v_MES_StationOutBillList_LastProc"); + } + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + /// <summary> + /// 鍏ュ簱鈥斺�旂敓浜ф眹鎶ュ崟 + /// </summary> + /// <param name="InterID">宸ュ簭姹囨姤鍗曚富ID</param> + /// <returns></returns> + [Route("Sc_ProcessMangement/SaveICMOReportBill")] + [HttpGet] + public object SaveICMOReportBill(string InterID, string user, string BillNo, string OrganizationID) + { + try + { + //鑾峰彇鐢熶骇姹囨姤鍗曟渶澶nterID鍜屽崟鎹彿 + Int64 HInterID = DBUtility.ClsPub.CreateBillID("3711", ref DBUtility.ClsPub.sExeReturnInfo); + string HBillNo = DBUtility.ClsPub.CreateBillCode("3711", ref DBUtility.ClsPub.sExeReturnInfo, true); + //鑾峰彇缁勭粐浠g爜 + string OrganizationNUM = oCN.RunProcReturn("select HNumber from Xt_ORGANIZATIONS where HItemID=" + OrganizationID, "Xt_ORGANIZATIONS").Tables[0].Rows[0]["HNumber"].ToString(); + //鏍规嵁宸ュ簭姹囨姤鍗曚富ID鑾峰彇宸ュ簭姹囨姤鍏ュ簱鍗曠殑鏁版嵁 + DataSet ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList_LastProc where HInterID=" + InterID, "h_v_MES_StationOutBillList_LastProc"); + DataRow dr = ds.Tables[0].Rows[0]; + //淇濆瓨 + oCN.BeginTran(); + //鐢熶骇姹囨姤鍗曚富琛� + oCN.RunProc("Insert Into Sc_ICMOReportBillMain " + + "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate,HBillStatus,HChecker,HCheckDate" + + ",HYear,HPeriod,HRemark,HEmpID,HEmpNumber" + + ",HGroupID,HDeptID,HDeptNumber" + + ",HMainSourceBillNo,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType" + + ") " + + " values('3711','3711'," + HInterID.ToString() + ",'" + HBillNo + "',getdate(),'" + user + "',getdate(),2,'" + user + "',getdate()" + + ",DATENAME(YEAR,GETDATE()),0,'','" + dr["HEmpID"].ToString() + "','" + dr["鎿嶄綔鍛樹唬鐮�"].ToString() + + "','" + dr["HGroupID"].ToString() + "',0,''" + + ",'" + BillNo.ToString() + "'," + InterID.ToString() + ", 0,'3791'" + + ") "); + //鐢熶骇姹囨姤鍗曞瓙琛� + oCN.RunProc("Insert into Sc_ICMOReportBillSub " + + " (HInterID,HEntryID,HMaterID,HMaterNumber" + + ",HQty,HUnitID,HUnitNumber,HTimes,HSourceID" + + ",HQtyMust,HWorkerID,HWorkerNumber,HBadCount,HWasterQty," + + "HCloseMan,HCloseType,HRemark," + + "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + + ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" + + ",HICMOInterID,HICMOBillNo,HBarCode" + + ") values(" + + HInterID.ToString() + ",1," + dr["HMaterID"].ToString() + ",'" + dr["浜у搧浠g爜"].ToString() + "'" + + "," + dr["鍚堟牸鏁伴噺"].ToString() + ",0,'',0,0" + + "," + dr["鎺ユ敹鏁伴噺"].ToString() + "," + dr["HEmpID"].ToString() + ",'" + dr["鎿嶄綔鍛樹唬鐮�"].ToString() + "'," + dr["涓嶈壇鏁伴噺"].ToString() + "," + dr["鎶ュ簾鏁伴噺"].ToString() + + ",'',0,''" + + "," + InterID.ToString() + ",0,'" + BillNo.ToString() + "','3791',0,0" + + ",0,0,''" + + "," + dr["HICMOInterID"].ToString() + ",'" + dr["浠诲姟鍗�"].ToString() + "',''" + + ") "); + //鍚屾閲戣澏 + //璁块棶閲戣澏 + var loginRet = InvokeHelper.Login(); + var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); + if (isSuccess == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎿嶄綔澶辫触,閲戣澏璐﹀彿鐧诲綍寮傚父銆�" + loginRet; + objJsonResult.data = null; + return objJsonResult; + } + //鏍规嵁浠诲姟鍗曟煡鎵惧埌閲戣澏鐨勭敓浜ц鍗� + DataSet ds1 = oCN.RunProcReturn("select * from h_v_TOERP_StationOutBillList_LastProc where HICMOInterID=" + dr["HICMOInterID"].ToString(), "h_v_TOERP_StationOutBillList_LastProc"); + DataRow dr1 = ds1.Tables[0].Rows[0]; + + JObject model = new JObject(); + model.Add("FBillType", "50fa7c2eda7947b89fab5431bf25d48e"); //鍗曟嵁绫诲瀷1 + model.Add("FPrdOrgId", new JObject() { ["Fnumber"] = dr1["FPrdOrgNUMBER"].ToString() }); //鐢熶骇缁勭粐1 + model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //鍗曟嵁鏃ユ湡1 + JArray Fentity = new JArray(); + foreach (DataRow item in ds.Tables[0].Rows) + { + JObject FentityModel = new JObject(); + FentityModel.Add("FReportType", "BD_OwnerOrg");//鐢熶骇姹囨姤绫诲瀷 + FentityModel.Add("FTimeUnitId", "1");//鏃堕棿鍗曚綅 + FentityModel.Add("FWorkshipId", new JObject() { ["Fnumber"] = dr1["FWorkShopNUM"].ToString() }); // 鐢熶骇杞﹂棿 + FentityModel.Add("FStandHourUnitId", "3600"); // 鍗曚綅鏍囧噯宸ユ椂鍗曚綅 + FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = dr1["FMaterialNUM"].ToString() }); // 鐗╂枡缂栫爜 + FentityModel.Add("FMoEntrySeq", dr1["HICMOEntryID"].ToString());//鐢熶骇璁㈠崟琛屽彿 + FentityModel.Add("FMoId", dr1["HICMOInterID"].ToString());//鐢熶骇璁㈠崟鍐呯爜 + FentityModel.Add("FFinishQty", item["鎺ユ敹鏁伴噺"].ToString());//瀹屾垚鏁伴噺1 + FentityModel.Add("FQuaQty", item["鍚堟牸鏁伴噺"].ToString());//鍚堟牸鏁伴噺1 + FentityModel.Add("FStockInOrgId ", OrganizationNUM);// 鍏ュ簱缁勭粐 + FentityModel.Add("FStockId", new JObject() { ["Fnumber"] = dr1["FStockNUM"].ToString() }); // 浠撳簱 + FentityModel.Add("FSrcBillType", "PRD_MO");// 婧愬崟绫诲瀷 + FentityModel.Add("FSrcBillNo", item["浠诲姟鍗�"].ToString());// 婧愬崟缂栧彿 + FentityModel.Add("FSrcInterId", dr1["HICMOInterID"].ToString());// 婧愬崟鍐呯爜 + FentityModel.Add("FSrcEntryId", dr1["HICMOEntryID"].ToString());// 婧愬崟鍒嗗綍鍐呯爜 + + //JArray Fentity2 = new JArray(); + //JObject FentityModel2 = new JObject(); + //FentityModel2.Add("FDetailEntity_Link_FRULEID", "PUR_PurchaseOrder-PUR_ReceiveBill"); + //FentityModel2.Add("FDetailEntity_Link_FSTableName", "t_PUR_POOrderEntry"); + //FentityModel2.Add("FDetailEntity_Link_FSBillId", item["FID"].ToString()); + //FentityModel2.Add("FDetailEntity_Link_FSId", item["FEntryID"].ToString()); + //Fentity2.Add(FentityModel2); + //FentityModel.Add("FDetailEntity_Link", Fentity2); + //Fentity.Add(FentityModel); + } + model.Add("FDetailEntity", Fentity); //鏄庣粏淇℃伅 + JObject jsonRoot = new JObject() + { + ["Creator"] = "", + ["NeedUpDateFields"] = new JArray(), + ["NeedReturnFields"] = new JArray(), + ["IsDeleteEntry"] = "false", + ["SubSystemId"] = "", + ["IsVerifyBaseDataField"] = "false", + //["IsAutoSubmitAndAudit"] = true,//鑷姩璋冪敤鎻愪氦鍜屽鏍稿姛鑳� + ["Model"] = model + }; + string result = InvokeHelper.Submit("PRD_MORPT", JsonConvert.SerializeObject(jsonRoot)); + //鍒ゆ柇瀹℃牳鏄惁鎴愬姛 + if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"宸ュ簭姹囨姤鍏ュ簱鍗曞悓姝ラ噾铦朵簯澶辫触锛佸崟鍙�:{dr["鍗曟嵁鍙�"].ToString()}" + result; + objJsonResult.data = null; + return objJsonResult; + } + oCN.Commit(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + /// <summary> /// 杩斿洖鐢熶骇姹囨姤鍗曞垪琛� ///鍙傛暟锛歴tring sql銆� diff --git "a/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs" "b/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs" index 9ae9001..26fc827 100644 --- "a/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs" +++ "b/WebAPI/Controllers/\345\215\232\346\227\245\350\207\252\345\212\250\346\211\253\347\240\201\347\272\277/ScanlineAPIController.cs" @@ -108,9 +108,9 @@ bool IsBarCodePack = oBill.IsBarCodePack(list.packagebarcode); if (IsBarCodePack == false) { - LogService.Write("绠辩爜宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�"); + LogService.Write($"绠辩爜:{list.packagebarcode}宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�"); objJsonResult.status = -1; - objJsonResult.msg = "绠辩爜宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�"; + objJsonResult.msg = $"绠辩爜:{list.packagebarcode}宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�"; objJsonResult.data = null; return objJsonResult; } @@ -159,12 +159,13 @@ for (int i = 0; i < list.barcodes.Count; i++) { //鍒ゆ柇鏉$爜鏄惁瀛樺湪 - bool IsBarCode = oBill.IsBarCodePack(list.barcodes[i].barcode); + bool IsBarCode = oBill.IsBarCode(list.barcodes[i].barcode); if (IsBarCodePack == false) { - LogService.Write("鏉$爜宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�"); + DataTable dt = oCN.RunProcReturn("Select HBarCode_Pack from Sc_PackUnionBillSub Where HBarCode='" + list.barcodes[i].barcode + "'", "Sc_PackUnionBillSub").Tables[0]; + LogService.Write($"鏉$爜锛歿list.barcodes[i].barcode}锛屽凡瀛樺湪绠辩爜锛歿dt.Rows[0]["HBarCode_Pack"]}涓紝鏈缁戝畾绠辩爜涓猴細{list.packagebarcode},缁戝畾澶辫触,涓嶈兘閲嶅缁戝畾锛�"); objJsonResult.status = -1; - objJsonResult.msg = "鏉$爜宸插瓨鍦�,涓嶈兘閲嶅缁戝畾锛�"; + objJsonResult.msg = $"鏉$爜锛歿list.barcodes[i].barcode}锛屽凡瀛樺湪绠辩爜锛歿dt.Rows[0]["HBarCode_Pack"]}涓紝鏈缁戝畾绠辩爜涓猴細{list.packagebarcode},缁戝畾澶辫触,涓嶈兘閲嶅缁戝畾锛�"; objJsonResult.data = null; return objJsonResult; } diff --git "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\346\212\245\345\267\245\345\217\260\345\267\245\345\272\217/Sc_MESBeginStepWorkBillController.cs" "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\346\212\245\345\267\245\345\217\260\345\267\245\345\272\217/Sc_MESBeginStepWorkBillController.cs" index c8a07f5..c0bbff3 100644 --- "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\346\212\245\345\267\245\345\217\260\345\267\245\345\272\217/Sc_MESBeginStepWorkBillController.cs" +++ "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\346\212\245\345\267\245\345\217\260\345\267\245\345\272\217/Sc_MESBeginStepWorkBillController.cs" @@ -1626,8 +1626,8 @@ string result1 = string.Empty; string result2 = string.Empty; - //鍒ゆ柇褰撳墠鐢ㄧ敓浜ф枡娓呭崟鍗曠姸鎬佲�斺�斿凡鍒涘缓鍒欏厛鎻愪氦鍐嶅鏍搞�佷互鎻愪氦鍒欏彧瀹℃牳 - if (Ds.Tables[0].Rows[0][2].ToString() == "A") + //鍒ゆ柇褰撳墠鐢ㄧ敓浜ф枡娓呭崟鍗曠姸鎬佲�斺�斿凡鍒涘缓鍒欏厛鎻愪氦鍐嶅鏍搞�佷互鎻愪氦鍒欏彧瀹℃牳--A:鍒涘缓锛孊:鎻愪氦,C:瀹℃牳,D:閲嶆柊瀹℃牳 + if (Ds.Tables[0].Rows[0][2].ToString() == "A"|| Ds.Tables[0].Rows[0][2].ToString() == "D") { result1 = InvokeHelper.Submit("PRD_PPBOM", JsonConvert.SerializeObject(json)); result2 = InvokeHelper.Audit("PRD_PPBOM", JsonConvert.SerializeObject(json)); @@ -1636,6 +1636,7 @@ { result2 = InvokeHelper.Audit("PRD_PPBOM", JsonConvert.SerializeObject(json)); } + LogService.Write("result2=" + result2); //鍒ゆ柇瀹℃牳鏄惁鎴愬姛 if (JObject.Parse(result2)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") { diff --git a/WebAPI/InvokeHelper.cs b/WebAPI/InvokeHelper.cs index 55aee42..d7eaf36 100644 --- a/WebAPI/InvokeHelper.cs +++ b/WebAPI/InvokeHelper.cs @@ -4,29 +4,28 @@ using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; +using WebAPI.Utility; namespace WebAPI { public static class InvokeHelper { - //private static string CloudUrl = "http://localhost/k3cloud/";//K/3 Cloud 涓氬姟绔欑偣鍦板潃 - //private static string CloudUrl = "http://60.190.4.42:9002/k3cloud/";//K/3 Cloud 涓氬姟绔欑偣鍦板潃 - private static string CloudUrl = "http://47.96.97.237/k3cloud/";//K/3 Cloud 涓氬姟绔欑偣鍦板潃 - //private static string CloudUrl = "http://60.190.4.42:9002/K3CLOUD/";//澶忓疂 - //private static string CloudUrl = "http://124.70.129.242/k3cloud/";//闆呯惇璇� - + private static string CloudUrl = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "KDApiUrl");//K/3 Cloud 涓氬姟绔欑偣鍦板潃 /// <summary> /// 鐧婚檰 /// </summary> public static string Login() { + var dbId = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DbId"); + var useName = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "UserName"); + var pwd = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "PassWord"); HttpClient httpClient = new HttpClient(); httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc"); List<object> Parameters = new List<object>(); - Parameters.Add("6204a70eba35fc");//璐﹀鏍囩ず - Parameters.Add("Administrator");//鐢ㄦ埛鍚� - Parameters.Add("qaz!@#123");//瀵嗙爜 + Parameters.Add(dbId);//璐﹀鏍囩ず + Parameters.Add(useName);//鐢ㄦ埛鍚� + Parameters.Add(pwd);//瀵嗙爜 Parameters.Add(2052);//2052浠h〃涓枃 httpClient.Content = JsonConvert.SerializeObject(Parameters); diff --git a/WebAPI/Utility/Util.cs b/WebAPI/Utility/Util.cs new file mode 100644 index 0000000..3e818fc --- /dev/null +++ b/WebAPI/Utility/Util.cs @@ -0,0 +1,124 @@ +锘縰sing Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace WebAPI.Utility +{ + public class Util + { + public static string GetObjectType(object obj) + { + var isType = false; + isType = obj.GetType() == typeof(string); + if (isType) + { + return "string"; + } + + isType = obj.GetType() == typeof(double); + if (isType) + { + return "double"; + } + + isType = obj.GetType() == typeof(long); + if (isType) + { + return "long"; + } + + isType = obj.GetType() == typeof(DateTime); + if (isType) + { + return "date"; + } + + isType = obj.GetType() == typeof(int); + if (isType) + { + return "int"; + } + + isType = obj.GetType() == typeof(decimal); + if (isType) + { + return "decimal"; + } + + return "string"; + } + + public static JObject JsonVerify(string json) + { + if (string.IsNullOrEmpty(json)) + { + throw new Exception("鍙傛暟涓嶈兘涓虹┖"); + } + try + { + return JObject.Parse(json.ToString().Replace("\r", "").Replace("\n", "").Replace("\t", "")); + } + catch (Exception) + { + throw; + } + } + + //public static T DeepCopy<T>(T obj) + //{ + // object retval; + // using (MemoryStream ms = new MemoryStream()) + // { + // XmlSerializer xml = new XmlSerializer(typeof(T)); + // xml.Serialize(ms, obj); + // ms.Seek(0, SeekOrigin.Begin); + // retval = xml.Deserialize(ms); + // ms.Close(); + // } + // return (T)retval; + //} + + public static String GetConfigKey(String configPath, String key) + { + Configuration ConfigurationInstance = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap() + { + ExeConfigFilename = configPath + }, ConfigurationUserLevel.None); + + + if (ConfigurationInstance.AppSettings.Settings[key] != null) + return ConfigurationInstance.AppSettings.Settings[key].Value; + else + + return string.Empty; + } + + public static bool SetConfigKey(String configPath, String key, String vls) + { + try + { + Configuration ConfigurationInstance = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap() + { + ExeConfigFilename = configPath + }, ConfigurationUserLevel.None); + + if (ConfigurationInstance.AppSettings.Settings[key] != null) + ConfigurationInstance.AppSettings.Settings[key].Value = vls; + else + ConfigurationInstance.AppSettings.Settings.Add(key, vls); + ConfigurationInstance.Save(ConfigurationSaveMode.Modified); + ConfigurationManager.RefreshSection("appSettings"); + return true; + } + catch + { + return false; + } + } + } +} diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj index 316c1da..45b5324 100644 --- a/WebAPI/WebAPI.csproj +++ b/WebAPI/WebAPI.csproj @@ -233,6 +233,7 @@ <Content Include="Index.html" /> <Content Include="Views\Scripts\bootstrap.js" /> <Content Include="Views\Scripts\bootstrap.min.js" /> + <Content Include="Config\kdapi.config" /> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> <LastGenOutput>Settings.Designer.cs</LastGenOutput> @@ -752,6 +753,7 @@ <Compile Include="Service\ProcessDal.cs" /> <Compile Include="Service\YqnDal.cs" /> <Compile Include="Service\YqnQbService.cs" /> + <Compile Include="Utility\Util.cs" /> <Compile Include="Web References\WebS\Reference.cs"> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> -- Gitblit v1.9.1