private void RunCategoryActionItems(string centralPath, UpdaterData data, Element element) { try { ReportingElementInfo reportingInfo = null; Document doc = data.GetDocument(); var infoFound = from info in reportingElements where info.CentralPath == centralPath && info.ReportingUniqueId == element.UniqueId select info; if (infoFound.Count() > 0) { reportingInfo = infoFound.First(); } BuiltInCategory bltCategory = (BuiltInCategory)element.Category.Id.IntegerValue; switch (bltCategory) { case BuiltInCategory.OST_Grids: Grid grid = element as Grid; if (GridUtils.ExtentGeometryChanged(centralPath, grid.Id, grid.GetExtents())) { if (null != reportingInfo) { ReportFailure(doc, reportingInfo); } } else if (GridUtils.gridParameters.ContainsKey(centralPath)) { //parameter changed foreach (ElementId paramId in GridUtils.gridParameters[centralPath]) { if (data.IsChangeTriggered(grid.Id, Element.GetChangeTypeParameter(paramId))) { if (null != reportingInfo) { ReportFailure(doc, reportingInfo); } } } } break; default: if (null != reportingInfo) { ReportFailure(doc, reportingInfo); } break; } } catch (Exception ex) { string message = ex.Message; LogUtil.AppendLog("DTMUpdater-RunCategoryActionItems:" + ex.Message); } }
/// <summary> /// /// </summary> /// <param name="doc"></param> /// <param name="eInfo"></param> private static void ReportFailure(Document doc, ReportingElementInfo eInfo) { try { DTMFailure.IsElementModified = true; DTMFailure.ElementModified = eInfo; DTMFailure.CurrentDoc = doc; FailureProcessor.IsFailureFound = true; } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } }
private void ReportFailure(Document doc, ReportingElementInfo eInfo) { try { DTMFailure.IsElementModified = true; DTMFailure.ElementModified = eInfo; DTMFailure.CurrentDoc = doc; FailureProcessor.IsFailureFound = true; } catch (Exception ex) { string message = ex.Message; LogUtil.AppendLog("DTMUpdater-ReportFailure:" + ex.Message); } }
private void AddElementToStorage(string configId, string centralPath, Element element) { try { string categoryName = element.Category.Name; string triggerMessage = GetTriggerMessage(configId, centralPath, element); ReportingElementInfo eInfo = new ReportingElementInfo(configId, updaterGuid.ToString(), centralPath, categoryName, triggerMessage, element.Id, element.UniqueId); reportingElements.Add(eInfo); } catch (Exception ex) { string message = ex.Message; LogUtil.AppendLog("DTMUpdater-AddElementToStorage:" + ex.Message); } }
public DTMWindow(Document doc, ReportingElementInfo info) { currentDoc = doc; reportingInfo = info; if (!string.IsNullOrEmpty(info.Description)) { descriptionText = info.Description; } else { descriptionText = reportingInfo.CategoryName + " are locked."; } InitializeComponent(); this.Title = "DTM Tool v." + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); }
public DTMViewModel(Document doc, ReportingElementInfo info) { Doc = doc; reportingInfo = info; Title = "DTM Tool v." + Assembly.GetExecutingAssembly().GetName().Version; if (!string.IsNullOrEmpty(info.Description)) { DescriptionText = info.Description; } else { DescriptionText = reportingInfo.CategoryName + " are locked."; } ButtonPlayCommand = new RelayCommand(OnButtonPlay); ButtonIgnoreCommand = new RelayCommand <Window>(OnButtonIgnore); ButtonEditCommand = new RelayCommand <Window>(OnButtonEdit); }
/// <summary> /// /// </summary> /// <param name="doc"></param> /// <param name="pUpdater"></param> public void RefreshTriggers(Document doc, ProjectUpdater pUpdater) { try { var centralPath = FileInfoUtil.GetCentralFilePath(doc); var configId = ""; if (MissionControlSetup.Configurations.ContainsKey(centralPath)) { configId = MissionControlSetup.Configurations[centralPath].Id; } UpdaterRegistry.RemoveDocumentTriggers(_updaterId, doc); var elementsToDelete = _reportingElements.Where(x => x.CentralPath == centralPath).ToList(); if (elementsToDelete.Any()) { foreach (var eInfo in elementsToDelete) { _reportingElements.Remove(eInfo); } } foreach (var trigger in pUpdater.CategoryTriggers) { if (!trigger.IsEnabled) { continue; } var catFilter = new ElementCategoryFilter(_catDictionary[trigger.CategoryName]); UpdaterRegistry.AddTrigger(_updaterId, catFilter, Element.GetChangeTypeAny()); UpdaterRegistry.AddTrigger(_updaterId, catFilter, Element.GetChangeTypeElementAddition()); UpdaterRegistry.AddTrigger(_updaterId, catFilter, Element.GetChangeTypeElementDeletion()); switch (trigger.CategoryName) { case "Grids": { GridUtils.CollectGridExtents(doc, centralPath); if (GridUtils.gridParameters.ContainsKey(centralPath)) { foreach (var paramId in GridUtils.gridParameters[centralPath]) { UpdaterRegistry.AddTrigger(_updaterId, catFilter, Element.GetChangeTypeParameter(paramId)); } } var elements = new FilteredElementCollector(doc) .WherePasses(catFilter) .WhereElementIsNotElementType() .ToElements(); foreach (var element in elements) { var reportingInfo = new ReportingElementInfo( configId, UpdaterGuid.ToString(), centralPath, trigger.CategoryName, trigger.Description, element.Id, element.UniqueId); _reportingElements.Add(reportingInfo); } } break; case "Views": { var viewTemplates = new FilteredElementCollector(doc) .WherePasses(catFilter) .WhereElementIsNotElementType() .Cast <View>() .Where(x => x.IsTemplate) .ToList(); if (viewTemplates.Any()) { foreach (var view in viewTemplates) { var reportingInfo = new ReportingElementInfo( configId, UpdaterGuid.ToString(), centralPath, trigger.CategoryName, trigger.Description, view.Id, view.UniqueId); _reportingElements.Add(reportingInfo); } } } break; default: { var elements = new FilteredElementCollector(doc) .WherePasses(catFilter) .WhereElementIsNotElementType() .ToElements(); foreach (var element in elements) { var reportingInfo = new ReportingElementInfo( configId, UpdaterGuid.ToString(), centralPath, trigger.CategoryName, trigger.Description, element.Id, element.UniqueId); _reportingElements.Add(reportingInfo); } } break; } } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } }
/// <summary> /// /// </summary> /// <param name="centralPath"></param> /// <param name="data"></param> /// <param name="element"></param> /// <param name="reportingInfo"></param> private static void RunCategoryActionItems(string centralPath, UpdaterData data, Element element, ReportingElementInfo reportingInfo) { try { var doc = data.GetDocument(); var bltCategory = (BuiltInCategory)element.Category.Id.IntegerValue; switch (bltCategory) { case BuiltInCategory.OST_Grids: var grid = (Grid)element; if (GridUtils.ExtentGeometryChanged(centralPath, grid.Id, grid.GetExtents())) { ReportFailure(doc, reportingInfo); } else if (GridUtils.gridParameters.ContainsKey(centralPath)) { //parameter changed foreach (var paramId in GridUtils.gridParameters[centralPath]) { if (!data.IsChangeTriggered(grid.Id, Element.GetChangeTypeParameter(paramId))) { continue; } ReportFailure(doc, reportingInfo); } } break; default: ReportFailure(doc, reportingInfo); break; } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } }
public void RefreshTriggers(Document doc, ProjectUpdater pUpdater) { try { string centralPath = FileInfoUtil.GetCentralFilePath(doc); string configId = ""; if (AppCommand.Instance.ConfigDictionary.ContainsKey(centralPath)) { configId = AppCommand.Instance.ConfigDictionary[centralPath]._id; } UpdaterRegistry.RemoveDocumentTriggers(updaterId, doc); var elementsToDelete = from eInfo in reportingElements where eInfo.CentralPath == centralPath select eInfo; if (elementsToDelete.Count() > 0) { List <ReportingElementInfo> elementsInfo = elementsToDelete.ToList(); foreach (ReportingElementInfo eInfo in elementsInfo) { reportingElements.Remove(eInfo); } } foreach (CategoryTrigger trigger in pUpdater.CategoryTriggers) { if (trigger.isEnabled) { ElementCategoryFilter catFilter = new ElementCategoryFilter(catDictionary[trigger.categoryName]); UpdaterRegistry.AddTrigger(updaterId, catFilter, Element.GetChangeTypeAny()); UpdaterRegistry.AddTrigger(updaterId, catFilter, Element.GetChangeTypeElementAddition()); UpdaterRegistry.AddTrigger(updaterId, catFilter, Element.GetChangeTypeElementDeletion()); if (trigger.categoryName == "Grids") { GridUtils.CollectGridExtents(doc, centralPath); if (GridUtils.gridParameters.ContainsKey(centralPath)) { foreach (ElementId paramId in GridUtils.gridParameters[centralPath]) { UpdaterRegistry.AddTrigger(updaterId, catFilter, Element.GetChangeTypeParameter(paramId)); } } FilteredElementCollector collector = new FilteredElementCollector(doc); List <Element> elements = collector.WherePasses(catFilter).WhereElementIsNotElementType().ToElements().ToList(); foreach (Element element in elements) { ReportingElementInfo reportingInfo = new ReportingElementInfo(configId, updaterGuid.ToString(), centralPath, trigger.categoryName, trigger.description, element.Id, element.UniqueId); reportingElements.Add(reportingInfo); } } else if (trigger.categoryName == "Views") { FilteredElementCollector collector = new FilteredElementCollector(doc); List <View> views = collector.WherePasses(catFilter).WhereElementIsNotElementType().ToElements().Cast <View>().ToList(); var viewTemplates = from view in views where view.IsTemplate select view; if (viewTemplates.Count() > 0) { foreach (Element view in viewTemplates) { ReportingElementInfo reportingInfo = new ReportingElementInfo(configId, updaterGuid.ToString(), centralPath, trigger.categoryName, trigger.description, view.Id, view.UniqueId); reportingElements.Add(reportingInfo); } } } else { FilteredElementCollector collector = new FilteredElementCollector(doc); List <Element> elements = collector.WherePasses(catFilter).WhereElementIsNotElementType().ToElements().ToList(); foreach (Element element in elements) { ReportingElementInfo reportingInfo = new ReportingElementInfo(configId, updaterGuid.ToString(), centralPath, trigger.categoryName, trigger.description, element.Id, element.UniqueId); reportingElements.Add(reportingInfo); } } } } } catch (Exception ex) { string message = ex.Message; LogUtil.AppendLog("DTMUpdater-RefreshTriggers:" + ex.Message); } }