/// <summary> /// 从IP列表获取有效IP /// </summary> /// <param name="ips"></param> /// <param name="port"></param> /// <returns></returns> private static string GetValidIp(string ips, int port) { string[] ipsArr = ips.Split(','); foreach (var ip in ipsArr) { if (ip != "127.0.0.1") { Thrift.Transport.TTransport service = new Thrift.Transport.TSocket(ip, port, 300); try { if (!service.IsOpen) { service.Open(); return(ip); } } catch { // } finally { if (service.IsOpen) { service.Close(); service.Dispose(); } } } } return(string.Empty); }
/// <summary> /// 更新比对记录标识 /// </summary> /// <param name="info"></param> /// <param name="IP"></param> /// <returns></returns> public static int UpdateCmp(RealtimeCmpInfoLBS info, string IP) { try { // 生成socket套接字; Thrift.Transport.TSocket tsocket = new Thrift.Transport.TSocket(IP, 6000); //设置连接超时为100; tsocket.Timeout = 3000; //生成客户端对象 Thrift.Transport.TTransport transport = tsocket; Thrift.Protocol.TProtocol protocol = new Thrift.Protocol.TBinaryProtocol(transport); UIServer.Client _BusinessServerClient = new UIServer.Client(protocol); transport.Open(); //_BusinessServerClient.UpdateRealtimeCmp(info, "##@" + info.Channel); info.Channelname = "##@" + info.Channelname; _BusinessServerClient.UpdateRealtimeCmpLBS(info); if ("DEBUG".Equals(GlobalCache.AppMode)) { MessageBox.Show("推送成功"); } transport.Close(); return(0); } catch (Exception ex) { if ("DEBUG".Equals(GlobalCache.AppMode)) { MessageBox.Show(ex.Message); } Logger <WarningMessageCmd> .Log.Error("UpdateCmp", ex); return(-1); } }
public static void Main(String[] args) { try { Thrift.Transport.TTransport transport; transport = new Thrift.Transport.TSocket("suchlol.com", 9090); transport.Open(); Thrift.Protocol.TProtocol protocol = new Thrift.Protocol.TBinaryProtocol(transport); client = new geospatial.thrift.Geospatial.Client(protocol); perform(client); transport.Close(); } catch (TException x) { Console.WriteLine(x.StackTrace); } }
/// <summary> /// 推送比对记录 /// </summary> /// <param name="info"></param> /// <param name="IP"></param> /// <returns></returns> public int UpdateCmp(RealtimeCmpInfo info, string IP) { try { // 生成socket套接字; Thrift.Transport.TSocket tsocket = new Thrift.Transport.TSocket(IP, 6000); //设置连接超时为100; tsocket.Timeout = 3000; //生成客户端对象 Thrift.Transport.TTransport transport = tsocket; Thrift.Protocol.TProtocol protocol = new Thrift.Protocol.TBinaryProtocol(transport); UIServer.Client _BusinessServerClient = new UIServer.Client(protocol); transport.Open(); _BusinessServerClient.UpdateRealtimeCmp(info, "##@" + info.Channel); transport.Close(); return(0); } catch (Exception ex) { _WriteLog.WriteToLog("UpdateCmp", ex); return(-1); } }