示例#1
0
        static void Main()
        {
            if (appUnique.IsUnique("BigBirdConsole"))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                R.MainUI = new MainForm();

                //初始化配置信息
                InitConfig();
                R.Log = new Log();                  //启动日志记录
                SystemSleepAPI.PreventSleep(false); //禁用计算机息屏和待机

                //启动进程
                TxHelper.Start();
                TxConvertHelper.Connect();
                TxReadQueue.Start();
                PlanTaskCore.Start();
                StorePersistanceTask.Start();
                CommandReader.Start();

                Application.Run(R.MainUI);
            }
        }
示例#2
0
 private void button2_Click(object sender, EventArgs e)
 {
     SystemSleepAPI.ResotreSleep();
     label2.Text = "已恢复";
 }
示例#3
0
        static void Main()
        {
            //taskkill /IM BigBirdDeployer-1.exe /F
            //启动自动运行指定最新版本
            string appoint_name = IniTool.GetString(R.Files.Settings, "Appoint", "Name", "");
            string appoint_md5  = IniTool.GetString(R.Files.Settings, "Appoint", "MD5", "");
            string current_file = Path.GetFileName(R.Files.App);

            if (Str.Ok(appoint_name, appoint_md5))
            {
                string file = DirTool.Combine(R.Paths.App, appoint_name);
                if (File.Exists(file) && FileTool.GetMD5(file) == appoint_md5)
                {
                    R.Log.V($"appoint:{appoint_name}   current:{current_file}");
                    R.Log.V($"appoint:{file}   current:{R.Files.App}");

                    if (appoint_name != current_file)
                    {
                        if (ProcessTool.Start(file))
                        {
                            return;
                        }
                    }
                }
            }

            //var a = FileTool.GetAllFile(@"F:\Temp\logs", new[] { "*.log"});
            //解决进程互斥
            if (!AppUnique.IsUnique(R.AppName))
            {
                return;
            }

            try
            {
                //处理未捕获的异常
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                //处理UI线程异常
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                //处理非UI线程异常
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                R.Log.i("========== 程序启动:BigBirdDeployer(正常启动) ==========");
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                R.MainUI = new MainForm();

                InitIni();                           //初始化Ini配置信息
                StatusLog.Instance.Start();          //启动计算机状态日志记录
                R.Log.SetCacheDays(10);              //保存最近10天的普通日志信息
                StatusLog.Instance.SetCacheDays(10); //保存最近10天的状态日志信息
                SystemSleepAPI.PreventSleep(false);  //禁用计算机息屏和待机
                PlanTaskCore.Start();                //启动定时任务

                Application.Run(R.MainUI);           //启动主UI
            }
            catch (Exception ex)
            {
                R.Log.e("应用程序异常 App Main Exception");
                WriteExceptionAndRestart(ex);
            }
        }
示例#4
0
 private void button1_Click(object sender, EventArgs e)
 {
     SystemSleepAPI.PreventSleep(true);
     label2.Text = "已阻止";
 }