public static void Main(string[] args) { /* Start DB services */ Core.Init(); var db = new DataBase(Path.Combine(Config.DBDir(),Constants.DB_FILE)); Project p = db.GetProject(db.GetAllProjects()[0].UUID); ExcelExporter ee = new ExcelExporter(); ee.ExportProject(p, "/home/andoni/test.xls"); }
void StartMigrationThread() { string dbdir = System.IO.Path.Combine (LongoMatch.Config.HomeDir, "db"); string teamdir = System.IO.Path.Combine (LongoMatch.Config.HomeDir, "db", "teams"); string analysisdir = System.IO.Path.Combine (LongoMatch.Config.HomeDir, "db", "analysis"); bool withError = false; MessageDialog d; if (!Directory.Exists (teamdir)) { UpdateText ("Creating directory " + teamdir + "\n"); Directory.CreateDirectory (teamdir); } if (!Directory.Exists (analysisdir)) { UpdateText ("Creating directory " + analysisdir + "\n"); Directory.CreateDirectory (analysisdir); } foreach (string dbfile in dbs) { UpdateText ("Converting dabase " + dbfile + "..." + "\n"); try { string dboutputdir; string dbname; DataBase db; dbname = System.IO.Path.GetFileName (dbfile).Split ('.') [0] + ".ldb"; dboutputdir = System.IO.Path.Combine (dbfile, System.IO.Path.Combine (dbdir, dbname)); if (!Directory.Exists (dboutputdir)) { Directory.CreateDirectory (dboutputdir); } db = new DataBase (dbfile); foreach (ProjectDescription pd in db.GetAllProjects ()) { try { Project p = db.GetProject (pd.UUID); UpdateText ("Converting project " + p.Description.Title + "..." + "\n"); LongoMatch.Migration.Converter.ConvertProject (p, dboutputdir); } catch (Exception ex) { UpdateText ("ERROR\n"); UpdateText (ex.ToString ()); withError = true; } } System.IO.File.Delete (System.IO.Path.Combine (dboutputdir, db.Name + ".ldb")); UpdateText ("OK\n"); } catch (Exception ex) { UpdateText ("ERROR\n"); UpdateText (ex.ToString ()); withError = true; } } foreach (string f in teams) { if (System.IO.Path.GetFileNameWithoutExtension (f) == "default") { continue; } UpdateText ("Converting team template " + f + "..."); try { string p = System.IO.Path.Combine (teamdir, System.IO.Path.GetFileName (f)); LongoMatch.Migration.Converter.ConvertTeamTemplate (f, p); UpdateText ("OK\n"); } catch (Exception ex) { UpdateText ("ERROR\n"); UpdateText (ex.ToString ()); withError = true; } } foreach (string f in categories) { if (System.IO.Path.GetFileNameWithoutExtension (f) == "default") { continue; } UpdateText ("Converting analysis template " + f + "..."); try { string p = System.IO.Path.Combine (analysisdir, System.IO.Path.GetFileName (f)); LongoMatch.Migration.Converter.ConvertCategories (f, p); UpdateText ("OK\n"); } catch (Exception ex) { UpdateText ("ERROR\n"); UpdateText (ex.ToString ()); withError = true; } } Application.Invoke (delegate { if (!withError) { d = new MessageDialog (this, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, "Everything migrated correctly!"); d.Run (); Application.Quit (); } else { convertbutton.Visible = false; progressbar1.Visible = false; d = new MessageDialog (this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, "Some errors where found migrating the old content."); d.Run (); d.Destroy (); } }); }
public void TestGetAllProjects() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); ProjectDescriptionLongoMatch pd1 = new ProjectDescriptionLongoMatch (); ProjectDescriptionLongoMatch pd2 = new ProjectDescriptionLongoMatch (); ProjectLongoMatch p1 = new ProjectLongoMatch {Description = pd1}; ProjectLongoMatch p2 = new ProjectLongoMatch {Description = pd2}; db.AddProject (p1); db.AddProject (p2); Assert.AreEqual (db.Count, 2); List<ProjectDescriptionLongoMatch> projects = db.GetAllProjects (); Assert.AreEqual (db.Count, 2); Assert.AreEqual (projects.Count, 2); Assert.AreEqual (projects[0], pd1); Assert.AreEqual (projects[1], pd2); }