コード例 #1
0
ファイル: LoadingForm.cs プロジェクト: AKROGIS/ThemeManager
        internal async Task<string> SyncNodeAsync(TmNode root)
        {
            if (root == null)
                return "No node provided for sync";

            root.SuspendUpdates();
            List<TmNode> nodes = root.Recurse(x => x.Children)
                                        .Where(n => !string.IsNullOrEmpty(n.Metadata.Path))
                                        .ToList();
            int count = nodes.Count;
            int index = 0;
            foreach (var node in nodes)
            {
                progressLabel.Text = string.Format("Syncing {1} of {2} ({0})", node.Name, index + 1, count);
                progressBar.Value = (int)(100 * (float)index / count);
                try
                {
                    await node.SyncWithMetadataAsync(false);
                }
                catch (Exception ex)
                {
                    root.ResumeUpdates(); 
                    return ex.Message;
                }
                if (CancelRequested)
                {
                    root.ResumeUpdates();
                    return null;
                }
                index++;
            }
            root.ResumeUpdates();
            return null;
        }
コード例 #2
0
ファイル: AdminReports.cs プロジェクト: AKROGIS/ThemeManager
        internal DataTable ListThemesWithUnknownIcon(TmNode themeList, BackgroundWorker bw)
        {
            DataTable data = new DataTable();

            data.Columns.Add(new DataColumn("Category", typeof(string)));
            data.Columns.Add(new DataColumn("Theme", typeof(string)));
            data.Columns.Add(new DataColumn("Type", typeof(string)));
            data.Columns.Add(new DataColumn("Theme Path", typeof(string)));
            data.Columns.Add(new DataColumn("Theme Type", typeof(string)));
            foreach (var theme in themeList.Recurse(x => x.Children)
                     .Where(n => (n.IsTheme || n.IsSubTheme) &&
                            (n.ImageKey == "Theme" || n.ImageKey == "Themelock" || n.ImageKey == "Themenew" ||
                             n.Data.Type.Contains("Error", StringComparison.OrdinalIgnoreCase))))
            {
                DataRow row = data.NewRow();
                row["Category"]   = theme.CategoryPath();
                row["Theme"]      = theme.Name;
                row["Type"]       = (theme.IsTheme) ? "Theme" : "SubTheme";
                row["Theme Path"] = theme.Data.Path;
                row["Theme Type"] = theme.Data.Type;
                data.Rows.Add(row);
                if (bw.CancellationPending)
                {
                    return(data);
                }
            }
            return(data);
        }
コード例 #3
0
ファイル: LoadingForm.cs プロジェクト: AKROGIS/ThemeManager
        internal async Task<string> ReloadNodeAsync(TmNode root)
        {
            if (root == null)
                return "No node provided for reload";

            root.SuspendUpdates();
            List<TmNode> nodes = root.Recurse(x => x.Children)
                                        .Where(n => n.IsTheme)
                                        .ToList();
            int count = nodes.Count;
            int index = 0;
            foreach (var node in nodes)
            {
                progressLabel.Text = string.Format("Loading {1} of {2} ({0})", node.Name, index + 1, count);
                progressBar.Value = (int)(100 * (float)index / count);
                try
                {
                    await node.ReloadThemeAsync();
                }
                catch (Exception ex)
                {
                    root.ResumeUpdates();
                    return ex.Message;
                }
                if (CancelRequested)
                {
                    root.ResumeUpdates();
                    return null;
                }
                index++;
            }
            root.ResumeUpdates();
            return null;
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: AKROGIS/ThemeManager
        static async Task ReloadAsync(TmNode root)
        {
            List <TmNode> nodes = root.Recurse(x => x.Children)
                                  .Where(n => n.IsTheme)
                                  .ToList();

            Console.WriteLine($"Reloading {nodes.Count} Themes");
            //TODO: reload nodes in parallel
            foreach (var node in nodes)
            {
                try
                {
                    await node.ReloadThemeAsync();
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"\nError reloading node {node.CategoryPath()}/{node.Name}: {ex.Message}");
                }
                if (!node.HasData)
                {
                    Console.WriteLine($"\nNode {node.CategoryPath()}/{node.Name} has no data");
                }
                if (!node.HasMetadata)
                {
                    Console.WriteLine($"\nNode {node.CategoryPath()}/{node.Name} ({node.Data?.Type}) has no metadata");
                }
                Console.Write(".");
            }
            Console.WriteLine("");
        }
