using Common.system; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace XHZB.DAL { public class Class1 { /// /// API请求地址 /// private string APIRequestAddress = FileToolsCommon.GetConfigValue("APIRequestAddress"); /// /// 文件请求地址 /// private string FileRequestAddress = FileToolsCommon.GetConfigValue("FileRequestAddress"); /// /// 测试 /// /// /// public bool test( string FileCode, out string Message) { Exception ex = null; Message = "";//请求重试5次 共5秒 for (int num = 0; num < 5; num++) { try { JObject jo = HttpHelper.PostFunction(FileRequestAddress + @"/chunkdb/mergechunk", @"application/x-www-form-urlencoded", @"identifier=" + FileCode, ""); if (jo == null) { Message = "无法访问文件服务器,请检查网络或文件服务器地址。"; return false; } //string retString = ""; //JObject.Parse(retString); //string str = jo["c"].ToString(); //Model.ResultVo resultObj = JsonHelper.JsonToObj>(jo.ToString()); //APP.ResourceAddTwo = new Model_ResourceAddTwo(); ////0成功,1失败 //if (resultObj.code == 0 && resultObj.obj != null) //{ // APP.ResourceAddTwo = resultObj.obj; // return true; //} //else //{ // //Message = "上传失败!"; // Message = jo["msg"].ToString(); // return false; //} } catch (Exception e) { Message = e.Message; ex = e; Thread.Sleep(1000); } } string ErrMessage = "【请求失败】(test):请求失败。" + Message; LogHelper.WriteErrLog(ErrMessage, ex); return false; } } }