async Task Migrate1_0_to_1_1(IStorage storage)
        {
            Guid id = Guid.NewGuid();

            progress.Report(0.1f, "Migrating teams", id);
            MigrateTeams();

            progress.Report(0.5f, "Migrating dashboards", id);
            MigrateDashboards();

            progress.Report(1f, "Migrated database objects", id);
            storage.Info.Version = new Version(1, 1);
            storage.Store(storage.Info);
        }
Beispiel #2
0
		static void InitGStreamer (IProgressReport progress)
		{
			Guid id = Guid.NewGuid ();
			progress.Report (0.1f, "Initializing GStreamer", id);
			GStreamer.Init ();
			progress.Report (1f, "GStreamer initialized", id);
		}
Beispiel #3
0
		static void InitAddins (IProgressReport progress)
		{
			Guid id = Guid.NewGuid ();
			progress.Report (0.1f, "Initializing addins", id);
			AddinsManager.Initialize (App.Current.PluginsConfigDir, App.Current.PluginsDir);
			progress.Report (0.5f, "Addins parsed", id);
			AddinsManager.LoadConfigModifierAddins ();
			AddinsManager.LoadExportProjectAddins ();
			AddinsManager.LoadMultimediaBackendsAddins (App.Current.MultimediaToolkit);
			AddinsManager.LoadUIBackendsAddins (App.Current.GUIToolkit);
			AddinsManager.LoadServicesAddins ();
			progress.Report (1, "Addins initialized", id);
		}
Beispiel #4
0
        bool MigrateTeamsAndDashboards()
        {
            bool                        ret = true;
            float                       count;
            float                       percent        = 0;
            List <string>               teamFiles      = new List <string> ();
            List <string>               dashboardFiles = new List <string> ();
            Guid                        id             = Guid.NewGuid();
            ConcurrentQueue <LMTeam>    teams          = new ConcurrentQueue <LMTeam> ();
            ConcurrentQueue <Dashboard> dashboards     = new ConcurrentQueue <Dashboard> ();
            List <Task>                 tasks          = new List <Task> ();

            progress.Report(0, "Migrating teams and dashboards", id);

            try {
                teamFiles = Directory.EnumerateFiles(Path.Combine(App.Current.DBDir, "teams")).
                            Where(f => f.EndsWith(".ltt")).ToList();
            } catch (DirectoryNotFoundException ex) {
                percent += 0.5f;
                progress.Report(percent, "Migrated teams", id);
            }
            try {
                dashboardFiles = Directory.EnumerateFiles(Path.Combine(App.Current.DBDir, "analysis")).
                                 Where(f => f.EndsWith(".lct")).ToList();
            } catch (DirectoryNotFoundException ex) {
                percent += 0.5f;
                progress.Report(percent, "Migrated dashboards", id);
            }
            if (teamFiles.Count == 0 && dashboardFiles.Count == 0)
            {
                progress.Report(1, "Migrated teams and dashboards", id);
                return(true);
            }
            count = (teamFiles.Count + dashboardFiles.Count) * 2 + 1;

            // We can't use the FileStorage here, since it will migate the Team or Dashboard
            foreach (string teamFile in teamFiles)
            {
                try {
                    LMTeam team = Serializer.Instance.Load <LMTeam> (teamFile);
                    percent += 1 / count;
                    progress.Report(percent, "Imported team " + team.Name, id);
                    teams.Enqueue(team);
                } catch (Exception ex) {
                    Log.Exception(ex);
                }
            }

            foreach (string dashboardFile in dashboardFiles)
            {
                try {
                    Dashboard dashboard = Serializer.Instance.Load <Dashboard> (dashboardFile);
                    percent += 1 / count;
                    progress.Report(percent, "Imported dashboard " + dashboard.Name, id);
                    dashboards.Enqueue(dashboard);
                } catch (Exception ex) {
                    Log.Exception(ex);
                }
            }

            foreach (LMTeam team in teams)
            {
                var migrateTask = Task.Run(() => {
                    try {
                        Log.Information("Migrating team " + team.Name);
                        TeamMigration.Migrate0(team, teamNameToID);
                        App.Current.TeamTemplatesProvider.Save(team);
                        percent += 1 / count;
                        progress.Report(percent, "Migrated team " + team.Name, id);
                    } catch (Exception ex) {
                        Log.Exception(ex);
                        ret = false;
                    }
                });
                tasks.Add(migrateTask);
            }

            foreach (Dashboard dashboard in dashboards)
            {
                var migrateTask = Task.Run(() => {
                    try {
                        Log.Information("Migrating dashboard " + dashboard.Name);
                        DashboardMigration.Migrate0(dashboard, scoreNameToID, penaltyNameToID);
                        App.Current.CategoriesTemplatesProvider.Save(dashboard as LMDashboard);
                        percent += 1 / count;
                        progress.Report(percent, "Migrated team " + dashboard.Name, id);
                    } catch (Exception ex) {
                        Log.Exception(ex);
                        ret = false;
                    }
                });
                tasks.Add(migrateTask);
            }

            Task.WaitAll(tasks.ToArray());

            try {
                string backupDir = Path.Combine(App.Current.TemplatesDir, "backup");
                if (!Directory.Exists(backupDir))
                {
                    Directory.CreateDirectory(backupDir);
                }

                foreach (string templateFile in Directory.EnumerateFiles(Path.Combine(App.Current.DBDir, "teams")).Concat(
                             Directory.EnumerateFiles(Path.Combine(App.Current.DBDir, "analysis"))))
                {
                    string outputFile = Path.Combine(backupDir, Path.GetFileName(templateFile));
                    if (File.Exists(outputFile))
                    {
                        File.Delete(outputFile);
                    }
                    File.Move(templateFile, outputFile);
                }
            } catch (Exception ex) {
                Log.Error("Error moving templates to the backup directory.");
                Log.Exception(ex);
            }

            progress.Report(1, "Teams and dashboards migrated", id);
            return(ret);
        }
Beispiel #5
0
 public static void Report(IProgressReport progress, ProgressType type, int count)
 {
     if (progress != null)
     {
         progress.Report(type, count);
     }
 }