Пример #1
0
        public void Execute(IJobExecutionContext context)
        {
            Thread thread = new Thread(() =>
            {
                try
                {
                    Random random = new Random(Guid.NewGuid().GetHashCode());
                    Thread.Sleep(random.Next(1, 3600 * 4) * 1000);//4小时内,暂停随机时间

                    LogHelper.CommLogger.Info("CheckUpdateJob...");
                    UpdateRequest updateRequest = CheckUpdateHelper.GetUploadRequest();
                    if (updateRequest != null)
                    {
                        LogHelper.CommLogger.Info("开始执行升级操作");
                        CheckUpdateHelper.ExecuteUpdate(updateRequest);
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.CommLogger.Error(ex, "CheckUpdateJob失败");
                }
            });

            thread.Name         = "检测升级线程";
            thread.IsBackground = true;
            thread.Start();
            //测试
            //UpdateRequest updateRequest = new UpdateRequest();
            //updateRequest.Guid = Guid.NewGuid().ToString();
            //updateRequest.Product = "JSOCT2016";
            //updateRequest.RootPath = @"D:\Program Files (x86)\Jielink";
            //updateRequest.PackagePath = @"D:\迅雷下载\JSOCT2016 V2.6.2 Jielink+智能终端操作平台安装包\obj\JSOCT2016-V2.6.2.zip";
            //ExecuteUpdate(updateRequest);
        }
Пример #2
0
        public void Execute(IJobExecutionContext context)
        {
            context.Scheduler.UnscheduleJob(context.Trigger.Key);
            UpdateRequest updateRequest = CheckUpdateHelper.GetUploadRequest();

            if (updateRequest != null)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    if (MessageBoxHelper.MessageBoxShowQuestion($"检测到新版本{updateRequest.Version}[当前版本{EnvironmentInfo.CurrentVersion}],是否立即升级?") == MessageBoxResult.Yes)
                    {
                        CheckUpdateHelper.ExecuteUpdate(updateRequest);
                    }
                }));
            }
        }
        public void Execute(IJobExecutionContext context)
        {
            Console.WriteLine("CheckUpdateJob...");
            UpdateRequest updateRequest = CheckUpdateHelper.GetUploadRequest();

            if (updateRequest != null)
            {
                CheckUpdateHelper.ExecuteUpdate(updateRequest);
            }

            //测试
            //UpdateRequest updateRequest = new UpdateRequest();
            //updateRequest.Guid = Guid.NewGuid().ToString();
            //updateRequest.Product = "JSOCT2016";
            //updateRequest.RootPath = @"D:\Program Files (x86)\Jielink";
            //updateRequest.PackagePath = @"D:\迅雷下载\JSOCT2016 V2.6.2 Jielink+智能终端操作平台安装包\obj\JSOCT2016-V2.6.2.zip";
            //ExecuteUpdate(updateRequest);
        }