AbstractProcess.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using Newtonsoft.Json.Linq;
  2. using PTMedicalInsurance.Entity;
  3. using PTMedicalInsurance.Helper;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace PTMedicalInsurance.Business
  10. {
  11. abstract class AbstractProcess
  12. {
  13. protected CenterBusiness cBus = new CenterBusiness();
  14. protected HisMainBusiness hBus = new HisMainBusiness();
  15. protected HisIrisServices hIS = new HisIrisServices();
  16. protected MIIrisServices mIS = new MIIrisServices();
  17. protected InvokeHelper invoker = new InvokeHelper();
  18. protected string outParam = "";
  19. public JObject OrginalInput { set; get; }
  20. /// <summary>
  21. /// 使用原始参数
  22. /// </summary>
  23. public bool UseOrginal {
  24. get;set;
  25. }
  26. /// <summary>
  27. /// 返回成功信息
  28. /// </summary>
  29. /// <returns></returns>
  30. protected CallResult Success()
  31. {
  32. return Success("成功");
  33. }
  34. protected CallResult Success(string msg)
  35. {
  36. return new CallResult(0, msg, outParam);
  37. }
  38. /// <summary>
  39. /// 解析中心返回结果
  40. /// </summary>
  41. /// <param name="outData"></param>
  42. /// <param name="re"></param>
  43. /// <returns></returns>
  44. protected CallResult Parse(string outData)
  45. {
  46. BaseResult br = JsonHelper.toObject<BaseResult>(JObject.Parse(outData));
  47. return new CallResult(br.infcode, br.err_msg, br.output.ToString(), outData);
  48. }
  49. protected CallResult Parse(JObject outData)
  50. {
  51. return Parse(outData.ToString());
  52. }
  53. /// <summary>
  54. /// 返回失败信息
  55. /// </summary>
  56. /// <param name="code"></param>
  57. /// <param name="errMsg"></param>
  58. /// <returns></returns>
  59. protected CallResult Error(int code, string errMsg)
  60. {
  61. return Exception(code, errMsg, outParam);
  62. }
  63. protected CallResult Exception(int code, string errMsg,string param)
  64. {
  65. outParam = JsonHelper.setExceptionJson(code, errMsg, param).ToString();
  66. return new CallResult(code, errMsg, outParam,param);
  67. }
  68. protected CallResult Exception(string errMsg, string param)
  69. {
  70. return Exception(-1, errMsg, param);
  71. }
  72. protected CallResult IrisReturn(string msg,JObject obj)
  73. {
  74. outParam = JsonHelper.setIrisReturnValue(0, msg, obj).ToString();
  75. return new CallResult(0, msg, outParam,obj);
  76. }
  77. /// <summary>
  78. /// 返回失败信息
  79. /// </summary>
  80. /// <param name="errMsg"></param>
  81. /// <returns></returns>
  82. protected CallResult Error(string errMsg)
  83. {
  84. return new CallResult(-1, errMsg, outParam);
  85. }
  86. /// <summary>
  87. /// 业务过程
  88. /// </summary>
  89. /// <param name="input"></param>
  90. /// <returns></returns>
  91. public abstract CallResult Process(JObject input);
  92. }
  93. }