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("Data Path", typeof(string))); data.Columns.Add(new DataColumn("Data Set Name", typeof(string))); data.Columns.Add(new DataColumn("Data Type", 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("Workspace Path", 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 Set Type", typeof(string))); data.Columns.Add(new DataColumn("Data Source Path", 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["Data Path"] = theme.Data.Path; row["Data Set Name"] = theme.Data.DataSetName; row["Data Type"] = theme.Data.Type; row["Workspace Type"] = theme.Data.WorkspaceType; row["Workspace ProgID"] = theme.Data.WorkspaceProgId; row["Workspace Path"] = theme.Data.WorkspacePath; row["Container"] = theme.Data.Container; row["Container Type"] = theme.Data.ContainerType; row["Data Source"] = theme.Data.DataSourceName; row["Data Set Type"] = theme.Data.DataSetType; row["Data Source Path"] = theme.Data.DataSource; data.Rows.Add(row); if (bw.CancellationPending) return data; } return data; }
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 { error = theme.Metadata.Description; 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; }
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("Data Path", typeof(string))); data.Columns.Add(new DataColumn("Data 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"))) { DataRow row = data.NewRow(); row["Category"] = theme.CategoryPath(); row["Theme"] = theme.Name; row["Type"] = (theme.IsTheme) ? "Theme" : "SubTheme"; row["Data Path"] = theme.Data.Path; row["Data Type"] = theme.Data.Type; data.Rows.Add(row); if (bw.CancellationPending) return data; } return data; }
internal DataTable ListThemesWithNoMetadata(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))); foreach (var theme in themeList.Recurse(x => x.Children) .Where(n => n.IsTheme || n.IsSubTheme && string.IsNullOrEmpty(n.Metadata.Path))) { DataRow row = data.NewRow(); row["Category"] = theme.CategoryPath(); row["Theme"] = theme.Name; row["Type"] = (theme.IsTheme) ? "Theme" : "SubTheme"; data.Rows.Add(row); if (bw.CancellationPending) return data; } return data; }
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; }
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; }
internal string ReloadNode(BackgroundWorker bw, TmNode root, string path) { if (root == null) return "No node provided for reload"; root.BeginUpdate(); List<TmNode> nodes = root.Recurse(x => x.Children) .Where(n => n is ThemeNode) .ToList(); int count = nodes.Count; int index = 0; foreach (var node in nodes) { Message = string.Format("Loading {1} of {2} ({0})", node.Name, index + 1, count); bw.ReportProgress((int)(100 * (float)index / count)); try { // node.ReloadTheme() may need to load to query ArcObjects // which could throw any number of exceptions. node.Reload(); } catch (Exception ex) { return ex.Message; } if (bw.CancellationPending) return null; index++; } root.EndUpdate(); return null; }
internal string SyncNode(BackgroundWorker bw, TmNode root, string path) { if (root == null) return "No node provided for sync"; root.BeginUpdate(); 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) { Message = string.Format("Syncing {1} of {2} ({0})", node.Name, index + 1, count); bw.ReportProgress((int)(100 * (float)index / count)); try { // node.SyncWithMetadata() will load/verify metadata // which could throw any number of exceptions. node.SyncWithMetadata(); } catch (Exception ex) { return ex.Message; } if (bw.CancellationPending) return null; index++; } root.EndUpdate(); return null; }