Ejemplo n.º 1
0
        public void Start()
        {
            m_accountInfo = MainAccountInfo.LoadAccount(m_mainFile);
            if (!File.Exists(m_mainFile))
            {
                m_accountInfo.Save();
            }

            m_mainEntity = new MainEntity(m_accountInfo);
            MainTaskMgr.Instance.InitEntityTasks(m_mainEntity);
            m_mainEntity.DescriptionChanged += MainEntityOnDescriptionChanged;
            m_mainEntity.Start();

            foreach (var t in WxHelper.GetEnumValues <WlySwitchType>())
            {
                var info    = m_accountInfo.GetSwitchInfo(t);
                var wrapper = new WlyTaskSwitchWrapper(info);
                wrapper.Changed += WrapperOnChanged;
                Switches.Add(wrapper);
            }

            // 主账号监测
            m_cancellationTokenSource = new CancellationTokenSource();
            var token = m_cancellationTokenSource.Token;

            Task.Run(() =>
            {
                while (!token.IsCancellationRequested)
                {
                    try
                    {
                        Thread.Sleep(TimeSpan.FromMinutes(1));
                        if (!m_mainEntity.Run)
                        {
                            WxLog.Debug($"WlyAutoVM.Start 对主账号进行重置 <{DateTime.Now}>");
                            m_mainEntity.Stop();
                            m_mainEntity.DescriptionChanged -= MainEntityOnDescriptionChanged;
                            MainEntity = new MainEntity(m_accountInfo);
                            MainTaskMgr.Instance.InitEntityTasks(m_mainEntity);
                            m_mainEntity.DescriptionChanged += MainEntityOnDescriptionChanged;
                            m_mainEntity.Start();
                        }
                    }
                    catch (Exception ex)
                    {
                        WxLog.Error($"WlyAutoVM.Start Error <{ex}>");
                    }
                }

                WxLog.Debug($"WlyAutoVM.Start Stop On <{ResetTime}>");
            }, token);

            //StartSubCmdExecute(this);
        }
Ejemplo n.º 2
0
        private void BeginAutoHookCmdExecute(object obj)
        {
            if (m_mainEntity != null)
            {
                return;
            }

            m_mainEntity = new MainEntity(Account, Password);
            m_mainEntity.Start(m_config.ProgramPath);
        }