dengjunjie
2024-10-30 680ccbedf08839143215f40dea5273dc2819100c
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseServices/ServiceBase.cs
@@ -58,6 +58,68 @@
            return pageGridData;
        }
        public string ValidatePageOptions(PageDataOptions options)
        {
            options = options ?? new PageDataOptions();
            string text = "";
            List<SearchParameters> searchParametersList = new List<SearchParameters>();
            if (options.Filter != null && options.Filter.Count > 0)
            {
                searchParametersList.AddRange(options.Filter);
            }
            else if (!string.IsNullOrEmpty(options.Wheres))
            {
                try
                {
                    searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
                    options.Filter = searchParametersList;
                }
                catch
                {
                }
            }
            base.QueryRelativeList?.Invoke(searchParametersList);
            int i;
            for (i = 0; i < searchParametersList.Count; i++)
            {
                if (string.IsNullOrEmpty(searchParametersList[i].Value))
                {
                    continue;
                }
                PropertyInfo propertyInfo = TProperties.Where((PropertyInfo c) => c.Name.ToUpper() == searchParametersList[i].Name.ToUpper()).FirstOrDefault();
                if (propertyInfo == null)
                {
                    continue;
                }
                object[] values = searchParametersList[i].Value.Split(',');
                List<(bool, string, object)> list = propertyInfo.ValidationValueForDbType(values).ToList();
                if (list == null || list.Count() == 0)
                {
                    continue;
                }
                for (int j = 0; j < list.Count(); j++)
                {
                    if (j == 0)
                    {
                        text += "(";
                    }
                    text = ((searchParametersList[i].DisplayType.GetLinqCondition() != 0) ? (text + $"{searchParametersList[i].Name} {searchParametersList[i].DisplayType} '{list[j].Item3}'") : (text + $"{searchParametersList[i].Name} = '{list[j].Item3}'"));
                    text = ((j != list.Count() - 1) ? (text + " or ") : (text + ")"));
                }
                if (i < searchParametersList.Count - 1)
                {
                    text += " and ";
                }
            }
            return text;
        }
        public virtual object GetDetailPage(PageDataOptions pageData)
        {