private async Task CreateElasticsearchTemplateAsync()
        {
            string uri         = $"_template/{ConfigurationManager.ElasticSearchIndex}_rts";
            var    getResponse = await m_client.GetAsync(uri);

            if (getResponse.StatusCode != HttpStatusCode.NotFound)
            {
                return;
            }

            var context           = new SphDataContext();
            var entityDefinitions = context.LoadFromSources <EntityDefinition>();
            var mappings          = from ed in entityDefinitions
                                    where !ExcludeTypes.Contains(ed.Name)
                                    let map                       = ed.GetElasticsearchMapping().Trim()
                                                         let trim = map.Trim()
                                                                    select trim.Substring(1, trim.Length - 2).Trim();

            var template = $@"
{{
  ""template"": ""{ConfigurationManager.ElasticSearchIndex}_rts_*"",
  ""aliases"": {{
    ""{ConfigurationManager.ElasticSearchIndex}_rts"": {{}}
  }},
  ""mappings"": {{
        {mappings.ToString(",\r\n")}
  }}
}}";
            var response = await m_client.PutAsync(uri, new StringContent(template));

            response.EnsureSuccessStatusCode();
        }
        /// <summary>
        /// Determines whether the specified <see cref="Type"/> matches requirements set in the attribute.
        /// </summary>
        /// <param name="type">Type to test.</param>
        /// <returns>
        /// A <see cref="bool"/> value indicating if the type specified by <paramref name="type"/>
        /// matches the requirements and should thus be selectable.
        /// </returns>
        public virtual bool MatchesRequirements(Type type)
        {
            if (ExcludeTypes == null)
            {
                return(true);
            }

            return(!ExcludeTypes.Contains(type));
        }
        public AddEditExcludeItem(ExcludeTypes excType)
        {
            this.HideIcon();

            InitializeComponent();

            WindowTitle = "Add To Exclude List";
            AddEditText = "Add Entry";

            RootKey      = RootKeys[0];
            SelectedType = excType;

            OnPropertyChanged(nameof(Description));
            OnPropertyChanged(nameof(RegistryVisible));
            OnPropertyChanged(nameof(FileVisible));
            OnPropertyChanged(nameof(FolderVisible));
        }
Пример #4
0
        internal static IList <Property> GetTypeProperties(this Type model, ExcludeTypes exclude, Property parentData = null)
        {
            var allProperties = ContextCommon.Cache.Get <IList <Property> >(model.FullName);

            if (allProperties == null)
            {
                model.CacheType();

                allProperties = ContextCommon.Cache.Get <IList <Property> >(model.FullName);
            }

            var filteredProperties = allProperties.Where(p => p.AttributeData == null || p.AttributeData.ExcludeFrom != exclude).ToList();

            filteredProperties.ForEach(p =>
            {
                p.ResultSetIndex = parentData?.ResultSetIndex ?? p.OriginalResultSetIndex;
            });

            return(filteredProperties);
        }
Пример #5
0
        internal static IList <Property> GetTypeProperties(this Type model, ExcludeTypes exclusion, Property parentData = null)
        {
            var primaryKeyProp = GetPrimaryKeyProperty(model);

            var properties =
                model.GetTypeInfo()
                .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy)
                .Where(p =>
            {
                var attrib = p.GetCustomAttribute <MappingAttribute>();
                return(attrib == null ||
                       (attrib.ExcludeFrom != exclusion && attrib.ExcludeFrom != ExcludeTypes.All));
            })
                .OrderBy(p => p.MetadataToken);

            var modelTypeInfo = model.GetTypeInfo();

            var propertyList = properties.Select(p => new Property
            {
                PropertyInfo               = p,
                PropertyName               = p.Name,
                ResultSetIndex             = p.GetPropertyValueOrDefault("ResultSetIndex", -1),
                ColumnName                 = p.GetPropertyValueOrDefault("ColumnName", p.Name),
                UnderlyingType             = p.GetActualType(),
                ParameterName              = $"@{p.GetPropertyValueOrDefault("ParameterName", p.Name).Replace("@", string.Empty)}",
                IsValueFromOutputParameter = p.GetPropertyValueOrDefault("IsOutput", false),
                PrimaryKeyProperty         = primaryKeyProp,
                GroupingProperty           = p.GetGroupingProperty(modelTypeInfo)
            }).ToList();

            propertyList.ForEach(p =>
            {
                p.UnderlyingTypeInfo = p.UnderlyingType.GetTypeInfo();
                p.Mapper             = p.UnderlyingTypeInfo.GetPropertyMapper();
                p.ResultSetIndex     = p.ResultSetIndex == -1 ? parentData?.ResultSetIndex ?? 0 : p.ResultSetIndex;
            });

            return(propertyList);
        }
    static public IQueryable <StaffBroker.User> GetStaffExcl(int PortalId = 0, params string[] ExcludeTypes)
    {
        StaffBrokerDataContext d = new StaffBrokerDataContext();
        var q = from c in d.Users where c.AP_StaffBroker_Staffs.Active && c.AP_StaffBroker_Staffs.PortalId == PortalId && !(ExcludeTypes.Contains(c.AP_StaffBroker_Staffs.AP_StaffBroker_StaffType.Name)) select c;

        q = q.Union(from c in d.Users join b in d.AP_StaffBroker_Staffs on c.UserID equals b.UserId2 where b.Active && b.PortalId == PortalId && !(ExcludeTypes.Contains(b.AP_StaffBroker_StaffType.Name)) select c);
        return(q.OrderBy(c => c.LastName).ThenBy(c => c.FirstName));
    }
