|
@@ -14,8 +14,9 @@ namespace MOKA_Factory_Tools
|
|
|
{
|
|
|
public static SanhuaMESLoginInfo sanhuaLoginInfo = new SanhuaMESLoginInfo();
|
|
|
|
|
|
- public static bool CheckLogin()
|
|
|
+ public static bool CheckLogin(out string message)
|
|
|
{
|
|
|
+ message = string.Empty;
|
|
|
HttpHelper http = new HttpHelper();
|
|
|
HttpItem item = new HttpItem() {URL = sanhuaLoginInfo.url + "api/MESTestCollect/CheckLogin", Encoding = Encoding.UTF8,Method = "post", PostEncoding = Encoding.UTF8, KeepAlive = false};
|
|
|
item.ContentType = "application/json;charset=utf-8";
|
|
@@ -28,22 +29,33 @@ namespace MOKA_Factory_Tools
|
|
|
}
|
|
|
|
|
|
string ParseText = result.Html;
|
|
|
+ Log.WriteInfoLog(string.Format("CheckLogin Html:{0}", result.Html));
|
|
|
|
|
|
try
|
|
|
{
|
|
|
JObject jObject = JObject.Parse(ParseText);
|
|
|
+ bool success = jObject["success"].Value<bool>();
|
|
|
+ message = jObject["message"].Value<string>();
|
|
|
+
|
|
|
+ if (!success)
|
|
|
+ {
|
|
|
+ Log.WriteErrorLog(string.Format("CheckLogin Error:{0}", message));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
- catch (Exception)
|
|
|
+ catch (Exception e)
|
|
|
{
|
|
|
-
|
|
|
- throw;
|
|
|
+ message = e.Message;
|
|
|
+ Log.WriteErrorLog(string.Format("CheckLogin Error:{0}", e.Message));
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public static bool ProductRouteCheck(string productSN)
|
|
|
+ public static bool ProductRouteCheck(string productSN, out string message)
|
|
|
{
|
|
|
+ message = string.Empty;
|
|
|
HttpHelper http = new HttpHelper();
|
|
|
HttpItem item = new HttpItem() { URL = sanhuaLoginInfo.url + "api/MESTestCollect/ProductRouteCheck", Encoding = Encoding.UTF8, Method = "post", PostEncoding = Encoding.UTF8, KeepAlive = false };
|
|
|
item.ContentType = "application/json;charset=utf-8";
|
|
@@ -57,26 +69,37 @@ namespace MOKA_Factory_Tools
|
|
|
}
|
|
|
|
|
|
string ParseText = result.Html;
|
|
|
+ Log.WriteInfoLog(string.Format("ProductRouteCheck Html:{0}", result.Html));
|
|
|
|
|
|
try
|
|
|
{
|
|
|
JObject jObject = JObject.Parse(ParseText);
|
|
|
+ bool success = jObject["success"].Value<bool>();
|
|
|
+ message = jObject["message"].Value<string>();
|
|
|
+
|
|
|
+ if (!success)
|
|
|
+ {
|
|
|
+ Log.WriteErrorLog(string.Format("ProductRouteCheck Error:{0}", message));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
- catch (Exception)
|
|
|
+ catch (Exception e)
|
|
|
{
|
|
|
-
|
|
|
- throw;
|
|
|
+ message = e.Message;
|
|
|
+ Log.WriteErrorLog(string.Format("ProductRouteCheck Error:{0}", e.Message));
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public static bool UploadIdcData(string productSN, string acasId)
|
|
|
+ public static bool UploadIdcData(string productSN, string acasId, out string message)
|
|
|
{
|
|
|
+ message = string.Empty;
|
|
|
HttpHelper http = new HttpHelper();
|
|
|
HttpItem item = new HttpItem() { URL = sanhuaLoginInfo.url + "api/MESTestCollect/UploadIdcData", Encoding = Encoding.UTF8, Method = "post", PostEncoding = Encoding.UTF8, KeepAlive = false };
|
|
|
item.ContentType = "application/json;charset=utf-8";
|
|
|
- item.Postdata = string.Format("{{\"jigEdition\":\"{0}\",\"resourceCode\":\"{1}\",\"staffCode\":\"{2}\",\"productSN\":\"{3}\",\"attr\":\"{{\"ACASID\",\"{4}\"}}\"}}",
|
|
|
+ item.Postdata = string.Format("{{\"jigEdition\":\"{0}\",\"resourceCode\":\"{1}\",\"staffCode\":\"{2}\",\"productSN\":\"{3}\",\"attr\":\"{{\"ACASID\":\"{4}\"}}\"}}",
|
|
|
sanhuaLoginInfo.jigEdtion, sanhuaLoginInfo.resourceCode, sanhuaLoginInfo.staffCode, productSN, acasId);
|
|
|
HttpResult result = http.GetHtml(item);
|
|
|
if (result.StatusCode != System.Net.HttpStatusCode.OK)
|
|
@@ -86,22 +109,33 @@ namespace MOKA_Factory_Tools
|
|
|
}
|
|
|
|
|
|
string ParseText = result.Html;
|
|
|
+ Log.WriteInfoLog(string.Format("UploadIdcData Html:{0}", result.Html));
|
|
|
|
|
|
try
|
|
|
{
|
|
|
JObject jObject = JObject.Parse(ParseText);
|
|
|
+ bool success = jObject["success"].Value<bool>();
|
|
|
+ message = jObject["message"].Value<string>();
|
|
|
+
|
|
|
+ if (!success)
|
|
|
+ {
|
|
|
+ Log.WriteErrorLog(string.Format("UploadIdcData Error:{0}", message));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
- catch (Exception)
|
|
|
+ catch (Exception e)
|
|
|
{
|
|
|
-
|
|
|
- throw;
|
|
|
+ message = e.Message;
|
|
|
+ Log.WriteErrorLog(string.Format("UploadIdcData Error:{0}", e.Message));
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public static bool ProductMoveNext(string productSN, string result, string defectCode)
|
|
|
+ public static bool ProductMoveNext(string productSN, string result, string defectCode, out string message)
|
|
|
{
|
|
|
+ message = string.Empty;
|
|
|
HttpHelper http = new HttpHelper();
|
|
|
HttpItem item = new HttpItem() { URL = sanhuaLoginInfo.url + "api/MESTestCollect/ProductMoveNext", Encoding = Encoding.UTF8, Method = "post", PostEncoding = Encoding.UTF8, KeepAlive = false };
|
|
|
item.ContentType = "application/json;charset=utf-8";
|
|
@@ -115,15 +149,25 @@ namespace MOKA_Factory_Tools
|
|
|
}
|
|
|
|
|
|
string ParseText = hResult.Html;
|
|
|
+ Log.WriteInfoLog(string.Format("ProductMoveNext Html:{0}", hResult.Html));
|
|
|
|
|
|
try
|
|
|
{
|
|
|
JObject jObject = JObject.Parse(ParseText);
|
|
|
+ bool success = jObject["success"].Value<bool>();
|
|
|
+ message = jObject["message"].Value<string>();
|
|
|
+
|
|
|
+ if (!success)
|
|
|
+ {
|
|
|
+ Log.WriteErrorLog(string.Format("ProductMoveNext Error:{0}", message));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
- catch (Exception)
|
|
|
+ catch (Exception e)
|
|
|
{
|
|
|
-
|
|
|
- throw;
|
|
|
+ message = e.Message;
|
|
|
+ Log.WriteErrorLog(string.Format("ProductMoveNext Error:{0}", e.Message));
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
return true;
|