123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- 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
- {
- /// <summary>
- /// API请求地址
- /// </summary>
- private string APIRequestAddress = FileToolsCommon.GetConfigValue("APIRequestAddress");
- /// <summary>
- /// 文件请求地址
- /// </summary>
- private string FileRequestAddress = FileToolsCommon.GetConfigValue("FileRequestAddress");
- /// <summary>
- /// 测试
- /// </summary>
- /// <param name="Message"></param>
- /// <returns></returns>
- 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<Model_ResourceAddTwo> resultObj = JsonHelper.JsonToObj<Model.ResultVo<Model_ResourceAddTwo>>(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;
- }
- }
- }
|