Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            WxFrameworkService.Instance.Init();

            var processes = Process.GetProcessesByName("uqee");

            foreach (var p in processes)
            {
                p.Kill();
                p.Close();
                p.Dispose();
            }

            var file    = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "account.xml");
            var account = MainAccountInfo.LoadAccount(file);
            var entity  = new AssistEntity(account);

            AssistTaskMgr.Instance.InitEntityTasks(entity);
            entity.Start();

            while (true)
            {
                Thread.Sleep(60000);
            }
        }
Exemplo n.º 2
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);
        }