|
@@ -7,6 +7,8 @@ using System.Collections.Generic;
|
|
|
using System.Data.SQLite;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
+using System.Runtime.CompilerServices;
|
|
|
+using System.Security.Policy;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
@@ -24,6 +26,7 @@ namespace MOKA_Factory_Tools
|
|
|
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=";
|
|
|
private static string url_getMainBoardPSNWithSN = "http://smes-app-prod.tclking.com:9006/api/xm/GetXMTVParts?TVSN=";
|
|
|
+ private static string url_getTVInfo = "http://smes-app-prod.tclking.com:9006/api/PE/GetTVInfo?sn=";
|
|
|
|
|
|
public static void SetMexicanConfig(bool bMexican=false)
|
|
|
{
|
|
@@ -32,10 +35,72 @@ namespace MOKA_Factory_Tools
|
|
|
url_MaInfo = "http://SMES.TMSA.MX:9002/SAPService.asmx";
|
|
|
url_ReportKey = "http://SMES.TMSA.MX/FireTVApi/api/SMESMX/RecordKey";
|
|
|
url_getOrderProductStatus = "http://SMES.TMSA.MX/FireTVApi/api/SMESMX/getOrderProductStatus?sn=";
|
|
|
+ url_getTVInfo = "http://SMES.TMSA.MX:9006/api/PE/GetTVInfo?sn=";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static bool GetMaInfo(string sn, string order, out MaInfo maInfo, SQLiteConnection errorDBNow)
|
|
|
+ {
|
|
|
+ if (GetMaInfoBySAP(sn, order, out maInfo, errorDBNow))
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return GetMaInfoByMES(sn, order, out maInfo, errorDBNow);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static bool GetMaInfoByMES(string sn, string order, out MaInfo maInfo, SQLiteConnection errorDBNow)
|
|
|
+ {
|
|
|
+ maInfo = null;
|
|
|
+ if (s_maInfo != null && s_maInfo.ODF.Equals(order, StringComparison.InvariantCultureIgnoreCase))
|
|
|
+ {
|
|
|
+ maInfo = s_maInfo;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ HttpHelper http = new HttpHelper();
|
|
|
+ HttpItem item = new HttpItem()
|
|
|
+ {
|
|
|
+ URL = url_getTVInfo + sn,
|
|
|
+ Encoding = Encoding.UTF8,
|
|
|
+ Method = "get",
|
|
|
+ PostEncoding = Encoding.UTF8,
|
|
|
+ KeepAlive = false
|
|
|
+ };
|
|
|
+ item.ContentType = "application/x-www-form-urlencoded";
|
|
|
+ HttpResult hResult = http.GetHtml(item);
|
|
|
+ if (hResult.StatusCode == System.Net.HttpStatusCode.OK)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ using (JsonTextReader reader = new JsonTextReader(new StringReader(hResult.Html)))
|
|
|
+ {
|
|
|
+ JObject jObject = (JObject)JToken.ReadFrom(reader);
|
|
|
+ reader.Close();
|
|
|
+
|
|
|
+ maInfo.ODF = jObject["ODF"].Value<string>();
|
|
|
+ maInfo.BOM = jObject["ProductCode"].Value<string>();
|
|
|
+ maInfo.Model = jObject["ProductName"].Value<string>().Split('/')[1];
|
|
|
+ maInfo.SIZE = maInfo.Model.Substring(0, 3);
|
|
|
+ Log.WriteInfoLog("GetMaInfoByMES:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
|
|
|
+ s_maInfo = maInfo;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ Log.WriteErrorLog("GetMaInfoByMES error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log.WriteInfoLog("GetMaInfoByMES error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static bool GetMaInfoBySAP(string sn, string order, out MaInfo maInfo, SQLiteConnection errorDBNow)
|
|
|
{
|
|
|
string desc;
|
|
|
maInfo = null;
|
|
@@ -188,7 +253,7 @@ namespace MOKA_Factory_Tools
|
|
|
catch (Exception)
|
|
|
{
|
|
|
Log.WriteErrorLog("ReportDataBurningResultToMES error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
|
|
|
- throw;
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
else
|