public ShelfControl() { InitializeComponent(); // combo box needs init ComboClassId.Items.Clear(); foreach (var dc in (DefinitionsVDI2770.Vdi2770DocClass[])Enum.GetValues( typeof(DefinitionsVDI2770.Vdi2770DocClass))) { ComboClassId.Items.Add( "" + DefinitionsVDI2770.GetDocClass(dc) + " - " + DefinitionsVDI2770.GetDocClassName(dc)); } ComboClassId.SelectedIndex = 0; // bind to view model this.DataContext = this.theViewModel; this.theViewModel.ViewModelChanged += TheViewModel_ViewModelChanged; var entities = new List <DocumentEntity>(); entities.Add(new DocumentEntity("Titel", "Orga", "cdskcnsdkjcnkjsckjsdjn", new[] { "de", "GB" })); ScrollMainContent.ItemsSource = entities; // a bit hacky: explicetly load CountryFlag.dll #if __not_working__in_Release__ var x = CountryFlag.CountryCode.DE; if (x != CountryFlag.CountryCode.DE) { return(null); } #else // CountryFlag does not work in XAML (at least not in Release binary) ResetCountryRadioButton(RadioLangEN, CountryFlag.CountryCode.GB); ResetCountryRadioButton(RadioLangDE, CountryFlag.CountryCode.DE); ResetCountryRadioButton(RadioLangCN, CountryFlag.CountryCode.CN); ResetCountryRadioButton(RadioLangJP, CountryFlag.CountryCode.JP); ResetCountryRadioButton(RadioLangKR, CountryFlag.CountryCode.KR); ResetCountryRadioButton(RadioLangFR, CountryFlag.CountryCode.FR); ResetCountryRadioButton(RadioLangES, CountryFlag.CountryCode.ES); #endif // Timer for loading System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += DispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 1000); dispatcherTimer.Start(); }
/// <summary> /// Create form descriptions for the new v1.1 template of VDIO2770 /// </summary> public static FormDescSubmodelElementCollection CreateVdi2770v11TemplateDesc() { // shortcut var defs = AasxPredefinedConcepts.VDI2770v11.Static; // DocumentItem var descDoc = new FormDescSubmodelElementCollection( "Document", FormMultiplicity.ZeroToMany, defs.CD_Document?.GetSingleKey(), "Document{0:00}", "Each document item comprises a set of elements describing the information of a VDI 2770 Document " + "with directly attached DocumentVersion."); // DocumentIdDomain var descDocIdDom = new FormDescSubmodelElementCollection( "DocumentIdDomain", FormMultiplicity.OneToMany, defs.CD_DocumentId?.GetSingleKey(), "DocumentIdDomain{0:00}", "Set of information on the Document within a given domain, e.g. the providing organisation."); descDoc.Add(descDocIdDom); descDocIdDom.Add(new FormDescProperty( "DocumentDomainId", FormMultiplicity.One, defs.CD_DocumentDomainId?.GetSingleKey(), "DocumentDomainId", "Identification of the Domain, e.g. the providing organisation.")); descDocIdDom.Add(new FormDescProperty( "DocumentId", FormMultiplicity.One, defs.CD_DocumentId?.GetSingleKey(), "DocumentId", "Identification of the Document within a given domain, e.g. the providing organisation.")); descDocIdDom.Add(new FormDescProperty( "IsPrimary", FormMultiplicity.ZeroToOne, defs.CD_IsPrimary?.GetSingleKey(), "IsPrimary", "Flag indicating that a DocumentId within a collection of at least two DocumentId`s is the " + "‘primary’ identifier for the document. This is the preferred ID of the document (commonly from " + "the point of view of the owner of the asset).")); // DocumentClassification var descDocClass = new FormDescSubmodelElementCollection( "DocumentClassification", FormMultiplicity.ZeroToMany, defs.CD_DocumentClassification?.GetSingleKey(), "DocumentClassification{0:00}", "Set of information on the Document within a given domain, e.g. the providing organisation."); descDoc.Add(descDocClass); var descDocClassSystem = new FormDescProperty( "ClassificationSystem", FormMultiplicity.One, defs.CD_ClassificationSystem?.GetSingleKey(), "ClassificationSystem", "Identification of the classification system. A classification according to " + "VDI2770:2018 shall be given."); descDocClassSystem.comboBoxChoices = new[] { "VDI2770:2018", "IEC 61355-1:2008", "IEC/IEEE 82079-1:2019" }; descDocClass.Add(descDocClassSystem); var descDocClassId = new FormDescProperty( "ClassId", FormMultiplicity.One, defs.CD_ClassId?.GetSingleKey(), "ClassId", "ClassId of the document in VDI2770 or other."); var cbList = new List <string>(new[] { "(free text)" }); var vlList = new List <string>(new[] { "" }); foreach (var dc in (DefinitionsVDI2770.Vdi2770DocClass[])Enum.GetValues( typeof(DefinitionsVDI2770.Vdi2770DocClass))) { if ((int)dc == 0) { continue; } cbList.Add("VDI2770 - " + DefinitionsVDI2770.GetDocClass(dc) + " - " + DefinitionsVDI2770.GetDocClassName(dc)); vlList.Add("" + DefinitionsVDI2770.GetDocClass(dc)); } descDocClassId.comboBoxChoices = cbList.ToArray(); descDocClassId.valueFromComboBoxIndex = vlList.ToArray(); descDocClass.Add(descDocClassId); var descDocName = new FormDescProperty( "ClassName", FormMultiplicity.One, defs.CD_ClassName?.GetSingleKey(), "ClassName", "ClassName of the document in VDI2770 or other. " + "This property is automatically computed based on ClassId."); descDocName.SlaveOfIdShort = "ClassId"; descDocName.valueFromMasterValue = new Dictionary <string, string>(); descDocName.valueFromMasterValue.Add("", ""); foreach (var dc in (DefinitionsVDI2770.Vdi2770DocClass[])Enum.GetValues( typeof(DefinitionsVDI2770.Vdi2770DocClass))) { descDocName.valueFromMasterValue.Add( DefinitionsVDI2770.GetDocClass(dc), DefinitionsVDI2770.GetDocClassName(dc)); } descDocClass.Add(descDocName); // DocumentVersion var descDocVer = new FormDescSubmodelElementCollection( "DocumentVersion", FormMultiplicity.OneToMany, defs.CD_DocumentVersion?.GetSingleKey(), "DocumentVersion", "VDI2770 allows for multiple DocumentVersions for a document to be delivered."); descDoc.Add(descDocVer); descDocVer.Add(new FormDescProperty( "Languages", FormMultiplicity.OneToMany, defs.CD_Language?.GetSingleKey(), "Language{0:00}", "List of languages used in the DocumentVersion. For most cases, " + "at least one language shall be given.")); descDocVer.Add(new FormDescProperty( "DocumentVersionId", FormMultiplicity.One, defs.CD_DocumentVersionId?.GetSingleKey(), "DocumentVersionId", "Unambigous identification number of a DocumentVersion.")); descDocVer.Add(new FormDescMultiLangProp( "Title", FormMultiplicity.One, defs.CD_Title?.GetSingleKey(), "Title", "Language dependent title of the document.")); descDocVer.Add(new FormDescMultiLangProp( "SubTitle", FormMultiplicity.ZeroToOne, defs.CD_SubTitle?.GetSingleKey(), "SubTitle", "Language dependent sub title of the document.")); descDocVer.Add(new FormDescMultiLangProp( "Summary", FormMultiplicity.One, defs.CD_Summary?.GetSingleKey(), "Summary", "Language dependent summary of the document.")); descDocVer.Add(new FormDescMultiLangProp( "Keywords", FormMultiplicity.One, defs.CD_KeyWords?.GetSingleKey(), "Keywords", "Language dependent keywords of the document.")); descDocVer.Add(new FormDescProperty( "SetDate", FormMultiplicity.One, defs.CD_SetDate?.GetSingleKey(), "SetDate", "Date when the document status was set. Format is YYYY-MM-dd.")); var descStatus = new FormDescProperty( "StatusValue", FormMultiplicity.One, defs.CD_StatusValue?.GetSingleKey(), "StatusValue", "Each document version represents a point in time in the document life cycle. " + "This status value refers to the milestones in the document life cycle. " + "The following two statuses should be used for the application of this guideline: " + "InReview (under review), Released (released)."); descDocVer.Add(descStatus); descStatus.comboBoxChoices = new[] { "InReview", "Released" }; descDocVer.Add(new FormDescProperty( "OrganizationName", FormMultiplicity.One, defs.CD_OrganizationName?.GetSingleKey(), "OrganizationName", "Organiziation name of the author of the Document.")); descDocVer.Add(new FormDescProperty( "OrganizationOfficialName", FormMultiplicity.One, defs.CD_OrganizationOfficialName?.GetSingleKey(), "OrganizationOfficialName", "Official name of the organization of author of the Document " + "(which might be longer or include legal information).")); descDocVer.Add(new FormDescFile( "DigitalFile", FormMultiplicity.OneToMany, defs.CD_DigitalFile?.GetSingleKey(), "DigitalFile{0:00}", "Digital file, which represents the Document and DocumentVersion. " + "A PDF/A format is required for textual representations.")); descDocVer.Add(new FormDescFile( "PreviewFile", FormMultiplicity.ZeroToOne, defs.CD_PreviewFile?.GetSingleKey(), "PreviewFile{0:00}", "Provides a preview image of the Document, e.g. first page, in a commonly used " + "image format and low resolution.")); descDocVer.Add(new FormDescReferenceElement( "RefersTo", FormMultiplicity.ZeroToMany, defs.CD_RefersTo?.GetSingleKey(), "RefersTo{0:00}", "Forms a generic RefersTo-relationship to another Document or DocumentVersion. " + "They have a loose relationship.")); descDocVer.Add(new FormDescReferenceElement( "BasedOn", FormMultiplicity.ZeroToMany, defs.CD_BasedOn?.GetSingleKey(), "BasedOn{0:00}", "Forms a BasedOn-relationship to another Document or DocumentVersion. Typically states, that the " + "content of the document bases on another document (e.g. specification requirements). Both have a " + "strong relationship.")); descDocVer.Add(new FormDescReferenceElement( "TranslationOf", FormMultiplicity.ZeroToMany, defs.CD_TranslationOf?.GetSingleKey(), "TranslationOf{0:00}", "Forms a TranslationOf-relationship to another Document or DocumentVersion. Both have a " + "strong relationship.")); // back to Document descDoc.Add(new FormDescReferenceElement( "DocumentedEntity", FormMultiplicity.ZeroToOne, defs.CD_DocumentedEntity?.GetSingleKey(), "DocumentedEntity", "Identifies the Entity, which is subject to the Documentation.")); // end return(descDoc); }
/// <summary> /// Create a default template description for VDI2770 based on the SemanticIds from the <c>options</c> /// </summary> /// <param name="opt"></param> /// <returns></returns> public static FormDescSubmodelElementCollection CreateVdi2770TemplateDesc(DocumentShelfOptions opt) { if (opt == null) { return(null); } var semConfig = DocuShelfSemanticConfig.CreateDefault(); // DocumentItem var descDoc = new FormDescSubmodelElementCollection( "Document", FormMultiplicity.ZeroToMany, semConfig.SemIdDocument, "Document{0:00}", "Each document item comprises a set of elements describing the information of a VDI 2770 Document " + "with directly attached DocumentVersion."); // Document descDoc.Add(new FormDescProperty( "DocumentId", FormMultiplicity.One, semConfig.SemIdDocumentId, "DocumentId", "The combination of DocumentId and DocumentVersionId shall be unqiue.")); descDoc.Add(new FormDescProperty( "IsPrimary", FormMultiplicity.One, semConfig.SemIdIsPrimaryDocumentId, "IsPrimary", "True, if primary document id for the document.")); var descDocClass = new FormDescProperty( "ClassId", FormMultiplicity.One, semConfig.SemIdDocumentClassId, "ClassId", "VDI2770 ClassId of the document."); var cbList = new List <string>(); var vlList = new List <string>(); foreach (var dc in (DefinitionsVDI2770.Vdi2770DocClass[])Enum.GetValues( typeof(DefinitionsVDI2770.Vdi2770DocClass))) { if ((int)dc == 0) { continue; } cbList.Add("" + DefinitionsVDI2770.GetDocClass(dc) + " - " + DefinitionsVDI2770.GetDocClassName(dc)); vlList.Add("" + DefinitionsVDI2770.GetDocClass(dc)); } descDocClass.comboBoxChoices = cbList.ToArray(); descDocClass.valueFromComboBoxIndex = vlList.ToArray(); descDoc.Add(descDocClass); var descDocName = new FormDescProperty( "ClassName", FormMultiplicity.One, semConfig.SemIdDocumentClassName, "ClassName", "VDI2770 ClassName of the document. This property is automaticall computed based on ClassId.", isReadOnly: true); descDocName.SlaveOfIdShort = "ClassId"; descDocName.valueFromMasterValue = new Dictionary <string, string>(); foreach (var dc in (DefinitionsVDI2770.Vdi2770DocClass[])Enum.GetValues( typeof(DefinitionsVDI2770.Vdi2770DocClass))) { descDocName.valueFromMasterValue.Add( DefinitionsVDI2770.GetDocClass(dc), DefinitionsVDI2770.GetDocClassName(dc)); } descDoc.Add(descDocName); descDoc.Add( new FormDescProperty( "ClassificationSystem", FormMultiplicity.One, semConfig.SemIdDocumentClassificationSystem, "ClassificationSystem", "This property is always set to VDI2770:2018", isReadOnly: true, presetValue: "VDI2770:2018")); descDoc.Add(new FormDescProperty( "ReferencedObject", FormMultiplicity.One, semConfig.SemIdReferencedObject, "ReferencedObject", "Reference to Asset or Entity, on which the Document is related to.")); // DocumentVersion var descDocVer = new FormDescSubmodelElementCollection( "DocumentVersion", FormMultiplicity.OneToMany, semConfig.SemIdDocumentVersion, "DocumentVersion", "VDI2770 allows for multiple DocumentVersions for a document to be delivered."); descDoc.Add(descDocVer); descDocVer.Add(new FormDescProperty( "DocumentVersionId", FormMultiplicity.One, semConfig.SemIdDocumentVersionIdValue, "DocumentVersionId", "The combination of DocumentId and DocumentVersionId shall be unqiue.")); descDocVer.Add(new FormDescProperty( "Languages", FormMultiplicity.ZeroToMany, semConfig.SemIdLanguage, "Language{0}", "List of languages used in the DocumentVersion. For most cases, " + "at least one language shall be given.")); descDocVer.Add(new FormDescMultiLangProp( "Title", FormMultiplicity.One, semConfig.SemIdTitle, "Title", "Language dependent title of the document.")); descDocVer.Add(new FormDescMultiLangProp( "Summary", FormMultiplicity.One, semConfig.SemIdSummary, "Summary", "Language dependent summary of the document.")); descDocVer.Add(new FormDescMultiLangProp( "Keywords", FormMultiplicity.One, semConfig.SemIdKeywords, "Keywords", "Language dependent keywords of the document.")); descDocVer.Add(new FormDescFile( "DigitalFile", FormMultiplicity.OneToMany, semConfig.SemIdDigitalFile, "DigitalFile{0:00}", "Digital file, which represents the Document and DocumentVersion. " + "A PDF/A format is required for textual representations.")); descDocVer.Add(new FormDescProperty( "SetDate", FormMultiplicity.One, semConfig.SemIdDate, "SetDate", "Date when the document was introduced into the AAS or set to the status. Format is YYYY-MM-dd.")); var descStatus = new FormDescProperty( "StatusValue", FormMultiplicity.One, semConfig.SemIdStatusValue, "StatusValue", "Each document version represents a point in time in the document life cycle. " + "This status value refers to the milestones in the document life cycle. " + "The following two statuses should be used for the application of this guideline: " + "InReview (under review), Released (released)."); descDocVer.Add(descStatus); descStatus.comboBoxChoices = new[] { "InReview", "Released" }; var descRole = new FormDescProperty( "Role", FormMultiplicity.One, semConfig.SemIdRole, "Role", "Define a role for the organisation according to the following selection list."); descDocVer.Add(descRole); descRole.comboBoxChoices = new[] { "Author", "Customer", "Supplier", "Manufacturer", "Responsible" }; descDocVer.Add(new FormDescProperty( "OrganizationName", FormMultiplicity.One, semConfig.SemIdOrganizationName, "OrganizationName", "Common name for the organisation.")); descDocVer.Add(new FormDescProperty( "OrganizationOfficialName", FormMultiplicity.One, semConfig.SemIdOrganizationOfficialName, "OrganizationOfficialName", "Official name for the organisation (which might be longer or include legal information).")); return(descDoc); }
public static ListOfDocumentEntity ParseSubmodelForV11( AdminShellPackageEnv thePackage, AdminShell.Submodel subModel, AasxPredefinedConcepts.VDI2770v11 defs11, string defaultLang, int selectedDocClass, AasxLanguageHelper.LangEnum selectedLanguage) { // set a new list var its = new ListOfDocumentEntity(); if (thePackage == null || subModel == null || defs11 == null) { return(its); } // look for Documents if (subModel.submodelElements != null) { foreach (var smcDoc in subModel.submodelElements.FindAllSemanticIdAs <AdminShell.SubmodelElementCollection>( defs11.CD_Document?.GetReference(), AdminShellV20.Key.MatchMode.Relaxed)) { // access if (smcDoc == null || smcDoc.value == null) { continue; } // look immediately for DocumentVersion, as only with this there is a valid List item foreach (var smcVer in smcDoc.value.FindAllSemanticIdAs <AdminShell.SubmodelElementCollection>( defs11.CD_DocumentVersion?.GetReference(), AdminShellV20.Key.MatchMode.Relaxed)) { // access if (smcVer == null || smcVer.value == null) { continue; } // // try to lookup info in smcDoc and smcVer // // take the 1st title var title = "" + smcVer.value.FindFirstSemanticIdAs <AdminShell.Property>( defs11.CD_Title?.GetReference(), AdminShellV20.Key.MatchMode.Relaxed)?.value; // could be also a multi-language title foreach (var mlp in smcVer.value.FindAllSemanticIdAs <AdminShell.MultiLanguageProperty>( defs11.CD_Title?.GetReference(), AdminShellV20.Key.MatchMode.Relaxed)) { if (mlp.value != null) { title = mlp.value.GetDefaultStr(defaultLang); } } // have multiple opportunities for orga var orga = "" + smcVer.value.FindFirstSemanticIdAs <AdminShell.Property>( defs11.CD_OrganizationOfficialName?.GetReference(), AdminShellV20.Key.MatchMode.Relaxed)?.value; if (orga.Trim().Length < 1) { orga = "" + smcVer.value.FindFirstSemanticIdAs <AdminShell.Property>( defs11.CD_OrganizationName?.GetReference(), AdminShellV20.Key.MatchMode.Relaxed)?.value; } // try find language // collect country codes var countryCodesStr = new List <string>(); var countryCodesEnum = new List <AasxLanguageHelper.LangEnum>(); foreach (var cclp in smcVer.value.FindAllSemanticIdAs <AdminShell.Property>(defs11.CD_Language?.GetReference(), AdminShellV20.Key.MatchMode.Relaxed)) { // language code var candidate = "" + cclp.value; if (candidate.Length < 1) { continue; } // convert to country codes and add var le = AasxLanguageHelper.FindLangEnumFromLangCode(candidate); if (le != AasxLanguageHelper.LangEnum.Any) { countryCodesEnum.Add(le); countryCodesStr.Add(AasxLanguageHelper.GetCountryCodeFromEnum(le)); } } var okLanguage = (selectedLanguage == AasxLanguageHelper.LangEnum.Any || countryCodesEnum == null || // make only exception, if no language not all (not only the preferred // of LanguageSelectionToISO639String) are in the property countryCodesStr.Count < 1 || countryCodesEnum.Contains(selectedLanguage)); // try find a 2770 classification var okDocClass = false; foreach (var smcClass in smcDoc.value.FindAllSemanticIdAs <AdminShell.SubmodelElementCollection>( defs11.CD_DocumentClassification?.GetReference(), AdminShellV20.Key.MatchMode.Relaxed)) { // access if (smcClass?.value == null) { continue; } // shall be a 2770 classification var classSys = "" + smcVer.value.FindFirstSemanticIdAs <AdminShell.Property>( defs11.CD_ClassificationSystem?.GetReference(), AdminShellV20.Key.MatchMode.Relaxed)?.value; if (classSys.ToLower().Trim() != DefinitionsVDI2770.Vdi2770Sys.ToLower()) { continue; } // class infos var classId = "" + smcDoc.value.FindFirstSemanticIdAs <AdminShell.Property>( defs11.CD_ClassId?.GetReference(), AdminShellV20.Key.MatchMode.Relaxed)?.value; // evaluate, if in selection okDocClass = okDocClass || (classId.Trim().Length < 1 || classId.Trim() .StartsWith( DefinitionsVDI2770.GetDocClass( (DefinitionsVDI2770.Vdi2770DocClass)selectedDocClass))); } // success for selections? if (!(selectedDocClass < 1 || okDocClass) || !okLanguage) { continue; } // further info var further = ""; foreach (var fi in smcVer.value.FindAllSemanticIdAs <AdminShell.Property>( defs11.CD_DocumentVersionId?.GetReference())) { further += "\u00b7 version: " + fi.value; } foreach (var fi in smcVer.value.FindAllSemanticIdAs <AdminShell.Property>( defs11.CD_DocumentIdValue?.GetReference())) { further += "\u00b7 id: " + fi.value; } foreach (var fi in smcVer.value.FindAllSemanticIdAs <AdminShell.Property>(defs11.CD_SetDate?.GetReference(), AdminShellV20.Key.MatchMode.Relaxed)) { further += "\u00b7 date: " + fi.value; } if (further.Length > 0) { further = further.Substring(2); } // construct entity var ent = new DocumentEntity(title, orga, further, countryCodesStr.ToArray()); ent.ReferableHash = String.Format( "{0:X14} {1:X14}", thePackage.GetHashCode(), smcDoc.GetHashCode()); // for updating data, set the source elements of this document entity ent.SourceElementsDocument = smcDoc.value; ent.SourceElementsDocumentVersion = smcVer.value; // file informations var fl = smcVer.value.FindFirstSemanticIdAs <AdminShell.File>( defs11.CD_DigitalFile?.GetReference(), AdminShellV20.Key.MatchMode.Relaxed); if (fl != null) { ent.DigitalFile = new DocumentEntity.FileInfo(fl); } fl = smcVer.value.FindFirstSemanticIdAs <AdminShell.File>( defs11.CD_PreviewFile?.GetReference(), AdminShellV20.Key.MatchMode.Relaxed); if (fl != null) { ent.PreviewFile = new DocumentEntity.FileInfo(fl); } // relations SearchForRelations(smcVer.value, DocumentEntity.DocRelationType.DocumentedEntity, defs11.CD_DocumentedEntity?.GetReference(), ent); SearchForRelations(smcVer.value, DocumentEntity.DocRelationType.RefersTo, defs11.CD_RefersTo?.GetReference(), ent); SearchForRelations(smcVer.value, DocumentEntity.DocRelationType.BasedOn, defs11.CD_BasedOn?.GetReference(), ent); SearchForRelations(smcVer.value, DocumentEntity.DocRelationType.TranslationOf, defs11.CD_TranslationOf?.GetReference(), ent); // add ent.SmVersion = DocumentEntity.SubmodelVersion.V11; its.Add(ent); } } } // ok return(its); }
// // Default // public static ListOfDocumentEntity ParseSubmodelForV10( AdminShellPackageEnv thePackage, AdminShell.Submodel subModel, AasxPluginDocumentShelf.DocumentShelfOptions options, string defaultLang, int selectedDocClass, AasxLanguageHelper.LangEnum selectedLanguage) { // set a new list var its = new ListOfDocumentEntity(); // look for Documents if (subModel?.submodelElements != null) { foreach (var smcDoc in subModel.submodelElements.FindAllSemanticIdAs <AdminShell.SubmodelElementCollection>( _semConfig.SemIdDocument, AdminShellV20.Key.MatchMode.Relaxed)) { // access if (smcDoc == null || smcDoc.value == null) { continue; } // look immediately for DocumentVersion, as only with this there is a valid List item foreach (var smcVer in smcDoc.value.FindAllSemanticIdAs <AdminShell.SubmodelElementCollection>( _semConfig.SemIdDocumentVersion, AdminShellV20.Key.MatchMode.Relaxed)) { // access if (smcVer == null || smcVer.value == null) { continue; } // // try to lookup info in smcDoc and smcVer // // take the 1st title var title = "" + smcVer.value.FindFirstSemanticIdAs <AdminShell.Property>(_semConfig.SemIdTitle, AdminShellV20.Key.MatchMode.Relaxed)?.value; // could be also a multi-language title foreach (var mlp in smcVer.value.FindAllSemanticIdAs <AdminShell.MultiLanguageProperty>( _semConfig.SemIdTitle, AdminShellV20.Key.MatchMode.Relaxed)) { if (mlp.value != null) { title = mlp.value.GetDefaultStr(defaultLang); } } // have multiple opportunities for orga var orga = "" + smcVer.value.FindFirstSemanticIdAs <AdminShell.Property>( _semConfig.SemIdOrganizationOfficialName, AdminShellV20.Key.MatchMode.Relaxed)?.value; if (orga.Trim().Length < 1) { orga = "" + smcVer.value.FindFirstSemanticIdAs <AdminShell.Property>( _semConfig.SemIdOrganizationName, AdminShellV20.Key.MatchMode.Relaxed)?.value; } // class infos var classId = "" + smcDoc.value.FindFirstSemanticIdAs <AdminShell.Property>( _semConfig.SemIdDocumentClassId, AdminShellV20.Key.MatchMode.Relaxed)?.value; // collect country codes var countryCodesStr = new List <string>(); var countryCodesEnum = new List <AasxLanguageHelper.LangEnum>(); foreach (var cclp in smcVer.value.FindAllSemanticIdAs <AdminShell.Property>(_semConfig.SemIdLanguage, AdminShellV20.Key.MatchMode.Relaxed)) { // language code var candidate = "" + cclp.value; if (candidate.Length < 1) { continue; } // convert to country codes and add var le = AasxLanguageHelper.FindLangEnumFromLangCode(candidate); if (le != AasxLanguageHelper.LangEnum.Any) { countryCodesEnum.Add(le); countryCodesStr.Add(AasxLanguageHelper.GetCountryCodeFromEnum(le)); } } // evaluate, if in selection var okDocClass = selectedDocClass < 1 || classId.Trim().Length < 1 || classId.Trim() .StartsWith( DefinitionsVDI2770.GetDocClass( (DefinitionsVDI2770.Vdi2770DocClass)selectedDocClass)); var okLanguage = selectedLanguage == AasxLanguageHelper.LangEnum.Any || // make only exception, if no language not all (not only the preferred // of LanguageSelectionToISO639String) are in the property countryCodesStr.Count < 1 || countryCodesEnum.Contains(selectedLanguage); if (!okDocClass || !okLanguage) { continue; } // further info var further = ""; foreach (var fi in smcVer.value.FindAllSemanticIdAs <AdminShell.Property>( _semConfig.SemIdDocumentVersionIdValue)) { further += "\u00b7 version: " + fi.value; } foreach (var fi in smcVer.value.FindAllSemanticIdAs <AdminShell.Property>(_semConfig.SemIdDate, AdminShellV20.Key.MatchMode.Relaxed)) { further += "\u00b7 date: " + fi.value; } if (further.Length > 0) { further = further.Substring(2); } // construct entity var ent = new DocumentEntity(title, orga, further, countryCodesStr.ToArray()); ent.ReferableHash = String.Format( "{0:X14} {1:X14}", thePackage.GetHashCode(), smcDoc.GetHashCode()); // for updating data, set the source elements of this document entity ent.SourceElementsDocument = smcDoc.value; ent.SourceElementsDocumentVersion = smcVer.value; // filename var fl = smcVer.value.FindFirstSemanticIdAs <AdminShell.File>( _semConfig.SemIdDigitalFile, AdminShellV20.Key.MatchMode.Relaxed); ent.DigitalFile = new DocumentEntity.FileInfo(fl); // add ent.SmVersion = DocumentEntity.SubmodelVersion.Default; its.Add(ent); } } } // ok return(its); }
private void ParseSubmodelToListItems( AdminShell.Submodel subModel, AasxPluginDocumentShelf.DocumentShelfOptions options, int selectedDocClass, ViewModel.LanguageSelection selectedLanguage, ViewModel.ListType selectedListType) { try { // influence list view rendering, as well if (selectedListType == ViewModel.ListType.Bars) { ScrollMainContent.ItemTemplate = (DataTemplate)ScrollMainContent.Resources["ItemTemplateForBar"]; ScrollMainContent.ItemsPanel = (ItemsPanelTemplate)ScrollMainContent.Resources["ItemsPanelForBar"]; } if (selectedListType == ViewModel.ListType.Grid) { ScrollMainContent.ItemTemplate = (DataTemplate)ScrollMainContent.Resources["ItemTemplateForGrid"]; ScrollMainContent.ItemsPanel = (ItemsPanelTemplate)ScrollMainContent.Resources["ItemsPanelForGrid"]; } // clean table ScrollMainContent.ItemsSource = null; // access if (subModel == null || options == null) { return; } // make sure for the right Submodel var found = false; if (options.AllowSubmodelSemanticIds != null) { foreach (var x in options.AllowSubmodelSemanticIds) { if (subModel.semanticId != null && subModel.semanticId.Matches(x)) { found = true; break; } } } if (!found) { return; } // what defaultLanguage string defaultLang = null; if (theViewModel != null && theViewModel.TheSelectedLanguage > ViewModel.LanguageSelection.All) { defaultLang = ViewModel.LanguageSelectionToISO639String[(int)theViewModel.TheSelectedLanguage]; } // set a new list var its = new List <DocumentEntity>(); // look for Documents if (subModel?.submodelElements != null) { foreach (var smcDoc in subModel.submodelElements.FindAllSemanticIdAs <AdminShell.SubmodelElementCollection>( options?.SemIdDocument)) { // access if (smcDoc == null || smcDoc.value == null) { continue; } // look immediately for DocumentVersion, as only with this there is a valid List item foreach (var smcVer in smcDoc.value.FindAllSemanticIdAs <AdminShell.SubmodelElementCollection>( options?.SemIdDocumentVersion)) { // access if (smcVer == null || smcVer.value == null) { continue; } // // try to lookup info in smcDoc and smcVer // // take the 1st title var title = "" + smcVer.value.FindFirstSemanticIdAs <AdminShell.Property>(options?.SemIdTitle)?.value; // could be also a multi-language title foreach (var mlp in smcVer.value.FindAllSemanticIdAs <AdminShell.MultiLanguageProperty>( options?.SemIdTitle)) { if (mlp.value != null) { title = mlp.value.GetDefaultStr(defaultLang); } } // have multiple opportunities for orga var orga = "" + smcVer.value.FindFirstSemanticIdAs <AdminShell.Property>( options?.SemIdOrganizationOfficialName)?.value; if (orga.Trim().Length < 1) { orga = "" + smcVer.value.FindFirstSemanticIdAs <AdminShell.Property>( options?.SemIdOrganizationName)?.value; } // class infos var classId = "" + smcDoc.value.FindFirstSemanticIdAs <AdminShell.Property>( options?.SemIdDocumentClassId)?.value; // collect country codes var countryCodesStr = new List <string>(); var countryCodesEnum = new List <ViewModel.LanguageSelection>(); foreach (var cclp in smcVer.value.FindAllSemanticIdAs <AdminShell.Property>(options?.SemIdLanguage)) { // language code var candidate = ("" + cclp.value).Trim().ToUpper(); if (candidate.Length < 1) { continue; } // convert to country codes foreach (var ev in (ViewModel.LanguageSelection[])Enum.GetValues(typeof(ViewModel.LanguageSelection))) { if (candidate == ViewModel.LanguageSelectionToISO639String[(int)ev]?.ToUpper()) { candidate = ViewModel.LanguageSelectionToISO3166String[(int)ev]?.ToUpper(); countryCodesEnum.Add(ev); } } // add countryCodesStr.Add(candidate); } // evaluate, if in selection var okDocClass = (selectedDocClass < 1 || classId == null || classId.Trim().Length < 1 || classId.Trim() .StartsWith( DefinitionsVDI2770.GetDocClass( (DefinitionsVDI2770.Vdi2770DocClass)selectedDocClass))); var okLanguage = (selectedLanguage == ViewModel.LanguageSelection.All || countryCodesEnum == null || // make only exception, if no language not all (not only the preferred // of LanguageSelectionToISO639String) are in the property countryCodesStr.Count < 1 || countryCodesEnum.Contains(selectedLanguage)); if (!okDocClass || !okLanguage) { continue; } // further info var further = ""; foreach (var fi in smcVer.value.FindAllSemanticIdAs <AdminShell.Property>( options?.SemIdDocumentVersionIdValue)) { further += "\u00b7 version: " + fi.value; } foreach (var fi in smcVer.value.FindAllSemanticIdAs <AdminShell.Property>(options?.SemIdDate)) { further += "\u00b7 date: " + fi.value; } if (further.Length > 0) { further = further.Substring(2); } // construct entity var ent = new DocumentEntity(title, orga, further, countryCodesStr.ToArray()); ent.ReferableHash = String.Format( "{0:X14} {1:X14}", thePackage.GetHashCode(), smcDoc.GetHashCode()); // for updating data, set the source elements of this document entity ent.SourceElementsDocument = smcDoc.value; ent.SourceElementsDocumentVersion = smcVer.value; // filename var fn = smcVer.value.FindFirstSemanticIdAs <AdminShell.File>( options?.SemIdDigitalFile)?.value; ent.DigitalFile = fn; // make viewbox to host __later__ created image! var vb = new Viewbox(); vb.Stretch = Stretch.Uniform; ent.ImgContainer = vb; // can already put a generated image into the viewbox? if (referableHashToCachedBitmap != null && referableHashToCachedBitmap.ContainsKey(ent.ReferableHash)) { var img = new Image(); img.Source = referableHashToCachedBitmap[ent.ReferableHash]; ent.ImgContainer.Child = img; } else { // trigger generation of image // check if already in list DocumentEntity foundDe = null; foreach (var de in theDocEntitiesToPreview) { if (ent.ReferableHash == de.ReferableHash) { foundDe = de; } } lock (theDocEntitiesToPreview) { if (foundDe != null) { theDocEntitiesToPreview.Remove(foundDe); } theDocEntitiesToPreview.Add(ent); } } // attach events and add ent.DoubleClick += DocumentEntity_DoubleClick; ent.MenuClick += DocumentEntity_MenuClick; its.Add(ent); } } } // make new list box items ScrollMainContent.ItemsSource = its; } catch (Exception ex) { Log.Error(ex, "Exception when parse/ display Submodel"); } }