コード例 #1
0
ファイル: ServerManager.cs プロジェクト: windygu/KQERP
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            bootstrap.Stop();
            txtMsg.Items.Add("Server Has Stop ");
            //var bootstrap = BootstrapFactory.CreateBootstrap();
            //if (!bootstrap.Initialize())
            //{
            //    txtMsg.Items.Add("Failed to initialize!");
            //    //Console.ReadKey();
            //    return;
            //}
            //bootstrap.Stop()
            var result = bootstrap.Start();

            //TelnetServer sss = bootstrap.AppServers.First() as TelnetServer;
            //sss.NewSessionConnected += sss_NewSessionConnected;
            txtMsg.Items.Add(string.Format("Start result: {0}!", result));

            if (result == StartResult.Failed)
            {
                txtMsg.Items.Add("Failed to start!");
                // Console.ReadKey();
                return;
            }
        }
コード例 #2
0
 private void btnStartStop_Click(object sender, EventArgs e)
 {
     if (btnStartStop.Text == "启动服务")
     {
         bootstrap = BootstrapFactory.CreateBootstrap();
         if (!bootstrap.Initialize())
         {
             ServiceStatus = false;
             MessageBox.Show("Failed to initialize!");
             return;
         }
         else
         {
             StartResult result = bootstrap.Start();
             if (result == StartResult.Failed)
             {
                 ServiceStatus = false;
             }
             else if (result == StartResult.Success)
             {
                 var transferServer = bootstrap.GetServerByName("TransferServer") as TransferServer;
                 transferServer.NewSessionConnected += transferServer_NewSessionConnected;
                 transferServer.SessionClosed       += transferServer_SessionClosed;
                 var userServer = bootstrap.GetServerByName("UserServer") as UserServer;
                 userServer.UserJoin     += userServer_UserJoin;
                 userServer.UserLeave    += userServer_UserLeave;
                 userServer.SendToServer += userServer_UserSendToServer;
                 userServer.UserWhisper  += userServer_UserWhisper;
                 userServer.Broadcast    += userServer_UserBroadcast;
                 ServiceStatus            = true;
             }
             else
             {
                 //MessageBox.Show(string.Format("Start result: {0}!", result));
             }
             this.lblStatus.Text = result.ToString();
         }
     }
     else
     {
         bootstrap.Stop();
         ServiceStatus       = false;
         this.lblStatus.Text = "The server was stopped!";
     }
     if (ServiceStatus)
     {
         btnStartStop.Text = "停止服务";
     }
     else
     {
         btnStartStop.Text = "启动服务";
     }
 }
コード例 #3
0
 public static void Stop()
 {
     if (bootstrap != null)
     {
         bootstrap.Stop();
     }
 }
コード例 #4
0
ファイル: MainFrm.cs プロジェクト: predatorZhang/SensorHubEY
 /**
  * 关闭server服务器实例
  * **/
 private void StopServer()
 {
     if (bootstrap != null)
     {
         bootstrap.Stop();
     }
 }
コード例 #5
0
ファイル: Form1.cs プロジェクト: jonny-xhl/my-demo
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (bootstrap != null)
     {
         bootstrap.Stop();
     }
 }
コード例 #6
0
 void Application_End(object sender, EventArgs e)
 {
     if (m_Bootstrap != null)
     {
         m_Bootstrap.Stop();
     }
 }
コード例 #7
0
 public void ClearBootstrap()
 {
     if (m_BootStrap != null)
     {
         m_BootStrap.Stop();
         m_BootStrap = null;
     }
 }
コード例 #8
0
ファイル: Frm_Main.cs プロジェクト: wuyunhai/EasyCareAuto
 private void pOPBackWork()
 {
     if (m_Bootstrap != null)
     {
         m_Bootstrap.Stop();
         LogInfo log = new LogInfo(mesServer, LogLevel.Info, "服务器已关闭.");
     }
 }
コード例 #9
0
 protected override void OnBootstrapCleared()
 {
     if (m_ActiveServerBootstrap != null)
     {
         m_ActiveServerBootstrap.Stop();
         m_ActiveServerBootstrap = null;
         AppDomain.CurrentDomain.SetData("Bootstrap", null);
     }
 }
