AbstractProcess.cs 2.6 KB

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