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)); }
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)); }
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); } }