コード例 #10
0
ファイル: WorkerRole.cs プロジェクト: mdavid/SuperWebSocket
        public override void OnStop()
        {
            if (m_Bootstrap != null)
            {
                m_Bootstrap.Stop();
            }

            base.OnStop();
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: evolution124/SuperSocket
        static void RunAsConsole()
        {
            IBootstrap bootstrap = BootstrapFactory.CreateBootstrap();

            if (!bootstrap.Initialize())
            {
                Console.WriteLine("Failed to initialize SuperSocket server! Please check error log for more information!");
                return;
            }

            var result = bootstrap.Start();

            foreach (var server in bootstrap.AppServers)
            {
                if (server.IsRunning)
                {
                    Console.WriteLine("- {0} has been started", server.Name);
                }
                else
                {
                    Console.WriteLine("- {0} failed to start", server.Name);
                }
            }

            switch (result)
            {
            case (StartResult.None):
                Console.WriteLine("No server is configured, please check you configuration!");
                break;

            case (StartResult.Success):
                Console.WriteLine("The server engine has been started!");
                break;

            case (StartResult.Failed):
                Console.WriteLine("Failed to start the server engine! Please check error log for more information!");
                break;

            case (StartResult.PartialSuccess):
                Console.WriteLine("Some server instances were started successfully, but the others failed to start! Please check error log for more information!");
                break;
            }

            Console.WriteLine("Press key 'q' to stop the server engine.");

            while (Console.ReadKey().Key != ConsoleKey.Q)
            {
                Console.WriteLine();
                continue;
            }

            bootstrap.Stop();

            Console.WriteLine();
            Console.WriteLine("The server engine has been stopped!");
        }
コード例 #12
0
        void Application_End(object sender, EventArgs e)
        {
            m_SecureSocketPushTimer.Change(Timeout.Infinite, Timeout.Infinite);
            m_SecureSocketPushTimer.Dispose();

            if (m_Bootstrap != null)
            {
                m_Bootstrap.Stop();
            }
        }
コード例 #13
0
        static void RunAsConsole()
        {
            Console.WriteLine("Welcome to NRack.Server!");

            CheckCanSetConsoleColor();

            Console.WriteLine("Initializing...");

            IBootstrap bootstrap = BootstrapFactory.CreateBootstrap();

            if (!bootstrap.Initialize())
            {
                SetConsoleColor(ConsoleColor.Red);

                Console.WriteLine("Failed to initialize NRack.Server! Please check error log for more information!");
                Console.ReadKey();
                return;
            }

            Console.WriteLine("Starting...");

            bootstrap.Start();

            Console.WriteLine("-------------------------------------------------------------------");

            foreach (var server in bootstrap.AppServers)
            {
                if (server.State == ServerState.Running)
                {
                    SetConsoleColor(ConsoleColor.Green);
                    Console.WriteLine("- {0} has been started", server.Name);
                }
                else
                {
                    SetConsoleColor(ConsoleColor.Red);
                    Console.WriteLine("- {0} failed to start", server.Name);
                }
            }

            Console.ResetColor();
            Console.WriteLine("-------------------------------------------------------------------");

            Console.ResetColor();
            Console.WriteLine("Enter key 'quit' to stop the NRack.Server.");

            RegisterCommands();

            ReadConsoleCommand(bootstrap);

            bootstrap.Stop();

            Console.WriteLine("The NRack.Server has been stopped!");
        }
コード例 #14
0
 public void ClearBootstrap()
 {
     if (m_BootStrap != null)
     {
         m_BootStrap.Stop();
         (m_BootStrap as IDisposable).Dispose();
         m_BootStrap = null;
         OnBootstrapCleared();
         GC.Collect();
         GC.WaitForFullGCComplete();
     }
 }
コード例 #15
0
ファイル: Handle.cs プロジェクト: Lantnr/MyTest
        public void CloseBootstrap()
        {
            var msg = string.Format("服务器socket停止");

            DisplayGlobal.log.Write(msg);
            if (bootstrap == null)
            {
                return;
            }
            bootstrap.Stop();
            //日志记录
            (new Share.Log()).WriteServerLog((int)LogType.Stop);
        }
コード例 #16
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press any key to start the server!");

            Console.ReadKey();
            Console.WriteLine();

            IBootstrap bootstrap = null;

            try {
                bootstrap = BootstrapFactory.CreateBootstrap();
            } catch (System.Configuration.ConfigurationErrorsException ex) {
                Console.WriteLine(ex.Message);
                Environment.Exit(-1);
            }

            if (!bootstrap.Initialize())
            {
                Console.WriteLine("Failed to initialize!");
                Console.ReadKey();
                return;
            }

            var result = bootstrap.Start();

            Console.WriteLine("Start result: {0}!", result);

            if (result == StartResult.Failed)
            {
                Console.WriteLine("Failed to start!");
                Console.ReadKey();
                return;
            }

            Console.WriteLine("Press key 'q' to stop it!");

            while (Console.ReadKey().KeyChar != 'q')
            {
                Console.WriteLine();
                continue;
            }


            Console.WriteLine();

            //Stop the appServer
            bootstrap.Stop();

            Console.WriteLine("The server was stopped!");
            Console.ReadKey();
        }