Пример #7
0
        private void InitDiff(IEnumerable <TypeDefinition> toTypes, TypeDefinition parent = null)
        {
            foreach (var toType in toTypes)
            {
                if (ExcludeTypes.Contains(toType.FullName) ||
                    parent == null && ExcludeNamespaces.Contains(toType.Namespace))
                {
                    continue;
                }

                var fromType = from.GetType(toType.FullName);

                if (fromType == null)
                {
                    fieldsToInclude[toType.FullName]  = toType.Fields.ToList();
                    methodsToInclude[toType.FullName] = toType.Methods.ToList();

                    if (parent == null)
                    {
                        typesToInclude.Add(toType);
                    }
                    else
                    {
                        if (!nestedTypesToInclude.TryGetValue(parent.FullName, out var list))
                        {
                            nestedTypesToInclude[parent.FullName] = list = new List <TypeDefinition>();
                        }
                        list.Add(toType);
                    }

                    InitDiff(toType.NestedTypes, toType);
                    continue;
                }

                foreach (var toField in toType.Fields)
                {
                    var fromField = fromType.Fields.FirstOrDefault(f => f.Name == toField.Name);

                    if (fromField == null || fromField.FieldType.FullName != toField.FieldType.FullName ||
                        fromField.Attributes != toField.Attributes)
                    {
                        if (!fieldsToInclude.TryGetValue(toType.FullName, out var list))
                        {
                            fieldsToInclude[toType.FullName] = list = new List <FieldDefinition>();
                        }
                        list.Add(toField);
                    }
                }

                foreach (var toMethod in toType.Methods)
                {
                    var fromMethod = fromType.Methods.FirstOrDefault(m => m.FullName == toMethod.FullName);

                    if (fromMethod == null || fromMethod.HasBody != toMethod.HasBody ||
                        fromMethod.Body?.Instructions.Count != toMethod.Body?.Instructions.Count)
                    {
                        if (!methodsToInclude.TryGetValue(toType.FullName, out var list))
                        {
                            methodsToInclude[toType.FullName] = list = new List <MethodDefinition>();
                        }
                        list.Add(toMethod);
                        continue;
                    }

                    if (toMethod.HasBody &&
                        !toMethod.Body.Instructions.SequenceEqual(fromMethod.Body.Instructions, InstructionComparer))
                    {
                        if (!methodsToInclude.TryGetValue(toType.FullName, out var list))
                        {
                            methodsToInclude[toType.FullName] = list = new List <MethodDefinition>();
                        }
                        list.Add(toMethod);
                    }
                }

                if (fieldsToInclude.ContainsKey(toType.FullName) || methodsToInclude.ContainsKey(toType.FullName) ||
                    nestedTypesToInclude.ContainsKey(toType.FullName))
                {
                    if (parent == null)
                    {
                        typesToInclude.Add(toType);
                    }
                    else
                    {
                        if (!nestedTypesToInclude.TryGetValue(toType.FullName, out var list))
                        {
                            nestedTypesToInclude[toType.FullName] = list = new List <TypeDefinition>();
                        }
                        list.Add(toType);
                    }
                }

                InitDiff(toType.NestedTypes, toType);
            }
        }