private ErrorRow UpdateOneElement(Element elem, DataRow row) { ErrorRow errorRow = new ErrorRow(row); ParameterMap parameterMap = null; try { parameterMap = elem.ParametersMap; } catch (System.Exception ex) { Log.WriteLine(string.Concat(new object[] { "TableName:", base.TableInfo.Name, " ElementId:", elem.Id.IntegerValue })); Log.WriteLine(ex.ToString()); } foreach (ColumnInfo current in base.TableInfo.Values) { Parameter param; if (current.BuiltInParameter != (BuiltInParameter)(-1)) { param = elem.get_Parameter(current.BuiltInParameter); } else { param = APIObjectList.GetParameterByDefinitionName(parameterMap, current.Name); } object paramValue = row[current.Name]; UpdateResult state = (current.BuiltInParameter == (BuiltInParameter)(-1002500)) ? UpdateResult.AssemblyCode : this.UpdateParameter(param, paramValue); ErrorCell value = new ErrorCell(current.Name, state); errorRow.Cells.Add(current.Name, value); switch (state) { case UpdateResult.Unknown: case UpdateResult.Success: case UpdateResult.Failed: case UpdateResult.ReadOnlyFailed: case UpdateResult.ParameterNull: case UpdateResult.Exception: errorRow.HasChange = true; break; } } return(errorRow); }
public override ErrorTable ImportFromDataTable(DataTable dataTable) { ErrorTable errorTable = new ErrorTable(base.TableInfo.TableId, base.TableInfo.Name); foreach (DataRow dataRow in dataTable.Rows) { if (dataRow.RowState != DataRowState.Deleted) { Element element = this.GetRevitObject(dataRow) as Element; ErrorRow errorRow; if (element == null) { element = this.CreateNewElement(dataRow); if (element == null) { errorRow = new ErrorRow(dataRow); errorRow.State = DataRowState.Deleted; errorRow.HasChange = true; for (int i = 0; i < dataTable.Columns.Count; i++) { string columnName = dataTable.Columns[i].ColumnName; errorRow.Cells.Add(columnName, new ErrorCell(columnName, UpdateResult.Equals)); } } else { errorRow = this.UpdateOneElement(element, dataRow); errorRow.State = DataRowState.Added; errorRow.HasChange = true; } } else { errorRow = this.UpdateOneElement(element, dataRow); } errorTable.Rows.Add(errorRow); if (!errorTable.HasChange && errorRow.HasChange) { errorTable.HasChange = true; } } } return(errorTable); }