AbstractProcess.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. protected CallResult Exception(int code, string errMsg, string param)
  62. {
  63. outParam = JsonHelper.setExceptionJson(code, errMsg, param).ToString();
  64. Global.writeLog(this.GetType().Name, errMsg, outParam);
  65. return new CallResult(code, errMsg, outParam, param);
  66. }
  67. protected CallResult Exception(string errMsg, string param)
  68. {
  69. return Exception(-1, errMsg, param);
  70. }
  71. protected CallResult Exception(string errMsg)
  72. {
  73. return Exception(-1, errMsg, outParam);
  74. }
  75. protected CallResult Exception()
  76. {
  77. return Exception(-1, "", outParam);
  78. }
  79. protected CallResult IrisReturn(string msg, JObject obj)
  80. {
  81. outParam = JsonHelper.setIrisReturnValue(0, msg, obj).ToString();
  82. return new CallResult(0, msg, outParam, obj);
  83. }
  84. /// <summary>
  85. /// 返回失败信息
  86. /// </summary>
  87. /// <param name="errMsg"></param>
  88. /// <returns></returns>
  89. protected CallResult Error(string errMsg)
  90. {
  91. return new CallResult(-1, errMsg, outParam);
  92. }
  93. /// <summary>
  94. /// 业务过程
  95. /// </summary>
  96. /// <param name="input"></param>
  97. /// <returns></returns>
  98. public abstract CallResult Process(JObject input);
  99. }
  100. }