当前位置: 首页>>代码示例>>C#>>正文


C# FormDataCollection.Where方法代码示例

本文整理汇总了C#中FormDataCollection.Where方法的典型用法代码示例。如果您正苦于以下问题:C# FormDataCollection.Where方法的具体用法?C# FormDataCollection.Where怎么用?C# FormDataCollection.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormDataCollection的用法示例。


在下文中一共展示了FormDataCollection.Where方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PerformMemberSearch

        public static IEnumerable<SearchResult> PerformMemberSearch(string filter, FormDataCollection queryStrings, out int totalRecordCount,
            string memberType = "",
            int pageNumber = 0,
            int pageSize = 0,
            string orderBy = "",
            Direction orderDirection = Direction.Ascending)
        {
            var internalSearcher = ExamineManager.Instance.SearchProviderCollection[Constants.Examine.InternalMemberSearcher];
            ISearchCriteria criteria = internalSearcher.CreateSearchCriteria().RawQuery(" +__IndexType:member");

            //build a lucene query
            if (string.IsNullOrWhiteSpace(filter) &&
                !queryStrings.Any(qs => qs.Key.StartsWith("f_") && !string.IsNullOrWhiteSpace(qs.Value)))
            {
                // Generic get everything...
                criteria.RawQuery("a* b* c* d* e* f* g* h* i* j* k* l* m* n* o* p* q* r* s* t* u* v* w* x* y* z*");
            }
            else
            {
                // the __nodeName will be boosted 10x without wildcards
                // then __nodeName will be matched normally with wildcards
                // the rest will be normal without wildcards
                if (!string.IsNullOrWhiteSpace(filter))
                {
                    var sb = new StringBuilder();
                    sb.Append("+(");
                    //node name exactly boost x 10
                    sb.AppendFormat("__nodeName:{0}^10.0 ", filter.ToLower());

                    //node name normally with wildcards
                    sb.AppendFormat(" __nodeName:{0}* ", filter.ToLower());

                    var basicFields = new List<string>() { "id", "_searchEmail", "email", "loginName" };
                    var userFields = ExamineManager.Instance.IndexProviderCollection["InternalMemberIndexer"].IndexerData.UserFields.Select(x => x.Name);
                    basicFields.AddRange(userFields);

                    foreach (var field in basicFields.Distinct())
                    {
                        //additional fields normally
                        sb.AppendFormat("{0}:{1} ", field, filter);
                    }
                    sb.Append(")");
                    criteria.RawQuery(sb.ToString());
                }

                // Now specific field searching. - these should be ANDed and grouped.
                foreach (var qs in queryStrings.Where(q => q.Key.StartsWith("f_") && !string.IsNullOrWhiteSpace(q.Value)))
                {
                    // Got a filter.
                    string alias = qs.Key.Substring(2);

                    var values = queryStrings.GetValue<string>(qs.Key).Split(',');

                    if (values.Length > 0)
                    {
                        criteria.GroupedOr(new[] { alias }, values);
                    }
                }
            }

            //must match index type
            if (!string.IsNullOrWhiteSpace(memberType))
            {
                criteria.NodeTypeAlias(memberType);
            }

            //// Order the results
            //// Examine Sorting seems too unreliable, particularly on nodeName
            //if (orderDirection == Direction.Ascending) {
            //    criteria.OrderBy(orderBy.ToLower() == "name" ? "nodeName" : "email");
            //} else {
            //    criteria.OrderByDescending(orderBy.ToLower() == "name" ? "nodeName" : "email");
            //}

            var result = internalSearcher.Search(criteria);
            totalRecordCount = result.TotalItemCount;

            // Order the results
            var orderedResults = orderDirection == Direction.Ascending
                ? result.OrderBy(o => orderBy.ToLower() == "name" ? o.Fields["nodeName"] : o.Fields["email"])
                : result.OrderByDescending(o => orderBy.ToLower() == "name" ? o.Fields["nodeName"] : o.Fields["email"]);

            if (pageSize > 0)
            {
                int skipCount = (pageNumber > 0 && pageSize > 0) ? Convert.ToInt32((pageNumber - 1) * pageSize) : 0;
                if (result.TotalItemCount < skipCount)
                {
                    skipCount = result.TotalItemCount / pageSize;
                }

                return orderedResults.Skip(skipCount).Take(pageSize);
            }
            return orderedResults;
        }
开发者ID:AzarinSergey,项目名称:project-site,代码行数:94,代码来源:MemberSearch.cs

示例2: AddQueryStringsToAdditionalData

 /// <summary>
 /// The AdditionalData of a node is always populated with the query string data, this method performs this
 /// operation and ensures that special values are not inserted or that duplicate keys are not added.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="queryStrings"></param>
 protected void AddQueryStringsToAdditionalData(TreeNode node, FormDataCollection queryStrings)
 {
     foreach (var q in queryStrings.Where(x => node.AdditionalData.ContainsKey(x.Key) == false))
     {
         node.AdditionalData.Add(q.Key, q.Value);
     }
 }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:13,代码来源:TreeControllerBase.cs

