void ProcessDownloads() { List <string> files = null; lock (m_pendingDownloads) if (m_pendingDownloads.Count > 0) { files = m_pendingDownloads.ToList(); m_pendingDownloads.Clear(); } if (files != null) { string localDlgFolder = AppPaths.DialogFolderPath; string cxnReqFile = Names.ConnectionReqFile; var netEngin = new NetEngin(AppContext.Settings.NetworkSettings); for (int i = files.Count - 1; i >= 0; --i) { string fileName = files[i]; string destPath = Path.Combine(localDlgFolder, fileName); string srcURL = Urls.DialogDirURL + fileName; try { netEngin.Download(destPath, srcURL); } catch (Exception ex) { AppContext.LogManager.LogSysError("Traitement des transferts à partir du serveur: " + ex.Message, true); continue; } if (string.Compare(fileName, cxnReqFile, true) == 0) { try { ProcessConnectionReq(DialogEngin.ReadConnectionsReq(AppPaths.ConnectionReqPath)); } catch (Exception ex) { TextLogger.Warning(ex.Message); } } else { uint clID = uint.Parse(Path.GetFileNameWithoutExtension(fileName), System.Globalization.NumberStyles.AllowHexSpecifier); try { ProcessDialog(clID, DialogEngin.ReadHubDialog(Path.Combine(localDlgFolder, fileName), clID)); } catch (Exception ex) { AppContext.LogManager.LogSysError("Traitement des transferts à partir du serveur: " + ex.Message, true); continue; } } files.RemoveAt(i); } foreach (string file in files) { AddDownload(file); } } //allways need to be downlaoded AddDownload(Names.ConnectionReqFile); }
private void UploadAppUpdates_Click(object sender, EventArgs e) { var filesNames = new Dictionary <AppArchitecture_t, string> { { AppArchitecture_t.Win7SP1, WIN7SP1_UPDATE_FILENAME }, { AppArchitecture_t.Win7SP1X64, WIN7SP1X64_UPADTE_FILENAME }, { AppArchitecture_t.WinXP, WINXP_UPADTE_FILENAME } }; var waitDlg = new Jobs.ProcessingDialog(); Action run = () => { KeyIndexer ndxer = AppContext.AccessPath.GetKeyIndexer(InternalTablesID.APP_UPDATE); var seq = (from AppUpdate up in ndxer.Source.Enumerate() where up.DeployTime == AppUpdate.NOT_YET select up).ToArray(); //maj app manifest + manifest global Dictionary <AppArchitecture_t, string> appManifest; try { appManifest = UpdateEngin.ReadAppManifest(AppPaths.AppManifestPath); } catch (Exception ex) { TextLogger.Warning(ex.Message); appManifest = new Dictionary <AppArchitecture_t, string>(); } IUpdateManifest gManifest; try { gManifest = UpdateEngin.ReadUpdateManifest(AppPaths.ManifestPath); } catch (Exception ex) { TextLogger.Warning(ex.Message); gManifest = new UpdateManifest(0, 0); } var netEngin = new NetEngin(AppContext.Settings.NetworkSettings); foreach (AppUpdate up in seq) { gManifest.Versions[up.AppArchitecture] = up.Version; appManifest[up.AppArchitecture] = filesNames[up.AppArchitecture]; string srcFileName = up.ID.ToString("X"); string destFileName = filesNames[up.AppArchitecture]; string dst = Urls.AppUpdateDirURL + destFileName; waitDlg.Message = $"Transfert du fichier {destFileName}. Cette opération peut durer plusieurs minutes."; netEngin.Upload(dst, Path.Combine(AppPaths.AppUpdateFolder, srcFileName)); up.DeployTime = DateTime.Now; ndxer.Source.Replace(ndxer.IndexOf(up.ID), up); } waitDlg.Message = "Transfert du manifest des applications..."; UpdateEngin.WriteAppManifest(AppPaths.AppManifestPath, appManifest); netEngin.Upload(Urls.AppManifestURL, AppPaths.AppManifestPath); waitDlg.Message = "Transfert du manifest global..."; UpdateEngin.WriteUpdateManifest(gManifest, AppPaths.ManifestPath); netEngin.Upload(Urls.ManifestURL, AppPaths.ManifestPath); }; Action onSucces = () => { m_tsbUploadAppUpdates.Enabled = false; waitDlg.Dispose(); }; Action <Task> onErr = t => { waitDlg.Dispose(); this.ShowError(t.Exception.InnerException.Message); TextLogger.Error(t.Exception.InnerException.Message); }; var task = new Task(run, TaskCreationOptions.LongRunning); task.OnSuccess(onSucces); task.OnError(onErr); task.Start(); waitDlg.ShowDialog(this); }