UrlFileKeyParse.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:UrlFileKeyParse
  3. * 作者:xulisong
  4. * 创建时间: 2019/4/28 10:26:25
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using FirmHttpDao;
  13. using Newtonsoft.Json;
  14. using SAGA.DotNetUtils.Data;
  15. namespace Com.FirmLib.UI
  16. {
  17. public class UrlFileKeyParse
  18. {
  19. /// <summary>
  20. /// 创建文件key
  21. /// </summary>
  22. /// <param name="urlFile"></param>
  23. /// <returns></returns>
  24. public static string CreatKey(UrlFile urlFile)
  25. {
  26. if (urlFile == null)
  27. return string.Empty;
  28. return JsonConvert.SerializeObject(urlFile);
  29. }
  30. /// <summary>
  31. /// 解析文件key
  32. /// </summary>
  33. /// <param name="urlKey"></param>
  34. /// <returns></returns>
  35. public static UrlFile ParseKey(string urlKey)
  36. {
  37. UrlFile urlFile = null;
  38. try
  39. {
  40. urlFile = JsonConvert.DeserializeObject<UrlFile>(urlKey);
  41. }
  42. catch (Exception)
  43. {
  44. }
  45. if (urlFile == null)
  46. {
  47. urlFile = new UrlFile();
  48. urlFile.FileType = "image";
  49. urlFile.Key = urlKey;
  50. urlFile.SystemId = BllHttpSetting.Instance.Default.SystemId;
  51. }
  52. return urlFile;
  53. }
  54. /// <summary>
  55. /// 创建UrlFile文件
  56. /// </summary>
  57. /// <param name="fileKey"></param>
  58. /// <returns></returns>
  59. public static UrlFile CreateImageUrlFile(string fileKey)
  60. {
  61. UrlFile urlFile = new UrlFile();
  62. urlFile.FileType = "image";
  63. urlFile.Key = fileKey;
  64. urlFile.SystemId = BllHttpSetting.Instance.Default.SystemId;
  65. return urlFile;
  66. }
  67. }
  68. }