GetIndustryJsonResult.cs 2.7 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. /// GetIndustryJsonResult
  24. /// </summary>
  25. public class GetIndustryJsonResult : WxJsonResult
  26. {
  27. /// <summary>
  28. /// 帐号设置的主营行业
  29. /// </summary>
  30. public GetIndustry_Item primary_industry { get; set; }
  31. /// <summary>
  32. /// 帐号设置的副营行业
  33. /// </summary>
  34. public GetIndustry_Item secondary_industry { get; set; }
  35. }
  36. /// <summary>
  37. /// GetIndustry_Item
  38. /// </summary>
  39. public class GetIndustry_Item
  40. {
  41. /// <summary>
  42. /// 主行业
  43. /// </summary>
  44. public string first_class { get; set; }
  45. /// <summary>
  46. /// 副行业
  47. /// </summary>
  48. public string second_class { get; set; }
  49. /// <summary>
  50. /// 将当前对象转成IndustryCode
  51. /// </summary>
  52. /// <param name="item"></param>
  53. /// <returns></returns>
  54. public IndustryCode ConvertToIndustryCode()
  55. {
  56. var enumName = string.Format("{0}_{1}", first_class,
  57. second_class.Replace("|", "_").Replace("/", "_"));
  58. IndustryCode code;
  59. #if NET35
  60. try
  61. {
  62. code = (IndustryCode)Enum.Parse(typeof(IndustryCode), enumName, true);
  63. }
  64. catch
  65. {
  66. return IndustryCode.其它_其它;//没有成功,此处也可以抛出异常
  67. }
  68. #else
  69. if (!Enum.TryParse(enumName,true,out code))
  70. {
  71. return IndustryCode.其它_其它;//没有成功,此处也可以抛出异常
  72. }
  73. #endif
  74. return code;
  75. }
  76. }
  77. }