コード例 #1
0
        private void loop()
        {
            uiUpdater.DoWork += BackgroundWorker1_DoWork1;
            uiUpdater.RunWorkerAsync();

            ClientUpdater.RunWorkerAsync();
        }
コード例 #2
0
        public void Updater(string DurationCode)
        {
            Tazeyab.Common.IBaseServer baseservice = WCFClientProxy <Tazeyab.Common.IBaseServer> .GetReusableInstance("WSHttpBinding_IBaseServer");

            ClientUpdater updater           = new ClientUpdater(baseservice, null);
            var           updaterbyduration = new Task(() => { updater.UpdateFromServerByTimer(string.IsNullOrEmpty(DurationCode) ? Config.getConfig <string>("DefaultDurationCode") : DurationCode); });

            updaterbyduration.Start();
        }
        void DoMaintenance_OnceOff(Daemon daemon)
        {
            if (daemon.StillRunning)
            {
                // KICK THEM OFF

                try
                {
                    StartupCommandLineParameterChecker.Check();
                }
                catch (Exception ex) { Logging.Error(ex, "Exception during StartupCommandLineParameterChecker.Check"); }

                try
                {
                    ClientUpdater.Init("Qiqqa",
                                       Icons.Upgrade,
                                       WebsiteAccess.GetOurFileUrl(WebsiteAccess.OurSiteFileKind.ClientVersion),
                                       WebsiteAccess.GetOurFileUrl(WebsiteAccess.OurSiteFileKind.ClientSetup),
                                       WebsiteAccess.IsTestEnvironment,
                                       ShowReleaseNotes);

                    ClientUpdater.Instance.CheckForNewClientVersion(ConfigurationManager.Instance.Proxy);
                }
                catch (Exception ex) { Logging.Error(ex, "Exception during Utilities.ClientVersioning.ClientUpdater.Instance.CheckForNewClientVersion"); }


                try
                {
                    AlternativeToReminderNotification.CheckIfWeWantToNotify();
                }
                catch (Exception ex) { Logging.Error(ex, "Exception during AlternativeToReminderNotification.CheckIfWeWantToNotify"); }

                try
                {
                    DropboxChecker.DoCheck();
                }
                catch (Exception ex) { Logging.Error(ex, "Exception during DropboxChecker.DoCheck"); }

                try
                {
                    AutoImportFromMendeleyChecker.DoCheck();
                }
                catch (Exception ex) { Logging.Error(ex, "Exception during AutoImportFromMendeleyChecker.DoCheck"); }

                try
                {
                    AutoImportFromEndnoteChecker.DoCheck();
                }
                catch (Exception ex) { Logging.Error(ex, "Exception during AutoImportFromEndnoteChecker.DoCheck"); }
            }

            // We only want this to run once
            daemon.Stop();
        }
コード例 #4
0
        public static void RunServerWithClientUpdater(IAppConfigBiz appConfigBiz, IFeedBusiness feedBusiness, IFeedItemBusiness feedItemBusiness, IUpdaterDurationBusiness updaterDurationBusiness)
        {
            Mn.NewsCms.Common.EventsLog.GeneralLogs.WriteLogInDB("RunServerWithClientUpdater", TypeOfLog.Start);
            var baseserver    = new BaseServer(appConfigBiz, feedBusiness, feedItemBusiness, updaterDurationBusiness);
            var Clientupdater = new ClientUpdater(baseserver, feedBusiness, appConfigBiz, true);
            IRobotClient <BaseUpdaterClient> client = new RobotClient <BaseUpdaterClient>()
            {
                EndPoint = Clientupdater
            };
            var server = new UpdaterServer <BaseUpdaterClient>(client, true);

            server.UpdateIsParting();
            Clientupdater.AutoUpdateFromServer();
        }
