AbstractProcess.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. outParam = JsonHelper.setIrisReturnValue(0, msg, obj).ToString();
  59. return new CallResult(0, msg, outParam);
  60. }
  61. /// <summary>
  62. /// 返回失败信息
  63. /// </summary>
  64. /// <param name="errMsg"></param>
  65. /// <returns></returns>
  66. protected CallResult Error(string errMsg)
  67. {
  68. return new CallResult(-1, errMsg, outParam);
  69. }
  70. /// <summary>
  71. /// 业务过程
  72. /// </summary>
  73. /// <param name="input"></param>
  74. /// <returns></returns>
  75. public abstract CallResult Process(JObject input);
  76. }
  77. }