本文整理汇总了C#中FormDataCollection.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# FormDataCollection.GetValue方法的具体用法?C# FormDataCollection.GetValue怎么用?C# FormDataCollection.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormDataCollection
的用法示例。
在下文中一共展示了FormDataCollection.GetValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMembersExport
public HttpResponseMessage GetMembersExport(FormDataCollection queryStrings)
{
// Base Query data
string memberType = queryStrings.HasKey("memberType") ? queryStrings.GetValue<string>("memberType") : "";
string orderBy = queryStrings.HasKey("orderBy") ? queryStrings.GetValue<string>("orderBy") : "email";
Direction orderDirection = queryStrings.HasKey("orderDirection") ? queryStrings.GetValue<Direction>("orderDirection") : Direction.Ascending;
string filter = queryStrings.HasKey("filter") ? queryStrings.GetValue<string>("filter") : "";
int totalMembers = 0;
var members = Mapper.Map<IEnumerable<MemberExportModel>>(MemberSearch.PerformMemberSearch(filter, queryStrings, out totalMembers,
memberType,
orderBy: orderBy,
orderDirection: orderDirection));
var content = members.CreateCSV();
// see http://stackoverflow.com/questions/9541351/returning-binary-file-from-controller-in-asp-net-web-api
// & http://stackoverflow.com/questions/12975886/how-to-download-a-file-using-web-api-in-asp-net-mvc-4-and-jquery
// We really should use an async version - the above reference includes an example.
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new StringContent(content);
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
result.Content.Headers.ContentDisposition.FileName = string.Format("Members_{0:yyyyMMdd}.csv", DateTime.Now);
return result;
}
示例2: GetMembers
public PagedResult<MemberListItem> GetMembers(FormDataCollection queryStrings)
{
// Base Query data
int pageNumber = queryStrings.HasKey("pageNumber") ? queryStrings.GetValue<int>("pageNumber") : 1;
int pageSize = queryStrings.HasKey("pageSize") ? queryStrings.GetValue<int>("pageSize") : 10;
string orderBy = queryStrings.HasKey("orderBy") ? queryStrings.GetValue<string>("orderBy") : "email";
Direction orderDirection = queryStrings.HasKey("orderDirection") ? queryStrings.GetValue<Direction>("orderDirection") : Direction.Ascending;
string memberType = queryStrings.HasKey("memberType") ? queryStrings.GetValue<string>("memberType") : "";
string filter = queryStrings.HasKey("filter") ? queryStrings.GetValue<string>("filter") : "";
int totalMembers = 0;
var members = Mapper.Map<IEnumerable<MemberListItem>>(MemberSearch.PerformMemberSearch(filter, queryStrings, out totalMembers,
memberType, pageNumber, pageSize,
orderBy, orderDirection));
if (totalMembers == 0)
return new PagedResult<MemberListItem>(0, 0, 0);
var pagedResult = new PagedResult<MemberListItem>(
totalMembers,
pageNumber,
pageSize);
pagedResult.Items = members;
return pagedResult;
}
示例3: GetTreeNodes
/// <summary>
/// This will automatically check if the recycle bin needs to be rendered (i.e. its the first level)
/// and will automatically append it to the result of GetChildNodes.
/// </summary>
/// <param name="id"></param>
/// <param name="queryStrings"></param>
/// <returns></returns>
protected sealed override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
//check if we're rendering the root
if (id == Constants.System.Root.ToInvariantString() && UserStartNode == Constants.System.Root)
{
var nodes = new TreeNodeCollection();
var altStartId = string.Empty;
if(queryStrings.HasKey(TreeQueryStringParameters.StartNodeId))
altStartId = queryStrings.GetValue<string>(TreeQueryStringParameters.StartNodeId);
//check if a request has been made to render from a specific start node
//TODO: This 'undefined' check should not be required whatseover - this parameter should not be sent up ever it if is null from the front-end.
if (!string.IsNullOrEmpty(altStartId) && altStartId != "undefined" && altStartId != Constants.System.Root.ToString(CultureInfo.InvariantCulture))
{
id = queryStrings.GetValue<string>(TreeQueryStringParameters.StartNodeId);
//we need to verify that the user has access to view this node, otherwise we'll render an empty tree collection
// TODO: in the future we could return a validation statement so we can have some UI to notify the user they don't have access
if (HasPathAccess(id, queryStrings))
{
nodes = GetTreeNodesInternal(id, queryStrings);
}
}
else
{
//load normally
nodes = GetTreeNodesInternal(id, queryStrings);
}
//only render the recycle bin if we are not in dialog and the start id id still the root
if (IsDialog(queryStrings) == false && id == Constants.System.Root.ToInvariantString())
{
nodes.Add(CreateTreeNode(
RecycleBinId.ToInvariantString(),
id,
queryStrings,
ui.GetText("general", "recycleBin"),
"icon-trash",
RecycleBinSmells,
//TODO: This would be nice to enable so we can have a nice recyclebin view, see the NOTE: in the routes.js angular file
// for the time being we'll just load the dashboard of the section.
//queryStrings.GetValue<string>("application") + TreeAlias.EnsureStartsWith('/') + "/recyclebin"));
queryStrings.GetValue<string>("application")));
}
return nodes;
}
return GetTreeNodesInternal(id, queryStrings);
}
示例4: 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;
}
示例5: IsDialog
/// <summary>
/// If the request is for a dialog mode tree
/// </summary>
/// <param name="queryStrings"></param>
/// <returns></returns>
protected bool IsDialog(FormDataCollection queryStrings)
{
return queryStrings.GetValue<bool>(TreeQueryStringParameters.IsDialog);
}
示例6: CreateRootNode
/// <summary>
/// Helper method to create a root model for a tree
/// </summary>
/// <returns></returns>
protected virtual TreeNode CreateRootNode(FormDataCollection queryStrings)
{
var rootNodeAsString = Constants.System.Root.ToString(CultureInfo.InvariantCulture);
var currApp = queryStrings.GetValue<string>(TreeQueryStringParameters.Application);
var node = new TreeNode(
rootNodeAsString,
null, //this is a root node, there is no parent
Url.GetTreeUrl(GetType(), rootNodeAsString, queryStrings),
Url.GetMenuUrl(GetType(), rootNodeAsString, queryStrings))
{
HasChildren = true,
RoutePath = currApp,
Name = RootNodeDisplayName
};
return node;
}
示例7: CreateRootNode
/// <summary>
/// Helper method to create a root model for a tree
/// </summary>
/// <returns></returns>
protected virtual TreeNode CreateRootNode(FormDataCollection queryStrings)
{
var getChildNodesUrl = Url.GetTreeUrl(GetType(), RootNodeId, queryStrings);
var isDialog = queryStrings.GetValue<bool>(TreeQueryStringParameters.DialogMode);
//var node = new TreeNode(RootNodeId, BackOfficeRequestContext.RegisteredComponents.MenuItems, jsonUrl)
var node = new TreeNode(RootNodeId, getChildNodesUrl)
{
HasChildren = true,
//THIS IS TEMPORARY UNTIL WE FIGURE OUT HOW WE ARE LOADING STUFF (I.E. VIEW NAMES, ACTION NAMES, DUNNO)
EditorUrl = queryStrings.HasKey(TreeQueryStringParameters.OnNodeClick) //has a node click handler?
? queryStrings.Get(TreeQueryStringParameters.OnNodeClick) //return node click handler
: isDialog //is in dialog mode without a click handler ?
? "#" //return empty string, otherwise, return an editor URL:
: "mydashboard",
Title = RootNodeDisplayName
};
//add the tree type to the root
node.AdditionalData.Add("treeType", GetType().FullName);
////add the tree-root css class
//node.Style.AddCustom("tree-root");
//node.AdditionalData.Add("id", node.HiveId.ToString());
//node.AdditionalData.Add("title", node.Title);
AddQueryStringsToAdditionalData(node, queryStrings);
//check if the tree is searchable and add that to the meta data as well
if (this is ISearchableTree)
{
node.AdditionalData.Add("searchable", "true");
}
return node;
}