Ejemplo n.º 1
0
 private void gridView1_CustomRowCellEditForEditing(object sender,
                                                    DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
 {
     if (e.Column.FieldName != "FName")
     {
         object     obj    = e.CellValue;
         TreeRecord record = _treeRecords.FirstOrDefault(p => p.FName == obj.ToString());
         if (record != null && record.IsDomain)
         {
             RepositoryItemComboBox combo = new RepositoryItemComboBox();
             gridControl1.RepositoryItems.AddRange(new RepositoryItem[] { combo });
             if (record.DoaminValue != null)
             {
                 combo.Items.AddRange(((List <CodeValuePair>)record.DoaminValue).Select(p => p.Name).ToList());
             }
             e.RepositoryItem = combo;
             return;
         }
         if (record != null && record.FieldType == esriFieldType.esriFieldTypeDate)
         {
             RepositoryItemDateEdit dateEdit = new RepositoryItemDateEdit();
             gridControl1.RepositoryItems.AddRange(new RepositoryItem[] { dateEdit });
             e.RepositoryItem = dateEdit;
             return;
         }
         RepositoryItemTextEdit textEdit = new RepositoryItemTextEdit();
         gridControl1.RepositoryItems.AddRange(new RepositoryItem[] { textEdit });
         e.RepositoryItem = textEdit;
     }
 }
Ejemplo n.º 2
0
 private void BuildFeatureListDataSouce()
 {
     _treeRecords = new List <TreeRecord>();
     if (_lineFeature1 == null)
     {
         return;
     }
     if (_lineFeature2 == null)
     {
         return;
     }
     for (int i = 0; i < _lineFeature1.Fields.FieldCount; i++)
     {
         IField pField = _lineFeature1.Fields.Field[i];
         if (pField.Type == esriFieldType.esriFieldTypeOID ||
             pField.Type == esriFieldType.esriFieldTypeGeometry ||
             pField.Type == esriFieldType.esriFieldTypeRaster || pField.Editable == false)
         {
             continue;
         }
         TreeRecord pRecord = new TreeRecord();
         if (pField.Domain == null)
         {
             pRecord = new TreeRecord(false, pField.Type, pField.AliasName, _lineFeature1.Value[i], null, i, -1,
                                      _lineFeature2.Value[i], "");
         }
         else
         {
             IDomain pDomain = pField.Domain;
             if (pDomain is CodedValueDomain)
             {
                 ICodedValueDomain pCodeDomain = pDomain as ICodedValueDomain;
                 if (pCodeDomain == null)
                 {
                     continue;
                 }
                 List <CodeValuePair> pairs = new List <CodeValuePair>();
                 for (int j = 0; j < pCodeDomain.CodeCount; j++)
                 {
                     CodeValuePair pair = new CodeValuePair
                     {
                         Name  = pCodeDomain.Name[j],
                         Value = pCodeDomain.Value[j]
                     };
                     pairs.Add(pair);
                 }
                 pRecord = new TreeRecord(true, pField.Type, pField.AliasName, _lineFeature1.Value[i], pairs, i,
                                          -1, _lineFeature2.Value[i], "");
             }
             else
             {
                 IRangeDomain pRangeDomain = pDomain as IRangeDomain;
             }
         }
         _treeRecords.Add(pRecord);
     }
 }
Ejemplo n.º 3
0
        private string GetDetailUrl(TreeRecord tree, string language)
        {
            switch (language.ToLower())
            {
            case "de": return("#/de/archiv/einheit/" + tree.ArchiveRecordId);

            case "fr": return("#/fr/archive/unite/" + tree.ArchiveRecordId);

            case "it": return("#/it/archivio/unita/" + tree.ArchiveRecordId);

            case "en": return("#/en/archive/unit/" + tree.ArchiveRecordId);

            default: return(null);
            }
        }
        public void When_tree_record_is_leaf_return_null()
        {
            // Given
            this.InitializeMocksAndTestClass();
            // when
            var treeRecord = new TreeRecord {
                IsLeaf = true
            };
            var result = entityDecorator.GetChildren(treeRecord, 22, null, null);

            // Verify
            result.Should().NotBe(null);
            result.Items.Count.Should().Be(0);
            result.Paging.Should().NotBe(null);
            result.Paging.Total.Should().Be(null);
            result.Paging.SortOrder.Should().Be("Ascending");
            result.Paging.OrderBy.Should().Be("treeSequence");
        }
        public ModelType GetEntityType(TreeRecord entity)
        {
            var type = GetTypeByName(BaseTypeName);

            if (entity?.Level != null)
            {
                if (GetTypeByName(entity.Level) != null)
                {
                    type = GetTypeByName(entity.Level) ?? type;
                }
                else if (!string.IsNullOrEmpty(entity.ExternalDisplayTemplateName))
                {
                    var formId           = entity.ExternalDisplayTemplateName.Split(':')[0];
                    var templatetypeName = string.Format(TemplateBaseSubNamePattern, formId);
                    type = GetTypeByName(templatetypeName) ?? type;
                }
            }

            return(type);
        }
        public void When_paging_is_not_null_not_change_tree_sort_order()
        {
            // Given
            this.InitializeMocksAndTestClass();
            this.SetupServiceMock();

            // when
            var treeRecord = new TreeRecord {
                IsLeaf = false, TreeSequence = 3
            };
            var userAccess = new UserAccess("id1", string.Empty, string.Empty, new[] { "1", "2" }, true);
            var paging     = new Paging {
                Skip = 22, OrderBy = "me", Total = 0
            };
            var result = entityDecorator.GetChildren(treeRecord, 11, userAccess, paging);

            // Verify
            result.Should().NotBe(null);
            result.Paging.Should().BeEquivalentTo(paging);
        }
        public void When_paging_is_null_change_tree_sort_order()
        {
            // Given
            this.InitializeMocksAndTestClass();
            this.SetupMocksWithResults();

            // when
            var treeRecord = new TreeRecord {
                IsLeaf = false, TreeSequence = 3
            };
            var userAccess = new UserAccess("id1", string.Empty, string.Empty, new[] { "1", "2" }, true);
            var result     = entityDecorator.GetChildren(treeRecord, 11, userAccess, null);

            // Verify
            result.Should().NotBe(null);
            result.Items.Count.Should().Be(1);
            result.Paging.Should().NotBe(null);
            result.Paging.Total.Should().Be(1);
            result.Paging.SortOrder.Should().Be("Ascending");
            result.Paging.OrderBy.Should().Be("treeSequence");
        }
        public List <TreeRecord> GetAncestors(ElasticArchiveRecord record)
        {
            var ancestors = new List <TreeRecord>();
            var items     = record.ArchiveplanContext;

            if (items == null)
            {
                return(ancestors);
            }

            foreach (var contextItem in items)
            {
                var item = new TreeRecord
                {
                    ArchiveRecordId = contextItem.ArchiveRecordId,
                    Title           = contextItem.Title,
                    ReferenceCode   = contextItem.RefCode
                };

                ancestors.Add(item);
            }

            return(ancestors);
        }
        private JObject GetMetadata(TreeRecord entity, UserAccess access)
        {
            if (entity?.Level == null)
            {
                return(null);
            }

            var type = modelData.GetEntityType(entity);

            if (type == null)
            {
                Log.Information($"No type found for entiy level {entity?.Level} and external template {entity.ExternalDisplayTemplateName}");
                return(null);
            }

            var language = access.Language ?? WebHelper.DefaultLanguage;

            JObject metadata     = null;
            var     jsonEntity   = JObject.FromObject(entity);
            var     customFields = JsonHelper.GetTokenValue <JObject>(jsonEntity, customFieldKey, true) ?? new JObject();

            var categories = type.MetaCategories ?? new List <ModelTypeMetaCategory>();

            foreach (var category in categories)
            {
                var attributes = new JObject();

                // Nur wenn die Sektion (category) Felder hat und wir mindestens ein öffentliches Feld haben, oder der Benutzer ein BAR Benutzer ist, gehen wir überhaupt weiter.
                // (Fall abfangen, dass eine Kategorie nur interne Felder hat
                if (category?.Fields != null && (category.Fields.Any(f => f.Visibility == (int)DataElementVisibility.@public) ||
                                                 access.RolePublicClient == AccessRoles.RoleBAR))
                {
                    foreach (var field in category.Fields)
                    {
                        // Interne Felder sind nur für BAR Benutzer sichtbar
                        if (field.Visibility == (int)DataElementVisibility.@internal && access.RolePublicClient != AccessRoles.RoleBAR)
                        {
                            continue;
                        }

                        JToken token = null;
                        var    name  = field.Name.ToLowerCamelCase();
                        if (name.StartsWith(customFieldPrefix, StringComparison.OrdinalIgnoreCase))
                        {
                            var subKey  = field.Key.Substring(customFieldPrefix.Length);
                            var subName = name.Substring(customFieldPrefix.Length);
                            name  = subName.ToLowerCamelCase();
                            token = customFields.GetTokenByKey(subName, true) ?? customFields.GetTokenByKey(subKey, true);
                        }
                        else
                        {
                            token = jsonEntity.GetTokenByKey(name, true) ?? jsonEntity.GetTokenByKey(field.Key, true);
                        }

                        if (token != null)
                        {
                            var value = field.AsFieldValue(token, language);
                            if (value != null)
                            {
                                attributes.Add(name, value);
                            }
                        }
                    }
                }

                if (attributes.Children().Any())
                {
                    metadata = metadata ?? new JObject();

                    if (category.Labels != null && category.Labels.Any())
                    {
                        var title = category.Labels.ContainsKey(language) ? category.Labels[language] : category.Labels.Values.First();
                        JsonHelper.AddOrSet(attributes, "_title", title);
                    }

                    metadata.Add(category.Identifier.ToLowerCamelCase(), attributes);
                }
            }

            return(metadata);
        }
Ejemplo n.º 10
0
 private string GetCreationPeriod(TreeRecord tree)
 {
     return(tree.CreationPeriod?.Text != null ? $"({tree.CreationPeriod.Text})" : string.Empty);
 }
Ejemplo n.º 11
0
 private string GetClass(TreeRecord tree)
 {
     return(tree.ChildCount > 0 ? "class=\"tree-collapse icon icon--before icon--greater\"" : string.Empty);
 }