AbstractProcess.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. /// <returns></returns>
  35. protected CallResult Success()
  36. {
  37. return Success("成功");
  38. }
  39. protected CallResult Success(string msg)
  40. {
  41. Global.writeLog(this.GetType().Name, msg, outParam);
  42. return new CallResult(0, msg, outParam);
  43. }
  44. /// <summary>
  45. /// 返回失败信息
  46. /// </summary>
  47. /// <param name="code"></param>
  48. /// <param name="errMsg"></param>
  49. /// <returns></returns>
  50. protected CallResult Error(int code, string errMsg)
  51. {
  52. return Exception(code, errMsg, outParam);
  53. }
  54. protected CallResult Exception(int code, string errMsg, string param)
  55. {
  56. outParam = JsonHelper.setExceptionJson(code, errMsg, param).ToString();
  57. Global.writeLog(this.GetType().Name, errMsg, outParam);
  58. return new CallResult(code, errMsg, outParam, param);
  59. }
  60. protected CallResult Exception(string errMsg, string param)
  61. {
  62. return Exception(-1, errMsg, param);
  63. }
  64. protected CallResult IrisReturn(string msg, JObject obj)
  65. {
  66. outParam = JsonHelper.setIrisReturnValue(0, msg, obj).ToString();
  67. return new CallResult(0, msg, outParam, obj);
  68. }
  69. /// <summary>
  70. /// 返回失败信息
  71. /// </summary>
  72. /// <param name="errMsg"></param>
  73. /// <returns></returns>
  74. protected CallResult Error(string errMsg)
  75. {
  76. return new CallResult(-1, errMsg, outParam);
  77. }
  78. /// <summary>
  79. /// 业务过程
  80. /// </summary>
  81. /// <param name="input"></param>
  82. /// <returns></returns>
  83. public abstract CallResult Process(JObject input);
  84. }
  85. }