소스 검색

二期接口:对接IT,并配置Config启动项。

JeffWang 2 년 전
부모
커밋
a4bda5472c

+ 12 - 4
FactoryTool_CShare/BLL/NTFBLL.cs

@@ -11,15 +11,23 @@ namespace MOKA_Factory_Tools.BLL
 {
     public partial class NTFBLL
     {
+        public NTFBLL(bool bMexican = false)
+        {
+            dalAMResult = new DAL_AMResult(bMexican);
+            dalAMYields = new DAL_AMYields(bMexican);
+            dalAMResultTR = new DAL_AMResult_TR(bMexican);
+            dalAMYieldsTR = new DAL_AMYields_TR(bMexican);
+        }
+
         /// <summary>
         /// ""=异常,OncePass,NTF,ReadFial
         /// </summary>
         public string ResultType = "";
         private string _strLastSN = "";
-        protected readonly DAL_AMResult dalAMResult = new DAL_AMResult();
-        protected readonly DAL_AMYields dalAMYields = new DAL_AMYields();
-        protected readonly DAL_AMResult_TR dalAMResultTR = new DAL_AMResult_TR();
-        protected readonly DAL_AMYields_TR dalAMYieldsTR = new DAL_AMYields_TR();
+        protected readonly DAL_AMResult dalAMResult = null;// new DAL_AMResult();
+        protected readonly DAL_AMYields dalAMYields = null;//new DAL_AMYields();
+        protected readonly DAL_AMResult_TR dalAMResultTR = null;//new DAL_AMResult_TR();
+        protected readonly DAL_AMYields_TR dalAMYieldsTR = null;//new DAL_AMYields_TR();
         /// <summary>
         /// 设置数据抄写结果;
         /// </summary>

+ 17 - 3
FactoryTool_CShare/Business/GMethod.cs

@@ -16,6 +16,20 @@ namespace MOKA_Factory_Tools
     {
         private static Dictionary<string, string> LastKaylaOrderInfo = new Dictionary<string, string>();
 
+        private static string url_MaInfo = "http://smes-prd-app01.tclking.com:9002/SAPService.asmx";
+        private static string url_ReportKey = "http://smes-app-prod.tclking.com/FireTVApi/api/SMES/RecordKey";
+        private static string url_getOrderProductStatus = "http://smes-app-prod.tclking.com/FireTVApi/api/SMES/getOrderProductStatus?sn=";
+
+        public static void SetMexicanConfig(bool bbMexican=false)
+        {
+            if (bbMexican) 
+            {
+                url_MaInfo = "http://SMES.TMSA.MX:9002/SAPService.asmx";
+                url_ReportKey = "http://SMES.TMSA.MX/FireTVApi/api/SMES/RecordKey";
+                url_getOrderProductStatus = "http://SMES.TMSA.MX/FireTVApi/api/SMES/getOrderProductStatus?sn=";
+            }
+        }
+
         public static bool GetMaInfo(string sn, out MaInfo maInfo, SQLiteConnection errorDBNow)
         {
             string desc;
@@ -38,7 +52,7 @@ namespace MOKA_Factory_Tools
                 KeepAlive = false
             };
 
-            item.URL = "http://smes-prd-app01.tclking.com:9002/SAPService.asmx";
+            item.URL = url_MaInfo;
             item.Postdata = strPost;
             HttpResult result = http.GetHtml(item);
             if (result.StatusCode == System.Net.HttpStatusCode.OK)
@@ -83,7 +97,7 @@ namespace MOKA_Factory_Tools
             };
 
             // 测试地址;
-            item.URL = "http://smes-app-prod.tclking.com/FireTVApi/api/SMES/RecordKey";
+            item.URL = url_ReportKey;
             item.Postdata = strPost;
             HttpResult hResult = http.GetHtml(item);
             if (hResult.StatusCode == System.Net.HttpStatusCode.OK)
@@ -191,7 +205,7 @@ namespace MOKA_Factory_Tools
             };
 
             // 测试地址;
-            item.URL = "http://smes-app-prod.tclking.com/FireTVApi/api/SMES/getOrderProductStatus?sn=" + sn;
+            item.URL = url_getOrderProductStatus + sn;
             HttpResult hResult = http.GetHtml(item);
             if (hResult.StatusCode == System.Net.HttpStatusCode.OK)
             {

+ 19 - 8
FactoryTool_CShare/Business/V2Method.cs

@@ -21,7 +21,7 @@ namespace MOKA_Factory_Tools
         public static void Test()
         {
             MidList mid;
-            bool bRet = GetMidInfo("http://test.scbc.qhmoka.com/scbc-server/clientType/getMessage.do", "TEST_WJF", "04-D4-C4-EE-6B-CD", null, out mid);
+            bool bRet = GetMidInfo("TEST_WJF", "04-D4-C4-EE-6B-CD", null, out mid);
             if (bRet)
             {
                 List<KeyType> key2Write;
@@ -55,6 +55,17 @@ namespace MOKA_Factory_Tools
         }
 #endif
 
+        private static string url_getMessage = "https://cn.uc.qhmoka.com/scbc-server/clientType/getMessage.do";
+
+        public static void SetMexicanConfig(bool bMexican = false)
+        {
+            if (bMexican)
+                url_getMessage = "https://cn.uc.qhmoka.com/scbc-server/clientType/getMessage.do";
+
+            if ( TestMode.testMode)
+                url_getMessage = "http://test.scbc.qhmoka.com/scbc-server/clientType/getMessage.do";
+        }
+
         /// <summary>
         /// 
         /// </summary>
@@ -64,14 +75,14 @@ namespace MOKA_Factory_Tools
         /// <param name="sqliteConn"></param>
         /// <param name="mid"></param>
         /// <returns></returns>
-        public static bool GetMidInfo(string url, string order, string pcmac, SQLiteConnection sqliteConn, out MidList mid)
+        public static bool GetMidInfo(string order, string pcmac, SQLiteConnection sqliteConn, out MidList mid)
         {
             mid = new MidList();
             string postData = string.Format("{{\"bid\":\"{0}\",\"mac\":\"{1}\"}}", order, pcmac);
             HttpHelper http = new HttpHelper();
             HttpItem item = new HttpItem()
             {
-                URL = url,//URL这里都是测试URl必需项
+                URL = url_getMessage,//URL这里都是测试URl必需项
                 Encoding = Encoding.UTF8,//编码格式(utf-8,gb2312,gbk)可选项 默认类会自动识别//Encoding = Encoding.Default,
                 Method = "post",
                 Postdata = postData,
@@ -88,12 +99,12 @@ namespace MOKA_Factory_Tools
             string ParseText = result.Html;
             if (result.StatusCode == System.Net.HttpStatusCode.OK)
             {
-                Log.WriteGetKeyLog("\r\nGet MID info\r\nUsing time:" + usingtime + "ms\r\n" + ParseText + "\r\nAddress:" + url + "\r\nPostdata:" + postData);
+                Log.WriteGetKeyLog("\r\nGet MID info\r\nUsing time:" + usingtime + "ms\r\n" + ParseText + "\r\nAddress:" + url_getMessage + "\r\nPostdata:" + postData);
             }
             else
             {
-                Log.WriteErrorLog("\r\nFail to GetMidInfo:" + result.StatusDescription + result.Html + "\r\nAddress:" + url + "\r\nPostdata:" + postData);
-                CommonMethod.ReportErrormsg("Fail to GetMidInfo", result.StatusDescription + result.Html + "\r\nAddress:" + url + "\r\nPostdata:" + postData, sqliteConn);
+                Log.WriteErrorLog("\r\nFail to GetMidInfo:" + result.StatusDescription + result.Html + "\r\nAddress:" + url_getMessage + "\r\nPostdata:" + postData);
+                CommonMethod.ReportErrormsg("Fail to GetMidInfo", result.StatusDescription + result.Html + "\r\nAddress:" + url_getMessage + "\r\nPostdata:" + postData, sqliteConn);
                 return false;
             }
 
@@ -141,8 +152,8 @@ namespace MOKA_Factory_Tools
             }
             catch (Exception ex)
             {
-                Log.WriteErrorLog("\r\nFail to parse MID info," + ex.Message + ":" + ParseText + "\r\nAddress:" + url + "\r\nPostdata:" + postData);
-                CommonMethod.ReportErrormsg("Fail to parse MID info", ex.Message + ":" + ParseText + "\r\nAddress:" + url + "\r\nPostdata:" + postData, sqliteConn);
+                Log.WriteErrorLog("\r\nFail to parse MID info," + ex.Message + ":" + ParseText + "\r\nAddress:" + url_getMessage + "\r\nPostdata:" + postData);
+                CommonMethod.ReportErrormsg("Fail to parse MID info", ex.Message + ":" + ParseText + "\r\nAddress:" + url_getMessage + "\r\nPostdata:" + postData, sqliteConn);
                 MessageBox.Show("Fail to parse MID info\r\n " + ex.Message);
             }
 

+ 6 - 2
FactoryTool_CShare/DAL/DAL_AMResult.cs

@@ -12,9 +12,11 @@ namespace MOKA_Factory_Tools.DAL
 {
     public class DAL_AMResult : BaseDAL
     {
-        public DAL_AMResult()
+        public DAL_AMResult(bool bMexican=false)
         {
             this.TableFieldNameString = "";
+            if (bMexican)
+                this.cps.SetConnectParameters(databaseServer:"10.138.96.109", databaseName: "IDOtherData", databaseAccount: "usr_rd", databasePassword: "Pa55W0rd4TMSA@202207#");
         }
 
 
@@ -259,9 +261,11 @@ namespace MOKA_Factory_Tools.DAL
 
     public class DAL_AMResult_TR : BaseDAL
     {
-        public DAL_AMResult_TR()
+        public DAL_AMResult_TR(bool bMexican = false)
         {
             this.TableFieldNameString = "";
+            if (bMexican)
+                this.cps.SetConnectParameters(databaseServer: "10.138.96.109", databaseName: "IDOtherData", databaseAccount: "usr_rd", databasePassword: "Pa55W0rd4TMSA@202207#");
         }
 
 

+ 6 - 2
FactoryTool_CShare/DAL/DAL_AMYields.cs

@@ -10,9 +10,11 @@ namespace MOKA_Factory_Tools.DAL
 {
     public class DAL_AMYields : BaseDAL
     {
-        public DAL_AMYields()
+        public DAL_AMYields(bool bMexican = false)
         {
             this.TableFieldNameString = "";
+            if (bMexican)
+                this.cps.SetConnectParameters(databaseServer: "10.138.96.109", databaseName: "IDOtherData", databaseAccount: "usr_rd", databasePassword: "Pa55W0rd4TMSA@202207#");
         }
 
 
@@ -180,9 +182,11 @@ namespace MOKA_Factory_Tools.DAL
 
     public class DAL_AMYields_TR : BaseDAL
     {
-        public DAL_AMYields_TR()
+        public DAL_AMYields_TR(bool bMexican = false)
         {
             this.TableFieldNameString = "";
+            if (bMexican)
+                this.cps.SetConnectParameters(databaseServer: "10.138.96.109", databaseName: "IDOtherData", databaseAccount: "usr_rd", databasePassword: "Pa55W0rd4TMSA@202207#");
         }
 
 

+ 4 - 0
FactoryTool_CShare/Models/StructList.cs

@@ -248,6 +248,10 @@ namespace MOKA_Factory_Tools
         public bool LeaveFactory { get; set; } = false;
         // 当SN连接2次抄写时提示,主要防止一个SN被扫描在2台机器上;
         public bool SNDoubleTips { get; set; } = false;
+        /// <summary>
+        /// 是否使用墨西哥;
+        /// </summary>
+        public bool Mexican { get; set; }  = false;
     }
 
     public enum KEY_FROM

+ 1 - 1
FactoryTool_CShare/Views/CreateDBManually.cs

@@ -38,7 +38,7 @@ namespace MOKA_Factory_Tools
             {
                 dbPath = AppDomain.CurrentDomain.BaseDirectory + "\\Keys\\" + Order_Text.Text.Trim() + ".db";
                 order = Order_Text.Text.Trim();
-                if (V2Method.GetMidInfo(url, order, TestMode.MAC, errorDBNow, out midList1))
+                if (V2Method.GetMidInfo(order, TestMode.MAC, errorDBNow, out midList1))
                 {
                     if (V2Method.GetOfflineData(midList1.host, order, errorDBNow, out List<MidAddress> midAddress2))
                     {

+ 9 - 3
FactoryTool_CShare/Views/Main.cs

@@ -105,7 +105,7 @@ namespace MOKA_Factory_Tools
         {
             SQLiteHelper.DeleteOldData(ErrorDB);//删除30天以前已经上报的数据
             if (TestMode.serverurl == Serverurl.Testurl)
-            {
+            {// 此软件连接测试服务器,请勿用于生产
                 MessageBoxButtons messButton = MessageBoxButtons.YesNo;
                 DialogResult dr = MessageBox.Show(LResource.TestServerUsingError, LResource.Error, messButton);
                 if (dr == DialogResult.Yes)
@@ -254,7 +254,7 @@ namespace MOKA_Factory_Tools
                     else
                     {
                         // 预绑定模式下:没有db数据库时需要下载json包;
-                        if (V2Method.GetMidInfo(TestMode.serverurl, OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out midList1))
+                        if (V2Method.GetMidInfo(OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out midList1))
                         {
                             if (V2Method.GetOfflineData(midList1.host, OrderText.Text.Trim(), ErrorDB, out List<MidAddress> midAddress2))
                             {
@@ -428,7 +428,7 @@ namespace MOKA_Factory_Tools
                 }
                 else
                 {
-                    if (V2Method.GetMidInfo(TestMode.serverurl, OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out midList1))
+                    if (V2Method.GetMidInfo(OrderText.Text.Trim(), TestMode.MAC, ErrorDB, out midList1))
                     {
                         CommonMethod.CheckKeyType(midList1.keytype, cfg_writedone, out key2Write);
                         OperationPanel.key2Write = key2Write;
@@ -710,6 +710,12 @@ namespace MOKA_Factory_Tools
                 functionSetting1.LeaveFactory = jObject["LeaveFactory"] == null ? false : jObject["LeaveFactory"].Value<bool>();
                 functionSetting1.SNDoubleTips = jObject["SNDoubleTips"] == null ? false : jObject["SNDoubleTips"].Value<bool>();
 
+                #region 是否启用墨西哥抄写
+                functionSetting1.Mexican = jObject["Mexican"] == null ? false : jObject["Mexican"].Value<bool>();
+                GMethod.SetMexicanConfig(functionSetting1.Mexican);
+                V2Method.SetMexicanConfig(functionSetting1.Mexican);
+                #endregion
+
                 // 导出日规acas与sn;
                 if (jObject["ExportSNACASID"] == null)
                 {

+ 1 - 1
FactoryTool_CShare/Views/OperationPanel.cs

@@ -102,7 +102,7 @@ namespace MOKA_Factory_Tools
             if (midListNow.rokuCustomer != null)
                 ProductMsg_Text.Text = "Roku:";
             if (functionSetting.NTF)
-                ntfBLL = new NTFBLL();
+                ntfBLL = new NTFBLL(functionSetting.Mexican);
         }
 
         /// <summary>