示例#1
0
        protected override JsonCommand DoExecute(BidderRegisterResponse req)
        {
            logger.InfoFormat("Response of ClientLogin: clientNo is {0}", req.ClientNo);

            ClientService.AssignedClientNo = req.ClientNo;

            if (req.ServerTime != null)
            {
                TimeSynchronizer.SyncDateTime(req.ServerTime);
                logger.InfoFormat("in register command - set machine time to {0}", req.ServerTime);
            }



            return(null);
        }
示例#2
0
        private void InitBizComponent()
        {
            robot = ApplicationContext.me.Get <WindowSimulator>();
            // TODO: 开启异步会带来很多不一致,coding时必须实时注意 异步
            robot.SetEnableAsync(false);

            actionManager   = ApplicationContext.me.Get <BidActionManager>();
            biddingScreen   = ApplicationContext.me.Get <BiddingScreen>();
            conf            = ApplicationContext.me.Get <ProjectConfig>();
            loginActManager = ApplicationContext.me.Get <LoginActManager>();

            // 为了禁用js错误提示
            this.webBro.LoadCompleted += new LoadCompletedEventHandler((sender, e) =>
            {
                loginActManager.BeforeLogin();

                logger.InfoFormat("webBro.LoadCompleted - EnableAutoInputAccount is {0}.", conf.EnableAutoInputAccount);

                // TODO: 这里每次都会在每一个页面载入的时候, 都会执行这一段逻辑。所以不能开启这段逻辑
                if (conf.EnableAutoInputAccount)
                {
                    InputLoginAccount();
                }
            });
            this.webBro.Navigated += new NavigatedEventHandler(wbMain_Navigated);
            this.webBro.Navigate(new Uri(conf.BidLoginUrl));

            biddingScreen.SetWebBrowser(this.webBro);
            biddingScreen.SetShowUpBlock(this.RecoBlock);
            biddingScreen.StrategyBlock = this.StrategyBlock;
            biddingScreen.ActionBlock   = this.ActionBlock;

            biddingScreen.SetStrategyText();

            if (conf.EnableSaberRobot)
            {
                socketClient  = ApplicationContext.me.Get <SocketClient>();
                clientService = ApplicationContext.me.Get <ClientService>();

                socketClient.AfterSuccessConnected = (aa) =>
                {
                    try
                    {
                        clientService.DoClientRegister();
                    }
                    catch (Exception e)
                    {
                        logger.Error("DoClientLogin error", e);
                    }
                    return(aa);
                };
                socketClient.EnableSocketGuard = true;

                socketClient.StartClient();
            }

            var captchaTaskDaemon = ApplicationContext.me.Get <CaptchaTaskDaemon>();

            captchaTaskDaemon.SetCaptchaInputCallbackFunc(biddingScreen.CaptchaAnswerInputCallback);
            captchaTaskDaemon.RestartInquiryThread();

            string osName = KK.GetFitOSName();

            logger.InfoFormat("osName is {0}.", osName);

            foreach (int dictIdx in Enum.GetValues(typeof(DictIndex)))
            {
                if (dictIdx == 0)
                {
                    robot.SetDict(0, string.Format("Resource/dict/dict-{0}.txt", osName));
                    continue;
                }

                robot.SetDict(dictIdx, string.Format("Resource/dict/{0}/dict-{0}-{1}.txt", osName, dictIdx));
            }

            if (conf.EnableCorrectNetTime)
            {
                ThreadUtils.StartNewTaskSafe(() => {
                    var bo = TimeSynchronizer.SyncFromNtpServer();
                    logger.InfoFormat("TimeSynchronizer.SyncFromNtpServer result is {0}.", bo);
                });
            }
        }
        protected override JsonCommand DoExecute(string args)
        {
            bool bo = TimeSynchronizer.SyncFromNtpServer();

            return(null);
        }