コード例 #17
0
        public void Init()
        {
            //Console.WriteLine("Press any key to start the server!");

            //Console.ReadKey();
            //Console.WriteLine();

            bootstrap = BootstrapFactory.CreateBootstrap();

            if (!bootstrap.Initialize())
            {
                Console.WriteLine("服务器未初始化");
                Console.ReadKey();
                return;
            }
            var result = bootstrap.Start();

            Console.WriteLine("socket服务器启动结果{0}", result);

            if (result == StartResult.Failed)
            {
                Console.WriteLine("失败!");
                Console.ReadKey();
                return;
            }
            SeverTimer serverTimer = new SeverTimer();

            serverTimer.Init();

            Console.WriteLine("按Q键退出服务器");

            while (Console.ReadKey().KeyChar != 'q')
            {
                Console.WriteLine();
                continue;
            }

            Console.WriteLine();

            //Stop the appServer
            bootstrap.Stop();

            Console.WriteLine("服务器正常停止!");
            Console.ReadKey();
        }
コード例 #18
0
        static void Main(string[] args)
        {
            IBootstrap bootstrap = BootstrapFactory.CreateBootstrapFromConfigFile("SuperSocket.config");

            if (!bootstrap.Initialize())
            {
                Console.WriteLine("Failed to initialize!");
                Console.ReadKey();
                return;
            }

            var result = bootstrap.Start();

            //Console.WriteLine("Start result: {0}!", result);

            if (result == StartResult.Failed)
            {
                Console.WriteLine("Failed to start!");
                Console.ReadKey();
                return;
            }

            //foreach (var s in bootstrap.AppServers)
            //{
            //    Console.WriteLine($"{s.Config.Ip}:{s.Config.Port}");
            //}
            //Console.WriteLine("Press key 'q' to stop it!");

            while (Console.ReadKey().KeyChar != 'q')
            {
                Console.WriteLine();
                continue;
            }

            Console.WriteLine();

            //Stop the appServer
            bootstrap.Stop();

            Console.WriteLine("The server was stopped!");
        }
コード例 #19
0
        private void restartSuperSocketServer()
        {
            defaultBootstrap?.Stop();
            defaultBootstrap = null;
            var bootstrap = BootstrapFactory.CreateBootstrap();

            if (!bootstrap.Initialize())
            {
                NoticeAdmin($"{nameof(restartSuperSocketServer) } :Supersocket  initlialize failed!");
            }
            RemoteSuperSocketPort = bootstrap.AppServers.ElementAtOrDefault(0).Config.Port;
            var result = bootstrap.Start();

            Console.WriteLine("Start result: {0}!", result);
            if (result == StartResult.Failed)
            {
                NoticeAdmin($"{nameof(restartSuperSocketServer) } :Supersocket  start failed! result:{result.ToString()}");
            }
            if (result == StartResult.Success)
            {
                defaultBootstrap = bootstrap;
            }
        }