コード例 #5
0
ファイル: AdminReports.cs プロジェクト: AKROGIS/ThemeManager
        internal DataTable ListThemesWithNoMetadataInfo(TmNode themeList, BackgroundWorker bw)
        {
            DataTable data = new DataTable();

            data.Columns.Add(new DataColumn("Category", typeof(string)));
            data.Columns.Add(new DataColumn("Theme", typeof(string)));
            data.Columns.Add(new DataColumn("Type", typeof(string)));
            data.Columns.Add(new DataColumn("Metadata Path", typeof(string)));
            foreach (var theme in themeList.Recurse(x => x.Children)
                     .Where(n => (n.IsTheme || n.IsSubTheme) &&
                            !string.IsNullOrWhiteSpace(n.Metadata.Path) &&
                            string.IsNullOrWhiteSpace(n.Description) &&
                            string.IsNullOrWhiteSpace(n.Summary) &&
                            string.IsNullOrWhiteSpace(n.Tags)))
            {
                DataRow row = data.NewRow();
                row["Category"]      = theme.CategoryPath();
                row["Theme"]         = theme.Name;
                row["Type"]          = (theme.IsTheme) ? "Theme" : "SubTheme";
                row["Metadata Path"] = theme.Metadata.Path;
                data.Rows.Add(row);
                if (bw.CancellationPending)
                {
                    return(data);
                }
            }
            return(data);
        }
コード例 #6
0
ファイル: AdminReports.cs プロジェクト: AKROGIS/ThemeManager
        private DataTable ListThemes(TmNode themeList, BackgroundWorker bw)
        {
            DataTable data = new DataTable();

            data.Columns.Add(new DataColumn("Category", typeof(string)));
            data.Columns.Add(new DataColumn("Theme", typeof(string)));
            data.Columns.Add(new DataColumn("File", typeof(string)));
            data.Columns.Add(new DataColumn("File Type", typeof(string)));
            foreach (var theme in themeList.Recurse(x => x.Children).Where(n => n.IsTheme))
            {
                DataRow row = data.NewRow();
                row["Category"] = theme.CategoryPath();
                row["Theme"]    = theme.Name;
                row["File"]     = theme.Data.Path;
                if (!string.IsNullOrEmpty(theme.Data.Path))
                {
                    row["File Type"] = Path.GetExtension(theme.Data.Path);
                }
                data.Rows.Add(row);
                if (bw.CancellationPending)
                {
                    return(data);
                }
            }
            return(data);
        }
コード例 #7
0
ファイル: AdminReports.cs プロジェクト: AKROGIS/ThemeManager
        internal DataTable ListDataSources(TmNode themeList, BackgroundWorker bw)
        {
            DataTable data = new DataTable();

            data.Columns.Add(new DataColumn("Category", typeof(string)));
            data.Columns.Add(new DataColumn("Theme", typeof(string)));
            data.Columns.Add(new DataColumn("Type", typeof(string)));
            data.Columns.Add(new DataColumn("Theme Path", typeof(string)));
            data.Columns.Add(new DataColumn("Layer Name", typeof(string)));
            data.Columns.Add(new DataColumn("Theme Type", typeof(string)));
            data.Columns.Add(new DataColumn("Data Source Path", typeof(string)));
            data.Columns.Add(new DataColumn("Workspace Path", typeof(string)));
            data.Columns.Add(new DataColumn("Workspace Type", typeof(string)));
            data.Columns.Add(new DataColumn("Workspace ProgID", typeof(string)));
            data.Columns.Add(new DataColumn("Container", typeof(string)));
            data.Columns.Add(new DataColumn("Container Type", typeof(string)));
            data.Columns.Add(new DataColumn("Data Source", typeof(string)));
            data.Columns.Add(new DataColumn("Data Source Type", typeof(string)));
            foreach (var theme in themeList.Recurse(x => x.Children)
                     .Where(n => (n.IsTheme || n.IsSubTheme)))
            {
                DataRow row = data.NewRow();
                //reload cannot be done in the background, because treeview
                // on UI thread gets property updates
                //theme.ReloadTheme();
                row["Category"]         = theme.CategoryPath();
                row["Theme"]            = theme.Name;
                row["Type"]             = (theme.IsTheme) ? "Theme" : "SubTheme";
                row["Theme Path"]       = theme.Data.Path;
                row["Layer Name"]       = theme.Data.DataSetName;
                row["Theme Type"]       = theme.Data.Type;
                row["Data Source Path"] = theme.Data.DataSource;
                row["Workspace Path"]   = theme.Data.WorkspacePath;
                row["Workspace Type"]   = theme.Data.WorkspaceType;
                row["Workspace ProgID"] = theme.Data.WorkspaceProgId;
                row["Container"]        = theme.Data.Container;
                row["Container Type"]   = theme.Data.ContainerType;
                row["Data Source"]      = theme.Data.DataSourceName;
                row["Data Source Type"] = theme.Data.DataSetType;
                data.Rows.Add(row);
                if (bw.CancellationPending)
                {
                    return(data);
                }
            }
            return(data);
        }
