private void buttonDelete_Click(object sender, RoutedEventArgs e) { try { if (null != dataGridParameters.SelectedItem) { SheetParameter selectedParam = dataGridParameters.SelectedItem as SheetParameter; MessageBoxResult msgResult = MessageBox.Show("Are you sure you want to delete the parameter [" + selectedParam.ParameterName + "]?\nAll data currently stored under the parameter will be lost.", "Delete Parameter", MessageBoxButton.YesNo, MessageBoxImage.Question); if (msgResult == MessageBoxResult.Yes) { this.RvtSheetData.SheetParameters.Remove(selectedParam); bool updatedTable = SheetDataWriter.ChangeSheetParameter(selectedParam, CommandType.DELETE); //delete from RevitSheet for (int i = 0; i < rvtSheetData.Sheets.Count; i++) { this.RvtSheetData.Sheets[i].SheetParameters.Remove(selectedParam.ParameterId); } } } } catch (Exception ex) { string message = ex.Message; } }
private void buttonAdd_Click(object sender, RoutedEventArgs e) { try { bool added = false; var viewNames = from view in rvtSheetData.Views select view.Name; for (int i = 1; i < 100; i++) { string viewName = "New View " + i; if (!viewNames.Contains(viewName)) { RevitView rvtView = new RevitView(Guid.NewGuid(), viewName); this.RvtSheetData.Views.Add(rvtView); added = SheetDataWriter.ChangeViewItem(rvtView, CommandType.INSERT); break; } } if (!added) { MessageBox.Show("Please assign view names before you add more view items.", "View Name", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { MessageBox.Show("Failed to add view items.\n" + ex.Message, "Add Views", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { try { if (e.NewItems != null && e.Action == NotifyCollectionChangedAction.Add) { foreach (RevitItemMapper item in e.NewItems) { int index = rvtSheetData.ItemMaps.IndexOf(item); Guid itemMapId = Guid.NewGuid(); this.RvtSheetData.ItemMaps[index].ItemId = itemMapId; bool dbUpdated = SheetDataWriter.ChangeReplaceItem(rvtSheetData.ItemMaps[index], CommandType.INSERT); } } if (e.OldItems != null && e.Action == NotifyCollectionChangedAction.Remove) { foreach (RevitItemMapper item in e.OldItems) { bool dbUpdated = SheetDataWriter.ChangeReplaceItem(item, CommandType.DELETE); } } } catch (Exception ex) { string message = ex.Message; } }
private void buttonDelete_Click(object sender, RoutedEventArgs e) { try { if (null != dataGridDisciplines.SelectedItem) { MessageBoxResult msgResult = MessageBox.Show("Sheet items under the selected discipline will be set to [Undefined].\nWould you like to continue?", "Sheet Items Found", MessageBoxButton.YesNo, MessageBoxImage.Question); if (msgResult == MessageBoxResult.Yes) { Discipline selectedDiscipline = dataGridDisciplines.SelectedItem as Discipline; var undefinedDiscipline = from discipline in rvtSheetData.Disciplines where discipline.Id == Guid.Empty select discipline; if (undefinedDiscipline.Count() > 0) { Discipline undefined = undefinedDiscipline.First() as Discipline; var sheetsToChange = from sheet in rvtSheetData.Sheets where sheet.DisciplineObj.Id == selectedDiscipline.Id select sheet; if (sheetsToChange.Count() > 0) { foreach (RevitSheet sheet in sheetsToChange) { int index = rvtSheetData.Sheets.IndexOf(sheet); this.RvtSheetData.Sheets[index].DisciplineObj = undefined; } } } this.RvtSheetData.Disciplines.Remove(selectedDiscipline); bool databaseUpdated = SheetDataWriter.ChangeDisciplineItem(selectedDiscipline, CommandType.DELETE); } } } catch (Exception ex) { string messag = ex.Message; } }
public void CreateDBExecuted(object param) { try { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Title = "Create a New Sheet Data File"; saveDialog.DefaultExt = ".sqlite"; saveDialog.Filter = "SQLITE File (.sqlite)|*.sqlite"; if ((bool)saveDialog.ShowDialog()) { this.DBFile = saveDialog.FileName; bool created = SheetDataWriter.CreateDatabase(dbFile); if (created) { this.RvtSheetData = SheetDataReader.ReadSheetDatabase(dbFile, rvtSheetData); this.RvtSheetData.SelectedDisciplineIndex = 0; this.DatabaseOpened = true; this.StatusText = dbFile; } } } catch (Exception ex) { MessageBox.Show("Failed to create the database file.\n" + ex.Message, "Create Database File", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void dataGridParameters_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { try { List <string> paramNames = GetExistingParameters(); DataGridRow row = e.Row; TextBox textBox = e.EditingElement as TextBox; if (null != row && null != textBox) { SheetParameter oldParameter = row.Item as SheetParameter; string updatedParameter = textBox.Text; if (paramNames.Contains(updatedParameter)) { e.Cancel = true; MessageBox.Show(updatedParameter + " already exists.\nPlease enter a different name.", "Existing Sheet Parameter", MessageBoxButton.OK, MessageBoxImage.Information); return; } int index = rvtSheetData.SheetParameters.IndexOf(oldParameter); this.RvtSheetData.SheetParameters.RemoveAt(index); oldParameter.ParameterName = updatedParameter; this.RvtSheetData.SheetParameters.Insert(index, oldParameter); bool databaseUpdated = SheetDataWriter.ChangeSheetParameter(oldParameter, CommandType.UPDATE); } } catch (Exception ex) { string message = ex.Message; } }
private void UserControl_Drop(object sender, DragEventArgs e) { try { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { string fileExtension = System.IO.Path.GetExtension(file); if (fileExtension.Contains("sqlite")) { viewModel.DBFile = file; viewModel.RvtSheetData = SheetDataReader.ReadSheetDatabase(file, viewModel.RvtSheetData); viewModel.RvtSheetData.SelectedDisciplineIndex = 0; viewModel.DatabaseOpened = true; viewModel.StatusText = file; bool opened = SheetDataWriter.OpenDatabase(file); break; } } } } catch (Exception ex) { MessageBox.Show("Failed to drop files.\n" + ex.Message, "File Drop", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private bool UpdateRevision(Revision revision, List <ElementId> paramIds) { bool updated = false; try { LinkedRevision linkedRevision = dataManager.GetLinkedRevision(revision.UniqueId, linkedProjectId); if (null != linkedRevision) { foreach (ElementId paramId in paramIds) { string paramName = revisionParameters[paramId]; Parameter param = revision.LookupParameter(paramName); if (null != param) { string paramValue = ""; switch (paramId.IntegerValue) { case (int)BuiltInParameter.PROJECT_REVISION_SEQUENCE_NUM: paramValue = param.AsInteger().ToString(); updated = SheetDataWriter.ChangeLinkedRevision(linkedRevision.Id, "LinkedRevision_Sequence", paramValue, CommandType.UPDATE); break; case (int)BuiltInParameter.PROJECT_REVISION_REVISION_NUM: paramValue = param.AsString(); updated = SheetDataWriter.ChangeLinkedRevision(linkedRevision.Id, "LinkedRevision_Number", paramValue, CommandType.UPDATE); break; case (int)BuiltInParameter.PROJECT_REVISION_REVISION_DESCRIPTION: paramValue = param.AsString(); updated = SheetDataWriter.ChangeRevisionItem(linkedRevision.RevisionId.ToString(), "Revision_Description", paramValue); break; case (int)BuiltInParameter.PROJECT_REVISION_REVISION_DATE: paramValue = param.AsString(); updated = SheetDataWriter.ChangeRevisionItem(linkedRevision.RevisionId.ToString(), "Revision_Date", paramValue); break; case (int)BuiltInParameter.PROJECT_REVISION_REVISION_ISSUED_TO: paramValue = param.AsString(); updated = SheetDataWriter.ChangeRevisionItem(linkedRevision.RevisionId.ToString(), "Revision_IssuedTo", paramValue); break; case (int)BuiltInParameter.PROJECT_REVISION_REVISION_ISSUED_BY: paramValue = param.AsString(); updated = SheetDataWriter.ChangeRevisionItem(linkedRevision.RevisionId.ToString(), "Revision_IssuedBy", paramValue); break; } } } } } catch (Exception ex) { string message = ex.Message; } return(updated); }
public void Execute(UpdaterData data) { try { if (IsSheetManagerOn) { return; } if (SheetDataWriter.dbFile != configuration.DatabaseFile) { SheetDataWriter.OpenDatabase(configuration.DatabaseFile); } Document doc = data.GetDocument(); foreach (ElementId sheetId in data.GetAddedElementIds()) { ViewSheet viewSheet = doc.GetElement(sheetId) as ViewSheet; if (null != viewSheet) { bool inserted = InsertSheet(viewSheet); } } foreach (ElementId sheetId in data.GetModifiedElementIds()) { ViewSheet viewSheet = doc.GetElement(sheetId) as ViewSheet; if (null != viewSheet) { List <ElementId> parameterChanged = new List <ElementId>(); foreach (ElementId paramId in sheetParameters.Keys) { if (data.IsChangeTriggered(sheetId, Element.GetChangeTypeParameter(paramId))) { parameterChanged.Add(paramId); } } bool updated = UpdateSheet(viewSheet, parameterChanged); } } foreach (ElementId sheetId in data.GetDeletedElementIds()) { //bool deleted = DeleteSheet(sheetId); } } catch (Exception ex) { string message = ex.Message; } }
private void buttonAdd_Click(object sender, RoutedEventArgs e) { try { Discipline discipline = new Discipline(Guid.NewGuid(), "New Discipline"); this.RvtSheetData.Disciplines.Add(discipline); bool databaseUpdated = SheetDataWriter.ChangeDisciplineItem(discipline, CommandType.INSERT); } catch (Exception ex) { string messag = ex.Message; } }
public void IfCellTypeIsBlankShouldWriteBlankCellXml() { _objectToTest = new SheetDataWriter(); _cell.CellStyle.Index.Returns((short)0); _cell.CellType.Returns(CellType.Blank); _objectToTest.WriteCell(0, _cell); _objectToTest.Close(); var lines = File.ReadAllLines(_objectToTest.TemporaryFilePath()); Assert.True(lines.Length == 1); Assert.AreEqual("<c r=\"A1\"></c>", lines[0]); }
private void buttonAdd_Click(object sender, RoutedEventArgs e) { try { bool added = false; var revisionDescriptions = from revision in rvtSheetData.Revisions select revision.Description; for (int i = 1; i < 100; i++) { string revisionDescription = "New Revision " + i; if (!revisionDescriptions.Contains(revisionDescription)) { RevitRevision rvtRevision = new RevitRevision(Guid.NewGuid(), revisionDescription, "", "", ""); this.RvtSheetData.Revisions.Add(rvtRevision); bool sheetDBUpdated = SheetDataWriter.ChangeRevisionItem(rvtRevision, CommandType.INSERT); //update Revision On Sheet if (rvtSheetData.Sheets.Count > 0) { List <RevisionOnSheet> rosList = new List <RevisionOnSheet>(); for (int sheetIndex = 0; sheetIndex < rvtSheetData.Sheets.Count; sheetIndex++) { RevisionOnSheet ros = new RevisionOnSheet(Guid.NewGuid(), rvtSheetData.Sheets[sheetIndex].Id, rvtRevision, false); if (!rvtSheetData.Sheets[sheetIndex].SheetRevisions.ContainsKey(ros.RvtRevision.Id)) { this.RvtSheetData.Sheets[sheetIndex].SheetRevisions.Add(ros.RvtRevision.Id, ros); rosList.Add(ros); } } bool rosDBUpdated = SheetDataWriter.InsertMultipleRevisionOnSheet(rosList); added = rosDBUpdated; } else { added = true; } break; } } if (!added) { MessageBox.Show("Please assign descriptions of revision items before you add more revisions.", "Revision Description", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { string message = ex.Message; } }
private void dataGridItem_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { try { DataGridRow row = e.Row; if (null != row) { RevitItemMapper item = row.Item as RevitItemMapper; string propertyName = e.Column.Header.ToString(); switch (propertyName) { case "Source Value": TextBox sourceTextBox = e.EditingElement as TextBox; if (null != sourceTextBox) { var itemFound = from itemMap in rvtSheetData.ItemMaps where itemMap.SourceValue == sourceTextBox.Text && itemMap.ItemType == item.ItemType && itemMap.ItemId != item.ItemId select item; if (itemFound.Count() > 0) { MessageBoxResult msgResult = MessageBox.Show("[" + sourceTextBox.Text + "] Item already exists in the list. \nPlease enter a different value.", "Existing Value", MessageBoxButton.OK, MessageBoxImage.Information); if (msgResult == MessageBoxResult.OK) { e.Cancel = true; } } else { item.SourceValue = sourceTextBox.Text; bool dbUpdated = SheetDataWriter.ChangeReplaceItem(item, CommandType.UPDATE); } } break; case "Target Value": TextBox targetTextBox = e.EditingElement as TextBox; if (null != targetTextBox) { item.TargetValue = targetTextBox.Text; bool dbUpdated = SheetDataWriter.ChangeReplaceItem(item, CommandType.UPDATE); } break; } } } catch (Exception ex) { string message = ex.Message; } }
private void buttonDelete_Click(object sender, RoutedEventArgs e) { try { if (null != dataGridRevision.SelectedItems) { StringBuilder strBuilder = new StringBuilder(); strBuilder.AppendLine("Would you like to delete following revision items and related information?\n"); List <RevitRevision> revisions = new List <RevitRevision>(); foreach (object selectedItem in dataGridRevision.SelectedItems) { RevitRevision rvtRevision = selectedItem as RevitRevision; strBuilder.AppendLine("\"" + rvtRevision.Description + "\""); revisions.Add(rvtRevision); } if (revisions.Count > 0) { MessageBoxResult msgResult = MessageBox.Show(strBuilder.ToString(), "Delete Revisions", MessageBoxButton.YesNo, MessageBoxImage.Question); if (msgResult == MessageBoxResult.Yes) { foreach (RevitRevision rvtRevision in revisions) { this.RvtSheetData.Revisions.Remove(rvtRevision); bool revisionDeleted = SheetDataWriter.ChangeRevisionItem(rvtRevision, CommandType.DELETE); bool rosDeleted = SheetDataWriter.DeleteRevisionOnSheet("RevisionsOnSheet_Revision_Id", rvtRevision.Id.ToString()); bool linkedDeleted = SheetDataWriter.ChangeLinkedRevision(rvtRevision.Id, "LinkedRevision_Revision_Id", rvtRevision.Id.ToString(), CommandType.DELETE); } for (int sheetIndex = 0; sheetIndex < rvtSheetData.Sheets.Count; sheetIndex++) { foreach (RevitRevision rvtRevision in revisions) { if (rvtSheetData.Sheets[sheetIndex].SheetRevisions.ContainsKey(rvtRevision.Id)) { this.RvtSheetData.Sheets[sheetIndex].SheetRevisions.Remove(rvtRevision.Id); } } } } } } } catch (Exception ex) { string message = ex.Message; } }
public void IfCellTypeIsStringShouldWriteStringCellXml() { _objectToTest = new SheetDataWriter(); _cell.CellStyle.Index.Returns((short)0); _cell.CellType.Returns(CellType.String); _cell.StringCellValue.Returns("''<>\t\n\r&\"? test:SLDFKj "); _objectToTest.WriteCell(0, _cell); _objectToTest.Close(); var lines = File.ReadAllLines(_objectToTest.TemporaryFilePath()); Assert.True(lines.Length == 1); Assert.AreEqual("<c r=\"A1\" t=\"inlineStr\"><is><t xml:space=\"preserve\">\'\'<>	

&"? test:SLDFKj </t></is></c>", lines[0]); }
public void IfCellTypeIsErrorShouldWriteErrorCellXml() { _objectToTest = new SheetDataWriter(); _cell.CellStyle.Index.Returns((short)0); _cell.CellType.Returns(CellType.Error); _cell.ErrorCellValue.Returns((byte)0x00); _objectToTest.WriteCell(0, _cell); _objectToTest.Close(); var lines = File.ReadAllLines(_objectToTest.TemporaryFilePath()); Assert.True(lines.Length == 1); Assert.AreEqual("<c r=\"A1\" t=\"e\"><v>#NULL!</v></c>", lines[0]); }
public void IfCellTypeIsBooleanFalseShouldWriteBooleanCellFalseXml() { _objectToTest = new SheetDataWriter(); _cell.CellStyle.Index.Returns((short)0); _cell.CellType.Returns(CellType.Boolean); _cell.BooleanCellValue.Returns(false); _objectToTest.WriteCell(0, _cell); _objectToTest.Close(); var lines = File.ReadAllLines(_objectToTest.TemporaryFilePath()); Assert.True(lines.Length == 1); Assert.AreEqual("<c r=\"A1\" t=\"b\"><v>0</v></c>", lines[0]); }
public void IfWritingRowWithZeroHeightShouldIncludeHiddenAttributeXml() { _objectToTest = new SheetDataWriter(); _row.HasCustomHeight().Returns(false); _row.ZeroHeight.Returns(true); _objectToTest.WriteRow(0, _row); _objectToTest.Close(); var lines = File.ReadAllLines(_objectToTest.TemporaryFilePath()); Assert.True(lines.Length == 2); Assert.AreEqual("<row r=\"" + 1 + "\" hidden=\"true\">", lines[0]); Assert.AreEqual("</row>", lines[1]); }
public void IfWritingRowWithCustomHeightShouldIncludeCustomHeightXml() { _objectToTest = new SheetDataWriter(); var row = new SXSSFRow(null); row.Height = 1; _objectToTest.WriteRow(0, row); _objectToTest.Close(); var lines = File.ReadAllLines(_objectToTest.TemporaryFilePath()); Assert.True(lines.Length == 2); Assert.AreEqual("<row r=\"" + 1 + "\" customHeight=\"true\" ht=\"" + row.HeightInPoints + "\">", lines[0]); Assert.AreEqual("</row>", lines[1]); }
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; } }
public void IfWritingRowThatIsFormattedShouldIncludeRowStyleIndexAndCustomFormatAttributeXml() { _objectToTest = new SheetDataWriter(); _row.HasCustomHeight().Returns(false); _row.ZeroHeight.Returns(false); _row.IsFormatted.Returns(true); _row.RowStyle.Index.Returns((short)1); _objectToTest.WriteRow(0, _row); _objectToTest.Close(); var lines = File.ReadAllLines(_objectToTest.TemporaryFilePath()); Assert.True(lines.Length == 2); Assert.AreEqual("<row r=\"" + 1 + "\" s=\"" + _row.RowStyle.Index + "\" customFormat=\"1\">", lines[0]); Assert.AreEqual("</row>", lines[1]); }
public void IfCellTypeIsFormulaShouldWriteFormulaCellXml() { _objectToTest = new SheetDataWriter(); _cell.CellStyle.Index.Returns((short)0); _cell.CellType.Returns(CellType.Formula); _cell.CellFormula.Returns("SUM(A1:A3)"); _cell.GetCachedFormulaResultTypeEnum().Returns(CellType.Numeric); _cell.NumericCellValue.Returns(1); _objectToTest.WriteCell(0, _cell); _objectToTest.Close(); var lines = File.ReadAllLines(_objectToTest.TemporaryFilePath()); Assert.True(lines.Length == 1); Assert.AreEqual("<c r=\"A1\"><f>SUM(A1:A3)</f><v>1</v></c>", lines[0]); }
public void IfWritingRowHasOutlineLevelGreaterThanZeroShouldAppendOutlineXml() { _objectToTest = new SheetDataWriter(); _row.HasCustomHeight().Returns(false); _row.ZeroHeight.Returns(false); _row.IsFormatted.Returns(false); _row.OutlineLevel.Returns(1); _objectToTest.WriteRow(0, _row); _objectToTest.Close(); var lines = File.ReadAllLines(_objectToTest.TemporaryFilePath()); Assert.True(lines.Length == 2); Assert.AreEqual("<row r=\"" + 1 + "\" outlineLevel=\"" + _row.OutlineLevel + "\">", lines[0]); Assert.AreEqual("</row>", lines[1]); }
private bool DeleteSheet(ElementId sheetId) { bool deleted = false; try { if (idMaps.ContainsKey(sheetId)) { string uniqueId = idMaps[sheetId]; LinkedSheet linkedSheet = dataManager.GetLinkedSheet(uniqueId, linkedProjectId); if (null != linkedSheet) { if (linkedSheet.IsSource) { MessageBoxResult msgResult = MessageBox.Show("Would you like to delete the sheet item in the linked database?", "Delete Sheet Source Item", MessageBoxButton.YesNo, MessageBoxImage.Question); if (msgResult == MessageBoxResult.Yes) { RevitSheet rvtSheet = new RevitSheet() { Id = linkedSheet.SheetId }; bool sheetDeleted = SheetDataWriter.ChangeSheetItem(rvtSheet, CommandType.DELETE); bool paramDeleted = SheetDataWriter.DeleteSheetParameterValue(rvtSheet.Id.ToString()); bool revisionDeleted = SheetDataWriter.DeleteRevisionOnSheet("RevisionsOnSheet_Sheet_Id", rvtSheet.Id.ToString()); bool linkDeleted = SheetDataWriter.ChangeLinkedSheet(linkedSheet, CommandType.DELETE); deleted = (sheetDeleted && paramDeleted && revisionDeleted && linkDeleted) ? true : false; } else { deleted = SheetDataWriter.ChangeLinkedSheet(linkedSheet, CommandType.DELETE); } } else { deleted = SheetDataWriter.ChangeLinkedSheet(linkedSheet, CommandType.DELETE); } } } } catch (Exception ex) { string message = ex.Message; } return(deleted); }
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 void IfWritingRowIsHiddenShouldAppendHiddenXml() { _objectToTest = new SheetDataWriter(); _row.HasCustomHeight().Returns(false); _row.ZeroHeight.Returns(false); _row.IsFormatted.Returns(false); _row.OutlineLevel.Returns(0); _row.Hidden.Returns(true); _objectToTest.WriteRow(0, _row); _objectToTest.Close(); var lines = File.ReadAllLines(_objectToTest.TemporaryFilePath()); Assert.True(lines.Length == 2); Assert.AreEqual("<row r=\"" + 1 + "\" hidden=\"" + (_row.Hidden.Value ? "1" : "0") + "\">", lines[0]); Assert.AreEqual("</row>", lines[1]); }
private void buttonAddItem_Click(object sender, RoutedEventArgs e) { try { if (null != comboBoxType.SelectedItem && null != comboBoxParameter.SelectedItem) { ItemMap itemMap = comboBoxType.SelectedItem as ItemMap; string parameter = comboBoxParameter.SelectedItem.ToString(); if (null != itemMap && !string.IsNullOrEmpty(parameter)) { string sampleSourceName = ""; double suffix = 0; if (dataGridItem.Items.Count > 0) { RevitItemMapper lastItem = dataGridItem.Items[dataGridItem.Items.Count - 1] as RevitItemMapper; sampleSourceName = lastItem.SourceValue.ToString(); if (DataGridUtils.GetSuffix(sampleSourceName, out suffix)) { sampleSourceName = sampleSourceName.Replace(suffix.ToString(), (suffix + 1).ToString()); } else { sampleSourceName += " " + (suffix + 1).ToString(); } } if (string.IsNullOrEmpty(sampleSourceName)) { sampleSourceName = "New Item 1"; } RevitItemMapper itemMapper = new RevitItemMapper(Guid.NewGuid(), itemMap.ItemMapType, parameter, sampleSourceName, ""); this.RvtSheetData.ItemMaps.Add(itemMapper); bool dbUpdated = SheetDataWriter.ChangeReplaceItem(itemMapper, CommandType.INSERT); } } } catch (Exception ex) { string message = ex.Message; } }
private void dataGridRevision_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { try { DataGridRow row = e.Row; string columnName = e.Column.Header.ToString(); if (null != row && !string.IsNullOrEmpty(columnName)) { RevitRevision oldRevision = row.Item as RevitRevision; if (columnName != "Document") { TextBox textBox = e.EditingElement as TextBox; string propertyValue = textBox.Text; string propertyName = ""; switch (columnName) { case "Description": propertyName = "Revision_Description"; break; case "Issued By": propertyName = "Revision_IssuedBy"; break; case "Issued To": propertyName = "Revision_IssuedTo"; break; case "Date": propertyName = "Revision_Date"; break; } bool databaseUpdated = SheetDataWriter.ChangeRevisionItem(oldRevision.Id.ToString(), propertyName, propertyValue); } } } catch (Exception ex) { string message = ex.Message; } }
private bool DeleteRevision(ElementId revisionId) { bool deleted = false; try { if (idMaps.ContainsKey(revisionId)) { string uniqueId = idMaps[revisionId]; LinkedRevision linkedRevision = dataManager.GetLinkedRevision(uniqueId, linkedProjectId); if (null != linkedRevision) { if (linkedRevision.IsSource) { MessageBoxResult msgResult = MessageBox.Show("Would you like to delete the revision item in the linked database?", "Delete Revision Source Item", MessageBoxButton.YesNo, MessageBoxImage.Question); if (msgResult == MessageBoxResult.Yes) { RevitRevision rvtRevision = new RevitRevision(); rvtRevision.Id = linkedRevision.RevisionId; bool revisionDeleted = SheetDataWriter.ChangeRevisionItem(rvtRevision, CommandType.DELETE); bool rosDeleted = SheetDataWriter.DeleteRevisionOnSheet("RevisionsOnSheet_Revision_Id", rvtRevision.Id.ToString()); bool linkDeleted = SheetDataWriter.ChangeLinkedRevision(linkedRevision, CommandType.DELETE); deleted = (revisionDeleted && rosDeleted && linkDeleted) ? true : false; } else { deleted = SheetDataWriter.ChangeLinkedRevision(linkedRevision, CommandType.DELETE); } } else { deleted = SheetDataWriter.ChangeLinkedRevision(linkedRevision, CommandType.DELETE); } } } } catch (Exception ex) { string message = ex.Message; } return(deleted); }
private void OnUnchecked(object sender, RoutedEventArgs e) { try { if (userMode && null != sender) { CheckBox checkBox = sender as CheckBox; RevisionOnSheet ros = GetRevisionOnSheet(checkBox); if (null != ros) { bool dbUpdated = SheetDataWriter.ChangeRevisionOnSheet(ros, CommandType.UPDATE); } } } catch (Exception ex) { MessageBox.Show("Failed to fire checkbox event.\n" + ex.Message, "Checkbox Unchecked", MessageBoxButton.OK, MessageBoxImage.Warning); } }