AbstractProcess.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using PTMedicalInsurance.Helper;
  4. using PTMedicalInsurance.Variables;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace PTMedicalInsurance.Business
  13. {
  14. abstract class AbstractProcess
  15. {
  16. protected CenterBusiness cBus = new CenterBusiness();
  17. protected HisMainBusiness hBus = new HisMainBusiness();
  18. protected HisIrisServices hIS = new HisIrisServices();
  19. protected MIIrisServices mIS = new MIIrisServices();
  20. protected InvokeHelper invoker = new InvokeHelper();
  21. protected string outParam = "";
  22. protected string errMsg = "";
  23. public JObject OrginalInput { set; get; }
  24. /// <summary>
  25. /// 使用原始参数
  26. /// </summary>
  27. public bool UseOrginal
  28. {
  29. get; set;
  30. }
  31. /// <summary>
  32. /// 合并原始参数
  33. /// </summary>
  34. public bool MergeOrginal
  35. {
  36. get; set;
  37. }
  38. /// <summary>
  39. /// 返回成功信息
  40. /// </summary>
  41. /// <returns></returns>
  42. protected CallResult Success()
  43. {
  44. return Success("成功");
  45. }
  46. protected CallResult Success(string msg)
  47. {
  48. Global.writeLog(this.GetType().Name, msg, outParam);
  49. return new CallResult(0, msg, outParam);
  50. }
  51. /// <summary>
  52. /// 返回失败信息
  53. /// </summary>
  54. /// <param name="code"></param>
  55. /// <param name="errMsg"></param>
  56. /// <returns></returns>
  57. protected CallResult Error(int code, string errMsg)
  58. {
  59. return Exception(code, errMsg, outParam);
  60. }
  61. /// <summary>
  62. /// 返回失败信息
  63. /// </summary>
  64. /// <param name="errMsg"></param>
  65. /// <returns></returns>
  66. protected CallResult Error()
  67. {
  68. return Error(-1, outParam);
  69. }
  70. protected CallResult Exception(int code, string errMsg, string param)
  71. {
  72. outParam = JsonHelper.setExceptionJson(code, errMsg, param).ToString();
  73. Global.writeLog(this.GetType().Name, errMsg, outParam);
  74. return new CallResult(code, errMsg, outParam, param);
  75. }
  76. protected CallResult Exception(string errMsg, string param)
  77. {
  78. return Exception(-1, errMsg, param);
  79. }
  80. protected CallResult Exception(string errMsg)
  81. {
  82. return Exception(-1, errMsg, outParam);
  83. }
  84. protected CallResult Exception()
  85. {
  86. return Exception(-1, "", outParam);
  87. }
  88. protected CallResult IrisReturn(string msg, JObject obj)
  89. {
  90. outParam = JsonHelper.setIrisReturnValue(0, msg, obj).ToString();
  91. return new CallResult(0, msg, outParam, obj);
  92. }
  93. /// <summary>
  94. /// 返回失败信息
  95. /// </summary>
  96. /// <param name="errMsg"></param>
  97. /// <returns></returns>
  98. //protected CallResult Error(string errMsg)
  99. //{
  100. // return new CallResult(-1, errMsg, outParam);
  101. //}
  102. /// <summary>
  103. /// 返回失败信息
  104. /// </summary>
  105. /// <param name="errMsg"></param>
  106. /// <returns></returns>
  107. protected CallResult Error(string errMsg)
  108. {
  109. return Error(-1, errMsg);
  110. }
  111. /// <summary>
  112. /// 业务过程
  113. /// </summary>
  114. /// <param name="input"></param>
  115. /// <returns></returns>
  116. public abstract CallResult Process(JObject input);
  117. }
  118. }