示例3: AddQueryStringsToAdditionalData

 /// <summary>
 /// The AdditionalData of a node is always populated with the query string data, this method performs this
 /// operation and ensures that special values are not inserted or that duplicate keys are not added.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="queryStrings"></param>
 protected virtual void AddQueryStringsToAdditionalData(TreeNode node, FormDataCollection queryStrings)
 {
     // Add additional data, ensure treeId isn't added as we've already done that
     foreach (var q in queryStrings
         .Where(x => x.Key != "treeId" && !node.AdditionalData.ContainsKey(x.Key)))
     {
         node.AdditionalData.Add(q.Key, q.Value);
     }
 }
开发者ID:jakobloekke,项目名称:Belle,代码行数:15,代码来源:TreeApiController.cs

示例4: Delete

        protected HttpResponseMessage Delete(FormDataCollection form)
        {
            foreach (string username in form.Where(kvp => kvp.Key.StartsWith("user_")).Select(kvp => kvp.Key.Substring(5)))
            {
                UserIDMapper.DeleteUser(username);
            }

            return GetUserId(form.Get("UserId"));
        }
开发者ID:klightspeed,项目名称:CloudPrintProxy,代码行数:9,代码来源:AuditronController.cs

示例5: ConvertFromLegacy

        /// <summary>
        /// Converts a legacy XmlTreeNode to a new TreeNode
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="xmlTreeNode"></param>
        /// <param name="urlHelper"></param>
        /// <param name="currentSection"></param>
        /// <param name="currentQueryStrings">
        /// The current query strings for the request - this is used to append the query strings to the menu URL of the item being rendered since the menu
        /// actually belongs to this same node (request) the query strings need to exist so the menu can be rendered in some cases.
        /// </param>
        /// <param name="isRoot"></param>
        /// <returns></returns>
        internal static TreeNode ConvertFromLegacy(string parentId, XmlTreeNode xmlTreeNode, UrlHelper urlHelper, string currentSection, FormDataCollection currentQueryStrings, bool isRoot = false)
        {
            //  /umbraco/tree.aspx?rnd=d0d0ff11a1c347dabfaa0fc75effcc2a&id=1046&treeType=content&contextMenu=false&isDialog=false

            //we need to convert the node source to our legacy tree controller
            var childNodesSource = urlHelper.GetUmbracoApiService<LegacyTreeController>("GetNodes");

            var childQuery = (xmlTreeNode.Source.IsNullOrWhiteSpace() || xmlTreeNode.Source.IndexOf('?') == -1)
                ? ""
                : xmlTreeNode.Source.Substring(xmlTreeNode.Source.IndexOf('?'));

            //append the query strings
            childNodesSource = childNodesSource.AppendQueryStringToUrl(childQuery);

            //for the menu source we need to detect if this is a root node since we'll need to set the parentId and id to -1
            // for which we'll handle correctly on the server side.            
            //if there are no menu items, then this will be empty
            var menuSource = "";
            if (xmlTreeNode.Menu != null && xmlTreeNode.Menu.Any())
            {
                menuSource = urlHelper.GetUmbracoApiService<LegacyTreeController>("GetMenu");
                //these are the absolute required query strings
                var menuQueryStrings = new Dictionary<string, object>
                    {
                        {"id", (isRoot ? "-1" : xmlTreeNode.NodeID)},
                        {"treeType", xmlTreeNode.TreeType},
                        {"parentId", (isRoot ? "-1" : parentId)},
                        {"section", currentSection}
                    };
                //append the extra ones on this request
                foreach (var i in currentQueryStrings.Where(x => menuQueryStrings.Keys.Contains(x.Key) == false))
                {
                    menuQueryStrings.Add(i.Key, i.Value);
                }
                
                menuSource = menuSource.AppendQueryStringToUrl(menuQueryStrings.ToQueryString());    
            }
            

            //TODO: Might need to add stuff to additional attributes

            var node = new TreeNode(xmlTreeNode.NodeID, isRoot ? null : parentId, childNodesSource, menuSource)
            {
                HasChildren = xmlTreeNode.HasChildren,
                Icon = xmlTreeNode.Icon,
                Name = xmlTreeNode.Text,
                NodeType = xmlTreeNode.NodeType
            };
            if (isRoot)
            {
                node.AdditionalData.Add("treeAlias", xmlTreeNode.TreeType);
            }

            //This is a special case scenario, we know that content/media works based on the normal Belle routing/editing so we'll ensure we don't
            // pass in the legacy JS handler so we do it the new way, for all other trees (Currently, this is a WIP), we'll render
            // the legacy js callback,.
            var knownNonLegacyNodeTypes = new[] { "content", "contentRecycleBin", "mediaRecyleBin", "media" };
            if (knownNonLegacyNodeTypes.InvariantContains(xmlTreeNode.NodeType) == false)
            {
                node.AssignLegacyJsCallback(xmlTreeNode.Action);
            }
            return node;
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:76,代码来源:LegacyTreeDataConverter.cs


注:本文中的FormDataCollection.Where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。