예제 #1
0
        //handlers
        private void BuildDataUpdate_Click(object sender, EventArgs e)
        {
            var  dlg         = new Jobs.ProcessingDialog();
            bool firstUpdate = AppContext.Settings.AppSettings.UpdateKey == 0;

            Action <Task> onErr = (t) =>
            {
                dlg.Dispose();
                this.ShowError(t.Exception.InnerException.Message);
            };

            Action onSuccess = () =>
            {
                dlg.Dispose();
                m_tsbBuildUpdate.Enabled       = false;
                m_tsbUploadDataUpdates.Enabled = true;

                if (firstUpdate)
                {
                    m_sslUpdateKey.Text =
                        $"Clé de mise à jour: {AppContext.Settings.AppSettings.UpdateKey}";
                }
            };

            var task = new Task(new UpdateBuilder().Run, TaskCreationOptions.LongRunning);

            task.OnSuccess(onSuccess);

            task.Start();
            dlg.ShowDialog(Parent);
        }
예제 #2
0
        private void UploadDataUpdates_Click(object sender, EventArgs e)
        {
            var dlg = new Jobs.ProcessingDialog();

            Action upload = () =>
            {
                KeyIndexer         ndxerInc = AppContext.AccessPath.GetKeyIndexer(InternalTablesID.INCREMENT);
                IEnumerable <uint> ids      = from UpdateIncrement inc in ndxerInc.Source.Enumerate()
                                              where inc.IsDeployed == false
                                              select inc.ID;

                var netEngin = new NetEngin(AppContext.Settings.NetworkSettings);

                foreach (var id in ids)
                {
                    string fileName = id.ToString("X");
                    string src      = Path.Combine(AppPaths.DataUpdateFolder, fileName);
                    string dst      = Urls.DataUpdateDirURL + fileName;
                    netEngin.Upload(dst, src);
                }

                netEngin.Upload(Urls.DataManifestURL, AppPaths.DataManifestPath);
                netEngin.Upload(Urls.ManifestURL, AppPaths.ManifestPath);

                foreach (uint id in ids)
                {
                    var inc = ndxerInc.Get(id) as UpdateIncrement;
                    inc.DeployTime = DateTime.Now;
                    ndxerInc.Source.Replace(ndxerInc.IndexOf(id), inc);
                }
            };

            Action <Task> onErr = t =>
            {
                dlg.Dispose();
                this.ShowError(t.Exception.InnerException.Message);
            };

            Action onSuccess = () =>
            {
                dlg.Dispose();
                m_tsbUploadDataUpdates.Enabled = false;
            };

            var task = new Task(upload, TaskCreationOptions.LongRunning);

            task.OnSuccess(onSuccess);
            task.OnError(onErr);

            task.Start();
            dlg.ShowDialog(Parent);
        }
예제 #3
0
        //handlers:
        private void Insert_Click(object sender, EventArgs e)
        {
            using (var dlg = new FolderBrowserDialog())
            {
                dlg.Description = "Sélectionnez le dossier racine.";


                if (RootFolder != null)
                {
                    dlg.SelectedPath = RootFolder;
                }

                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    RootFolder = dlg.SelectedPath;

                    var files = new List <string>();

                    var busyDlg = new Jobs.ProcessingDialog();

                    Func <ListViewItem[]> enumFiles = () =>
                    {
                        PopulateList(files, RootFolder, busyDlg);

                        busyDlg.Message = "Finalisation...";

                        files.Sort();
                        IEnumerable <string> seq = files.Distinct();

                        var items = from fl in seq
                                    let fName = Path.GetFileName(fl)
                                                let relDir = Path.GetDirectoryName(fl.Remove(0, RootFolder.Length + 1))
                                                             select new ListViewItem(new string[] { fName, relDir })
                        {
                            Tag = fl
                        };

                        return(items.ToArray());
                    };



                    Action <Task> onErr = t =>
                    {
                        busyDlg.Dispose();

                        MessageBox.Show(t.Exception.InnerException.Message,
                                        null, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    };

                    Action <Task <ListViewItem[]> > onSuccess = t =>
                    {
                        m_lvFiles.Items.Clear();
                        m_lvFiles.Items.AddRange(t.Result);

                        busyDlg.Dispose();
                    };


                    var task = new Task <ListViewItem[]>(enumFiles, TaskCreationOptions.LongRunning);
                    task.OnSuccess(onSuccess);
                    task.OnError(onErr);
                    task.Start();

                    busyDlg.ShowDialog(this);
                }
            }
        }
예제 #4
0
        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);
        }
예제 #5
0
        private void AddPackage_Click(object sender, EventArgs e)
        {
            using (var dlg = new AppUpdateDialog())
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    IDatumProvider dp      = null;
                    var            waitDlg = new Jobs.ProcessingDialog();

                    Action buildUpdate = () =>
                    {
                        var bag = new FilesBag();

                        foreach (string file in dlg.Files)
                        {
                            waitDlg.Message = $"Préparation de {file}";
                            string relDir = Path.GetDirectoryName(file.Remove(0, dlg.RootFolder.Length + 1));

                            if (relDir.Length > 0)
                            {
                                bag.Add(file, relDir);
                            }
                            else
                            {
                                bag.Add(file);
                            }
                        }

                        waitDlg.Message = "Compression en cours...";
                        dp = AppContext.TableManager.AppUpdates.DataProvider;
                        dp.Connect();

                        var update = new AppUpdate(AppContext.TableManager.AppUpdates.CreateUniqID(), dlg.Version, dlg.AppArchitecture);
                        bag.Compress(Path.Combine(AppPaths.AppUpdateFolder, update.ID.ToString("X")));

                        NormalizeAppUpdates(update);
                        dp.Insert(update);
                    };


                    Action <Task> onErr = t =>
                    {
                        TextLogger.Error(t.Exception.InnerException.Message);
                        this.ShowError(t.Exception.InnerException.Message);

                        dp?.Dispose();
                        waitDlg.Dispose();
                    };

                    Action onSuccess = () =>
                    {
                        dp?.Dispose();
                        waitDlg.Dispose();
                    };


                    var task = new Task(buildUpdate, TaskCreationOptions.LongRunning);
                    task.OnSuccess(onSuccess);
                    task.OnError(onErr);
                    task.Start();

                    waitDlg.ShowDialog(this);
                }
        }