示例#1
0
文件: Log.cs 项目: danorama/pace
 private void UpdateLogFileCB()
 {
     if (LogFile != null)
     {
         LogFile.Text = TraceOps.GetLog();
     }
 }
示例#2
0
 public static bool SetUpClientConnectionConfig(string toIp, int toPort, string fromIp, int fromPort)
 {
     try
     {
         TraceOps.Out("try to connect to " + toIp + " : " + toPort);
         var tcpClient = new TcpClient();
         try
         {
             tcpClient.Connect(toIp, toPort);
             TraceOps.Out("Connected with " + tcpClient.Client.RemoteEndPoint);
         }
         catch (Exception e)
         {
             TraceOps.Out(e.ToString());
         }
         if (tcpClient.Connected)
         {
             var networkStream = tcpClient.GetStream();
             var streamWriter  = new StreamWriter(networkStream);
             TraceOps.Out("Send data to " + tcpClient.Client.RemoteEndPoint);
             streamWriter.WriteLine("<XML>");
             streamWriter.WriteLine("<IP>" + fromIp + "</IP>");
             streamWriter.WriteLine("<PORT>" + fromPort + "</PORT>");
             streamWriter.WriteLine("</XML>");
             streamWriter.Flush();
             tcpClient.Close();
             return(true);
         }
     }
     catch (Exception ex)
     {
         TraceOps.Out(ex.ToString());
     }
     return(false);
 }
示例#3
0
        public static string[] GetDllsPath(string path)
        {
            TraceOps.Out("Looking for Plugins in: " + path);
            var filePaths = Directory.GetFiles(path, "*.dll");

            return(filePaths);
        }
示例#4
0
        public IClientPlugin[] LoadClientDlls(string[] strings)
        {
            var list = new List <IClientPlugin>();

            foreach (var s in strings)
            {
                TraceOps.Out("Lade Plugin: " + s);
                list.AddRange(ClientDllLoad(s));
            }
            return(list.ToArray());
        }
示例#5
0
 public static void SetAutoStart()
 {
     try
     {
         var clickOnceHelper = new ClickOnceHelper(Globals.PublisherName, Globals.ProductName, Globals.ProductSuite);
         clickOnceHelper.UpdateUninstallParameters();
         clickOnceHelper.AddShortcutToStartup();
     }
     catch (Exception ex)
     {
         TraceOps.Out(ex.ToString());
     }
 }
示例#6
0
文件: Log.cs 项目: danorama/pace
 public void UpdateLogFile()
 {
     if (LogFile != null && LogFile.InvokeRequired)
     {
         var d = new UpdateLogFileCallback(UpdateLogFile);
         Invoke(d, new object[] { });
     }
     else
     {
         if (LogFile != null)
         {
             LogFile.Text = TraceOps.GetLog();
         }
     }
 }
示例#7
0
 public static void GetService(string server, int port, Type type)
 {
     try
     {
         var url = "http://" + server + ":" + port + "/" + type.Name + ".rem";
         TraceOps.Out("Try to get service : " + url);
         var remoteType = new WellKnownClientTypeEntry(type, url);
         remoteType.ApplicationUrl = url;
         TraceOps.Out(remoteType.ObjectUrl);
         RemotingConfiguration.RegisterWellKnownClientType(remoteType);
     }
     catch (Exception exception)
     {
         TraceOps.Out(exception.ToString());
     }
 }
示例#8
0
        public IClientPlugin[] ClientDllLoad(string path)
        {
            var pluginLibrary        = Assembly.LoadFrom(path);
            IEnumerable <Type> types = pluginLibrary.GetTypes();

            var list = new List <IClientPlugin>();

            foreach (var type in types)
            {
                if (type.BaseType != null && type.Name == "ClientPlugin")
                {
                    TraceOps.Out("Lade ClientPlugin");
                    var plugin = (IClientPlugin)Activator.CreateInstance(type);
                    list.Add(plugin);
                }
            }
            return(list.ToArray());
        }
示例#9
0
        private void Tasks()
        {
            try
            {
                while (_running)
                {
                    Thread.Sleep(Threshold);

                    var m = _messageQueue.GetMessage(_name);
                    if (m != null)
                    {
                        Task.Invoke(m);
                    }
                }
            }
            catch (Exception exception)
            {
                TraceOps.Out(exception.ToString());
            }
        }
示例#10
0
        public static string GetAttribute(string[,] strings, string needle)
        {
            try
            {
                for (int i = 0; i < strings.GetLength(0); i++)
                {
                    var key   = strings[i, 0];
                    var value = strings[i, 1];
                    if (key.Equals(needle))
                    {
                        return(value);
                    }
                }
            }
            catch (Exception e)
            {
                TraceOps.Out(e.ToString());
            }

            return("");
        }
示例#11
0
        public static string GetIpString(string uri)
        {
            string dns = "0.0.0.0";

            try
            {
                foreach (IPAddress ipAddress in Dns.GetHostEntry(uri).AddressList)
                {
                    if (ipAddress.AddressFamily == AddressFamily.InterNetwork)
                    {
                        dns = ipAddress.ToString();
                    }
                }

                TraceOps.Out("Parsed DNS/IP 4: " + dns);
            }
            catch (Exception)
            {
                TraceOps.Out("Parsed DNS/IP 4: not parsed");
            }

            return(dns);
        }