예제 #1
0
        public PageInfo(PageConfig config)
        {
            this._config     = config;
            this._sourceName = config.SourceName;
            this.OutputName  = FieldNameHelper.Parse(config.Name);

            this.SourceFields = config.SourceFields;
        }
        private List <string> ValidateRequest(GetProviderOrganisationStatusQuery request)
        {
            const string ukprnFieldName   = nameof(request.Ukprn);
            const string ukprnRegex       = @"^\d{8}$";
            var          validationErrors = new List <string>();

            if (Regex.IsMatch(request.Ukprn.ToString(), ukprnRegex) == false)
            {
                validationErrors.Add($"Invalid {FieldNameHelper.ToCamelCasePropertyName(ukprnFieldName)}");
            }

            return(validationErrors);
        }
예제 #3
0
        private List <string> ValidateRequest(GetEmployerSummaryQuery request)
        {
            const string employerAccountIdFieldName = nameof(request.EmployerAccountId);
            const string employerAccountIdRegex     = @"^[A-Z0-9]{6}$";
            var          validationErrors           = new List <string>();

            if (string.IsNullOrEmpty(request.EmployerAccountId) || Regex.IsMatch(request.EmployerAccountId, employerAccountIdRegex) == false)
            {
                validationErrors.Add($"Invalid {FieldNameHelper.ToCamelCasePropertyName(employerAccountIdFieldName)}");
            }

            return(validationErrors);
        }
예제 #4
0
파일: PageInfo.cs 프로젝트: Paul-Moura/ETL
        public PageInfo(PageConfig config)
        {
            this._sourceName = config.Name;
            if (config.Name != null)
            {
                this.OutputName = FieldNameHelper.Parse(config.Name);
            }

            this.SourceFields = config.Fields.Select(x => x.Name);

            if (config.Fields != null)
            {
                foreach (var configField in config.Fields)
                {
                    this._configs[configField.Name] = configField;
                }
            }
        }
        private List <string> ValidateRequest(GetApplicantsQuery request)
        {
            const string vacancyReferenceFieldName = nameof(request.VacancyReference);
            const string applicantApplicationOutcomeFilterFieldName = nameof(request.ApplicantApplicationOutcomeFilter);
            var          validationErrors = new List <string>();

            if (request.VacancyReference < ValidMinimumRecruitVacancyReferenceNumber)
            {
                validationErrors.Add($"Invalid {FieldNameHelper.ToCamelCasePropertyName(vacancyReferenceFieldName)}");
            }

            if (!string.IsNullOrEmpty(request.ApplicantApplicationOutcomeFilter) &&
                _validFilters.All(filter => filter.Equals(request.ApplicantApplicationOutcomeFilter, StringComparison.InvariantCultureIgnoreCase) == false))
            {
                validationErrors.Add($"Invalid {FieldNameHelper.ToCamelCasePropertyName(applicantApplicationOutcomeFilterFieldName)}");
            }

            return(validationErrors);
        }
예제 #6
0
        private List <string> ValidateRequest(GetVacanciesQuery request)
        {
            const string employerAccountIdFieldName = nameof(request.EmployerAccountId);
            const string ukprnFieldName             = nameof(request.Ukprn);
            const string employerAccountIdRegex     = @"^[A-Z0-9]{6}$";
            const string ukprnRegex       = @"^\d{8}$";
            var          validationErrors = new List <string>();

            if (string.IsNullOrEmpty(request.EmployerAccountId) || Regex.IsMatch(request.EmployerAccountId, employerAccountIdRegex) == false)
            {
                validationErrors.Add($"Invalid {FieldNameHelper.ToCamelCasePropertyName(employerAccountIdFieldName)}");
            }

            if (request.Ukprn.HasValue && Regex.IsMatch(request.Ukprn.ToString(), ukprnRegex) == false)
            {
                validationErrors.Add($"Invalid {FieldNameHelper.ToCamelCasePropertyName(ukprnFieldName)}");
            }

            return(validationErrors);
        }
