GetPrivateTemplateJsonResult.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #region Apache License Version 2.0
  2. /*----------------------------------------------------------------
  3. Copyright 2019 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
  4. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
  5. except in compliance with the License. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software distributed under the
  8. License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  9. either express or implied. See the License for the specific language governing permissions
  10. and limitations under the License.
  11. Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md
  12. ----------------------------------------------------------------*/
  13. #endregion Apache License Version 2.0
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Linq;
  17. using System.Text;
  18. using System.Threading.Tasks;
  19. using Senparc.Weixin.Entities;
  20. namespace Senparc.Weixin.MP.AdvancedAPIs.TemplateMessage
  21. {
  22. /// <summary>
  23. /// GetPrivateTemplateJsonResult
  24. /// </summary>
  25. public class GetPrivateTemplateJsonResult : WxJsonResult
  26. {
  27. public List<GetPrivateTemplate_TemplateItem> template_list { get; set; }
  28. }
  29. public class GetPrivateTemplate_TemplateItem
  30. {
  31. /// <summary>
  32. /// 模板ID
  33. /// </summary>
  34. public string template_id { get; set; }
  35. /// <summary>
  36. /// 模板标题
  37. /// </summary>
  38. public string title { get; set; }
  39. /// <summary>
  40. /// 模板所属行业的一级行业
  41. /// </summary>
  42. public string primary_industry { get; set; }
  43. /// <summary>
  44. /// 模板所属行业的二级行业
  45. /// </summary>
  46. public string deputy_industry { get; set; }
  47. /// <summary>
  48. /// 模板内容
  49. /// </summary>
  50. public string content { get; set; }
  51. /// <summary>
  52. /// 模板示例
  53. /// </summary>
  54. public string example { get; set; }
  55. public IndustryCode ConvertToIndustryCode()
  56. {
  57. var enumName = string.Format("{0}_{1}", primary_industry,
  58. deputy_industry.Replace("|", "_").Replace("/", "_"));
  59. IndustryCode code;
  60. #if NET35
  61. try
  62. {
  63. code = (IndustryCode)Enum.Parse(typeof(IndustryCode), enumName, true);
  64. }
  65. catch
  66. {
  67. return IndustryCode.其它_其它;//没有成功,此处也可以抛出异常
  68. }
  69. #else
  70. if (!Enum.TryParse(enumName,true,out code))
  71. {
  72. return IndustryCode.其它_其它;//没有成功,此处也可以抛出异常
  73. }
  74. #endif
  75. return code;
  76. }
  77. }
  78. }