星火直播PC
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Class1.cs 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using Common.system;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading;
  8. using System.Threading.Tasks;
  9. namespace XHZB.DAL
  10. {
  11. public class Class1
  12. {
  13. /// <summary>
  14. /// API请求地址
  15. /// </summary>
  16. private string APIRequestAddress = FileToolsCommon.GetConfigValue("APIRequestAddress");
  17. /// <summary>
  18. /// 文件请求地址
  19. /// </summary>
  20. private string FileRequestAddress = FileToolsCommon.GetConfigValue("FileRequestAddress");
  21. /// <summary>
  22. /// 测试
  23. /// </summary>
  24. /// <param name="Message"></param>
  25. /// <returns></returns>
  26. public bool test( string FileCode, out string Message)
  27. {
  28. Exception ex = null;
  29. Message = "";//请求重试5次 共5秒
  30. for (int num = 0; num < 5; num++)
  31. {
  32. try
  33. {
  34. JObject jo = HttpHelper.PostFunction(FileRequestAddress + @"/chunkdb/mergechunk", @"application/x-www-form-urlencoded", @"identifier=" + FileCode, "");
  35. if (jo == null)
  36. {
  37. Message = "无法访问文件服务器,请检查网络或文件服务器地址。";
  38. return false;
  39. }
  40. //string retString = "";
  41. //JObject.Parse(retString);
  42. //string str = jo["c"].ToString();
  43. //Model.ResultVo<Model_ResourceAddTwo> resultObj = JsonHelper.JsonToObj<Model.ResultVo<Model_ResourceAddTwo>>(jo.ToString());
  44. //APP.ResourceAddTwo = new Model_ResourceAddTwo();
  45. ////0成功,1失败
  46. //if (resultObj.code == 0 && resultObj.obj != null)
  47. //{
  48. // APP.ResourceAddTwo = resultObj.obj;
  49. // return true;
  50. //}
  51. //else
  52. //{
  53. // //Message = "上传失败!";
  54. // Message = jo["msg"].ToString();
  55. // return false;
  56. //}
  57. }
  58. catch (Exception e)
  59. {
  60. Message = e.Message;
  61. ex = e;
  62. Thread.Sleep(1000);
  63. }
  64. }
  65. string ErrMessage = "【请求失败】(test):请求失败。" + Message;
  66. LogHelper.WriteErrLog(ErrMessage, ex);
  67. return false;
  68. }
  69. }
  70. }