예제 #7
0
        /// <summary>
        /// 添加所有数值和字符串字段名称到下拉框(除了 Count、OID)
        /// </summary>
        /// <param name="layer">图层</param>
        /// <param name="cboData">下拉框</param>
        public static void AddNumberAndStringFieldsToComboBox(IRasterLayer layer, ComboBox cboData)
        {
            List <string> fields = FieldNameHelper.GetIntegerOrStringOrFloatFieldNames(layer);

            AddFieldsToComboBox(fields, cboData);
        }
예제 #8
0
        private CmsSearchResultItem GetCmsSearchResultItem(ICmsContent node)
        {
            if (node.Id == null)
            {
                this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, "Node id is null, not recognized object for indexing. Skipping.", (Exception)null);
                return((CmsSearchResultItem)null);
            }
            object propertyValue1 = this.cmsIndexer.GetPropertyValue(node, "solisSearchNoIndex");

            if (propertyValue1 != null)
            {
                try
                {
                    if (Convert.ToBoolean(propertyValue1))
                    {
                        this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, "solisSearchNoIndex is true, removing it from index if exist and skips node.", (Exception)null);
                        this.DeleteFromIndex((object)node.Id);
                        return((CmsSearchResultItem)null);
                    }
                }
                catch (Exception ex)
                {
                    this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Error, "Error checking if node should be indexed.", ex);
                }
            }
            DocType docType = CurrentConfiguration.DocTypes[node.ContentType];

            if (docType != null && docType.Exclude)
            {
                this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, string.Format("DocType {0} is configured to be excluded from index, skipping", (object)node.ContentType), (Exception)null);
                return((CmsSearchResultItem)null);
            }
            if (docType == null)
            {
                this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Warn, string.Format("Cannot find any configuration for DocType {0}, loading default configuration", (object)node.ContentType), (Exception)null);
                docType = CurrentConfiguration.DocTypes["default"];
            }
            if (docType == null)
            {
                this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Warn, string.Format("Cannot find any configuration for DocType {0}, not even default backup configuration, cannot index content.", (object)node.ContentType), (Exception)null);
                return((CmsSearchResultItem)null);
            }
            CmsSearchResultItem searchResultItem = new CmsSearchResultItem()
            {
                Id           = node.Id,
                Name         = node.Name,
                LinkUrl      = this.cmsIndexer.GetContentUrl(node),
                Created      = node.CreateDate,
                StartPublish = node.StartPublish,
                LastModified = node.UpdateDate,
                EndPublish   = node.EndPublish,
                Breadcrumbs  = this.cmsIndexer.GetBreadcrumbs(node),
                Acl          = this.cmsIndexer.GetNodeAcl(node),
                Languages    = this.cmsIndexer.GetNodeLanguages(node),
                DocTypes     = this.cmsIndexer.GetContentTypes(node)
            };

            try
            {
                object propertyValue2 = this.cmsIndexer.GetPropertyValue(node, "solisSearchCustomUrl");
                if (propertyValue2 != null)
                {
                    if (!string.IsNullOrWhiteSpace(propertyValue2 as string))
                    {
                        this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, string.Format("Found custom value for node url, inserting to index {0}", propertyValue2), (Exception)null);
                        searchResultItem.LinkUrl = propertyValue2.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Error, "Error reading custom url", ex);
            }
            if (docType.AddPageNameToContent)
            {
                searchResultItem.Content.Add(node.Name);
            }
            foreach (Property property1 in docType.DocTypeProperties.Cast <Property>())
            {
                string       propertyName = property1.PropertyName;
                ICmsProperty property2    = this.cmsIndexer.GetProperty(node, propertyName);
                if (property2 == null)
                {
                    this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, string.Format("Property {0} not found on document, skipping", (object)propertyName), (Exception)null);
                }
                else
                {
                    IPropertyParser parser;
                    if (!string.IsNullOrEmpty(property1.Parser))
                    {
                        Type type = Type.GetType(property1.Parser);
                        if (type == (Type)null)
                        {
                            this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Error, string.Format("Parser was configured as {0}, but parser type is not recognized, will use default parser.", (object)property1.Parser), (Exception)null);
                            parser = (IPropertyParser) new DefaultParser();
                        }
                        else
                        {
                            parser = Activator.CreateInstance(type) as IPropertyParser;
                        }
                    }
                    else
                    {
                        parser = (IPropertyParser) new DefaultParser();
                    }
                    parser.CurrentCmsNode       = node;
                    parser.CurrentCmsProperty   = property2;
                    parser.CurrentSolisProperty = property1;
                    string str1 = property2 != null?parser.GetPropertyValue(property2.Value) : string.Empty;

                    if (property1.Recursive && string.IsNullOrEmpty(str1))
                    {
                        str1 = this.GetRecursiveValue(node, propertyName, parser);
                    }
                    bool   forceMultiValued      = property1.ForceMultiValued;
                    string dynamicFieldExtension = FieldNameHelper.GetDynamicFieldExtension(property1);
                    if (!string.IsNullOrEmpty(str1))
                    {
                        if (property2 != null)
                        {
                            if (searchResultItem.Documents == null)
                            {
                                searchResultItem.Documents = this.ExtractDocumentLinks(str1, property2.Name);
                            }
                            else
                            {
                                searchResultItem.Documents.AddRange((IEnumerable <string>) this.ExtractDocumentLinks(str1, property2.Name));
                            }
                        }
                        if (property1.StripHtml)
                        {
                            str1 = str1.StripHtml();
                        }
                        if (property1.Content)
                        {
                            this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, string.Format("Property is set as Content, adding content value from property {0} with value \"{1}\" to indexitem ", (object)propertyName, (object)str1), (Exception)null);
                            searchResultItem.Content.Add(str1);
                        }
                        string key = propertyName + dynamicFieldExtension;
                        this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, string.Format("Adding property {0} with value \"{1}\" to indexitem ", (object)key, (object)str1), (Exception)null);
                        if (forceMultiValued)
                        {
                            char[] trimchars = new char[3]
                            {
                                ' ',
                                '\n',
                                '\r'
                            };
                            IEnumerable <string> strings = ((IEnumerable <string>)Array.ConvertAll <string, string>(str1.Split(new string[1]
                            {
                                property1.SplitChar
                            }, StringSplitOptions.RemoveEmptyEntries), (Converter <string, string>)(s => s.Trim(trimchars)))).AsEnumerable <string>();
                            searchResultItem.CmsProperties.Add(new KeyValuePair <string, object>(key, (object)strings));
                            if (property1.AlphabeticalIndex)
                            {
                                this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, "Multivalued property is set for alphabetical index, adding first letters to alphaindex", (Exception)null);
                                foreach (string str2 in strings)
                                {
                                    string lower = str2.Substring(0, 1).ToLower();
                                    if (!searchResultItem.AlphaIndex.Contains(lower))
                                    {
                                        searchResultItem.AlphaIndex.Add(lower);
                                    }
                                }
                            }
                        }
                        else
                        {
                            searchResultItem.CmsProperties.Add(new KeyValuePair <string, object>(key, (object)str1));
                            if (property1.AlphabeticalIndex)
                            {
                                this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Debug, "Property is set for alphabetical index, adding first letter to alphaindex", (Exception)null);
                                string lower = str1.Substring(0, 1).ToLower();
                                if (!searchResultItem.AlphaIndex.Contains(lower))
                                {
                                    searchResultItem.AlphaIndex.Add(lower);
                                }
                            }
                        }
                    }
                }
            }
            return(searchResultItem);
        }
예제 #9
0
 /// <summary>
 /// 是选中或只读字段
 /// </summary>
 /// <param name="selectFieldName">选中字段列表</param>
 /// <param name="field">字段</param>
 /// <returns></returns>
 private static bool IsSelectOrReadonlyField(List <string> selectFieldName, IField field)
 {
     //是选中或只读字段
     return(selectFieldName.Contains(field.Name) || !FieldNameHelper.IsFieldEditable(field));
 }