From 3d3c8acf173a8f344d19415b3e152e293f292254 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 11 May 2017 15:06:14 +0100 Subject: [PATCH] Inform main window that an OS has been added. --- osrepodbmgr.Core/ChangeLog | 5 +++++ osrepodbmgr.Core/Workers.cs | 7 +++---- osrepodbmgr/ChangeLog | 6 ++++++ osrepodbmgr/frmAdd.cs | 12 ++++++++++++ osrepodbmgr/frmMain.cs | 7 +++++++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/osrepodbmgr.Core/ChangeLog b/osrepodbmgr.Core/ChangeLog index bc3ff88..461f751 100644 --- a/osrepodbmgr.Core/ChangeLog +++ b/osrepodbmgr.Core/ChangeLog @@ -1,3 +1,8 @@ +2017-05-11 Natalia Portillo + + * Workers.cs: + Inform main window that an OS has been added. + 2017-05-11 Natalia Portillo * DBOps.cs: diff --git a/osrepodbmgr.Core/Workers.cs b/osrepodbmgr.Core/Workers.cs index 026736d..33c1aba 100644 --- a/osrepodbmgr.Core/Workers.cs +++ b/osrepodbmgr.Core/Workers.cs @@ -592,11 +592,10 @@ namespace osrepodbmgr.Core if(UpdateProgress != null) UpdateProgress(null, "Adding OS information", counter, Context.hashes.Count); - long osId; - dbCore.DBOps.AddOS(Context.dbInfo, out osId); + dbCore.DBOps.AddOS(Context.dbInfo, out Context.dbInfo.id); if(UpdateProgress != null) UpdateProgress(null, "Creating OS table", counter, Context.hashes.Count); - dbCore.DBOps.CreateTableForOS(osId); + dbCore.DBOps.CreateTableForOS(Context.dbInfo.id); counter = 0; foreach(KeyValuePair kvp in Context.hashes) @@ -604,7 +603,7 @@ namespace osrepodbmgr.Core if(UpdateProgress != null) UpdateProgress(null, "Adding files to OS in database", counter, Context.hashes.Count); - dbCore.DBOps.AddFileToOS(kvp.Value, osId); + dbCore.DBOps.AddFileToOS(kvp.Value, Context.dbInfo.id); counter++; } diff --git a/osrepodbmgr/ChangeLog b/osrepodbmgr/ChangeLog index f631dd1..0afb671 100644 --- a/osrepodbmgr/ChangeLog +++ b/osrepodbmgr/ChangeLog @@ -1,3 +1,9 @@ +2017-05-11 Natalia Portillo + + * frmAdd.cs: + * frmMain.cs: + Inform main window that an OS has been added. + 2017-05-11 Natalia Portillo * frmAdd.cs: diff --git a/osrepodbmgr/frmAdd.cs b/osrepodbmgr/frmAdd.cs index ed6fba5..00bea40 100644 --- a/osrepodbmgr/frmAdd.cs +++ b/osrepodbmgr/frmAdd.cs @@ -51,6 +51,9 @@ public partial class frmAdd : Dialog ListStore fileView; ListStore osView; + public delegate void OnAddedOSDelegate(DBEntry os, bool existsInRepo, string pathInRepo); + public event OnAddedOSDelegate OnAddedOS; + public frmAdd() { Build(); @@ -791,6 +794,15 @@ public partial class frmAdd : Dialog // TODO: Update OS table + if(OnAddedOS != null) + OnAddedOS(Context.dbInfo, true, System.IO.Path.Combine(osrepodbmgr.Core.Settings.Current.RepositoryPath, + Context.dbInfo.mdid[0].ToString(), + Context.dbInfo.mdid[1].ToString(), + Context.dbInfo.mdid[2].ToString(), + Context.dbInfo.mdid[3].ToString(), + Context.dbInfo.mdid[4].ToString(), + Context.dbInfo.mdid) + ".zip"); + prgProgress.Visible = false; btnPack.Sensitive = true; btnClose.Sensitive = true; diff --git a/osrepodbmgr/frmMain.cs b/osrepodbmgr/frmMain.cs index de7d549..81d7bbd 100644 --- a/osrepodbmgr/frmMain.cs +++ b/osrepodbmgr/frmMain.cs @@ -222,6 +222,13 @@ namespace osrepodbmgr protected void OnBtnAddClicked(object sender, EventArgs e) { frmAdd _frmAdd = new frmAdd(); + _frmAdd.OnAddedOS += (os, existsInRepo, pathInRepo) => + { + string color = existsInRepo ? "green" : "red"; + osView.AppendValues(os.developer, os.product, os.version, os.languages, os.architecture, os.machine, + os.format, os.description, os.oem, os.upgrade, os.update, os.source, + os.files, os.netinstall, color, "black", pathInRepo, os.id, os.mdid); + }; _frmAdd.Run(); _frmAdd.Destroy(); }