Dal.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using Core.Mes.Client.Comm;
  2. using Core.Mes.Client.Comm.Tool;
  3. using CoreFS.CA06;
  4. using System.Data;
  5. namespace Core.StlMes.Client.Qcm
  6. {
  7. public class Dal
  8. {
  9. private OpeBase _ob = null;
  10. public Dal(OpeBase ob)
  11. {
  12. _ob = ob;
  13. }
  14. public CoreProductManageSvr CoreProductManage
  15. {
  16. get
  17. {
  18. return new CoreProductManageSvr(_ob);
  19. }
  20. }
  21. }
  22. public class CoreProductManageSvr
  23. {
  24. private string _serverName = "com.steering.pss.qcm.CoreProductManage";
  25. private DalEntity _dal;
  26. public CoreProductManageSvr(OpeBase ob)
  27. {
  28. _dal = new DalEntity("com.steering.pss.qcm.CoreProductManage", ob);
  29. }
  30. public DataRow IsExistStdName(params object[] param)
  31. {
  32. return _dal.GetRow("IsExistStdName", param);
  33. }
  34. public void CopyStd(params object[] param)
  35. {
  36. _dal.Set("CopyStd", param);
  37. }
  38. }
  39. public class DalEntity
  40. {
  41. private string _serverName = "";
  42. private OpeBase _ob = null;
  43. public DalEntity(string serverName, OpeBase ob)
  44. {
  45. _serverName = serverName;
  46. _ob = ob;
  47. }
  48. public DataTable GetTable(string methodName, params object[] param)
  49. {
  50. CoreClientParam ccp = new CoreClientParam();
  51. ccp.ServerName = _serverName;
  52. ccp.MethodName = methodName;
  53. ccp.ServerParams = param;
  54. ccp = _ob.ExecuteSortResultByQueryToDataTable(ccp, CoreInvokeType.Internal);
  55. if (ccp == null)
  56. {
  57. throw new MESException("服务端处理失败!");
  58. }
  59. if (ccp.ReturnCode < 0)
  60. {
  61. throw new MESException("服务端处理失败!", ccp.ReturnCode, ccp.ReturnInfo);
  62. }
  63. return ccp.SourceDataTable;
  64. }
  65. public DataRow GetRow(string methodName, params object[] param)
  66. {
  67. DataTable dt = GetTable(methodName, param);
  68. if (dt.Rows.Count == 0)
  69. {
  70. return null;
  71. }
  72. else
  73. {
  74. return dt.Rows[0];
  75. }
  76. }
  77. public DataSourceList<T> GetData<T>(string methodName, params object[] param)
  78. {
  79. return EntityHelper.GetData<T>(_serverName + "." + methodName, param, _ob);
  80. }
  81. public object Set(string methodName, params object[] param)
  82. {
  83. CoreClientParam ccp = new CoreClientParam();
  84. ccp.ServerName = _serverName;
  85. ccp.MethodName = methodName;
  86. ccp.ServerParams = param;
  87. ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  88. if (ccp == null)
  89. {
  90. throw new MESException("服务端处理失败!");
  91. }
  92. if (ccp.ReturnCode < 0)
  93. {
  94. throw new MESException("服务端处理失败!", ccp.ReturnCode, ccp.ReturnInfo);
  95. }
  96. return ccp.ReturnObject;
  97. }
  98. }
  99. }