private int GetRowIdFromClassName(string clsName) { try { for (int i = 0; i < this.Rows.Count; i++) { ECClass ecClass = this[s_WBSClassKey, i].Tag as ECClass; if (ecClass.Name.Equals(clsName)) { return(i); } } } catch { } // catch if s_WBSClassKey is not valid return(-1); }
private static ECSchema CreateSchema(DgnFile File) { ECSchema newSchema = new ECSchema(schemaName, 1, 0, schemaName); ECClass streamStateClass = new ECClass(className); ECProperty streamDataProp = new ECProperty(propertyName, ECObjects.StringType); streamStateClass.Add(streamDataProp); newSchema.AddClass(streamStateClass); var status = DgnECManager.Manager.ImportSchema(newSchema, File, new ImportSchemaOptions()); if (status != SchemaImportStatus.Success) { return(null); } return(newSchema); }
public void CreateAndImport() { ECSchema schema = new ECSchema(SchemaTreeViewItems.Last().Name, 1, 0, "PDIWT"); foreach (var classnode in SchemaTreeViewItems.Last().ClassNodes) { ECClass someclass = new ECClass(classnode.Name); foreach (var propnode in classnode.PropertyNodes) { ECProperty someProp = new ECProperty(propnode.Name, GetTypeFromString(propnode.PropertyType)); //someProp. someclass.Add(someProp); //someclass.AddProperty(); } schema.AddClass(someclass); } if (BDEC.DgnECManager.Manager.ImportSchema(schema, Program.GetActiveDgnFile(), new BDEC.ImportSchemaOptions()) == BD.SchemaImportStatus.Success) { MessageBox.Show($"{schema.FullName}导入成功", " 水规院", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static ECSchema AddSchema() { DgnFile File = Session.Instance.GetActiveDgnFile(); DgnECManager Manager = DgnECManager.Manager; ECSchema newSchema = new ECSchema(schemaName, 1, 0, schemaName); ECClass streamStateClass = new ECClass(className); ECProperty streamIdProp = new ECProperty("Id", ECObjects.StringType); ECProperty streamDataProp = new ECProperty("StreamData", ECObjects.StringType); streamStateClass.Add(streamIdProp); streamStateClass.Add(streamDataProp); newSchema.AddClass(streamStateClass); var status = Manager.ImportSchema(newSchema, File, new ImportSchemaOptions()); if (status != SchemaImportStatus.Success) { return(null); } return(newSchema); }
//update the WBS specific item based on the wbs ecinstance and relationship name private WBSUpdateType UpdateWBSComboxValue(IECInstance sourceWBS, string WBSRrelationshipName) { //set source WBS values //these values will be matched against values in existing datagrid combo box string sourceName = sourceWBS.ClassDefinition.Name; IECPropertyValue sourceVal = sourceWBS.FindPropertyValue(s_WBSName, false, false, false); if (sourceVal == null || sourceVal.IsNull) { return(WBSUpdateType.Error); } string sourceWbsValue = sourceVal.StringValue; DataGridViewCell dataGridClassCell = null; DataGridViewCell dataGridInstanceCell = null; //iterate items and try match passed in value against associated datagrid combox items for (int i = 0; i < this.Rows.Count; i++) { ECClass ecClass = this[s_WBSClassKey, i].Tag as ECClass; if (!ecClass.Name.Equals(WBSRrelationshipName)) { continue; } string currentValue = this[s_WBSInstanceKey, i].Value as string; //values are the same no need to update if (currentValue.Equals(sourceWbsValue)) { return(WBSUpdateType.ExistingFoundInDgn); } //list of existing WBS items are stored in tag Dictionary <string, IECInstance> cachedInstances = this[s_WBSInstanceKey, i].Tag as Dictionary <string, IECInstance>; if (cachedInstances == null || cachedInstances.Count == 0) { continue; } foreach (IECInstance wbsInst in cachedInstances.Values) { IECPropertyValue wbsPropval = wbsInst.FindPropertyValue(s_WBSName, false, false, false); if (wbsPropval == null || wbsPropval.IsNull) { return(WBSUpdateType.Error); } //if match is found set datagrid values if (wbsPropval.StringValue.Equals(sourceWbsValue)) { dataGridClassCell = this[s_WBSClassKey, i]; dataGridInstanceCell = this[s_WBSInstanceKey, i]; break; } } if (dataGridInstanceCell != null && dataGridClassCell != null) { break; } } //if all those values are found, set datagrid values if (dataGridInstanceCell != null && dataGridClassCell != null) { dataGridClassCell.Selected = true; dataGridInstanceCell.Selected = true; dataGridInstanceCell.Value = sourceWbsValue; return(WBSUpdateType.ExistingFoundInDgn); } return(WBSUpdateType.NeedToCreate); }