コード例 #20
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Press any key to start the server!");
            Console.ReadKey();
            Console.WriteLine();
            IBootstrap bootstrap = BootstrapFactory.CreateBootstrap();

            if (!bootstrap.Initialize())
            {
                Console.WriteLine("Failed to initialize!");
                Console.ReadKey();
            }
            else
            {
                StartResult result = bootstrap.Start();
                Console.WriteLine("Start result: {0}!", result);
                if (result == StartResult.Failed)
                {
                    Console.WriteLine("Failed to start!");
                    Console.ReadKey();
                }
                else
                {
                    Console.WriteLine("Press key 'q' to stop it!");
                    while (Console.ReadKey().KeyChar != 'q')
                    {
                        Console.WriteLine();
                    }
                    Console.WriteLine();
                    bootstrap.Stop();
                    foreach (var item in bootstrap.AppServers)
                    {
                    }
                    Console.WriteLine("The server was stopped!");
                }
            }
        }
コード例 #21
0
ファイル: AppDomainBootstrap.cs プロジェクト: Lantnr/MyTest
 /// <summary>
 /// Stops this bootstrap.
 /// </summary>
 public void Stop()
 {
     m_InnerBootstrap.Stop();
 }
コード例 #22
0
 /// <summary>
 /// 停止服务
 /// </summary>
 public void Stop()
 {
     _bootstrap.Stop();
 }
コード例 #23
0
 protected override void OnStop()
 {
     bootstrap.Stop();
     base.OnStop();
 }
