Exemple #1
0
        static void Main(string[] args)
        {
            try
            {
                rootReg = new Reg("sfMinerDigger");
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                int systemBegin = Environment.TickCount;
                Logger.OnLog += (x, xx) => { Console.WriteLine(xx.LogInfo); };


                var mainThreadCounter = rootReg.In("Main").In("Thread").In("Main");
                while (true)
                {
                    Thread.Sleep(1000);
                    switch (vpsStatus)
                    {
                    case VpsStatus.WaitConnect:
                    {
                        InitTcp();
                        vpsStatus = VpsStatus.Connecting;
                        break;
                    }
                    }
                }
            }
            catch (Exception ex)
            {
                var info = ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace;
                Program.setting.LogInfo(info, "ExceptionLog");
                Clipboard.SetText(info);
                Thread.Sleep(5000);
            }
        }
Exemple #2
0
 private static void ServerResetConfig()
 {
     vpsStatus      = VpsStatus.Running;
     anyTaskWorking = true;
     servers        = new ServerList();
     SummomPriceRule.Init();
     Goods.Equiment.EquimentPrice.Init();
     servers.ResetConfig(settingDelayTime, settingAssumePriceRate);
     Tcp.Send(new RpClientRunReadyMessage());
 }
Exemple #3
0
        private static void InitTcp()
        {
            var clientId       = rootReg.In("Main").In("Setting");
            var vpsName        = clientId.GetInfo("VpsClientId", "null");
            var clientDeviceId = clientId.GetInfo("clientDeviceId", HttpUtil.UUID);

            Tcp = new SfTcp.SfTcpClient();
            Tcp.RecieveMessage = (x, xx) =>
            {
                Logger.SysLog(xx, "通讯记录");
                if (xx.Contains("<setClientName>"))
                {
                    var ClientName = HttpUtil.GetElementInItem(xx, "setClientName");
                    setting = new Setting(ClientName);
                    clientId.SetInfo("VpsClientId", ClientName);
                    Program.vpsStatus = VpsStatus.Running;
                    Tcp.Send("<InitComplete>");
                }
                if (xx.Contains("<serverRun>"))
                {
                    ServerRun();
                }
                if (xx.Contains("<setting>"))
                {
                    SynSetting(xx);
                }

                if (xx.Contains("<versionCheck>"))
                {
                    SynFile(xx);
                }
            };
            Tcp.Disconnected = (x) => {
                Program.vpsStatus = VpsStatus.WaitConnect;
                Logger.SysLog("与服务器丢失连接.", "主记录");
            };

            Tcp.Send("<connectCmdRequire>" + vpsName + "</connectCmdRequire><clientDeviceId>" + clientDeviceId + "</clientDeviceId>");
        }
Exemple #4
0
        private static void Main(string[] args)
        {
            var fileName = Process.GetCurrentProcess().MainModule.FileName;
            var targetIp = HttpUtil.GetElement(fileName, "(", ")");

            if (targetIp != null)
            {
                var tmpInfo = targetIp.Split('!');
                if (tmpInfo.Length == 4)
                {
                    TcpMainTubeIp   = tmpInfo[0];
                    TcpMainTubePort = Convert.ToInt32(tmpInfo[1]);
                    TcpFileTubeIp   = tmpInfo[2];
                    TcpFileTubePort = Convert.ToInt32(tmpInfo[3]);
                }
            }

            rootReg  = new Reg("sfMinerDigger");
            clientId = rootReg.In("Main").In("Setting");
            CheckLastLoadEquipmentSetting();
            if (rootReg.In("Setting").GetInfo("developeModel") == "1")
            {
                Logger.OnLog            += (x, xx) => { Console.WriteLine(xx.LogInfo); };
                Logger.IsOnDevelopeModel = true;
            }

            try
            {
                var mainThreadCounter = rootReg.In("Main").In("Thread").In("Main");
                while (true)
                {
                    Thread.Sleep(1000);
                    if (VpsStatus.Running != vpsStatus)
                    {
                        Console.WriteLine(vpsStatus);
                    }
                    switch (vpsStatus)
                    {
                    case VpsStatus.Connecting:
                    {
                        if (disconnectTime++ > 5 && anyTaskWorking == false)
                        {
                            disconnectTime = 0;
                            vpsStatus      = VpsStatus.WaitConnect;
                        }
                        break;
                    }

                    case VpsStatus.WaitConnect:
                    {
                        if (disconnectTime++ > 5 && anyTaskWorking == false)
                        {
                            if (connectFailTime++ > 2)
                            {
                                connectFailTime = 0;
                                RedialToInternet();
                                Program.setting.LogInfo("连接到服务器失败次数达上限,重新拨号", "通讯记录");
                            }
                            else
                            {
                                disconnectTime = 0;
                                vpsStatus      = VpsStatus.Connecting;
                                InitTcp();
                            };                                            //尝试连接次数过多,则重连宽带

                            disconnectTime = 0;
                        }

                        break;
                    }

                    case VpsStatus.Idle:
                    {
                        if (idleTime-- < 0 && anyTaskWorking == false)
                        {
                            CheckLastLoadEquipmentSetting();
                            HelloToServer();
                            idleTime = 30;
                        }
                        break;
                    }

                    case VpsStatus.Running:
                    {
                        if (Environment.TickCount - servers.LastServerRunTime > 10000)
                        {
                            vpsIsDigging = false;
                            ServerBeginRun(0);
                        }
                        break;
                    }

                    case VpsStatus.Syning:
                    {
                        if (Tcp == null)
                        {
                            vpsStatus = VpsStatus.WaitConnect;
                        }
                        else
                        {
                            if (disconnectTime++ > 15 && anyTaskWorking == false)
                            {
                                disconnectTime = 0;
                                vpsStatus      = VpsStatus.WaitConnect;
                            }
                        }
                        break;
                    }
                    }
                }
            }
            catch (Exception ex)
            {
                var info = ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace;
                Logger.SysLog(info, "ExceptionLog");
                Clipboard.SetText(info);
                Thread.Sleep(5000);
            }
        }