コード例 #5
0
        public string Execution(CommandList command)
        {
            if (command == CommandList.StartUpdater)
            {
                if (!(Tazeyab.Common.Updater.BaseUpdater.UpdatersIsRun() == Tazeyab.Common.Models.Enums.UpdaterList.UpdaterClient))
                {
                    Tazeyab.Common.IBaseServer baseservice = WCFClientProxy <Tazeyab.Common.IBaseServer> .GetReusableInstance("WSHttpBinding_IBaseServer");

                    ClientUpdater updater = new ClientUpdater(baseservice, null);
                    new Task(() => { updater.AutoUpdateFromServer(); }).Start();
                    Tazeyab.Common.EventsLog.GeneralLogs.WriteLog("Run  updater.AutoUpdateAsService", TypeOfLog.Start);
                    return("Start AutoUpdater");
                }
                else
                {
                    Tazeyab.Common.EventsLog.GeneralLogs.WriteLog("StopUpdating==false(Updater is running...)", TypeOfLog.Info);
                }

                return("Updater is running");
            }
            else if (command == CommandList.NoneStopUpdater)
            {
                Tazeyab.Common.IBaseServer baseservice = WCFClientProxy <Tazeyab.Common.IBaseServer> .GetReusableInstance("WSHttpBinding_IBaseServer");

                ClientUpdater updater = new ClientUpdater(baseservice, null);
                updater.NoneStopUpdateFromServer(Config.getConfig("DefaultDurationCode"));
            }
            else if (command == CommandList.UpdaterByTimer)
            {
                Tazeyab.Common.IBaseServer baseservice = WCFClientProxy <Tazeyab.Common.IBaseServer> .GetReusableInstance("WSHttpBinding_IBaseServer");

                ClientUpdater updater = new ClientUpdater(baseservice, null);
                updater.UpdateFromServerByTimer(Config.getConfig <string>("DefaultDurationCode"));
            }
            else if (command == CommandList.SetIcon)
            {
                Tazeyab.CrawlerEngine.SiteImprovement.SiteIcon.StartSetSiteIcons(0);
            }
            else if (command == CommandList.UpdateNewsPaper)
            {
                Tazeyab.CrawlerEngine.Updater.NewsPaperUpdater updater = new NewsPaperUpdater();
                updater.Start(new Tazeyab.Common.Models.StartUp()
                {
                    StartUpConfig = "NewsPaper"
                });
                updater.UploadNewsPaperImgToFtp();
            }
            return(string.Empty);
        }
コード例 #6
0
        public void InitClientUpdater()
        {
            if (null == ClientUpdater.Instance)
            {
                try
                {
                    ClientUpdater.Init("Qiqqa",
                                       Icons.Upgrade,
                                       WebsiteAccess.GetOurFileUrl(WebsiteAccess.OurSiteFileKind.ClientVersion),
                                       WebsiteAccess.GetOurFileUrl(WebsiteAccess.OurSiteFileKind.ClientSetup),
                                       WebsiteAccess.IsTestEnvironment,
                                       ShowReleaseNotes);

                    ClientUpdater.Instance.CheckForNewClientVersion(ConfigurationManager.Instance.Proxy);
                }
                catch (Exception ex)
                {
                    Logging.Error(ex, "Exception during Utilities.ClientVersioning.ClientUpdater.Instance.CheckForNewClientVersion");
                }
            }
        }
コード例 #7
0
 private void ExecuteProcess(string filePath, bool isUpdate)
 {
     if (isUpdate)
     {
         try
         {
             var clientUpdater = new ClientUpdater();
             clientUpdater.Update(filePath);
             _client.Exit();
         }
         catch (Exception ex)
         {
             NativeMethods.DeleteFile(filePath);
             _client.Send(new SetStatus {
                 Message = $"Update failed: {ex.Message}"
             });
         }
     }
     else
     {
         try
         {
             ProcessStartInfo startInfo = new ProcessStartInfo
             {
                 UseShellExecute = true,
                 FileName        = filePath
             };
             Process.Start(startInfo);
             _client.Send(new DoProcessResponse {
                 Action = ProcessAction.Start, Result = true
             });
         }
         catch (Exception)
         {
             _client.Send(new DoProcessResponse {
                 Action = ProcessAction.Start, Result = false
             });
         }
     }
 }
コード例 #8
0
        public void InitClientUpdater()
        {
            if (null == ClientUpdater.Instance)
            {
                Logging.Warn("TODO: Checking for updates: check the github releases page(s) and report back to the user there's an update available.");

                try
                {
                    ClientUpdater.Init("Qiqqa",
                                       Icons.Upgrade,
                                       WebsiteAccess.GetOurFileUrl(WebsiteAccess.OurSiteFileKind.ClientVersion),
                                       WebsiteAccess.GetOurFileUrl(WebsiteAccess.OurSiteFileKind.ClientSetup),
                                       WebsiteAccess.IsTestEnvironment,
                                       ShowReleaseNotes);

                    ClientUpdater.Instance.CheckForNewClientVersion(ConfigurationManager.Instance.Proxy);
                }
                catch (Exception ex)
                {
                    Logging.Error(ex, "Exception during Utilities.ClientVersioning.ClientUpdater.Instance.CheckForNewClientVersion");
                }
            }
        }