コード例 #8
0
ファイル: AdminReports.cs プロジェクト: AKROGIS/ThemeManager
        internal DataTable ListMetadataProblems(TmNode themeList, BackgroundWorker bw)
        {
            DataTable data = new DataTable();

            data.Columns.Add(new DataColumn("Category", typeof(string)));
            data.Columns.Add(new DataColumn("Theme", typeof(string)));
            data.Columns.Add(new DataColumn("Metadata", typeof(string)));
            data.Columns.Add(new DataColumn("Error", typeof(string)));
            List <TmNode> nodes = themeList.Recurse(x => x.Children)
                                  .Where(n => n.IsTheme || n.IsSubTheme &&
                                         !string.IsNullOrEmpty(n.Metadata.Path))
                                  .ToList();
            int count = nodes.Count;
            int index = 0;

            foreach (var theme in nodes)
            {
                string error;
                try {
                    // This is in a cancellable background thread, so we can just wait for each result
                    // This can ignore the boolean "success" response, because we are checking the error message
                    var _ = theme.Metadata.GetGeneralInfoAsync().Result;
                    error = theme.Metadata.ErrorMessage;
                }
                catch (Exception ex)
                {
                    error = ex.Message;
                }
                if (error != null)
                {
                    DataRow row = data.NewRow();
                    row["Category"] = theme.CategoryPath();
                    row["Theme"]    = theme.Name;
                    row["Metadata"] = theme.Metadata.Path;
                    row["Error"]    = error;
                    data.Rows.Add(row);
                }
                index++;
                if (bw.CancellationPending)
                {
                    return(data);
                }
                bw.ReportProgress((int)(100 * (float)index / count));
            }
            return(data);
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: AKROGIS/ThemeManager
        static async Task SyncAsync(TmNode root)
        {
            List <TmNode> nodes = root.Recurse(x => x.Children)
                                  .Where(n => !string.IsNullOrEmpty(n.Metadata.Path))
                                  .ToList();

            Console.WriteLine($"Syncing metadata for {nodes.Count} Themes");
            foreach (var node in nodes)
            {
                try
                {
                    await node.SyncWithMetadataAsync(false);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"\nError syncing metadata for node {node.CategoryPath()}/{node.Name}: {ex.Message}");
                }
                Console.Write(".");
            }
            Console.WriteLine("");
        }
コード例 #10
0
ファイル: AdminReports.cs プロジェクト: AKROGIS/ThemeManager
        internal DataTable ListThemesNotFound(TmNode themeList, BackgroundWorker bw)
        {
            DataTable data = new DataTable();

            data.Columns.Add(new DataColumn("Category", typeof(string)));
            data.Columns.Add(new DataColumn("Theme", typeof(string)));
            data.Columns.Add(new DataColumn("File", typeof(string)));
            data.Columns.Add(new DataColumn("Error", typeof(string)));
            List <TmNode> nodes = themeList.Recurse(x => x.Children).Where(n => n.IsTheme).ToList();
            int           count = nodes.Count;
            int           index = 0;

            foreach (var theme in nodes)
            {
                if (string.IsNullOrEmpty(theme.Data.Path) || !File.Exists(theme.Data.Path))
                {
                    DataRow row = data.NewRow();
                    row["Category"] = theme.CategoryPath();
                    row["Theme"]    = theme.Name;
                    row["File"]     = theme.Data.Path;
                    if (string.IsNullOrEmpty(theme.Data.Path))
                    {
                        row["Error"] = "Theme has no file";
                    }
                    else
                    {
                        row["Error"] = "File not found";
                    }
                    data.Rows.Add(row);
                }
                index++;
                if (bw.CancellationPending)
                {
                    return(data);
                }
                bw.ReportProgress((int)(100 * (float)index / count));
            }
            return(data);
        }