internal string ReloadNode(BackgroundWorker bw, TmNode root, string path) { 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) { 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.ReloadTheme(); } catch (Exception ex) { return ex.Message; } if (bw.CancellationPending) return null; index++; } root.ResumeUpdates(); return null; }
internal string SyncNode(BackgroundWorker bw, TmNode root, string path) { 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) { 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.ResumeUpdates(); return null; }