private static Web.IRemoting.IMyRemoting GetWebService() { /*HttpChannel channel = new HttpChannel(2017); * ChannelServices.RegisterChannel(channel, false);*/ //IWebRemoting webservice = (IWebRemoting)RemotingObject.GetRemotingObject(typeof(IWebRemoting)); //IWebRemoting webservice = (IWebRemoting)Activator.GetObject(typeof(IWebRemoting), // "http://localhost:2017/LBProject"); Web.IRemoting.IMyRemoting webservice = (Web.IRemoting.IMyRemoting)Activator.GetObject(typeof(Web.IRemoting.IMyRemoting), RemotingObject.GetIPAddress()); return(webservice); }
/// <summary> /// 直接执行SQL /// </summary> /// <param name="strSQL"></param> /// <returns></returns> public static DataTable CallDirectSQL(string strSQL) { DataTable dtResult = null; Web.IRemoting.IMyRemoting webservice = GetWebService(); //LBWebService.LBWebService webservice = GetLBWebService(); string strErrorMsg = ""; bool bolIsError = false; dtResult = webservice.RunDirectSQL(LoginInfo.LoginName, strSQL, out strErrorMsg, out bolIsError); if (bolIsError) { throw new Exception(strErrorMsg); } return(dtResult); }
/// <summary> /// 调用存储过程或中间层 /// </summary> /// <param name="iSPType">存储过程号</param> /// <param name="dtInput">参数数据</param> /// <param name="dsReturn">返回的查询数据</param> /// <param name="dtOut">返回的参数值</param> public static void CallSP(int iSPType, DataTable dtInput, out DataSet dsReturn, out DataTable dtOut) { if (string.IsNullOrEmpty(dtInput.TableName)) { dtInput.TableName = "SPIN"; } Web.IRemoting.IMyRemoting webservice = GetWebService(); //LBWebService.LBWebService webservice = GetLBWebService(); string strErrorMsg = ""; bool bolIsError = false; dsReturn = null; dtOut = null; List <Dictionary <object, object> > lstDictValue = new List <Dictionary <object, object> >(); Dictionary <object, object> dictDataType = new Dictionary <object, object>(); foreach (DataRow dr in dtInput.Rows) { Dictionary <object, object> dict = new Dictionary <object, object>(); foreach (DataColumn dc in dtInput.Columns) { dict.Add(dc.ColumnName, dr[dc.ColumnName]); if (!dictDataType.ContainsKey(dc.ColumnName)) { dictDataType.Add(dc.ColumnName, dc.DataType.ToString()); } } lstDictValue.Add(dict); } byte[] bSerialValue = SerializeObject(lstDictValue); byte[] bSerialDataType = SerializeObject(dictDataType); dsReturn = webservice.RunProcedure(iSPType, LoginInfo.LoginName, bSerialValue, bSerialDataType, out dtOut, out strErrorMsg, out bolIsError); if (bolIsError) { throw new Exception(strErrorMsg); } if (CallSPEvent != null) { CallSPArgs args = new Args.CallSPArgs(iSPType, dtInput); CallSPEvent(args); } }
/// <summary> /// 查询视图 /// </summary> /// <param name="iViewType">视图号</param> /// <param name="strFieldNames">查询字段</param> /// <param name="strWhere">查询条件</param> /// <param name="strOrderBy">排序</param> /// <returns></returns> public static DataTable CallView(int iViewType, string strFieldNames, string strWhere, string strOrderBy) { DataTable dtResult = null; Web.IRemoting.IMyRemoting webservice = GetWebService(); //LBWebService.LBWebService webservice = GetLBWebService(); string strErrorMsg = ""; bool bolIsError = false; try { dtResult = webservice.RunView(iViewType, LoginInfo.LoginName, strFieldNames, strWhere, strOrderBy, out strErrorMsg, out bolIsError); if (bolIsError) { throw new Exception(strErrorMsg); } } catch (Exception ex) { throw new Exception(ex.Message); } return(dtResult); }
/// <summary> /// 测试连接状态 /// </summary> /// <returns></returns> public static bool TestConnectStatus() { Web.IRemoting.IMyRemoting webservice = GetWebService(); //LBWebService.LBWebService webservice = GetLBWebService(); return(webservice.ConnectServer()); }
public static void ReadRegister(out bool IsRegister, out int ProductType, out string RegisterInfoJson, out DateTime DeadLine) { Web.IRemoting.IMyRemoting webservice = GetWebService(); webservice.ReadRegister(out IsRegister, out ProductType, out RegisterInfoJson, out DeadLine); }