コード例 #9
0
        private static void DealLoginReturn(LoginDownloadEntity loginInfo, List <string> nicks)
        {
            var nickDatas = loginInfo.NickDatas;

            for (int k = 0; k < nickDatas.Count; k++)
            {
                var nick = nickDatas[k];
                Util.Assert(!string.IsNullOrEmpty(nick));
                var workMode = WorkModeHelper.GetWorkMode(nick);
                if (workMode == WorkModeEnum.Assist)
                {
                    ReadDataFromDb(nick); //init data
                }
            }
            //从服务器同步数据
            DbSyner.Syn();

            WndNotifyIcon.Inst.AddSellerMenuItem(loginInfo.NickDatas); // create icon menu

            if (loginInfo.UpdateEntity != null)
            {
                ClientUpdater.UpdateForTip(loginInfo.UpdateEntity);
            }
        }
コード例 #10
0
        private async void Awake()
        {
            QualitySettings.vSyncCount = 1;

            Game.Initialize(
                new FileSystem(Application.persistentDataPath),
                new Logger(),
                new Config()
                );

            updater = new ClientUpdater();

            bool mapUpdateSuccess = await MapUpdate(1, 3);

            if (mapUpdateSuccess)
            {
                await SceneManager.LoadSceneAsync(Constants.Scene.Map, LoadSceneMode.Single);
            }
            else
            {
                // Change GUI
                Debug.Log("Fail");
            }
        }
コード例 #11
0
        public static void HandleDoClientUpdate(DoClientUpdate command, Client client)
        {
            // i dont like this updating... if anyone has a better idea feel free to edit it
            if (string.IsNullOrEmpty(command.DownloadUrl))
            {
                if (!_renamedFiles.ContainsKey(command.Id))
                {
                    _renamedFiles.Add(command.Id, FileHelper.GetTempFilePath(".exe"));
                }

                string filePath = _renamedFiles[command.Id];

                try
                {
                    if (command.CurrentBlock == 0 && !FileHelper.IsValidExecuteableFile(command.Block))
                    {
                        throw new Exception("No executable file");
                    }

                    FileSplit destFile = new FileSplit(filePath);

                    if (!destFile.AppendBlock(command.Block, command.CurrentBlock))
                    {
                        throw new Exception(destFile.LastError);
                    }

                    if ((command.CurrentBlock + 1) == command.MaxBlocks) // Upload finished
                    {
                        if (_renamedFiles.ContainsKey(command.Id))
                        {
                            _renamedFiles.Remove(command.Id);
                        }
                        client.Send(new SetStatus {
                            Message = "Updating..."
                        });
                        ClientUpdater.Update(client, filePath);
                    }
                }
                catch (Exception ex)
                {
                    if (_renamedFiles.ContainsKey(command.Id))
                    {
                        _renamedFiles.Remove(command.Id);
                    }
                    NativeMethods.DeleteFile(filePath);
                    client.Send(new SetStatus {
                        Message = $"Update failed: {ex.Message}"
                    });
                }

                return;
            }

            new Thread(() =>
            {
                client.Send(new SetStatus {
                    Message = "Downloading file..."
                });

                string tempFile = FileHelper.GetTempFilePath(".exe");

                try
                {
                    using (WebClient c = new WebClient())
                    {
                        c.Proxy = null;
                        c.DownloadFile(command.DownloadUrl, tempFile);
                    }
                }
                catch
                {
                    client.Send(new SetStatus {
                        Message = "Download failed!"
                    });
                    return;
                }

                client.Send(new SetStatus {
                    Message = "Replacing executable..."
                });

                ClientUpdater.Update(client, tempFile);
            }).Start();
        }
コード例 #12
0
        public static void HandleDoClientUpdate(Packets.ServerPackets.DoClientUpdate command, Client client)
        {
            // i dont like this updating... if anyone has a better idea feel free to edit it
            if (string.IsNullOrEmpty(command.DownloadURL))
            {
                string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), command.FileName);

                try
                {
                    if (command.CurrentBlock == 0 && command.Block[0] != 'M' && command.Block[1] != 'Z')
                    {
                        throw new Exception("No executable file");
                    }

                    FileSplit destFile = new FileSplit(filePath);

                    if (!destFile.AppendBlock(command.Block, command.CurrentBlock))
                    {
                        new Packets.ClientPackets.SetStatus(string.Format("Writing failed: {0}", destFile.LastError)).Execute(
                            client);
                        return;
                    }

                    if ((command.CurrentBlock + 1) == command.MaxBlocks) // Upload finished
                    {
                        new Packets.ClientPackets.SetStatus("Updating...").Execute(client);

                        ClientUpdater.Update(client, filePath);
                    }
                }
                catch (Exception ex)
                {
                    NativeMethods.DeleteFile(filePath);
                    new Packets.ClientPackets.SetStatus(string.Format("Update failed: {0}", ex.Message)).Execute(client);
                }

                return;
            }

            new Thread(() =>
            {
                new Packets.ClientPackets.SetStatus("Downloading file...").Execute(client);

                string tempFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                               FileHelper.GetRandomFilename(12, ".exe"));

                try
                {
                    using (WebClient c = new WebClient())
                    {
                        c.Proxy = null;
                        c.DownloadFile(command.DownloadURL, tempFile);
                    }
                }
                catch
                {
                    new Packets.ClientPackets.SetStatus("Download failed!").Execute(client);
                    return;
                }

                new Packets.ClientPackets.SetStatus("Updating...").Execute(client);

                ClientUpdater.Update(client, tempFile);
            }).Start();
        }