コード例 #24
0
ファイル: Program.cs プロジェクト: SahadatHHredoy/timely
        private static void RunAsConsole()
        {
            int           startTime;
            int           endTime;
            int           runTime;
            List <string> tasks = new List <string>();

            //BackgroundWorker receiveWorker;
            CheckCanSetConsoleColor();
            Console.WriteLine("Press any key to start the SuperSocket ServiceEngine!");
            Console.ReadKey();
            Console.WriteLine();
            Console.WriteLine("Initializing...");



            IBootstrap bootstrap = BootstrapFactory.CreateBootstrap();

            if (!bootstrap.Initialize())
            {
                SetConsoleColor(ConsoleColor.Red);
                Console.WriteLine("Failed to initialize SuperSocket ServiceEngine! Please check error log for more information!");
                Console.ReadKey();
            }
            else
            {
                //var socketServer = bootstrap.AppServers.FirstOrDefault(s => s.Name.Equals("SuperWebSocket")) as WebSocketServer;
                var secureSocketServer = bootstrap.AppServers.FirstOrDefault(s => s.Name.Equals("SecureSuperWebSocket")) as WebSocketServer;



                secureSocketServer.NewSessionConnected += wsServer_NewSessionConnected;

                ///////////////////////////////database load
                DataSet    dsEnrolls;
                EnrollData ed = new EnrollData();
                ed.New("./");
                dsEnrolls = EnrollData.DataModule.GetEnrollDatas();
                //////////////////////////////////

                Console.WriteLine("Starting...");
                StartResult result = bootstrap.Start();
                Console.WriteLine("-------------------------------------------------------------------");
                foreach (IWorkItem server in bootstrap.AppServers)
                {
                    //装载事件
                    WebSocketLoader.Setup(server);
                    if (server.State == ServerState.Running)
                    {
                        SetConsoleColor(ConsoleColor.Green);
                        Console.WriteLine("- {0} has been started", server.Name);
                    }
                    else
                    {
                        SetConsoleColor(ConsoleColor.Red);
                        Console.WriteLine("- {0} failed to start", server.Name);
                    }
                }
                Console.ResetColor();
                Console.WriteLine("-------------------------------------------------------------------");
                switch (result)
                {
                case StartResult.None:
                    SetConsoleColor(ConsoleColor.Red);
                    Console.WriteLine("No server is configured, please check you configuration!");
                    Console.ReadKey();
                    return;

                case StartResult.Success:
                    Console.WriteLine("The SuperSocket ServiceEngine has been started!");
                    break;

                case StartResult.PartialSuccess:
                    SetConsoleColor(ConsoleColor.Red);
                    Console.WriteLine("Some server instances were started successfully, but the others failed! Please check error log for more information!");
                    break;

                case StartResult.Failed:
                    SetConsoleColor(ConsoleColor.Red);
                    Console.WriteLine("Failed to start the SuperSocket ServiceEngine! Please check error log for more information!");
                    Console.ReadKey();
                    return;
                }

                Console.ResetColor();
                Console.WriteLine("Press key 'q' to stop the ServiceEngine.");
                ///////////////////////////////////////////////////////////////
                /////////////////////////////////////////////////////
                //////////////below test the demo :server active send the command to terminal
                string str;
                bool   i = true;
                while (i == true)
                {
                    str = Console.ReadLine();
                    switch (str)
                    {
                    case "stop":
                        i = false;
                        break;

                    case "getuserlist":
                        WebSocketLoader.getuserlist(WebSocketLoader.g_now_sn);
                        break;

                    case "getuserinfo":
                        WebSocketLoader.getuserinfo(WebSocketLoader.g_now_sn, 1, 0);
                        break;

                    case "setpwd":
                        WebSocketLoader.setuserinfo(WebSocketLoader.g_now_sn, 1, "邹春庆", 10, 0, 123456, null);
                        break;

                    case "setcard":
                        WebSocketLoader.setuserinfo(WebSocketLoader.g_now_sn, 1, "邹春庆", 11, 0, 2352253, null);
                        break;

                    case "setfp":
                        //thbio 1.0
                        // WebSocketLoader.setuserinfo(WebSocketLoader.g_now_sn, 1,"邹春庆",0, 0,0,"cb09194bbe53ba6845befe6ecd9d0272ab7b0c76bb77147a97ef9c7eb5e1a482abc7d90de8936707d2c5ce00c26c0f02139efc0720b87c0e2f48bc02cefeec0551199a06d3abe862d047a966546b7b3ae496f198f4943796db30b166f91e5ff1177be39676ecaf2793c8a696e94f601b95dc6b4b5230e3c0cd336de4a438ce82d5d6a61f197090ed0b7ffeee4b09022f(100)0100320001(3)83604024cb091a4ea6578a6a05be9e6e0d9d62722a7bcc763a77d47a94effc7e34e1c48228c7a90d0897671ed246eb02006d66040198ec1e41b8dc03ec58c4646ede3c2a9339dfa88da91ee8774389e6d6676ba08c8c70509f8cbf1a9438f3fd719f3200065bb97eeaed6e07e3d4641bc40b6a27735056b41324528bca33503745285aafd3ffa427d93bb6ff55ee9b647130022f4be30c6f(108)");
                        //thbio 3.0
                        WebSocketLoader.setuserinfo(WebSocketLoader.g_now_sn, 1, "邹春庆", 0, 0, 0, "c51a6b00d9860af9ff3e19c769889355d08fa7c958877bc1d80bb8c36b8963d2789388d51c8b0bfdf97839048b8a8c16300b6a8749884c35c0d1c9082889fc71e1640b112c898c85d95a0b8f348924a5d8d5d98b4286f4cee0480a0438887ce1d8ce09893f87d501d08a19032f893576e1080c454486b58de7c0294446897c41b0e19ba6928b7c0d1fffd744268c74b5ff79fcc4358b94e5ff33fa87a78b5d26ef7fc94b5a857b95e7c5fa42bd85fd65ff7e188336885631d905fb86a589ae3116be1fc23289de3df83bffc340876e82cfc1fd45(272)28471547254213a3263581334462457f348445f41673f191352f3328f4152540893663833243454f2f2637f9f44262(65)146bd91d1191ae92382630a18b92185203a39cb3bc061020d9b9975601b199b4bb2214709590160a32d2de924e47443320c1f8053391ce8580155431cea1456210e1c8a119163682bc800c593076b292806c056416914b1b4061aba1c23c1614349102584104dc7159514293ceb12e578443d1f0f56544c87af0(60)090b080f070c060d030a05021304120e10161718(10)8eb0");
                        break;

                    case "getname":
                        WebSocketLoader.getusername(WebSocketLoader.g_now_sn, 1);
                        break;

                    case "setname":
                        WebSocketLoader.setusername(WebSocketLoader.g_now_sn);
                        break;

                    case "deleteuser":
                        WebSocketLoader.deleteuser(WebSocketLoader.g_now_sn, 1, 13);        //0~9 :fp  10 pwd ;11: card ;12: all fp ;13 :all(fp pwd card name)
                        break;

                    case "cleanuser":
                        WebSocketLoader.cleanuser(WebSocketLoader.g_now_sn);
                        break;

                    case "getnewlog":
                        WebSocketLoader.getnewlog(WebSocketLoader.g_now_sn);
                        break;

                    case "getalllog":
                        WebSocketLoader.getalllog(WebSocketLoader.g_now_sn);
                        break;

                    case "cleanlog":
                        WebSocketLoader.cleanlog(WebSocketLoader.g_now_sn);
                        break;

                    case "initsys":
                        WebSocketLoader.initsys(WebSocketLoader.g_now_sn);
                        break;

                    case "cleanadmin":
                        WebSocketLoader.cleanadmin(WebSocketLoader.g_now_sn);
                        break;

                    case "setdevinfo":
                        WebSocketLoader.setdevinfo(WebSocketLoader.g_now_sn);
                        break;

                    case "getdevinfo":
                        WebSocketLoader.getdevinfo(WebSocketLoader.g_now_sn);
                        break;

                    case "opendoor":
                        WebSocketLoader.opendoor(WebSocketLoader.g_now_sn);
                        break;

                    case "setdevlock":
                        WebSocketLoader.setdevlock(WebSocketLoader.g_now_sn);
                        break;

                    case "getdevlock":
                        WebSocketLoader.getdevlock(WebSocketLoader.g_now_sn);
                        break;

                    case "setuserlock":
                        WebSocketLoader.setuserlock(WebSocketLoader.g_now_sn);
                        break;

                    case "getuserlock":
                        WebSocketLoader.getuserlock(WebSocketLoader.g_now_sn, 2);
                        break;

                    case "deleteuserlock":
                        WebSocketLoader.deleteuserlock(WebSocketLoader.g_now_sn, 1);
                        break;

                    case "cleanuserlock":
                        WebSocketLoader.cleanuserlock(WebSocketLoader.g_now_sn);
                        break;

                    case "reboot":
                        WebSocketLoader.reboot(WebSocketLoader.g_now_sn);
                        break;

                    case "settime":
                        WebSocketLoader.settime(WebSocketLoader.g_now_sn);
                        break;

                    case "disabledevice":
                        WebSocketLoader.disabledevice(WebSocketLoader.g_now_sn);
                        break;

                    case "enabledevice":
                        WebSocketLoader.enabledevice(WebSocketLoader.g_now_sn);
                        break;

                    ////////////////////////////////////////////for debug
                    case "uploadalluser":
                        DataTable dbEnrollTble;
                        DataRow   dbRow;
                        DataSet   dsChange;
                        bool      doubleid = false;

                        dbEnrollTble = dsEnrolls.Tables[0];

                        int startalltime = System.Environment.TickCount;
                        int errorcount   = 0;
                        WebSocketLoader.disablereturn = false;
                        WebSocketLoader.disabledevice(WebSocketLoader.g_now_sn);
                        while (!WebSocketLoader.disablereturn)
                        {
                            ;
                        }
                        WebSocketLoader.getuserlistreturn = false;
                        WebSocketLoader.userlistindex     = 0;
                        WebSocketLoader.getuserlist(WebSocketLoader.g_now_sn);
                        while (!WebSocketLoader.getuserlistreturn)
                        {
                            ;
                        }
                        int a = 0;
                        while (a < WebSocketLoader.userlistindex)
                        {
                            errorcount = 0;
getagain:
                            WebSocketLoader.getuserinfoflag = false;
                            SetConsoleColor(ConsoleColor.Green);
                            Console.WriteLine("index:" + a + "==>getuser:"******";backupnum:" + WebSocketLoader.str_userlist[a].backupnum);
                            CheckCanSetConsoleColor();
                            startTime = System.Environment.TickCount;
                            WebSocketLoader.getuserinfo(WebSocketLoader.g_now_sn, WebSocketLoader.str_userlist[a].enrollid, WebSocketLoader.str_userlist[a].backupnum);
                            while (!WebSocketLoader.getuserinfoflag && System.Environment.TickCount - startTime < 10000)
                            {
                                ;
                            }
                            if (System.Environment.TickCount - startTime >= 10000)
                            {
                                if (errorcount > 3)
                                {
                                    Console.WriteLine("error!!!!!!!!!!!!!!!!!!!");
                                    goto getend;
                                }
                                else
                                {
                                    goto getagain;
                                }
                            }

                            endTime = System.Environment.TickCount;
                            runTime = endTime - startTime;
                            SetConsoleColor(ConsoleColor.Red);
                            Console.WriteLine("time=" + runTime + "ms");
                            CheckCanSetConsoleColor();
                            ////////////////////////////save to database
                            doubleid = false;
                            foreach (DataRow dbRow1 in dbEnrollTble.Rows)
                            {
                                if ((int)dbRow1["EnrollNumber"] == WebSocketLoader.tmpuserinfo.enrollid)
                                {
                                    if ((int)dbRow1["FingerNumber"] == WebSocketLoader.tmpuserinfo.backupnum)
                                    {
                                        doubleid = true;
                                        break;
                                    }
                                }
                            }
                            if (doubleid == false)
                            {
                                dbRow = dbEnrollTble.NewRow();
                                dbRow["EnrollNumber"] = WebSocketLoader.tmpuserinfo.enrollid;
                                dbRow["FingerNumber"] = WebSocketLoader.tmpuserinfo.backupnum;
                                dbRow["Privilige"]    = WebSocketLoader.tmpuserinfo.admin;
                                dbRow["Username"]     = WebSocketLoader.tmpuserinfo.name;
                                if (WebSocketLoader.tmpuserinfo.backupnum >= 10)
                                {
                                    dbRow["Password1"] = WebSocketLoader.tmpuserinfo.password;
                                }
                                else
                                {
                                    dbRow["Password1"] = 0;
                                    dbRow["FPdata"]    = WebSocketLoader.tmpuserinfo.fpdata;
                                }
                                dbEnrollTble.Rows.Add(dbRow);
                            }
                            a++;
                            ////////////////////////////////
                        }
                        WebSocketLoader.enablereturn = false;
                        WebSocketLoader.enabledevice(WebSocketLoader.g_now_sn);
                        while (!WebSocketLoader.enablereturn)
                        {
                            ;
                        }
getend:
                        dsChange = dsEnrolls.GetChanges();
                        EnrollData.DataModule.SaveEnrolls(dsEnrolls);
                        SetConsoleColor(ConsoleColor.Red);
                        Console.WriteLine("alltimes=" + (System.Environment.TickCount - startalltime) + "ms");
                        CheckCanSetConsoleColor();
                        break;

                    case "downloadalluser":
                        int    vEnrollNumber;
                        int    vFingerNumber;
                        int    vPrivilege;
                        int    glngEnrollPData;
                        string username;
                        string fpdata;

                        errorcount   = 0;
                        startalltime = System.Environment.TickCount;
                        WebSocketLoader.disablereturn = false;
                        WebSocketLoader.disabledevice(WebSocketLoader.g_now_sn);
                        while (!WebSocketLoader.disablereturn)
                        {
                            ;
                        }
                        dbEnrollTble = dsEnrolls.Tables[0];
                        if (dbEnrollTble.Rows.Count == 0)
                        {
                            SetConsoleColor(ConsoleColor.Red);
                            Console.WriteLine("no data in database!");
                            CheckCanSetConsoleColor();
                            break;
                        }
                        Console.WriteLine("allcount=" + dbEnrollTble.Rows.Count);
                        a = 1;
                        foreach (DataRow dbRow2 in dbEnrollTble.Rows)
                        {
                            errorcount      = 0;
                            vEnrollNumber   = (int)dbRow2["EnrollNumber"];
                            vFingerNumber   = (int)dbRow2["FingerNumber"];
                            vPrivilege      = (int)dbRow2["Privilige"];
                            glngEnrollPData = (int)dbRow2["Password1"];
                            username        = (string)dbRow2["Username"];
                            fpdata          = (string)dbRow2["FPdata"];
sendagain:
                            SetConsoleColor(ConsoleColor.Green);
                            Console.WriteLine("index:" + a + ":enrollid:" + vEnrollNumber + ",backnum=" + vFingerNumber + ",name=" + username);
                            CheckCanSetConsoleColor();
                            WebSocketLoader.setuserinfoflag = false;
                            startTime = System.Environment.TickCount;
                            WebSocketLoader.setuserinfo(WebSocketLoader.g_now_sn, vEnrollNumber, username, vFingerNumber, vPrivilege, glngEnrollPData, fpdata);
                            while (!WebSocketLoader.setuserinfoflag && System.Environment.TickCount - startTime < 10000)
                            {
                                ;
                            }
                            if (System.Environment.TickCount - startTime >= 10000)
                            {
                                errorcount++;
                                if (errorcount > 3)
                                {
                                    Console.WriteLine("error!!!!!!!!!!!!!!!!!!!");
                                    goto sendend;
                                }
                                else
                                {
                                    goto sendagain;
                                }
                            }
                            endTime = System.Environment.TickCount;
                            runTime = endTime - startTime;
                            SetConsoleColor(ConsoleColor.Red);
                            Console.WriteLine("time=" + runTime + "ms");
                            CheckCanSetConsoleColor();
                            a++;
                        }
                        WebSocketLoader.enablereturn = false;
                        WebSocketLoader.enabledevice(WebSocketLoader.g_now_sn);
                        while (!WebSocketLoader.enablereturn)
                        {
                            ;
                        }
sendend:
                        SetConsoleColor(ConsoleColor.Red);
                        Console.WriteLine("alltimes=" + (System.Environment.TickCount - startalltime) + "ms");
                        CheckCanSetConsoleColor();
                        break;

                    case "cleandb":
                        EnrollData.DataModule.DeleteDB();
                        break;

                    default:
                        Console.WriteLine("can not find this command!");
                        break;
                    }
                }
                bootstrap.Stop();
                Console.WriteLine();
                Console.WriteLine("The SuperSocket ServiceEngine has been stopped!");
            }
        }
