private void T_WORK() { try { DataTable dtResult = DBConnect.GetQueryResult(DBCommand.GetNewestWinVersion); if (dtResult != null) { byte[] DATA = (byte[])dtResult.Rows[0]["PAYLOAD"]; string VERSION = (string)dtResult.Rows[0]["VERSION_NO"]; string CHANGELOG = (string)dtResult.Rows[0]["CHANGELOG"]; DateTime RELEASE_DATE = (DateTime)dtResult.Rows[0]["DATE_OF_RELEASE"]; string tmpFileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".zip"; System.IO.File.WriteAllBytes(tmpFileName, DATA); System.Diagnostics.Process.Start(tmpFileName); UpdateComplete?.Invoke(new UpdateCompleteEventArgs(CHANGELOG, VERSION, true)); } } catch (Exception ex) { ErrorHandler.Handle(ex); UpdateComplete?.Invoke(new UpdateCompleteEventArgs("", "", false)); } }
public void DownloadUpdate(UpdateInfoArgs info, string dstPath) { try { // Create tmp file name string file = dstPath + ".tmp"; // Download the file to the tmp path Client.DownloadFile(info.UpdateItem, file); if (File.Exists(dstPath)) { // Delete current File.Delete(dstPath); } // Now that the file has downloaded we need to move it ot the dst path File.Move(file, dstPath); // Delete temp file File.Delete(file); // Invoke the update event UpdateComplete?.Invoke(this, info, dstPath); } catch (Exception ex) { throw new Exception("An error has occured while attempting to update. Please try again."); } }
public virtual void EndUpdate() { if (UpdateLocks == 0) { throw new InvalidOperationException("EndUpdate() called before BeginUpdate()"); } UpdateLocks--; if (UpdateLocks == 0) { // Rebuilt folder caches if necessary: if (folderCachesToBeRebuilt.Count > 0 && Options.HasFlag(LogicalTreeOptions.DisplayFolders)) { foreach (var table in folderCachesToBeRebuilt) { RebuildFolderCacheForTable(table); } folderCachesToBeRebuilt.Clear(); } if (Handler != null && Handler.UndoManager.BatchSize > 0) { UpdateComplete?.Invoke(this, new EventArgs()); } } }
protected virtual void ProcessUpdate() { SetLastError(string.Empty); UpdateStarted?.Invoke(this, EventArgs.Empty); DirectoryScanStarted?.Invoke(this, EventArgs.Empty); LocalFileMap.Clear(); BuildLocalFileMap(RootDir); DirectoryScanEnded?.Invoke(this, EventArgs.Empty); if (!GetRemoteFileList()) { FailThread(); return; } if (FilesToDownload.Count > 0) { SyncFiles(); } else { FileSyncNotNeeded?.Invoke(this, EventArgs.Empty); } lock (GUILocker) { Worker = null; InProgress = false; } UpdateComplete?.Invoke(this, EventArgs.Empty); }
void FileUpdateing(ByteFileInfoList pInfo, UpdateComplete onComplete, bool autoRetry) { curInfo = pInfo; curOnComplete = onComplete; curAutoRetry = autoRetry; ReleaseGroupLoader(); downLoadGroup = new DownLoadGroup("updateGroup"); foreach (var item in pInfo.fileInfoList) { string turl = GetServerUrl(item.resName); var tloader = downLoadGroup.AddByUrl(turl, GameCore.PersistentResDataPath, item.resName, item.fileMD5, item.fileSize, false); tloader.priority = item.priority; tloader.OnComplete += (a) => { if (a.IsCompleteDownLoad) { OnUpdateOneComplete(pInfo[a.FileName]); } }; } downLoadGroup.StartAsync(); UpdateProcess(); StartCoroutine(WaitUpdateDone()); }
public void OnUpdateComplete() { UpdateComplete?.Invoke(null, new UpdaterCompleteEventArgs() { UpdateSuccessful = true }); MyForm.Close(); }
public void ExecuteUpdate() { _downloadWorker = new BackgroundWorker() { WorkerSupportsCancellation = true, WorkerReportsProgress = true }; _downloadWorker.DoWork += (s, e) => { var fileRequest = WebRequest.Create(Manifest.PackageUrl); var fileResponse = fileRequest.GetResponse(); InstallerPath = Path.GetTempPath() + @"\" + GetFilenameFromUrl(Manifest.PackageUrl); using (var stream = fileResponse.GetResponseStream()) { ReadStreamToFile(stream, InstallerPath, (int)fileResponse.ContentLength); } if (_downloadWorker.CancellationPending) { e.Cancel = true; } else { CheckSignature(InstallerPath); // will throw on error } }; _downloadWorker.RunWorkerCompleted += (s, e) => { if (e.Cancelled) { Logger.Warn("update cancelled"); UpdateComplete?.Invoke(this, EventArgs.Empty); } else if (e.Error != null) { Logger.WarnException("an error occured processing update", e.Error); UpdateError?.Invoke(e.Error, EventArgs.Empty); } else { Process.Start(InstallerPath); Thread.Sleep(2000); UpdateComplete?.Invoke(this, EventArgs.Empty); App.Shutdown(); } }; _downloadWorker.ProgressChanged += (s, e) => { ProgressUpdate?.Invoke(e.ProgressPercentage); }; _downloadWorker.RunWorkerAsync(); }
static public void UpdateRes(ByteFileInfoList pInfo, UpdateComplete onComplete, bool autoRetry) { if (isUpdateing) { Debug.LogError("Updateing."); return; } isUpdateing = true; Instance.StartCoroutine(Instance.WaitStarUpdate(0.1f, pInfo, onComplete, autoRetry)); }
private void ErrorCallback(Exception e, string msg) { if (UpdateComplete != null) { UpdateComplete.Invoke(this, EventArgs.Empty); } ErrorWindow wnd = new ErrorWindow(e, msg); wnd.Show(); }
/// <summary> /// Refresh the weather data and update <see cref="DailyWeatherList"/> and <see cref="NextHoursWeatherList"/> lists /// </summary> /// <returns>Task</returns> public async Task RefreshAsync() { dynamic dailyWeather = await meteoClient.GetJsonAsync(new Uri($"https://api.meteo-concept.com/api/forecast/daily?insee={InseeNb}")); dynamic nextHoursWeather = await meteoClient.GetJsonAsync(new Uri($"https://api.meteo-concept.com/api/forecast/nextHours?insee={InseeNb}&hourly=true")); UpdateWeatherLists(dailyWeather, nextHoursWeather); UpdateComplete?.Invoke(); }
private void DataRetrieved(IList <PsaDataset> dataRetrieved) { data.Clear(); foreach (PsaDataset dataset in dataRetrieved) { data.Add(new PsaDatasetViewModel(dataset)); } if (UpdateComplete != null) { UpdateComplete.Invoke(this, EventArgs.Empty); } }
void CallUpdateOnComplete(UpdateComplete onComplete, ByteFileInfoList pInfo, string pError) { try { ReleaseGroupLoader(); ReTryCount = 0; onComplete?.Invoke(pInfo, pError); } catch (System.Exception erro) { Debug.LogError("CheckUpdate->" + erro.ToString()); } }
public virtual void EndUpdate() { if (UpdateLocks == 0) { throw new InvalidOperationException("EndUpdate() called before BeginUpdate()"); } UpdateLocks--; if (UpdateLocks == 0) { UpdateComplete?.Invoke(this, new EventArgs()); } }
public static void Start() { network.Start(config.MulticastInterface); redistribution.UpdateStart += () => UpdateStart?.Invoke(); redistribution.UpdateComplete += () => UpdateComplete?.Invoke(); redistribution.StateChangeEvent += (s) => StateChangeEvent?.Invoke(s); redistribution.HandleLogEvent += _client_HandleLogEvent; redistribution.HandleErrorEvent += _client_HandleErrorEvent; _client = new Client(network, config, redistribution); _client.StateChangeEvent += (s) => StateChangeEvent?.Invoke(s); }
private void UpdateRoles() { try { taskinprogress = true; UpdateStart?.Invoke(); do { Tuple <CommandId, RoleSet, IPAddress> request; lock (_requeststatemutex) { request = requeststate; } UpdateStart?.Invoke(); StateChangeEvent?.Invoke("Perform update operation"); Stop(); BuildFromConfig(request.Item2); if (request.Item1 == CommandId.DryRun) //do total repositori cleanup { try { DirectoryUtils.TryDeleteDirectory(_repositorystoragepath); } catch (Exception e) { OnErrorEvent(e.Message); } Directory.CreateDirectory(_repositorystoragepath); } RunCommandOnNodes(request.Item1, request.Item3); UpdateComplete?.Invoke(); StateChangeEvent?.Invoke("update operation finished"); lock (_requeststatemutex) { var checkrequest = requeststate; if (checkrequest.Item1 == requeststate.Item1 && checkrequest.Item2 == requeststate.Item2 && Equals(checkrequest.Item3, requeststate.Item3)) { taskinprogress = false; //finish operation } } } while (taskinprogress); } catch (Exception e) { taskinprogress = false; } }
public void Update(IEnumerable <AnalyzerResult> results) { var newResults = results.Where(r => !r.InvalidCompatibilityLevel && !r.RuleHasError) .GroupBy(r => r.Rule, r => r).ToDictionary(r => r.Key, r => r.Where(res => !res.RuleIgnored).ToList()); if (!newResults.Any() || !newResults.SelectMany(r => r.Value).SequenceEqual(_results.SelectMany(r => r.Value))) { _results = newResults; RuleCount = _results.Count; ObjectCount = _results.Sum(r => r.Value.Count); OnStructureChanged(); UpdateComplete?.Invoke(this, new EventArgs()); } }
public void Update(IEnumerable <AnalyzerResult> results) { _allResults = results.Where(r => !r.InvalidCompatibilityLevel) .GroupBy(r => r.Rule, r => r).ToDictionary(r => r.Key, r => r.ToList()); _results = results.Where(r => !r.InvalidCompatibilityLevel && !r.Ignored && r.RuleEnabled) .GroupBy(r => r.Rule, r => r).ToDictionary(r => r.Key, r => r.ToList()); if (!results.SequenceEqual(_rawResults)) { _rawResults = results.ToList(); RuleCount = _results.Count; ObjectCount = _results.Sum(r => r.Value.Count); IgnoredCount = _allResults.Sum(r => r.Value.Count(res => res.Ignored)); DisabledRulesCount = _allResults.Sum(r => r.Value.Count(res => !res.RuleEnabled)); OnStructureChanged(); UpdateComplete?.Invoke(this, new EventArgs()); } }
public void SetUpdateDelegate(UpdateComplete newdelegate) { OnUpdateComplete = newdelegate; }
public frmUpdate() { InitializeComponent(); OnUpdateComplete += new UpdateComplete(frmUpdate_OnUpdateComplete); }
private void T_WORK() { try { DataTable dtResult = DBConnect.GetQueryResult(DBCommand.GetNewestFirmware(false)); if (dtResult != null) { byte[] DATA = (byte[])dtResult.Rows[0]["PAYLOAD"]; string VERSION = (string)dtResult.Rows[0]["VERSION_NO"]; string CHANGELOG = (string)dtResult.Rows[0]["CHANGELOG"]; DateTime RELEASE_DATE = (DateTime)dtResult.Rows[0]["DATE_OF_RELEASE"]; string tmpFileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".hex"; System.IO.File.WriteAllBytes(tmpFileName, DATA); Process avrprog = new Process(); StreamReader avrstdout, avrstderr; StreamWriter avrstdin; string avrdude_exe = System.IO.Path.Combine(Application.StartupPath, "RESOURCES", "avrdude.exe"); string avrdude_conf = System.IO.Path.Combine(Application.StartupPath, "RESOURCES", "avrdude.conf"); if (File.Exists(avrdude_exe) == false) { MessageBox.Show("Could not find avrdude.exe!"); UpdateComplete?.Invoke(new UpdateCompleteEventArgs("", "", false)); return; } if (File.Exists(avrdude_conf) == false) { MessageBox.Show("Could not find avrdude.conf!"); UpdateComplete?.Invoke(new UpdateCompleteEventArgs("", "", false)); return; } //tmpFileName = @"C:\Users\danie\AppData\Local\Temp\arduino_build_51152\CC3_Enhancements.ino.hex"; // 0 => avrdude.exe 1 => avrdude.conf 2 => hex file 3=> COMX string command = "\"{0}\" -C\"{1}\" -v -patmega328p -carduino -P{3} -b57600 -D -Uflash:w:\"{2}\":i"; command = string.Format(command, avrdude_exe, avrdude_conf, tmpFileName, _portName); ProcessStartInfo psI = new ProcessStartInfo("cmd"); psI.UseShellExecute = false; psI.RedirectStandardInput = true; psI.RedirectStandardOutput = true; psI.RedirectStandardError = true; psI.CreateNoWindow = true; avrprog.StartInfo = psI; avrprog.Start(); avrstdin = avrprog.StandardInput; avrstdout = avrprog.StandardOutput; avrstderr = avrprog.StandardError; avrstdin.AutoFlush = true; avrstdin.WriteLine(command); avrstdin.Close(); string returnText = ""; //returnText = avrstdout.ReadToEnd(); returnText = avrstderr.ReadToEnd(); if (!returnText.Contains("bytes of flash verified")) { Clipboard.SetText(returnText); throw new Exception("Fehler während des Update-Prozesses. Weitere Informationen zur Sendung an null-bar in der Zwischenablage."); } UpdateComplete?.Invoke(new UpdateCompleteEventArgs(CHANGELOG, VERSION, true)); } } catch (Exception ex) { ErrorHandler.Handle(ex); UpdateComplete?.Invoke(new UpdateCompleteEventArgs("", "", false)); } }
public void Pre_1_1_0() { DataTable dt = DataAccess.ExecuteSelect("select name from sqlite_master where type='table' and name='Tags';").Tables[0]; //tag table update if (dt.Rows.Count == 0) { string query = @"CREATE TABLE 'Tags' ( 'TagID' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 'Name' TEXT NOT NULL, 'HasTab' INTEGER NOT NULL);" ; DataAccess.ExecuteSelect(query); query = @"CREATE TABLE 'TagMapping' ( 'FileID' INTEGER NOT NULL, 'TagID' INTEGER NOT NULL, PRIMARY KEY(FileID,TagID));" ; DataAccess.ExecuteSelect(query); } dt = DataAccess.ExecuteSelect("pragma table_info(Tags);").Tables[0]; if (!dt.Select("name = 'Color'").Any()) { DataAccess.ExecuteNonQuery("alter table Tags add column 'HasColor' int;"); DataAccess.ExecuteNonQuery("alter table Tags add column 'Color' int;"); } dt = DataAccess.ExecuteSelect("pragma table_info(GameFiles);").Tables[0]; //GameFile map count update if (!dt.Select("name = 'MapCount'").Any()) { CreateDatabaseBackup(); DataAccess.ExecuteNonQuery("alter table GameFiles add column 'MapCount' int;"); GameFileGetOptions options = new GameFileGetOptions(); options.SelectFields = new GameFileFieldType[] { GameFileFieldType.GameFileID, GameFileFieldType.Map }; IEnumerable <IGameFile> gameFiles = m_adapter.GetGameFiles(options); GameFileFieldType[] updateFields = new GameFileFieldType[] { GameFileFieldType.MapCount }; float total = gameFiles.Count(); int count = 0; foreach (IGameFile gameFile in gameFiles) { if (UpdateProgress != null) { ProgressPercent = Convert.ToInt32(count / total * 100); UpdateProgress(this, new EventArgs()); } if (gameFile.Map != null) { gameFile.MapCount = gameFile.Map.Count(x => x == ',') + 1; m_adapter.UpdateGameFile(gameFile, updateFields); } count++; } } if (!dt.Select("name = 'SettingsSpecificFiles'").Any()) { DataAccess.ExecuteNonQuery("alter table GameFiles add column 'SettingsSpecificFiles' TEXT;"); } WriteVersion(AppVersion.Version_1_1_0); UpdateComplete?.Invoke(this, new EventArgs()); }
public InstalledAppsManager(UpdateComplete OnUpdateComplete, Repository repository) { this.OnUpdateComplete = OnUpdateComplete; this.repository = repository; }
IEnumerator WaitStarUpdate(float delayTime, ByteFileInfoList pInfo, UpdateComplete onComplete, bool autoRetry) { yield return(new WaitForSeconds(delayTime)); Instance.FileUpdateing(pInfo, onComplete, autoRetry); }