[longomatch] Fixed several issues with database migraition tool
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [longomatch] Fixed several issues with database migraition tool
- Date: Tue, 25 Aug 2009 21:32:12 +0000 (UTC)
commit 577617b85258e68246baba4f9900051d24ae409c
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Tue Aug 25 23:17:56 2009 +0200
Fixed several issues with database migraition tool
Create a new thread to open the file
Disable 'Canel' button when importing
LongoMatch/Compat/0.0/DatabaseMigrator.cs | 33 ++++++++++++++++---
LongoMatch/Gui/Migrator.cs | 9 +++--
.../gtk-gui/LongoMatch.Gui.Dialog.Migrator.cs | 2 +
LongoMatch/gtk-gui/gui.stetic | 2 +
4 files changed, 37 insertions(+), 9 deletions(-)
---
diff --git a/LongoMatch/Compat/0.0/DatabaseMigrator.cs b/LongoMatch/Compat/0.0/DatabaseMigrator.cs
index 36c77e7..bf217ab 100644
--- a/LongoMatch/Compat/0.0/DatabaseMigrator.cs
+++ b/LongoMatch/Compat/0.0/DatabaseMigrator.cs
@@ -49,6 +49,8 @@ namespace LongoMatch.Compat
private string newDBFile;
+ private PreviewMediaFile file;
+
private Thread thread;
public DatabaseMigrator(string oldDBFile)
@@ -99,12 +101,13 @@ namespace LongoMatch.Compat
//SendEvent("Creating backup of the old database");
foreach (v00.DB.Project oldProject in backupProjects){
- PreviewMediaFile file;
+
string localName, visitorName;
int localGoals, visitorGoals;
DateTime date;
Sections sections;
Project newProject;
+ Thread openFileThread;
localName = oldProject.LocalName;
visitorName = oldProject.VisitorName;
@@ -113,12 +116,25 @@ namespace LongoMatch.Compat
date = oldProject.MatchDate;
SendEvent(String.Format("Trying to convert project {0}...",oldProject.Title));
try{
- file = PreviewMediaFile.GetMediaFile(oldProject.File.FilePath);
- //SendEvent(String.Format("[{0}]Getting properties of file {1}",oldProject.Title,oldProject.File.FilePath));
+ SendEvent(String.Format("[{0}]Getting properties of file {1}",oldProject.Title,oldProject.File.FilePath));
+ file = null;
+ //If file doesn't exits the metadata reader send and async message but doesn't not
+ //throw any Exception. We have to check if file exist and if not throw an
+ //Excecptio to jump to 'catch'
+ if (!File.Exists(oldProject.File.FilePath))
+ throw new Exception();
+ //Now we try to read the file until it's opened
+ while(file==null){
+ openFileThread = new Thread (new ParameterizedThreadStart(OpenFile));
+ openFileThread.Start(oldProject.File.FilePath);
+ openFileThread.Join(5000);
+ if (openFileThread.IsAlive)
+ openFileThread.Abort();
+ }
}
catch{
- //SendEvent(String.Format("[{0}]Failed to open file {1} \n",oldProject.Title,oldProject.File.FilePath));
- //SendEvent(String.Format("[{0}]Cannot scan the file properties\n, using default values",oldProject.Title));
+ SendEvent(String.Format("[{0}]Failed to open file {1} \n",oldProject.Title,oldProject.File.FilePath));
+ SendEvent(String.Format("[{0}]Cannot scan the file properties\n, using default values",oldProject.Title));
file = new PreviewMediaFile();
file.FilePath = oldProject.File.FilePath;
file.Fps = oldProject.File.Fps;
@@ -201,6 +217,7 @@ namespace LongoMatch.Compat
SendEvent(DONE);
}
+
private void ChangeDBNamespace(string DBFile){
using (IObjectContainer db = Db4oFactory.OpenFile(DBFile))
{
@@ -224,7 +241,11 @@ namespace LongoMatch.Compat
}
}
- public void SendEvent (string message){
+ private void OpenFile(object filePath){
+ file = PreviewMediaFile.GetMediaFile(filePath as string);
+ }
+
+ private void SendEvent (string message){
if (ConversionProgressEvent != null)
Application.Invoke(delegate {ConversionProgressEvent(message);});
}
diff --git a/LongoMatch/Gui/Migrator.cs b/LongoMatch/Gui/Migrator.cs
index 851dff1..f775bdb 100644
--- a/LongoMatch/Gui/Migrator.cs
+++ b/LongoMatch/Gui/Migrator.cs
@@ -122,9 +122,12 @@ namespace LongoMatch.Gui.Dialog
protected virtual void OnButtonCancelClicked (object sender, System.EventArgs e)
{
- dbMigrator.Cancel();
- plMigrator.Cancel();
- tpMigrator.Cancel();
+ if (dbMigrator != null)
+ dbMigrator.Cancel();
+ if (plMigrator != null)
+ plMigrator.Cancel();
+ if (tpMigrator != null)
+ tpMigrator.Cancel();
}
}
}
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.Migrator.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.Migrator.cs
index 41ece19..2957cbf 100644
--- a/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.Migrator.cs
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.Migrator.cs
@@ -159,6 +159,7 @@ namespace LongoMatch.Gui.Dialog {
w15.LayoutStyle = ((Gtk.ButtonBoxStyle)(4));
// Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
this.buttonCancel = new Gtk.Button();
+ this.buttonCancel.Sensitive = false;
this.buttonCancel.CanDefault = true;
this.buttonCancel.CanFocus = true;
this.buttonCancel.Name = "buttonCancel";
@@ -187,6 +188,7 @@ namespace LongoMatch.Gui.Dialog {
}
this.DefaultWidth = 821;
this.DefaultHeight = 300;
+ this.buttonCancel.Hide();
this.buttonOk.Hide();
this.Show();
this.buttonCancel.Clicked += new System.EventHandler(this.OnButtonCancelClicked);
diff --git a/LongoMatch/gtk-gui/gui.stetic b/LongoMatch/gtk-gui/gui.stetic
index 48d918e..ea0466a 100755
--- a/LongoMatch/gtk-gui/gui.stetic
+++ b/LongoMatch/gtk-gui/gui.stetic
@@ -4149,6 +4149,8 @@ If you are not sure about what you are doing, click ok</property>
<child>
<widget class="Gtk.Button" id="buttonCancel">
<property name="MemberName" />
+ <property name="Visible">False</property>
+ <property name="Sensitive">False</property>
<property name="CanDefault">True</property>
<property name="CanFocus">True</property>
<property name="UseStock">True</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]