| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- 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
- {
- /// <summary>
- /// 连接服务端数据处理类
- /// </summary>
- public class ZGServerHelper
- {
- /// <summary>
- /// 从服务端查询数据(query)
- /// </summary>
- /// <param name="methodId">服务端MethodId</param>
- /// <param name="param">参数数组,需与服务端方法参数一致</param>
- /// <param name="ob">界面OB对象</param>
- /// <exception cref="MESException">自定义异常</exception>
- /// <returns>查询数据集</returns>
- 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;
- }
- /// <summary>
- /// 向服务端设置数据(insert、update、delete、procedure)
- /// </summary>
- /// <param name="methodId">服务端MethodId</param>
- /// <param name="param">参数数组,需与服务端方法参数一致</param>
- /// <param name="ob">界面OB对象</param>
- /// <exception cref="MESException">自定义异常</exception>
- /// <returns>count处理数据行数,0 or -num表示失败</returns>
- 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;
- }
- /// <summary>
- /// 向服务端设置数据(insert、update、delete、procedure)
- /// </summary>
- /// <param name="methodId">服务端MethodId</param>
- /// <param name="param">参数数组,需与服务端方法参数一致</param>
- /// <param name="ob">界面OB对象</param>
- /// <exception cref="MESException">自定义异常</exception>
- /// <returns>返回服务端的setResult中的数据</returns>
- 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;
- }
- }
- }
|