Exemplo n.º 1
0
        static void Main(string[] args)
        {
            AutoCSer.Net.TcpInternalServer.ServerAttribute serverAttribute = AutoCSer.Web.Config.Pub.GetTcpRegisterAttribute(typeof(AutoCSer.Net.HttpRegister.Server));
            byte isStopListen = 0;

            do
            {
                try
                {
                    using (AutoCSer.Net.HttpRegister.Server serverValue = new AutoCSer.Net.HttpRegister.Server())
                    {
                        serverValue.OnLoadCacheDomain += () =>
                        {
                            if (isStopListen == 0)
                            {
                                isStopListen = 1;
                                try
                                {
                                    using (AutoCSer.Net.HttpRegister.Server.TcpInternalClient client = new AutoCSer.Net.HttpRegister.Server.TcpInternalClient(AutoCSer.MemberCopy.Copyer <AutoCSer.Net.TcpInternalServer.ServerAttribute> .MemberwiseClone(serverAttribute)))
                                    {
                                        client.stopListen(false);
                                        client.stopListen(true);
                                    }
                                }
                                catch { }
                            }
                        };
                        serverValue.OnStopListen += () =>
                        {
                            AutoCSer.Diagnostics.ProcessCopyClient.Remove();
                            AutoCSer.Threading.ThreadPool.TinyBackground.Start(() =>
                            {
                                Thread.Sleep(1000);
                                Environment.Exit(-1);
                            });
                        };
                        using (AutoCSer.Net.HttpRegister.Server.TcpInternalServer server = new AutoCSer.Net.HttpRegister.Server.TcpInternalServer(AutoCSer.MemberCopy.Copyer <AutoCSer.Net.TcpInternalServer.ServerAttribute> .MemberwiseClone(serverAttribute), null, serverValue))
                        {
                            if (server.IsListen)
                            {
                                Console.WriteLine("HTTP 服务启动成功");
                                AutoCSer.Diagnostics.ProcessCopyClient.Guard();
                                AutoCSer.Web.Config.Pub.ConsoleCommand();
                                AutoCSer.Diagnostics.ProcessCopyClient.Remove();
                                return;
                            }
                        }
                    }
                }
                catch (Exception error)
                {
                    Console.WriteLine(error.ToString());
                }
                Thread.Sleep(1000);
            }while (true);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            bool            createdProcessWait;
            EventWaitHandle processWait = new EventWaitHandle(false, EventResetMode.ManualReset, "AutoCSer.Example.WebView", out createdProcessWait);

            if (createdProcessWait)
            {
                using (processWait)
                {
                    Console.WriteLine(@"http://www.AutoCSer.com/WebView/Index.html
");
                    try
                    {
                        WebConfig webConfig = new WebConfig();
                        using (AutoCSer.Net.HttpRegister.Server server = AutoCSer.Net.HttpRegister.Server.Create <WebServer>(webConfig.MainHostPort))
                        {
                            if (server == null)
                            {
                                Console.WriteLine("HTTP服务启动失败");
                            }
                            else
                            {
                                System.Net.ServicePointManager.Expect100Continue = false;
                                Console.WriteLine(Ajax.Post.TestCase());
                                Console.WriteLine(Ajax.Get.TestCase());
                                Console.WriteLine(Ajax.RefOut.TestCase());
                                Console.WriteLine(Ajax.Asynchronous.TestCase());
                                Console.WriteLine(Ajax.Name.TestCase());
                                Console.WriteLine(Ajax.BoxSerialize.TestCase());
                                Console.WriteLine(Call.TestCase());
                                Console.WriteLine(CallAsynchronous.TestCase());
                                Console.WriteLine(CallBoxSerialize.TestCase());
                                Console.WriteLine(CallName.TestCase());
                                Console.WriteLine(Location.TestCase());
                                Console.WriteLine(Upload.TestCase());
                                Console.WriteLine(File.TestCase());

                                Process.Start("http://" + webConfig.MainDomain + "/");
                                Console.WriteLine("press quit to exit.");
                                while (Console.ReadLine() != "quit")
                                {
                                    ;
                                }
                            }
                        }
                    }
                    catch (Exception error)
                    {
                        Console.WriteLine(error.ToString());
                    }
                    Console.ReadKey();
                }
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            //System.Diagnostics.Process.GetCurrentProcess().ProcessorAffinity = (IntPtr)1;
            AutoCSer.Net.TcpInternalServer.ServerAttribute serverAttribute = AutoCSer.Web.Config.Pub.GetTcpRegisterAttribute(typeof(AutoCSer.Net.HttpRegister.Server));
            byte isStopListen = 0;

            do
            {
                try
                {
                    using (AutoCSer.Net.HttpRegister.Server serverValue = new AutoCSer.Net.HttpRegister.Server())
                    {
                        serverValue.OnLoadCacheDomain += () =>
                        {
                            if (isStopListen == 0)
                            {
                                isStopListen = 1;
                                try
                                {
                                    using (AutoCSer.Net.HttpRegister.Server.TcpInternalClient client = new AutoCSer.Net.HttpRegister.Server.TcpInternalClient(AutoCSer.MemberCopy.Copyer <AutoCSer.Net.TcpInternalServer.ServerAttribute> .MemberwiseClone(serverAttribute)))
                                    {
                                        client.stopListen(false);
                                        client.stopListen(true);
                                    }
                                }
                                catch { }
                            }
                        };
                        serverValue.OnStopListen += exit;
                        using (AutoCSer.Net.HttpRegister.Server.TcpInternalServer server = new AutoCSer.Net.HttpRegister.Server.TcpInternalServer(AutoCSer.MemberCopy.Copyer <AutoCSer.Net.TcpInternalServer.ServerAttribute> .MemberwiseClone(serverAttribute), null, serverValue))
                        {
                            if (server.IsListen)
                            {
                                Console.WriteLine("HTTP 服务启动成功 " + serverAttribute.Host + ":" + server.Port.toString());
                                AutoCSer.Diagnostics.ProcessCopyClient.Guard();
                                AutoCSer.Web.Config.Pub.ConsoleCommand();
                                AutoCSer.Diagnostics.ProcessCopyClient.Remove();
                                return;
                            }
                        }
                    }
                }
                catch (Exception error)
                {
                    Console.WriteLine(error.ToString());
                }
                Thread.Sleep(1000);
            }while (true);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            bool            createdProcessWait;
            EventWaitHandle processWait = new EventWaitHandle(false, EventResetMode.ManualReset, "AutoCSer.TestCase.WebPerformance", out createdProcessWait);

            if (createdProcessWait)
            {
                using (processWait)
                {
                    Console.WriteLine(@"http://www.AutoCSer.com/WebView/Index.html
");
                    try
                    {
                        using (AutoCSer.Net.HttpRegister.Server server = AutoCSer.Net.HttpRegister.Server.Create <WebServer>(new WebConfig().MainHostPort))
                        {
                            if (server == null)
                            {
                                Console.WriteLine("HTTP服务启动失败");
                            }
                            else
                            {
                                FileInfo clientFile = new FileInfo(Path.Combine(AutoCSer.PubPath.ApplicationPath, @"AutoCSer.TestCase.WebPerformanceClient.exe"));
                                if (clientFile.Exists)
                                {
                                    Process.Start(clientFile.FullName);
                                }
                                else
                                {
                                    Console.WriteLine("未找到 WEB 测试客户端程序");
                                }

                                Console.WriteLine("Press quit to exit.");
                                while (Console.ReadLine() != "quit")
                                {
                                    ;
                                }
                            }
                        }
                    }
                    catch (Exception error)
                    {
                        Console.WriteLine(error.ToString());
                    }
                    Console.ReadKey();
                }
            }
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            bool            createdProcessWait;
            EventWaitHandle processWait = new EventWaitHandle(false, EventResetMode.ManualReset, "AutoCSer.TestCase.SqlTableWeb", out createdProcessWait);

            if (createdProcessWait)
            {
                using (processWait)
                {
                    Console.WriteLine("http://www.AutoCSer.com/WebView/Index.html");
                    try
                    {
                        Process.Start(new FileInfo(Path.Combine(AutoCSer.PubPath.ApplicationPath, @"AutoCSer.TestCase.SqlTableCacheServer.exe")).FullName);
                        WebConfig webConfig = new WebConfig();
                        using (AutoCSer.Net.HttpRegister.Server server = AutoCSer.Net.HttpRegister.Server.Create <WebServer>(webConfig.MainHostPort))
                        {
                            if (server == null)
                            {
                                Console.WriteLine("HTTP服务启动失败");
                            }
                            else
                            {
                                Console.WriteLine("HTTP服务启动成功");
                                Thread.Sleep(1000);
                                Process.Start("http://" + webConfig.MainDomain + "/");

                                Console.WriteLine("Press quit to exit.");
                                while (Console.ReadLine() != "quit")
                                {
                                    ;
                                }
                                return;
                            }
                        }
                    }
                    catch (Exception error)
                    {
                        Console.WriteLine(error.ToString());
                    }
                    Console.ReadKey();
                }
            }
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
#if DotNetStandard
            Console.WriteLine("WARN : Linux .NET Core not support name EventWaitHandle");
#else
            bool            createdProcessWait;
            EventWaitHandle processWait = new EventWaitHandle(false, EventResetMode.ManualReset, "AutoCSer.TestCase.SqlTableWeb", out createdProcessWait);
            if (createdProcessWait)
            {
                using (processWait)
                {
#endif
            Console.WriteLine("http://www.AutoCSer.com/WebView/Index.html");
            try
            {
#if DotNetStandard
#if DEBUG
                FileInfo dataServerFile = new FileInfo(Path.Combine(AutoCSer.PubPath.ApplicationPath, @"..\..\..\..\SqlTableCacheServer\bin\Debug\netcoreapp2.0\AutoCSer.TestCase.SqlTableCacheServer.dll".pathSeparator()));
#else
                FileInfo dataServerFile = new FileInfo(Path.Combine(AutoCSer.PubPath.ApplicationPath, @"..\..\..\..\SqlTableCacheServer\bin\Release\netcoreapp2.0\AutoCSer.TestCase.SqlTableCacheServer.dll".pathSeparator()));
#endif
                ProcessStartInfo process = new ProcessStartInfo("dotnet", dataServerFile.FullName);
                process.UseShellExecute = true;
                Process.Start(process);
#else
                Process.Start(new FileInfo(Path.Combine(AutoCSer.PubPath.ApplicationPath, @"AutoCSer.TestCase.SqlTableCacheServer.exe")).FullName);
#endif

                WebConfig webConfig = new WebConfig();
                using (AutoCSer.Net.HttpRegister.Server server = AutoCSer.Net.HttpRegister.Server.Create <WebServer>(webConfig.MainHostPort))
                {
                    if (server == null)
                    {
                        Console.WriteLine("HTTP服务启动失败");
                    }
                    else
                    {
                        Console.WriteLine("HTTP服务启动成功");
                        Thread.Sleep(1000);
#if DotNetStandard
                        Console.WriteLine("http://" + webConfig.MainDomain + "/");
#else
                        Process.Start("http://" + webConfig.MainDomain + "/");
#endif
                        Console.WriteLine("Press quit to exit.");
                        while (Console.ReadLine() != "quit")
                        {
                            ;
                        }
                        return;
                    }
                }
            }
            catch (Exception error)
            {
                Console.WriteLine(error.ToString());
            }
            Console.ReadKey();
#if !DotNetStandard
        }
    }
#endif
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
#if DotNetStandard
            Console.WriteLine("WARN : Linux .NET Core not support name EventWaitHandle");
#else
            bool            createdProcessWait;
            EventWaitHandle processWait = new EventWaitHandle(false, EventResetMode.ManualReset, "AutoCSer.TestCase.WebPerformance", out createdProcessWait);
            if (createdProcessWait)
            {
                using (processWait)
                {
#endif
            Console.WriteLine(@"http://www.AutoCSer.com/WebView/Index.html
");
            try
            {
                using (AutoCSer.Net.HttpRegister.Server server = AutoCSer.Net.HttpRegister.Server.Create <WebServer>(new WebConfig().MainHostPort))
                {
                    if (server == null)
                    {
                        Console.WriteLine("HTTP服务启动失败");
                    }
                    else
                    {
#if DotNetStandard
                        FileInfo clientFile = new FileInfo(Path.Combine(AutoCSer.PubPath.ApplicationPath, @"AutoCSer.TestCase.WebPerformanceClient.dll"));
                        if (clientFile.Exists)
                        {
                            ProcessStartInfo process = new ProcessStartInfo("dotnet", clientFile.FullName);
                            process.UseShellExecute = true;
                            Process.Start(process);
                        }
#else
                        FileInfo clientFile = new FileInfo(Path.Combine(AutoCSer.PubPath.ApplicationPath, @"AutoCSer.TestCase.WebPerformanceClient.exe"));
                        if (clientFile.Exists)
                        {
                            Process.Start(clientFile.FullName);
                        }
#endif
                        else
                        {
                            Console.WriteLine("未找到 WEB 测试客户端程序");
                        }

                        Console.WriteLine("Press quit to exit.");
                        while (Console.ReadLine() != "quit")
                        {
                            ;
                        }
                    }
                }
            }
            catch (Exception error)
            {
                Console.WriteLine(error.ToString());
            }
            Console.ReadKey();
#if !DotNetStandard
        }
    }
#endif
        }