private void buttonProperty_Click(object sender, EventArgs e) { using (FormSelectProperty form = new FormSelectProperty(this.m_base as DocEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string valueprop = "NominalValue"; switch (form.SelectedProperty.PropertyType) { case DocPropertyTemplateTypeEnum.P_BOUNDEDVALUE: valueprop = "SetPointValue"; break; case DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE: valueprop = "EnumerationValues"; break; case DocPropertyTemplateTypeEnum.P_LISTVALUE: valueprop = "ListValues"; break; // other property types are not supported } string value = @"\" + this.m_base.Name + @".IsDefinedBy['" + form.SelectedPropertySet + @"']\IfcRelDefinesByProperties.RelatingPropertyDefinition\IfcPropertySet.HasProperties['" + form.SelectedProperty + @"']\" + form.SelectedProperty.GetEntityName() + @"." + valueprop + @"\" + form.SelectedProperty.PrimaryDataType; CvtValuePath valuepath = CvtValuePath.Parse(value, this.m_map); LoadValuePath(valuepath); } } }
public FormReference(DocProject docProject, DocDefinition docBase, Dictionary <string, DocObject> map, string value) : this() { this.m_project = docProject; this.m_base = docBase; this.m_map = map; // parse value CvtValuePath valuepath = CvtValuePath.Parse(value, map); LoadValuePath(valuepath); }
private void buttonQuantity_Click(object sender, EventArgs e) { using (FormSelectQuantity form = new FormSelectQuantity(this.m_base as DocEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string value = form.GenerateValuePath(); CvtValuePath valuepath = CvtValuePath.Parse(value, this.m_map); LoadValuePath(valuepath); } } }
private void buttonProperty_Click(object sender, EventArgs e) { using (FormSelectProperty form = new FormSelectProperty(this.m_base as DocEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string valueprop = "NominalValue"; string datatype = form.SelectedProperty.PrimaryDataType; switch (form.SelectedProperty.PropertyType) { case DocPropertyTemplateTypeEnum.P_BOUNDEDVALUE: valueprop = "SetPointValue"; break; case DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE: valueprop = "EnumerationValues"; break; case DocPropertyTemplateTypeEnum.P_LISTVALUE: valueprop = "ListValues"; break; case DocPropertyTemplateTypeEnum.P_REFERENCEVALUE: valueprop = "PropertyReference"; datatype = "IfcIrregularTimeSeries.Values[]\\" + form.SelectedProperty.SecondaryDataType; break; // other property types are not supported } string portprefix = String.Empty; if (form.SelectedPort != null) { portprefix = @".IsNestedBy[]\IfcRelNests.RelatedObjects['" + form.SelectedPort + @"']\IfcDistributionPort"; } string value = @"\" + this.m_base.Name + portprefix + @".IsDefinedBy['" + form.SelectedPropertySet + @"']\IfcRelDefinesByProperties.RelatingPropertyDefinition\IfcPropertySet.HasProperties['" + form.SelectedProperty + @"']\" + form.SelectedProperty.GetEntityName() + @"." + valueprop + @"\" + datatype; CvtValuePath valuepath = CvtValuePath.Parse(value, this.m_map); LoadValuePath(valuepath); } } }
private void buttonQuantity_Click(object sender, EventArgs e) { using (FormSelectQuantity form = new FormSelectQuantity(this.m_base as DocEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string suffix = null; switch (form.SelectedQuantity.QuantityType) { case DocQuantityTemplateTypeEnum.Q_AREA: suffix = @"IfcQuantityArea.AreaValue\IfcAreaMeasure"; break; case DocQuantityTemplateTypeEnum.Q_COUNT: suffix = @"IfcQuantityCount.CountValue\IfcInteger"; break; case DocQuantityTemplateTypeEnum.Q_LENGTH: suffix = @"IfcQuantityLength.LengthValue\IfcLengthMeasure"; break; case DocQuantityTemplateTypeEnum.Q_TIME: suffix = @"IfcQuantityTime.TimeValue\IfcTimeMeasure"; break; case DocQuantityTemplateTypeEnum.Q_VOLUME: suffix = @"IfcQuantityVolume.VolumeValue\IfcVolumeMeasure"; break; case DocQuantityTemplateTypeEnum.Q_WEIGHT: suffix = @"IfcQuantityWeight.WeightValue\IfcWeightMeasure"; break; } string value = @"\" + this.m_base.Name + @".IsDefinedBy['" + form.SelectedQuantitySet + @"']\IfcRelDefinesByProperties.RelatingPropertyDefinition\IfcElementQuantity.Quantities['" + form.SelectedQuantity + @"']\" + suffix; CvtValuePath valuepath = CvtValuePath.Parse(value, this.m_map); LoadValuePath(valuepath); } } }
private void toolStripButtonQuantity_Click(object sender, EventArgs e) { DocEntity docBaseEntity = this.m_project.GetDefinition(this.m_template.Type) as DocEntity; if (this.m_conceptroot != null && this.m_conceptroot.ApplicableEntity != null) { docBaseEntity = this.m_conceptroot.ApplicableEntity; } using (FormSelectQuantity form = new FormSelectQuantity(docBaseEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string value = form.GenerateValuePath(); Dictionary <string, DocObject> mapEntity = new Dictionary <string, DocObject>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { mapEntity.Add(docEntity.Name, docEntity); } foreach (DocType docType in docSchema.Types) { mapEntity.Add(docType.Name, docType); } } } CvtValuePath valuepath = CvtValuePath.Parse(value, mapEntity); this.ChangeTemplate(valuepath.ToTemplateDefinition()); this.LoadTemplateGraph(); this.ContentChanged(this, EventArgs.Empty); } } }
public string FormatData(DocProject docProject, DocPublication docPublication, DocExchangeDefinition docExchange, Dictionary <string, DocObject> map, Dictionary <long, SEntity> instances, SEntity root, bool markup) { //Guid guidMapping = Guid.Parse("");//... StringBuilder sb = new StringBuilder(); foreach (DocModelView docView in docPublication.Views) { foreach (DocConceptRoot docRoot in docView.ConceptRoots) { // look for specific concept root dealing with mappings foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if (docConcept.Definition != null && docConcept.Definition.Name.Equals("External Data Constraints") && docConcept.Items.Count > 0)//... { bool included = true; if (docExchange != null) { included = false; // if exhcnage specified, check for inclusion foreach (DocExchangeItem docExchangeItem in docConcept.Exchanges) { if (docExchangeItem.Exchange == docExchange && docExchangeItem.Requirement == DocExchangeRequirementEnum.Mandatory) { included = true; break; } } } // check if there are any instances to populate table if (included) { included = false; foreach (SEntity e in instances.Values) { string eachname = e.GetType().Name; if (docRoot.ApplicableEntity.IsInstanceOfType(e)) { included = true; break; } } } if (included) { string table = docConcept.Items[0].GetParameterValue("Table"); string query = docConcept.Items[0].GetParameterValue("Reference"); sb.AppendLine("<h4>" + docConcept.Name + "</h4>"); sb.AppendLine("<table class=\"gridtable\">"); List <string> colstyles = new List <string>(); List <string> colformat = new List <string>(); List <CvtValuePath> colmaps = new List <CvtValuePath>(); // generate header row sb.AppendLine("<tr>"); foreach (DocTemplateItem docItem in docConcept.Items) { string name = docItem.GetParameterValue("Name"); string disp = "#" + docItem.GetColor().ToArgb().ToString("X8"); //docItem.GetParameterValue("Color");docItem.GetParameterValue("Color"); string expr = docItem.GetParameterValue("Reference"); string form = docItem.GetParameterValue("Format"); string style = ""; if (!String.IsNullOrEmpty(disp)) { style = " style=\"background-color:" + disp + ";\""; } colstyles.Add(style); string format = ""; if (!String.IsNullOrEmpty(form)) { format = form; } colformat.Add(format); string desc = ""; CvtValuePath valpath = CvtValuePath.Parse(expr, map); //todo: move out of loop colmaps.Add(valpath); if (valpath != null) { desc = /*valpath.GetDescription(map) + " " + */ valpath.ToString().Replace("\\", " "); } sb.Append("<th><a href=\"../../schema/views/" + DocumentationISO.MakeLinkName(docView) + "/" + DocumentationISO.MakeLinkName(docExchange) + ".htm#" + DocumentationISO.MakeLinkName(docConcept) + "\" title=\"" + desc + "\">"); sb.Append(name); sb.Append("</a></th>"); } ; sb.AppendLine("</tr>"); // generate data rows foreach (SEntity e in instances.Values) { string eachname = e.GetType().Name; if (docRoot.ApplicableEntity.IsInstanceOfType(e)) { bool includerow = true; StringBuilder sbRow = new StringBuilder(); sbRow.Append("<tr>"); int iCol = 0; foreach (DocTemplateItem docItem in docConcept.Items) { sbRow.Append("<td" + colstyles[iCol]); CvtValuePath valpath = colmaps[iCol]; string format = colformat[iCol]; iCol++; if (valpath != null) { string nn = docItem.GetParameterValue("Name"); object value = valpath.GetValue(e, null); if (value == e) { value = e.GetType().Name; } else if (value is SEntity) { // use name FieldInfo fieldValue = value.GetType().GetField("Name"); if (fieldValue != null) { value = fieldValue.GetValue(value); } } else if (value is System.Collections.IList) { System.Collections.IList list = (System.Collections.IList)value; StringBuilder sbList = new StringBuilder(); foreach (object elem in list) { FieldInfo fieldName = elem.GetType().GetField("Name"); if (fieldName != null) { object elemname = fieldName.GetValue(elem); if (elemname != null) { FieldInfo fieldValue = elemname.GetType().GetField("Value"); if (fieldValue != null) { object elemval = fieldValue.GetValue(elemname); sbList.Append(elemval.ToString()); } } } sbList.Append("; <br/>"); } value = sbList.ToString(); } else if (value is Type) { value = ((Type)value).Name; } if (!String.IsNullOrEmpty(format)) { if (format.Equals("Required") && value == null) { includerow = false; } } if (value != null) { FieldInfo fieldValue = value.GetType().GetField("Value"); if (fieldValue != null) { value = fieldValue.GetValue(value); } if (format != null && format.Equals("True") && (value == null || !value.ToString().Equals("True"))) { includerow = false; } if (value is Double) { sbRow.Append(" align=\"right\">"); sbRow.Append(((Double)value).ToString("N3")); } else if (value is List <Int64> ) { sbRow.Append(">"); // latitude or longitude List <Int64> intlist = (List <Int64>)value; if (intlist.Count >= 3) { sbRow.Append(intlist[0] + "° " + intlist[1] + "' " + intlist[2] + "\""); } } else if (value != null) { sbRow.Append(">"); sbRow.Append(value.ToString()); // todo: html-encode } } else { sbRow.Append(">"); sbRow.Append(" "); } } else { sbRow.Append(">"); } sbRow.Append("</td>"); } sbRow.AppendLine("</tr>"); if (includerow) { sb.Append(sbRow.ToString()); } } } sb.AppendLine("</table>"); sb.AppendLine("<br/>"); } } } } } return(sb.ToString()); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.tabControl.TabPages.Clear(); foreach (DocConceptRoot docRoot in this.m_view.ConceptRoots) { foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if (docConcept.Definition != null && docConcept.Definition.Uuid == DocTemplateDefinition.guidTemplateMapping) { TabPage tabPage = new TabPage(); tabPage.Text = docRoot.Name; tabPage.Tag = docConcept; this.tabControl.TabPages.Add(tabPage); ListView listView = new ListView(); tabPage.Controls.Add(listView); listView.Dock = DockStyle.Fill; listView.View = View.Details; listView.FullRowSelect = true; ColumnHeader colHeaderIndex = new ColumnHeader(); colHeaderIndex.Text = "Index"; colHeaderIndex.Width = 100; listView.Columns.Add(colHeaderIndex); List <CvtValuePath> colmaps = new List <CvtValuePath>(); foreach (DocTemplateItem docItem in docConcept.Items) { string expr = docItem.GetParameterValue("Reference"); CvtValuePath valpath = CvtValuePath.Parse(expr, this.m_mapEntity); colmaps.Add(valpath); ColumnHeader columnHeader = new ColumnHeader(); columnHeader.Text = docItem.GetParameterValue("Name"); columnHeader.Tag = docItem; columnHeader.Width = 100; listView.Columns.Add(columnHeader); } // load instance data foreach (object instance in this.m_instances.Values) { string eachname = instance.GetType().Name; if (docRoot.ApplicableEntity != null && docRoot.ApplicableEntity.IsInstanceOfType(instance)) { ListViewItem lvi = new ListViewItem(); lvi.Text = (listView.Items.Count + 1).ToString(); listView.Items.Add(lvi); int iCol = 0; foreach (DocTemplateItem docItem in docConcept.Items) { CvtValuePath valpath = colmaps[iCol]; iCol++; object value = valpath.GetValue((SEntity)instance, null); if (value == instance) { value = e.GetType().Name; } else if (value is SEntity) { // use name FieldInfo fieldValue = value.GetType().GetField("Name"); if (fieldValue != null) { value = fieldValue.GetValue(value); } } else if (value is System.Collections.IList) { System.Collections.IList list = (System.Collections.IList)value; StringBuilder sbList = new StringBuilder(); foreach (object elem in list) { FieldInfo fieldName = elem.GetType().GetField("Name"); if (fieldName != null) { object elemname = fieldName.GetValue(elem); if (elemname != null) { FieldInfo fieldValue = elemname.GetType().GetField("Value"); if (fieldValue != null) { object elemval = fieldValue.GetValue(elemname); sbList.Append(elemval.ToString()); } } } sbList.Append("; <br/>"); } value = sbList.ToString(); } else if (value is Type) { value = ((Type)value).Name; } #if false if (!String.IsNullOrEmpty(format)) { if (format.Equals("Required") && value == null) { includerow = false; } } #endif string text = String.Empty; if (value != null) { FieldInfo fieldValue = value.GetType().GetField("Value"); if (fieldValue != null) { value = fieldValue.GetValue(value); } #if false if (format != null && format.Equals("True") && (value == null || !value.ToString().Equals("True"))) { includerow = false; } #endif if (value is Double) { text = ((Double)value).ToString("N3"); } else if (value is List <Int64> ) { // latitude or longitude List <Int64> intlist = (List <Int64>)value; if (intlist.Count >= 3) { text = intlist[0] + "° " + intlist[1] + "' " + intlist[2] + "\""; } } else if (value != null) { text = value.ToString(); } } lvi.SubItems.Add(text); } } } } } } }
private void buttonProperty_Click(object sender, EventArgs e) { using (FormSelectProperty form = new FormSelectProperty(this.m_base as DocEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string portprefix = String.Empty; if (form.SelectedPort != null) { portprefix = @".IsNestedBy[]\IfcRelNests.RelatedObjects['" + form.SelectedPort + @"']\IfcDistributionPort"; } if (form.SelectedPropertySet != null && form.SelectedPropertySet.PropertySetType == "PSET_PERFORMANCEDRIVEN") { portprefix += @".HasAssignments[]\IfcRelAssignsToControl.RelatingControl\IfcPerformanceHistory"; } string value = @"\" + this.m_base.Name + portprefix; if (form.SelectedProperty != null) { string valueprop = "NominalValue"; string datatype = form.SelectedProperty.PrimaryDataType; switch (form.SelectedProperty.PropertyType) { case DocPropertyTemplateTypeEnum.P_BOUNDEDVALUE: if (form.SelectedQualifier != null) { valueprop = form.SelectedQualifier; } else { valueprop = "SetPointValue"; } break; case DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE: valueprop = "EnumerationValues"; break; case DocPropertyTemplateTypeEnum.P_LISTVALUE: valueprop = "ListValues"; break; case DocPropertyTemplateTypeEnum.P_REFERENCEVALUE: valueprop = "PropertyReference"; datatype = "IfcIrregularTimeSeries.Values[]\\IfcIrregularTimeSeriesValue.ListValues[]\\" + form.SelectedProperty.SecondaryDataType; break; // other property types are not supported } if (form.SelectedProperty.PropertyType == DocPropertyTemplateTypeEnum.COMPLEX) { value += @".IsDefinedBy['" + form.SelectedPropertySet + @"']\IfcRelDefinesByProperties.RelatingPropertyDefinition\IfcPropertySet.HasProperties['" + form.SelectedProperty + @"']\" + form.SelectedProperty.GetEntityName(); } else { value += @".IsDefinedBy['" + form.SelectedPropertySet + @"']\IfcRelDefinesByProperties.RelatingPropertyDefinition\IfcPropertySet.HasProperties['" + form.SelectedProperty + @"']\" + form.SelectedProperty.GetEntityName() + @"." + valueprop + @"\" + datatype; } // special cases if (this.m_base.Name.Equals("IfcMaterial")) { value = @"\IfcMaterial.HasProperties['" + form.SelectedPropertySet + @"']\IfcMaterialProperties.Properties['" + form.SelectedProperty + @"']\" + form.SelectedProperty.GetEntityName() + @"." + valueprop + @"\" + datatype; } } else { value += @".GlobalId\IfcGloballyUniqueId"; } CvtValuePath valuepath = CvtValuePath.Parse(value, this.m_map); LoadValuePath(valuepath); } } }
private void toolStripButtonProperty_Click(object sender, EventArgs e) { DocEntity docBaseEntity = this.m_project.GetDefinition(this.m_template.Type) as DocEntity; if (this.m_conceptroot != null && this.m_conceptroot.ApplicableEntity != null) { docBaseEntity = this.m_conceptroot.ApplicableEntity; } using (FormSelectProperty form = new FormSelectProperty(docBaseEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string value = form.GenerateValuePath(); Dictionary <string, DocObject> mapEntity = new Dictionary <string, DocObject>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { mapEntity.Add(docEntity.Name, docEntity); } foreach (DocType docType in docSchema.Types) { mapEntity.Add(docType.Name, docType); } } } if (docBaseEntity.BaseDefinition == "IfcElement" || docBaseEntity.BaseDefinition == "IfcElementComponent" || docBaseEntity.BaseDefinition == "IfcBuildingElement" || docBaseEntity.BaseDefinition == "IfcReinforcingElement" || docBaseEntity.BaseDefinition == "IfcFlowSegment" || docBaseEntity.BaseDefinition == "IfcFeatureElement" || docBaseEntity.BaseDefinition == "IfcContext" || docBaseEntity.BaseDefinition == "IfcSpatialStructureElement" || docBaseEntity.BaseDefinition == "IfcFacility" || docBaseEntity.BaseDefinition == "IfcFacilityPart") { this.ChangeTemplate(this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePsetObject)); string[] psetParamNames = this.Concept.Definition.GetParameterNames(); DocTemplateItem pset = new DocTemplateItem(); pset.Name = form.SelectedPropertySet.Name; if (form.SelectedPropertySet.Name == "Pset_ElementCommon") { pset.Name = form.SelectedPropertySet.Name.Replace("Element", docBaseEntity.Name); } pset.RuleParameters = "PsetName=" + pset.Name; if (this.Concept.Items.Count == 0) { this.Concept.Items.Add(pset); } else { bool addItem = true; foreach (DocTemplateItem existingPsetDefinition in this.Concept.Items) { if (existingPsetDefinition.Name == pset.Name) { addItem = false; } } if (addItem) { this.Concept.Items.Add(pset); } } DocTemplateUsage propertyConcept = new DocTemplateUsage(); DocPropertyTemplateTypeEnum propertyType = form.SelectedProperty.PropertyType; propertyConcept.Operator = DocTemplateOperator.And; DocTemplateItem property = new DocTemplateItem(); string psetName = pset.Name; propertyConcept.Name = String.Join(" ", Regex.Split(form.SelectedProperty.Name, @"(?<!^)(?=[A-Z])")); switch (propertyType) { case DocPropertyTemplateTypeEnum.P_SINGLEVALUE: //propertyConcept.Name = "Single Value"; //propertyRule.RuleParameters = parameterNames[0] + "[Value]=" + "'" + form.SelectedProperty.Name + "'" + parameterNames[1] + "[Type]=" + "'" + form.SelectedProperty.PrimaryDataType + "'"; propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertySingle); //parameterNames = property.Definition.GetParameterNames(); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE: //propertyConcept.Name = "Enumerated Value"; propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyEnumerated); //parameterNames = property.Definition.GetParameterNames(); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_LISTVALUE: propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyList); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_BOUNDEDVALUE: propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyBounded); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_REFERENCEVALUE: propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyReference); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_TABLEVALUE: propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyTable); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; } //foreach(DocModelRule rule in property.Definition.Rules) //{ // if (!string.IsNullOrEmpty(rule.Identification)) // { // } //} } else { CvtValuePath valuepath = CvtValuePath.Parse(value, mapEntity); this.ChangeTemplate(valuepath.ToTemplateDefinition()); } } } }
public string FormatDataConcept(DocProject docProject, DocPublication docPublication, DocExchangeDefinition docExchange, Dictionary <string, DocObject> map, Dictionary <string, Type> typemap, Dictionary <long, SEntity> instances, SEntity root, bool markup, DocModelView docView, DocConceptRoot docRoot, DocTemplateUsage docConcept) { StringBuilder sb = new StringBuilder(); string table = docConcept.Items[0].GetParameterValue("Table"); string query = docConcept.Items[0].GetParameterValue("Reference"); sb.AppendLine("<h4>" + docConcept.Name + "</h4>"); sb.AppendLine("<table class=\"gridtable\">"); List <string> colstyles = new List <string>(); List <string> colformat = new List <string>(); List <CvtValuePath> colmaps = new List <CvtValuePath>(); // generate header row sb.AppendLine("<tr>"); foreach (DocTemplateItem docItem in docConcept.Items) { string name = docItem.GetParameterValue("Name"); string disp = "#" + docItem.GetColor().ToArgb().ToString("X8"); //docItem.GetParameterValue("Color");docItem.GetParameterValue("Color"); string expr = docItem.GetParameterValue("Reference"); string form = docItem.GetParameterValue("Format"); string style = ""; if (!String.IsNullOrEmpty(disp)) { style = " style=\"background-color:" + disp + ";\""; } colstyles.Add(style); string format = ""; if (!String.IsNullOrEmpty(form)) { format = form; } colformat.Add(format); string desc = ""; CvtValuePath valpath = CvtValuePath.Parse(expr, map); colmaps.Add(valpath); if (valpath != null) { desc = /*valpath.GetDescription(map) + " " + */ valpath.ToString().Replace("\\", " "); } sb.Append("<th><a href=\"../../schema/views/" + DocumentationISO.MakeLinkName(docView) + "/" + DocumentationISO.MakeLinkName(docExchange) + ".htm#" + DocumentationISO.MakeLinkName(docConcept) + "\" title=\"" + desc + "\">"); sb.Append(name); sb.Append("</a></th>"); } ; sb.AppendLine("</tr>"); // generate data rows List <DocModelRule> trace = new List <DocModelRule>(); foreach (SEntity e in instances.Values) { string eachname = e.GetType().Name; if (docRoot.ApplicableEntity.IsInstanceOfType(e)) { bool includerow = true; // if root has more complex rules, check them if (docRoot.ApplicableTemplate != null && docRoot.ApplicableItems.Count > 0) { includerow = false; // must check1 foreach (DocTemplateItem docItem in docRoot.ApplicableItems) { foreach (DocModelRule rule in docRoot.ApplicableTemplate.Rules) { try { trace.Clear(); bool?result = rule.Validate(e, docItem, typemap, trace, e, null, null); if (result == true && docRoot.ApplicableOperator == DocTemplateOperator.Or) { includerow = true; break; } } catch { docRoot.ToString(); } } // don't yet support AND or other operators if (includerow) { break; } } } if (includerow) { StringBuilder sbRow = new StringBuilder(); sbRow.Append("<tr>"); int iCol = 0; foreach (DocTemplateItem docItem in docConcept.Items) { sbRow.Append("<td" + colstyles[iCol]); CvtValuePath valpath = colmaps[iCol]; string format = colformat[iCol]; iCol++; if (valpath != null) { string nn = docItem.GetParameterValue("Name"); object value = valpath.GetValue(e, null); if (value == e) { value = e.GetType().Name; } else if (value is SEntity) { // use name FieldInfo fieldValue = value.GetType().GetField("Name"); if (fieldValue != null) { value = fieldValue.GetValue(value); } } else if (value is System.Collections.IList) { System.Collections.IList list = (System.Collections.IList)value; StringBuilder sbList = new StringBuilder(); foreach (object elem in list) { FieldInfo fieldName = elem.GetType().GetField("Name"); if (fieldName != null) { object elemname = fieldName.GetValue(elem); if (elemname != null) { FieldInfo fieldValue = elemname.GetType().GetField("Value"); if (fieldValue != null) { object elemval = fieldValue.GetValue(elemname); sbList.Append(elemval.ToString()); } } } sbList.Append("; <br/>"); } value = sbList.ToString(); } else if (value is Type) { value = ((Type)value).Name; } if (!String.IsNullOrEmpty(format)) { if (format.Equals("Required") && value == null) { includerow = false; } } if (value != null) { FieldInfo fieldValue = value.GetType().GetField("Value"); if (fieldValue != null) { value = fieldValue.GetValue(value); } if (format != null && format.Equals("True") && (value == null || !value.ToString().Equals("True"))) { includerow = false; } if (value is Double) { sbRow.Append(" align=\"right\">"); sbRow.Append(((Double)value).ToString("N3")); } else if (value is List <Int64> ) { sbRow.Append(">"); // latitude or longitude List <Int64> intlist = (List <Int64>)value; if (intlist.Count >= 3) { sbRow.Append(intlist[0] + "° " + intlist[1] + "' " + intlist[2] + "\""); } } else if (value != null) { sbRow.Append(">"); sbRow.Append(value.ToString()); // todo: html-encode } } else { sbRow.Append(">"); sbRow.Append(" "); } } else { sbRow.Append(">"); } sbRow.Append("</td>"); } sbRow.AppendLine("</tr>"); if (includerow) { sb.Append(sbRow.ToString()); } } } } sb.AppendLine("</table>"); sb.AppendLine("<br/>"); return(sb.ToString()); }