コード例 #25
0
        private static void RunAsConsole()
        {
            Console.WriteLine("Welcome to FireSinging!");

            Program.CheckCanSetConsoleColor();

            Console.WriteLine("Initializing...");

            IBootstrap bootstrap = BootstrapFactory.CreateBootstrap();

            if (!bootstrap.Initialize())
            {
                Program.SetConsoleColor(ConsoleColor.Red);

                Console.WriteLine("Failed to initialize FireSinging! Please check error log for more information!");

                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Starting...");

                StartResult startResult = bootstrap.Start();

                Console.WriteLine("-------------------------------------------------------------------");

                foreach (IWorkItem workItem in bootstrap.AppServers)
                {
                    if (workItem.State == ServerState.Running)
                    {
                        Program.SetConsoleColor(ConsoleColor.Green);

                        Console.WriteLine("- {0} has been started", (object)workItem.Name);
                    }
                    else
                    {
                        Program.SetConsoleColor(ConsoleColor.Red);

                        Console.WriteLine("- {0} failed to start", (object)workItem.Name);
                    }
                }

                Console.ResetColor();
                Console.WriteLine("-------------------------------------------------------------------");

                switch (startResult)
                {
                case StartResult.None:

                    Program.SetConsoleColor(ConsoleColor.Red);

                    Console.WriteLine("No server is configured, please check you configuration!");
                    Console.ReadKey();

                    return;

                case StartResult.Success:

                    Console.WriteLine("FireSinging has been started!");

                    break;

                case StartResult.PartialSuccess:

                    Program.SetConsoleColor(ConsoleColor.Red);

                    Console.WriteLine("Some server instances were started successfully, but the others failed! Please check error log for more information!");

                    break;

                case StartResult.Failed:

                    Program.SetConsoleColor(ConsoleColor.Red);

                    Console.WriteLine("Failed to start FireSinging! Please check error log for more information!");

                    Console.ReadKey();

                    return;
                }

                Console.ResetColor();
                Console.WriteLine("Enter key 'quit' to stop FireSinging.");

                Program.RegisterCommands();
                Program.ReadConsoleCommand(bootstrap);

                bootstrap.Stop();

                Console.WriteLine("FireSinging has been stopped!");
            }
        }
コード例 #26
0
 public override void OnStop()
 {
     m_Bootstrap.Stop();
     base.OnStop();
 }
コード例 #27
0
 private void StopWebSocketServer()
 {
     _bootstrapFactory.Stop();
 }
コード例 #28
0
 public void TearDown()
 {
     m_Bootstrap.Stop();
     m_Bootstrap = null;
 }
コード例 #29
0
 public bool Stop()
 {
     m_Bootstrap.Stop();
     return(true);
 }
コード例 #30
0
 public void StopServer()
 {
     m_Bootstrap.Stop();
 }