本文整理汇总了C#中System.Web.Script.Serialization.JavaScriptSerializer.Where方法的典型用法代码示例。如果您正苦于以下问题:C# Script.Serialization.JavaScriptSerializer.Where方法的具体用法?C# Script.Serialization.JavaScriptSerializer.Where怎么用?C# Script.Serialization.JavaScriptSerializer.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Script.Serialization.JavaScriptSerializer
的用法示例。
在下文中一共展示了Script.Serialization.JavaScriptSerializer.Where方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRoadmapReleasesFromFile
public static IEnumerable<AggregateView> GetRoadmapReleasesFromFile()
{
var import = new Import();
if (File.Exists(HttpContext.Current.Server.MapPath(import.YouTrackJsonFile)) == false)
import.SaveAllToFile();
var allText = File.ReadAllText(HttpContext.Current.Server.MapPath(import.YouTrackJsonFile));
var data = new JavaScriptSerializer().Deserialize<List<AggregateView>>(allText);
var result = data.Where(x => x.released == false && x.isPatch == false);
return result;
}
示例2: Process
/// <summary>Process
/// <para>
/// Process: Internal function to convert a RosetteFile into a dictionary to use for getResponse
/// </para>
/// </summary>
/// <param name="file">RosetteFile: File being uploaded to use as a request to the Rosette server.</param>
/// <returns>Dictionary<string, object>: Dictionary containing the results of the response from the server from the getResponse call.</returns>
private Dictionary<string, Object> Process(RosetteFile file)
{
Dictionary<string, string> dict = new Dictionary<string, string>(){
{ "content", file.getFileDataString()},
{ "contentType", file.getDataType()},
{ "unit", "doc"},
};
if(file.getOptions() != null){
Dictionary<string, string> opts = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(file.getOptions());
dict = (Dictionary<string, string>)dict.Concat(opts.Where(x=> !dict.Keys.Contains(x.Key)));
}
return getResponse(SetupClient(), new JavaScriptSerializer().Serialize(dict));
}
示例3: GetReportOutputConfiguration
private string GetReportOutputConfiguration(int reportId, int userId, IEnumerable<ReportColumn> columnsSwapHistory, IEnumerable<ReportColumn> columnsWidthHistory)
{
var userReport = GetUserReport(reportId, userId);
var columnsConfig = new JavaScriptSerializer().Deserialize<List<ReportColumn>>(userReport.OutputConfiguration);
columnsConfig.ForEach(reportConfig =>
{
var lastIndex = columnsSwapHistory.LastOrDefault(columnSwap => columnSwap.Name == reportConfig.Name);
//There was an index change so an offset has to be performed
if (!lastIndex.IsNull())
{
//Right offset
if (lastIndex.Index > reportConfig.Index)
{
foreach (var column in columnsConfig.Where(colum => colum.Index <= lastIndex.Index && colum.Index > reportConfig.Index))
column.Index--;
}
else
{
//Left offset
foreach (var column in columnsConfig.Where(colum => colum.Index >= lastIndex.Index && colum.Index < reportConfig.Index))
column.Index++;
}
reportConfig.Index = lastIndex.Index;
}
var lastWidth = columnsWidthHistory.LastOrDefault(columnWidth => columnWidth.Name == reportConfig.Name);
if (!lastWidth.IsNull())
reportConfig.Width = lastWidth.Width;
});
var jsonResult = new JsonSerializer().Serialize(columnsConfig);
return jsonResult;
}
示例4: UpdateColumnOrder
public ActionResult UpdateColumnOrder(int reportId, string columnName, int oldIndex, int newIndex)
{
try
{
var userReport = GetUserReport(reportId, GetLoggedUserId());
var currentOutput = userReport.Output;
var outputConfig = new JavaScriptSerializer().Deserialize<List<ReportColumn>>(userReport.OutputConfiguration);
var column = outputConfig.FirstOrDefault(col => col.Name == columnName);
if (!column.IsNull())
{
//Right offset
if (newIndex > oldIndex)
{
foreach (var col in outputConfig.Where(colum => colum.Index <= newIndex && colum.Index > oldIndex))
col.Index--;
}
else
{
//Left offset
foreach (var col in outputConfig.Where(colum => colum.Index >= newIndex && colum.Index < oldIndex))
col.Index++;
}
column.Index = newIndex;
var updatedOutputConfig = new JavaScriptSerializer().Serialize(outputConfig);
UpdateUserReportOutPutConfig(reportId, GetLoggedUserId(), updatedOutputConfig);
}
return Json(true);
}
catch (Exception)
{
return null;
}
}
示例5: GetOrderSummary
public ActionResult GetOrderSummary(string mySelection)
{
try
{
var selectionDeserialized = new JavaScriptSerializer().Deserialize<IEnumerable<MarketingMaterialSelection>>(mySelection);
var positiveSelection = selectionDeserialized.Where(selected => selected.Quantity > 0);
var allMaterials = GetMarketingMaterials();
var selection = allMaterials.Join(positiveSelection, marketing => marketing.Id, select => select.Id, (a, b) => new { a.Category, a.Id, b.Quantity });
var selectionGrouped = selection.GroupBy(a => a.Category);
var result = selectionGrouped.Select(group => new { Category = group.Key, Amount = group.Sum(a => a.Quantity) });
//To be changed
var shippingCost = 15;
return Json(new { Summary = result, Cost = shippingCost });
}
catch (Exception exception)
{
return null;
}
}
示例6: SendOrder
public ActionResult SendOrder(string things)
{
try
{
var userLogged = Session[Utils.UserKey] as UserModel;
var thingsSelected = new JavaScriptSerializer().Deserialize<IEnumerable<MarketingMaterialSelection>>(things);
var positiveSelection = thingsSelected.Where(selected => selected.Quantity > 0);
var thingsInfo = GetMarketingMaterials();
var thingsInOrder = positiveSelection.Join(thingsInfo, a => a.Id, b => b.Id, (a, b) => new MarketingProduct(b,b.Category,a.Quantity));
var cartHeader = GetOrderReady(thingsInOrder);
var request = Utils.GetRequestInfo(Method.POST, "/api/Orders/Add");
var insertOrderResponse = _webClient.Execute<OrderResponse>(new JsonSerializer().Serialize(cartHeader), ApiUrls.API_KEY, ApiUrls.API_SECRET, request);
var confirmation = new OrderConfirmation
{
OrderConfirmationNumber = insertOrderResponse.OrderId,
Address = Utils.GetFormattedAddress(userLogged.Address1, userLogged.Address2, userLogged.City, userLogged.State, userLogged.ZipCode, "USA"),
Email = userLogged.Email,
Phone = userLogged.Phone,
Name = userLogged.Name,
};
var result = insertOrderResponse.OrderId > 0? Utils.Success:"There were problems trying to process your order. Try it again later, please.";
return Json(new{ShippingInfo = confirmation, Result = result});
}
catch (Exception exception)
{
return Json(new { Result = "There were problems trying to process your order. Try it again later, please." });
}
}