private static bool CompareSheetParameters(ViewSheet viewSheet, RevitSheet rvtSheet, RevitSheetData sheetData, out string tooltip) { bool modified = false; tooltip = ""; try { if (viewSheet.SheetNumber != rvtSheet.Number || viewSheet.ViewName != rvtSheet.Name) { modified = true; tooltip = "Sheet number or sheet name is different from the linked element."; } else { foreach (SheetParameter sheetParam in sheetData.SheetParameters) { if (rvtSheet.SheetParameters.ContainsKey(sheetParam.ParameterId)) { SheetParameterValue paramValue = rvtSheet.SheetParameters[sheetParam.ParameterId]; Parameter param = viewSheet.LookupParameter(sheetParam.ParameterName); if (null != param) { string paramValueStr = ""; switch (param.StorageType) { case StorageType.Double: paramValueStr = param.AsDouble().ToString(); break; case StorageType.ElementId: paramValueStr = param.AsElementId().IntegerValue.ToString(); break; case StorageType.Integer: paramValueStr = param.AsInteger().ToString(); break; case StorageType.String: paramValueStr = param.AsString(); break; } if (paramValueStr != paramValue.ParameterValue.ToString()) { modified = true; tooltip = sheetParam.ParameterName + " values are different from the linked element."; break; } } } } } } catch (Exception ex) { string message = ex.Message; } return(modified); }
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { try { if (e.NewItems != null && e.Action == NotifyCollectionChangedAction.Add) { foreach (RevitSheet sheet in e.NewItems) { int index = rvtSheetData.Sheets.IndexOf(sheet); Guid sheetId = Guid.NewGuid(); this.RvtSheetData.Sheets[index].Id = sheetId; bool sheetDBUpdated = SheetDataWriter.ChangeSheetItem(rvtSheetData.Sheets[index], CommandType.INSERT); foreach (SheetParameter sheetParam in rvtSheetData.SheetParameters) { SheetParameterValue paramValue = new SheetParameterValue(); paramValue.ParameterValueId = Guid.NewGuid(); paramValue.Parameter = sheetParam; paramValue.SheetId = sheetId; this.RvtSheetData.Sheets[index].SheetParameters.Add(sheetParam.ParameterId, paramValue); } bool sheetParamDBUpdated = SheetDataWriter.InsertMultipleParameterValue(RvtSheetData.Sheets[index].SheetParameters.Values.ToList()); foreach (RevitRevision revision in rvtSheetData.Revisions) { RevisionOnSheet ros = new RevisionOnSheet(Guid.NewGuid(), sheetId, revision, false); this.RvtSheetData.Sheets[index].SheetRevisions.Add(revision.Id, ros); } bool rosDBUpdated = SheetDataWriter.InsertMultipleRevisionOnSheet(RvtSheetData.Sheets[index].SheetRevisions.Values.ToList()); } } if (e.OldItems != null && e.Action == NotifyCollectionChangedAction.Remove) { foreach (RevitSheet sheet in e.OldItems) { bool sheetDBUpdated = SheetDataWriter.ChangeSheetItem(sheet, CommandType.DELETE); bool sheetParamDBUpdated = SheetDataWriter.DeleteSheetParameterValue(sheet.Id.ToString()); bool rosDBUpdated = SheetDataWriter.DeleteRevisionOnSheet("RevisionsOnSheet_Sheet_Id", sheet.Id.ToString()); } } } catch (Exception ex) { string message = ex.Message; } }
private static bool UpdateDatabaseItem(object item, string propertyName, object propertyValue) { bool databaseUpdated = false; try { if (item.GetType() == typeof(RevitSheet)) { RevitSheet sheet = item as RevitSheet; switch (propertyName) { case "Sheet Number": databaseUpdated = SheetDataWriter.ChangeSheetItem(sheet.Id.ToString(), propertyName, propertyValue.ToString()); break; case "Sheet Name": databaseUpdated = SheetDataWriter.ChangeSheetItem(sheet.Id.ToString(), propertyName, propertyValue.ToString()); break; case "Discipline": Discipline discipline = propertyValue as Discipline; if (null != discipline) { databaseUpdated = SheetDataWriter.ChangeSheetItem(sheet.Id.ToString(), propertyName, discipline.Id.ToString()); } break; default: var paramValueFound = from paramValue in sheet.SheetParameters.Values where paramValue.Parameter.ParameterName == propertyName select paramValue; if (paramValueFound.Count() > 0) { SheetParameterValue paramValue = paramValueFound.First(); paramValue.ParameterValue = propertyValue.ToString(); databaseUpdated = SheetDataWriter.ChangeSheetParameterValue(paramValue, HOK.SheetManager.Database.CommandType.UPDATE); } break; } } } catch (Exception ex) { string message = ex.Message; } return(databaseUpdated); }
public static bool ChangeSheetParameterValue(SheetParameterValue item, CommandType cmdType) { bool result = false; try { if (null != connection && null != command) { switch (cmdType) { case CommandType.INSERT: command.CommandText = @"INSERT INTO SheetParameterValues (ParameterValue_Id, ParameterValue_Sheet_Id, ParameterValue_Parameter_Id, ParameterValue_Parameter_Value)" + "VALUES ('" + item.ParameterValueId.ToString() + "', '" + item.SheetId.ToString() + "', '" + item.Parameter.ParameterId.ToString() + "', '" + item.ParameterValue + "')"; if (command.ExecuteNonQuery() > 0) { result = true; } break; case CommandType.UPDATE: command.CommandText = @"UPDATE SheetParameterValues SET ParameterValue_Parameter_Value = '" + item.ParameterValue + "'" + " WHERE ParameterValue_Id = '" + item.ParameterValueId.ToString() + "'"; if (command.ExecuteNonQuery() > 0) { result = true; } break; case CommandType.DELETE: command.CommandText = "DELETE FROM SheetParameterValues WHERE ParameterValue_Id = '" + item.ParameterValueId.ToString() + "'"; if (command.ExecuteNonQuery() > 0) { result = true; } break; } } } catch (Exception ex) { string message = ex.Message; } return(result); }
public static object GetPropertyValue(object item, string propertyName) { object value = null; try { if (item.GetType() == typeof(RevitSheet)) { RevitSheet sheet = item as RevitSheet; switch (propertyName) { case "Sheet Number": value = sheet.Number; break; case "Sheet Name": value = sheet.Name; break; case "Discipline": value = sheet.DisciplineObj; break; default: var paramValueFound = from paramVal in sheet.SheetParameters.Values where paramVal.Parameter.ParameterName == propertyName select paramVal; if (paramValueFound.Count() > 0) { SheetParameterValue paramValue = paramValueFound.First(); value = paramValue.ParameterValue; } break; } } else { value = item.GetType().GetProperty(propertyName).GetValue(item, null); } } catch (Exception ex) { string message = ex.Message; } return(value); }
private void buttonAdd_Click(object sender, RoutedEventArgs e) { try { bool added = false; List <string> paramNames = GetExistingParameters(); for (int i = 1; i < 21; i++) { string paramName = "New Parameter " + i; if (!paramNames.Contains(paramName)) { SheetParameter sheetParam = new SheetParameter(Guid.NewGuid(), paramName, "TEXT"); this.RvtSheetData.SheetParameters.Add(sheetParam); bool databaseUpdated = SheetDataWriter.ChangeSheetParameter(sheetParam, CommandType.INSERT); //update RevitSheet List <SheetParameterValue> paramValues = new List <SheetParameterValue>(); for (int sheetIndex = 0; sheetIndex < rvtSheetData.Sheets.Count; sheetIndex++) { SheetParameterValue sheetParamValue = new SheetParameterValue(Guid.NewGuid(), rvtSheetData.Sheets[sheetIndex].Id, sheetParam, ""); this.RvtSheetData.Sheets[sheetIndex].SheetParameters.Add(sheetParam.ParameterId, sheetParamValue); paramValues.Add(sheetParamValue); } databaseUpdated = SheetDataWriter.InsertMultipleParameterValue(paramValues); added = true; break; } } if (!added) { MessageBox.Show("Please rename existing parameters before you add more parameters.", "Rename Parameter", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { string message = ex.Message; } }
public SheetParameterValue GetSheetParameterValue(Guid paramId, Guid sheetId) { SheetParameterValue paramValue = null; try { if (null != connection && null != command) { using (SQLiteCommand cmd = new SQLiteCommand(connection)) { cmd.CommandText = "SELECT * FROM SheetParameterValues WHERE ParameterValue_Parameter_Id= '" + paramId.ToString() + "' AND ParameterValue_Sheet_Id = '" + sheetId.ToString() + "'"; using (SQLiteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { paramValue = new SheetParameterValue(); paramValue.ParameterValueId = reader.GetGuid(reader.GetOrdinal("ParameterValue_Id")); paramValue.SheetId = reader.GetGuid(reader.GetOrdinal("ParameterValue_Sheet_Id")); Guid parameterId = reader.GetGuid(reader.GetOrdinal("ParameterValue_Parameter_Id")); paramValue.Parameter = new SheetParameter() { ParameterId = parameterId }; paramValue.ParameterValue = reader.GetString(reader.GetOrdinal("ParameterValue_Parameter_Value")); break; } } } } } catch (Exception ex) { string message = ex.Message; } return(paramValue); }
private bool UpdateSheet(ViewSheet viewSheet, List <ElementId> paramIds) { bool updated = false; try { LinkedSheet lsheet = dataManager.GetLinkedSheet(viewSheet.UniqueId, linkedProjectId); if (null != lsheet) { foreach (ElementId paramId in paramIds) { string paramName = sheetParameters[paramId]; Parameter param = viewSheet.LookupParameter(paramName); if (null != param) { string paramValue = ""; switch (param.StorageType) { case StorageType.Double: paramValue = param.AsDouble().ToString(); break; case StorageType.ElementId: paramValue = param.AsElementId().IntegerValue.ToString(); break; case StorageType.Integer: paramValue = param.AsInteger().ToString(); break; case StorageType.String: paramValue = param.AsString(); break; } var paramFound = from sheetParam in rvtSheetParameters where sheetParam.ParameterName == paramName select sheetParam; if (paramFound.Count() > 0) { SheetParameter sheetParam = paramFound.First(); SheetParameterValue sheetParamValue = dataManager.GetSheetParameterValue(sheetParam.ParameterId, lsheet.SheetId); sheetParamValue.ParameterValue = paramValue; updated = SheetDataWriter.ChangeSheetParameterValue(sheetParamValue, CommandType.UPDATE); } else if (paramId.IntegerValue == (int)BuiltInParameter.SHEET_NAME) { updated = SheetDataWriter.ChangeSheetItem(lsheet.SheetId.ToString(), "Sheet_Name", paramValue); } else if (paramId.IntegerValue == (int)BuiltInParameter.SHEET_NUMBER) { updated = SheetDataWriter.ChangeSheetItem(lsheet.SheetId.ToString(), "Sheet_Number", paramValue); } } } } } catch (Exception ex) { string message = ex.Message; } return(updated); }
private bool InsertSheet(ViewSheet sheet) { bool sheetInserted = false; try { // insert into the database connected RevitSheet rvtSheet = new RevitSheet(Guid.NewGuid(), sheet.SheetNumber, sheet.ViewName); LinkedSheet linkedSheet = new LinkedSheet(Guid.NewGuid(), rvtSheet.Id, new LinkedProject(linkedProjectId), sheet.UniqueId, true); rvtSheet.LinkedSheets.Add(linkedSheet); bool sheetDBUpdated = SheetDataWriter.ChangeSheetItem(rvtSheet, CommandType.INSERT); bool linkedSheetDBUpdated = SheetDataWriter.ChangeLinkedSheet(linkedSheet, CommandType.INSERT); List <SheetParameterValue> paramValues = new List <SheetParameterValue>(); foreach (SheetParameter sheetParam in rvtSheetParameters) { SheetParameterValue paramValue = new SheetParameterValue(); paramValue.ParameterValueId = Guid.NewGuid(); paramValue.Parameter = sheetParam; paramValue.SheetId = rvtSheet.Id; Parameter param = sheet.LookupParameter(sheetParam.ParameterName); if (null != param) { switch (param.StorageType) { case StorageType.Double: paramValue.ParameterValue = param.AsDouble().ToString(); break; case StorageType.ElementId: paramValue.ParameterValue = param.AsElementId().IntegerValue.ToString(); break; case StorageType.Integer: paramValue.ParameterValue = param.AsInteger().ToString(); break; case StorageType.String: paramValue.ParameterValue = param.AsString(); break; } } paramValues.Add(paramValue); } bool sheetParamDBUpdated = SheetDataWriter.InsertMultipleParameterValue(paramValues); List <Guid> revisionIds = dataManager.GetRevisionIds(); List <RevisionOnSheet> rosList = new List <RevisionOnSheet>(); foreach (Guid revisionId in revisionIds) { RevitRevision rvtRevision = new RevitRevision(); rvtRevision.Id = revisionId; RevisionOnSheet ros = new RevisionOnSheet(Guid.NewGuid(), rvtSheet.Id, rvtRevision, false); rvtSheet.SheetRevisions.Add(rvtRevision.Id, ros); rosList.Add(ros); } bool rosDBUpdated = SheetDataWriter.InsertMultipleRevisionOnSheet(rosList); sheetInserted = (sheetDBUpdated && linkedSheetDBUpdated && rosDBUpdated) ? true : false; if (sheetInserted && !idMaps.ContainsKey(sheet.Id)) { idMaps.Add(sheet.Id, sheet.UniqueId); } } catch (Exception ex) { string message = ex.Message; } return(sheetInserted); }
public static bool InsertNewSheet(ViewSheet sheet, Guid projectId, ref RevitSheetData sheetData) { bool inserted = false; try { var sheetNumberExisting = from rvtSheet in sheetData.Sheets where rvtSheet.Number == sheet.SheetNumber select rvtSheet; if (sheetNumberExisting.Count() > 0) { RevitSheet rvtSheet = sheetNumberExisting.First(); int sheetIndex = sheetData.Sheets.IndexOf(rvtSheet); LinkedSheet linkedSheet = new LinkedSheet(Guid.NewGuid(), rvtSheet.Id, new LinkedProject(projectId), sheet.UniqueId, false); sheetData.Sheets[sheetIndex].LinkedSheets.Add(linkedSheet); bool linkedSheetDBUpdated = SheetDataWriter.ChangeLinkedSheet(linkedSheet, CommandType.INSERT); RevitLinkStatus linkStatus = new RevitLinkStatus(); linkStatus.IsLinked = true; linkStatus.CurrentLinkedId = sheet.UniqueId; linkStatus.LinkedElementId = sheet.Id.IntegerValue; linkStatus.ToolTip = "Linked Sheet ElementId: " + sheet.Id.IntegerValue; string toolTip = ""; if (CompareSheetParameters(sheet, rvtSheet, sheetData, out toolTip)) { linkStatus.Modified = true; linkStatus.ToolTip = toolTip; } sheetData.Sheets[sheetIndex].LinkStatus = linkStatus; inserted = true; } else { RevitSheet rvtSheet = new RevitSheet(Guid.NewGuid(), sheet.SheetNumber, sheet.ViewName); LinkedSheet linkedSheet = new LinkedSheet(Guid.NewGuid(), rvtSheet.Id, new LinkedProject(projectId), sheet.UniqueId, true); rvtSheet.LinkedSheets.Add(linkedSheet); bool sheetDBUpdated = SheetDataWriter.ChangeSheetItem(rvtSheet, CommandType.INSERT); bool linkedSheetDBUpdated = SheetDataWriter.ChangeLinkedSheet(linkedSheet, CommandType.INSERT); RevitLinkStatus linkStatus = new RevitLinkStatus(); linkStatus.IsLinked = true; linkStatus.CurrentLinkedId = sheet.UniqueId; linkStatus.LinkedElementId = sheet.Id.IntegerValue; linkStatus.ToolTip = "Linked Sheet ElementId: " + sheet.Id.IntegerValue; rvtSheet.LinkStatus = linkStatus; foreach (SheetParameter sheetParam in sheetData.SheetParameters) { SheetParameterValue paramValue = new SheetParameterValue(); paramValue.ParameterValueId = Guid.NewGuid(); paramValue.Parameter = sheetParam; paramValue.SheetId = rvtSheet.Id; Parameter param = sheet.LookupParameter(sheetParam.ParameterName); if (null != param) { switch (param.StorageType) { case StorageType.Double: paramValue.ParameterValue = param.AsDouble().ToString(); break; case StorageType.ElementId: paramValue.ParameterValue = param.AsElementId().IntegerValue.ToString(); break; case StorageType.Integer: paramValue.ParameterValue = param.AsInteger().ToString(); break; case StorageType.String: paramValue.ParameterValue = param.AsString(); break; } } rvtSheet.SheetParameters.Add(sheetParam.ParameterId, paramValue); } bool sheetParamDBUpdated = SheetDataWriter.InsertMultipleParameterValue(rvtSheet.SheetParameters.Values.ToList()); List <RevisionOnSheet> rosList = new List <RevisionOnSheet>(); foreach (RevitRevision revision in sheetData.Revisions) { RevisionOnSheet ros = new RevisionOnSheet(Guid.NewGuid(), rvtSheet.Id, revision, false); rvtSheet.SheetRevisions.Add(revision.Id, ros); rosList.Add(ros); } bool rosDBUpdated = SheetDataWriter.InsertMultipleRevisionOnSheet(rosList); sheetData.Sheets.Add(rvtSheet); inserted = (sheetDBUpdated && linkedSheetDBUpdated && rosDBUpdated) ? true : false; } } catch (Exception ex) { MessageBox.Show("Failed to add a new sheet element.\n" + ex.Message, "New Sheet", MessageBoxButton.OK, MessageBoxImage.Warning); } return(inserted); }
private void dataGridSheet_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { try { DataGridRow row = e.Row; if (null != row) { RevitSheet oldSheet = row.Item as RevitSheet; string propertyName = e.Column.Header.ToString(); switch (propertyName) { case "Sheet Number": TextBox textBoxNumber = e.EditingElement as TextBox; if (null != textBoxNumber) { string updatedNumber = textBoxNumber.Text; var numbers = from sheet in rvtSheetData.Sheets select sheet.Number; if (numbers.Contains(updatedNumber)) { e.Cancel = true; MessageBox.Show(updatedNumber + " already exists in the list of sheets.\nPlease enter a different sheet name", "Existing Sheet Number", MessageBoxButton.OK, MessageBoxImage.Information); return; } else { bool databaseUpdated = SheetDataWriter.ChangeSheetItem(oldSheet.Id.ToString(), "Sheet_Number", textBoxNumber.Text); } } break; case "Sheet Name": TextBox textBoxName = e.EditingElement as TextBox; if (null != textBoxName) { bool databaseUpdated = SheetDataWriter.ChangeSheetItem(oldSheet.Id.ToString(), "Sheet_Name", textBoxName.Text); } break; case "Discipline": ComboBox comboBoxDiscipline = e.EditingElement as ComboBox; if (null != comboBoxDiscipline) { Discipline selectedDiscipline = comboBoxDiscipline.SelectedItem as Discipline; if (null != selectedDiscipline) { bool databaseUpdated = SheetDataWriter.ChangeSheetItem(oldSheet.Id.ToString(), "Sheet_Discipline_Id", selectedDiscipline.Id.ToString()); } } break; default: //sheetParameter changed TextBox textBoxParam = e.EditingElement as TextBox; var paramValueFound = from paramValue in oldSheet.SheetParameters.Values where paramValue.Parameter.ParameterName == propertyName select paramValue; if (paramValueFound.Count() > 0 && null != textBoxParam) { SheetParameterValue paramValue = paramValueFound.First(); paramValue.ParameterValue = textBoxParam.Text; bool databaseUpdated = SheetDataWriter.ChangeSheetParameterValue(paramValue, CommandType.UPDATE); } break; } } } catch (Exception ex) { string message = ex.Message; } }
private static void ReadRevitSheets(ref RevitSheetData sheetData) { try { ObservableCollection <LinkedSheet> linkedSheets = new ObservableCollection <LinkedSheet>(); using (SQLiteCommand cmd = new SQLiteCommand(connection)) { cmd.CommandText = "SELECT * FROM LinkedSheets"; using (SQLiteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { LinkedSheet lSheet = new LinkedSheet(); lSheet.Id = reader.GetGuid(reader.GetOrdinal("LinkedSheet_Id")); lSheet.SheetId = reader.GetGuid(reader.GetOrdinal("LinkedSheet_Sheet_Id")); Guid projectId = reader.GetGuid(reader.GetOrdinal("LinkedSheet_Project_Id")); var projectFound = from project in sheetData.LinkedProjects where project.Id == projectId select project; if (projectFound.Count() > 0) { lSheet.LinkProject = projectFound.First(); } lSheet.LinkedElementId = reader.GetString(reader.GetOrdinal("LinkedSheet_Element_Id")); lSheet.IsSource = reader.GetBoolean(reader.GetOrdinal("LinkedSheet_IsSource")); linkedSheets.Add(lSheet); } } } ObservableCollection <SheetParameterValue> sheetParameterValues = new ObservableCollection <SheetParameterValue>(); using (SQLiteCommand cmd = new SQLiteCommand(connection)) { cmd.CommandText = "SELECT * FROM SheetParameterValues"; using (SQLiteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { SheetParameterValue paramValue = new SheetParameterValue(); paramValue.ParameterValueId = reader.GetGuid(reader.GetOrdinal("ParameterValue_Id")); paramValue.SheetId = reader.GetGuid(reader.GetOrdinal("ParameterValue_Sheet_Id")); Guid parameterId = reader.GetGuid(reader.GetOrdinal("ParameterValue_Parameter_Id")); var paramFound = from param in sheetData.SheetParameters where param.ParameterId == parameterId select param; if (paramFound.Count() > 0) { paramValue.Parameter = paramFound.First(); } paramValue.ParameterValue = reader.GetString(reader.GetOrdinal("ParameterValue_Parameter_Value")); sheetParameterValues.Add(paramValue); } } } ObservableCollection <RevisionOnSheet> revisionOnSheets = new ObservableCollection <RevisionOnSheet>(); using (SQLiteCommand cmd = new SQLiteCommand(connection)) { cmd.CommandText = "SELECT * FROM RevisionsOnSheet"; using (SQLiteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { RevisionOnSheet ros = new RevisionOnSheet(); ros.MapId = reader.GetGuid(reader.GetOrdinal("RevisionsOnSheet_Id")); ros.SheetId = reader.GetGuid(reader.GetOrdinal("RevisionsOnSheet_Sheet_Id")); Guid revisionId = reader.GetGuid(reader.GetOrdinal("RevisionsOnSheet_Revision_Id")); var revisionFound = from rev in sheetData.Revisions where rev.Id == revisionId select rev; if (revisionFound.Count() > 0) { ros.RvtRevision = revisionFound.First(); } ros.Include = reader.GetBoolean(reader.GetOrdinal("RevisionsOnSheet_Include")); revisionOnSheets.Add(ros); } } } sheetData.Sheets.Clear(); using (SQLiteCommand cmd = new SQLiteCommand(connection)) { cmd.CommandText = "SELECT * FROM Sheets"; using (SQLiteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { RevitSheet sheet = new RevitSheet(); sheet.Id = reader.GetGuid(reader.GetOrdinal("Sheet_Id")); sheet.Number = reader.GetString(reader.GetOrdinal("Sheet_Number")); sheet.Name = reader.GetString(reader.GetOrdinal("Sheet_Name")); Guid disciplineId = reader.GetGuid(reader.GetOrdinal("Sheet_Discipline_Id")); var disciplineFound = from discipline in sheetData.Disciplines where discipline.Id == disciplineId select discipline; if (disciplineFound.Count() > 0) { sheet.DisciplineObj = disciplineFound.First(); } var linkedSheetFound = from linkedSheet in linkedSheets where linkedSheet.SheetId == sheet.Id select linkedSheet; if (linkedSheetFound.Count() > 0) { sheet.LinkedSheets = new ObservableCollection <LinkedSheet>(linkedSheetFound.ToList()); } foreach (SheetParameter param in sheetData.SheetParameters) { var parameterValueFound = from paramValue in sheetParameterValues where paramValue.SheetId == sheet.Id && paramValue.Parameter.ParameterId == param.ParameterId select paramValue; if (parameterValueFound.Count() > 0) { SheetParameterValue value = parameterValueFound.First(); sheet.SheetParameters.Add(param.ParameterId, value); } } var revisionOnSheetFound = from ros in revisionOnSheets where ros.SheetId == sheet.Id select ros; if (revisionOnSheetFound.Count() > 0) { foreach (RevisionOnSheet ros in revisionOnSheetFound) { if (!sheet.SheetRevisions.ContainsKey(ros.RvtRevision.Id)) { sheet.SheetRevisions.Add(ros.RvtRevision.Id, ros); } } } sheetData.Sheets.Add(sheet); } } } sheetData.Sheets = new ObservableCollection <RevitSheet>(sheetData.Sheets.OrderBy(o => o.Number)); } catch (Exception ex) { string message = ex.Message; } }