private static IFaxBusiness.IMyFaxBusiness GetWebService() { IFaxBusiness.IMyFaxBusiness webservice = (IFaxBusiness.IMyFaxBusiness)Activator.GetObject(typeof(IFaxBusiness.IMyFaxBusiness), RemotingObject.GetIPAddress()); return(webservice); }
private static IFaxBusiness.IMyFaxBusiness 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"); IFaxBusiness.IMyFaxBusiness webservice = (IFaxBusiness.IMyFaxBusiness)Activator.GetObject(typeof(IFaxBusiness.IMyFaxBusiness), RemotingObject.GetIPAddress()); return(webservice); }
//校验软件权限 public static void ReadRegister(out bool IsRegister, out int ProductType, out DateTime DeadLine, out Dictionary <string, object> dictModel) { dictModel = new Dictionary <string, object>(); string RegisterInfoJson; IFaxBusiness.IMyFaxBusiness webservice = GetWebService(); webservice.ReadRegister(out IsRegister, out ProductType, out RegisterInfoJson, out DeadLine); if (RegisterInfoJson != "") { dictModel = LBEncrypt.GetRegisterModelInfo(RegisterInfoJson); } }
public static void CallSP(int iSPType, bool bolIsNeedSession, DataTable dtInput, out DataSet dsReturn, out DataTable dtOut) { if (string.IsNullOrEmpty(dtInput.TableName)) { dtInput.TableName = "SPIN"; } IFaxBusiness.IMyFaxBusiness 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); string strdtOut; string strReturn = webservice.RunProcedure(iSPType, LoginInfo.SessionID, bolIsNeedSession, LoginInfo.LoginName, bSerialValue, bSerialDataType, out strdtOut, out strErrorMsg, out bolIsError); if (bolIsError) { throw new Exception(strErrorMsg); } dsReturn = UnRarDataSet(strReturn); dtOut = UnRarDataTable(strdtOut); if (CallSPEvent != null) { CallSPArgs args = new Args.CallSPArgs(iSPType, dtInput); CallSPEvent(args); } }
public static DataTable CallDirectSQL_Service(string strSQL) { DataTable dtResult = null; IFaxBusiness.IMyFaxBusiness webservice = GetWebService(); //LBWebService.LBWebService webservice = GetLBWebService(); string strErrorMsg = ""; bool bolIsError = false; string strReturn = webservice.RunDirectSQL_Service(LoginInfo.LoginName, strSQL, out strErrorMsg, out bolIsError); if (bolIsError) { throw new Exception(strErrorMsg); } dtResult = UnRarDataTable(strReturn); return(dtResult); }
public DataTable CallView(string LoginName, int iViewType, string strFieldNames, string strWhere, string strOrderBy) { DataTable dtResult = null; IFaxBusiness.IMyFaxBusiness webservice = GetWebService(); //LBWebService.LBWebService webservice = GetLBWebService(); string strErrorMsg = ""; bool bolIsError = false; try { dtResult = UnRarDataTable(webservice.RunView(iViewType, 0, false, LoginName, strFieldNames, strWhere, strOrderBy, out strErrorMsg, out bolIsError)); if (bolIsError) { throw new Exception(strErrorMsg); } } catch (Exception ex) { throw new Exception(ex.Message); } return(dtResult); }
public static DataTable CallView_Service(int iViewType, string strFieldNames, string strWhere, string strOrderBy) { DataTable dtResult = null; IFaxBusiness.IMyFaxBusiness webservice = GetWebService(); string strErrorMsg = ""; bool bolIsError = false; try { string strReturn = webservice.RunView_Service(iViewType, LoginInfo.LoginName, strFieldNames, strWhere, strOrderBy, out strErrorMsg, out bolIsError); if (bolIsError) { throw new Exception(strErrorMsg); } dtResult = UnRarDataTable(strReturn); } catch (Exception ex) { throw new Exception(ex.Message); } return(dtResult); }
public static void LogOutSession() { IFaxBusiness.IMyFaxBusiness webservice = GetWebService(); webservice.LogOutSession(LoginInfo.SessionID); }
/// <summary> /// 测试连接状态 /// </summary> /// <returns></returns> public static bool TestConnectStatus() { IFaxBusiness.IMyFaxBusiness webservice = GetWebService(); //LBWebService.LBWebService webservice = GetLBWebService(); return(webservice.ConnectServer()); }
private void StartAction() { try { #region -- 测试服务器连接情况 -- mActionStatus = enActionStatus.TestConnect; //Thread.Sleep(200); LoadServerConfig(); IFaxBusiness.IMyFaxBusiness webservice = null; bool bolIsConnected = false; if (this.txtServerAddress.Text != "") { webservice = RemotingObject.GetWebService(); bolIsConnected = webservice.ConnectServer(); } if (bolIsConnected)//连接服务器成功 { mActionStatus = enActionStatus.Connected; #region -- 获取服务器上的最新程序信息 -- DataTable dtServer = webservice.ReadClientFileInfo(); DataTable dtClient = GetLocalFile();//获取本地Client程序信息 //读取本地程序,与服务器程序进行对比,得出需求更新的程序清单 DataTable dtDiff; bool bolIsNeedUpdate; CompareClientInfo(dtClient, dtServer, out dtDiff, out mNeedUpdateFileSize, out bolIsNeedUpdate); DoData(0); SetProgressMaxNum(100); #endregion -- 获取服务器上的最新程序信息 -- if (bolIsNeedUpdate) { SetProgressVisible(true); mActionStatus = enActionStatus.UpdateDLL;//更新程序 mUpdatedFileSize = 0; string strStartUpPath = Path.Combine(Application.StartupPath, "Client"); if (!Directory.Exists(strStartUpPath)) { Directory.CreateDirectory(strStartUpPath); } //在Client下创建Ini文件 /*string strIniFile = Path.Combine(strStartUpPath, "WebLink.ini"); * if (!File.Exists(strIniFile)) * { * File.Create(strIniFile); * } * * IniClass iniWebLink = new IniClass(strIniFile); * iniWebLink.WriteValue("Link", "url", this.txtServerAddress.Text); */ #region -- 分段下单程序 -- int iMaxLength = 1024 * 100; foreach (DataRow dr in dtDiff.Rows) { string strFileName = dr["FileName"].ToString().TrimEnd(); if (strFileName.Equals("LBTSR.ini")) { continue; } DateTime dtFileTime = Convert.ToDateTime(dr["FileTime"]); long lFileSize = Convert.ToInt64(dr["FileSize"]); string strFullName = Path.Combine(strStartUpPath, strFileName); mstrCurrentUpdateDLL = strFullName;//正在更新的程序 FileInfo fi = new FileInfo(strFullName); if (!Directory.Exists(fi.DirectoryName)) { Directory.CreateDirectory(fi.DirectoryName); } string strFullName_temp = strFullName + "_temp"; if (File.Exists(strFullName_temp)) { File.Delete(strFullName_temp); } int iSplitCount = (int)Math.Ceiling(lFileSize / (float)iMaxLength); //long lTotalSize = 0; for (int i = 0; i < iSplitCount; i++) { int iPosition = i * iMaxLength; if (lFileSize >= iPosition) { byte[] bFile; webservice.ReadFileByte(strFileName, iPosition, iMaxLength, out bFile); mUpdatedFileSize += bFile.Length;//计算已更新的程序大小 using (FileStream fileStream = new FileStream(strFullName_temp, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Write)) { fileStream.Position = iPosition; fileStream.Write(bFile, 0, bFile.Length); fileStream.Flush(); fileStream.Close(); } int iPercent = (int)(mUpdatedFileSize / (float)mNeedUpdateFileSize * 100); DoData(iPercent); } if (i + 1 == iSplitCount) { if (File.Exists(strFullName_temp)) { if (File.Exists(strFullName)) { File.Delete(strFullName); } File.Move(strFullName_temp, strFullName); if (File.Exists(strFullName)) { FileInfo fiFile = new FileInfo(strFullName); fiFile.LastWriteTime = dtFileTime; } } } } } //将INi拷贝到Client目录下 string strIniPath = Path.Combine(Application.StartupPath, "WebLink.ini"); if (File.Exists(strIniPath)) { string strClientIniPath = Path.Combine(Application.StartupPath, @"Client\WebLink.ini"); if (File.Exists(strClientIniPath)) { File.Delete(strClientIniPath); } File.Copy(strIniPath, strClientIniPath); } DoData(100); #endregion -- 分段下单程序 -- } mActionStatus = enActionStatus.Success; } else { mActionStatus = enActionStatus.Fail; } #endregion -- 测试服务器连接情况 -- } catch (Exception ex) { mActionStatus = enActionStatus.Fail; } }