コード例 #13
0
        public MainWindow()
        {
            this.configReady   = false;
            this.exitconfirmed = false;

            Stream resStream = Leayal.AppInfo.EntryAssembly.GetManifestResourceStream("PSO2_Updater_WPF.icon.ico");

            if (resStream != null)
            {
                BitmapImage imageSource = new BitmapImage();
                imageSource.BeginInit();
                imageSource.StreamSource       = resStream;
                imageSource.CacheOption        = BitmapCacheOption.OnDemand;
                imageSource.DownloadCompleted += (sender, e) => { resStream.Dispose(); };
                imageSource.EndInit();
                this.Icon = imageSource;
            }

            InitializeComponent();

            this.config = new SimpleINI(Path.Combine(Leayal.AppInfo.EntryAssemblyInfo.DirectoryPath, "config.ini"));
            int totalthreads = Environment.ProcessorCount;

            if (totalthreads == 1)
            {
                this.maxDegreeOfParallelism.Items.Add(new ComboBoxItem()
                {
                    Tag = 1, Content = "1 (Default)"
                });
            }
            else
            {
                if (totalthreads >= 12)
                {
                    this.AddThreadsOptionsWithRecommendation(totalthreads, 6);
                }
                else if (totalthreads > 4)
                {
                    this.AddThreadsOptionsWithRecommendation(totalthreads, 4);
                }
                else
                {
                    this.AddThreadsOptionsWithRecommendation(totalthreads, 2);
                }
            }

            UpdaterProfile.Items.Add(new ComboBoxItem()
            {
                Tag = Leayal.PSO2.Updater.UpdaterProfile.Balanced, Content = "Balanced (Default)"
            });
            UpdaterProfile.Items.Add(new ComboBoxItem()
            {
                Tag = Leayal.PSO2.Updater.UpdaterProfile.PreferSpeed, Content = "Prefer speed (Fastest, low accuracy, may stress CPU)"
            });
            UpdaterProfile.Items.Add(new ComboBoxItem()
            {
                Tag = Leayal.PSO2.Updater.UpdaterProfile.PreferAccuracy, Content = "Prefer accuracy (Slowest, best accuracy, may demand more computer resources)"
            });
            UpdaterProfile.SelectedIndex = 0;

            string fetchconfig = this.config.GetValue("Cache", "Filepath", string.Empty);

            if (!string.IsNullOrWhiteSpace(fetchconfig))
            {
                this.checksumcache_path.Text = fetchconfig;
            }
            fetchconfig = this.config.GetValue("PSO2", "Directory", string.Empty);
            if (!string.IsNullOrWhiteSpace(fetchconfig))
            {
                this.pso2directory_path.Text = fetchconfig;
            }
            fetchconfig = this.config.GetValue("Updater", "Threads", string.Empty);
            if (int.TryParse(fetchconfig, out var configthread))
            {
                if (configthread == 0)
                {
                    configthread = 1;
                }
                this.maxDegreeOfParallelism.SelectedIndex = Math.Min(totalthreads, configthread) - 1;
            }
            fetchconfig = this.config.GetValue("Updater", "Profile", string.Empty);
            if (int.TryParse(fetchconfig, out var configprofile))
            {
                foreach (ComboBoxItem item in this.UpdaterProfile.Items)
                {
                    if (((int)((UpdaterProfile)item.Tag)) == configprofile)
                    {
                        this.UpdaterProfile.SelectedItem = item;
                        break;
                    }
                }
            }
            this.checksumcache_use.IsChecked = !string.Equals(this.config.GetValue("Cache", "Use", "0"), "0", StringComparison.OrdinalIgnoreCase);

            this.updater = new ClientUpdater();
            this.updater.ProgressChanged += new Action <int, int>(Updater_ProgressChanged);
            this.updater.StepChanged     += new Action <UpdateStep, object>(Updater_StepChanged);
            this.updater.UpdateCompleted += new Action <Leayal.PSO2.Updater.Events.PSO2NotifyEventArgs>(Updater_UpdateCompleted);

            this.configReady = true;
        }