using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using CoreFS.CA06; using Core.Mes.Client.Comm; namespace Core.StlMes.Client.ZGMil.Common { /// /// 连接服务端数据处理类 /// public class ZGServerHelper { /// /// 从服务端查询数据(query) /// /// 服务端MethodId /// 参数数组,需与服务端方法参数一致 /// 界面OB对象 /// 自定义异常 /// 查询数据集 public static DataTable GetData(string methodId, object[] param, OpeBase ob) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = methodId.Substring(0, methodId.LastIndexOf(".")); ccp.MethodName = methodId.Substring(methodId.LastIndexOf(".") + 1); ccp.ServerParams = param; ccp = ob.ExecuteSortResultByQueryToDataTable(ccp, CoreInvokeType.Internal); if (ccp == null) { throw new MESException("服务端处理失败!"); } //if (ccp.ReturnCode < 0) //{ // throw new MESException("服务端处理失败!", ccp.ReturnCode, ccp.ReturnInfo); //} return ccp.SourceDataTable; } /// /// 向服务端设置数据(insert、update、delete、procedure) /// /// 服务端MethodId /// 参数数组,需与服务端方法参数一致 /// 界面OB对象 /// 自定义异常 /// count处理数据行数,0 or -num表示失败 public static int SetData(string methodId, object[] param, OpeBase ob) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = methodId.Substring(0, methodId.LastIndexOf(".")); ccp.MethodName = methodId.Substring(methodId.LastIndexOf(".") + 1); ccp.ServerParams = param; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp == null) { throw new MESException("服务端处理失败!"); } if (ccp.ReturnCode < 0) { throw new MESException("服务端处理失败!", ccp.ReturnCode, ccp.ReturnInfo); } int count = 0; if (!int.TryParse(ccp.ReturnObject.ToString(), out count)) { throw new MESException("服务端处理成功,但返回处理数量不是数字!"); } return count; } /// /// 向服务端设置数据(insert、update、delete、procedure) /// /// 服务端MethodId /// 参数数组,需与服务端方法参数一致 /// 界面OB对象 /// 自定义异常 /// 返回服务端的setResult中的数据 public static object SetDataReturnObj(string methodId, object[] param, OpeBase ob) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = methodId.Substring(0, methodId.LastIndexOf(".")); ccp.MethodName = methodId.Substring(methodId.LastIndexOf(".") + 1); ccp.ServerParams = param; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp == null) { throw new MESException("服务端处理失败!"); } if (ccp.ReturnCode < 0) { throw new MESException("服务端处理失败!", ccp.ReturnCode, ccp.ReturnInfo); } return ccp.ReturnObject; } } }