|
@@ -1934,61 +1934,41 @@ namespace MOKA_Factory_Tools
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static bool GetFireTVDsn(string ordernum, string deviceCode, string FSN, string PSN, out string dsn, out string error, SQLiteConnection errorDBNow)
|
|
|
+ public static bool GetFireTVDsn(string url, string ordernum, string deviceCode, string FSN, string PSN, out string dsn, out string error, SQLiteConnection errorDBNow)
|
|
|
{
|
|
|
dsn = "";
|
|
|
error = "";
|
|
|
HttpHelper http = new HttpHelper();
|
|
|
HttpItem item = new HttpItem()
|
|
|
{
|
|
|
- Encoding = Encoding.Default,
|
|
|
- Method = "post",
|
|
|
- ContentType = "application/json;charset=utf-8",
|
|
|
+ Encoding = null, // 编码格式(utf-8,gb2312,gbk)可选项 默认类会自动识别Encoding = Encoding.Default,
|
|
|
+ Method = "GET", // URL 可选项 默认为Get
|
|
|
KeepAlive = false
|
|
|
};
|
|
|
- item.URL = TestMode.fireTVDsnUrl+ "getNewFiretvDsn.do?";
|
|
|
- item.Postdata = JsonConvert.SerializeObject(new FireTVDsnInput { ordernum = ordernum, fsn = FSN, psn = PSN, mac = TestMode.MAC, deviceCode = deviceCode });
|
|
|
+
|
|
|
+ item.URL = string.Format("{0}/getFiretvDsn.do?ordernum={1}&fsn={2}&psn={3}&deviceCode={4}&mac={5}", url, ordernum, FSN, PSN, deviceCode, HttpUtility.UrlEncode(TestMode.MAC));
|
|
|
HttpResult result = http.GetHtml(item);
|
|
|
if (result.StatusCode == System.Net.HttpStatusCode.OK)
|
|
|
{
|
|
|
+ string code;
|
|
|
+ string desc;
|
|
|
Log.WriteGetKeyLog("\r\nGetFireTVDsn :\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
|
|
|
- try
|
|
|
+ if (Xmlconfig.GetDSNXml(result.Html, "response", out code, out desc, out dsn))
|
|
|
{
|
|
|
- JObject o = JObject.Parse(result.Html);
|
|
|
- if (o["code"].ToString() == "200")
|
|
|
- {
|
|
|
- if (o["dsn"] != null)
|
|
|
- {
|
|
|
- dsn = o["dsn"].ToString();
|
|
|
- Log.WriteGetKeyLog("\r\nDSN=" + dsn);
|
|
|
- return true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- error = "error:dsn is null!";
|
|
|
- CommonMethod.ReportErrormsg("GetFireTVDsn error", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- error = o["message"].ToString();
|
|
|
- CommonMethod.ReportErrormsg("GetFireTVDsn error", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
|
|
|
- return false;
|
|
|
- }
|
|
|
+ Log.WriteGetKeyLog("\r\nDSN=" + dsn);
|
|
|
+ return true;
|
|
|
}
|
|
|
- catch(Exception ex)
|
|
|
+ else
|
|
|
{
|
|
|
- error = ex.Message;
|
|
|
- Log.WriteErrorLog("\r\nParse FireTVDsn error :\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html + "\r\n" + ex.Message);
|
|
|
- CommonMethod.ReportErrormsg("Parse FireTVDsn error", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
|
|
|
+ error = desc;
|
|
|
+ CommonMethod.ReportErrormsg("GetFireTVDsn error", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL, errorDBNow);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
error = "Communication with server failed";
|
|
|
- CommonMethod.ReportErrormsg("GetFireTVDsn error", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
|
|
|
+ CommonMethod.ReportErrormsg("GetFireTVDsn error", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL, errorDBNow);
|
|
|
return false;
|
|
|
}
|
|
|
}
|