예제 #1
0
    public void Init(string strIp = "localhost", int port = 9090)
    {
        this.strIp = strIp;
        this.nPort = port;

        SendLog("", "ResetLogMirror");

        try
        {
            transport = new TSocket(strIp, port);
            TProtocol protocol = new TBinaryProtocol(transport);
            client = new SendLog.Client(protocol);
            transport.Open();

            ThreadStart start = new ThreadStart(() =>
            {
                while (!_isStop)
                {
                    Update();
                    Thread.Sleep(100);
                }
            });
            Thread thread = new Thread(start);
            thread.Start();
        }
        catch (Exception x)
        {
            Debug.LogError("日志服务器连接失败!");
        }
    }
예제 #2
0
        public static void Main()
        {
            try
            {
                TTransport transport = new TSocket("localhost", 9090);
                TProtocol protocol = new TBinaryProtocol(transport);
                SendLog.Client client = new SendLog.Client(protocol);

                transport.Open();
                try
                {
                    Random ran = new Random();
                    string strContent = "";
                    List<LogInfo> lstLogInfo = new List<LogInfo>();
                    for (int i = 0; i < 1000; i++ )
                    {
                        LogInfo info = new LogInfo();
                        info.Content = strContent;
                        strContent += i;
                        info.DeviceName = i.ToString();
                        info.Time = (int)DateTime.UtcNow.Ticks;
                        info.Category = "category" + i;
                        lstLogInfo.Add(info);
                    }

                    client.send_log(lstLogInfo);
                }
                finally
                {
                    transport.Close();
                }
            }
            catch (TApplicationException x)
            {
                Console.WriteLine(x.StackTrace);
            }
        }
예제 #3
0
        public static void Main()
        {
            try
            {
                TTransport     transport = new TSocket("localhost", 9090);
                TProtocol      protocol  = new TBinaryProtocol(transport);
                SendLog.Client client    = new SendLog.Client(protocol);

                transport.Open();
                try
                {
                    Random         ran        = new Random();
                    string         strContent = "";
                    List <LogInfo> lstLogInfo = new List <LogInfo>();
                    for (int i = 0; i < 1000; i++)
                    {
                        LogInfo info = new LogInfo();
                        info.Content    = strContent;
                        strContent     += i;
                        info.DeviceName = i.ToString();
                        info.Time       = (int)DateTime.UtcNow.Ticks;
                        info.Category   = "category" + i;
                        lstLogInfo.Add(info);
                    }

                    client.send_log(lstLogInfo);
                }
                finally
                {
                    transport.Close();
                }
            }
            catch (TApplicationException x)
            {
                Console.WriteLine(x.StackTrace);
            }
        }