本文整理汇总了C#中System.Web.Script.Serialization.JavaScriptSerializer.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# Script.Serialization.JavaScriptSerializer.FirstOrDefault方法的具体用法?C# Script.Serialization.JavaScriptSerializer.FirstOrDefault怎么用?C# Script.Serialization.JavaScriptSerializer.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Script.Serialization.JavaScriptSerializer
的用法示例。
在下文中一共展示了Script.Serialization.JavaScriptSerializer.FirstOrDefault方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateColumnWidth
public ActionResult UpdateColumnWidth(int reportId, string columnName, int width)
{
try
{
var userReport = GetUserReport(reportId, GetLoggedUserId());
var outputConfig = new JavaScriptSerializer().Deserialize<List<ReportColumn>>(userReport.OutputConfiguration);
var column = outputConfig.FirstOrDefault(col => col.Name == columnName);
if (!column.IsNull())
{
column.Width = width;
var updatedOutputConfig = new JavaScriptSerializer().Serialize(outputConfig);
UpdateUserReportOutPutConfig(reportId, GetLoggedUserId(), updatedOutputConfig);
}
return Json(true);
}
catch (Exception)
{
return null;
}
}
示例2: GetReportColumns
private List<ReportColumn> GetReportColumns(UserReportViewModel userReport)
{
try
{
var userLogged = Session[Utils.UserKey] as UserModel;
var userLevel = Utils.GetUserLevel(userLogged.UserCategory);
var userReportOutPut = userReport.Output.Split(',').ToList();
var reportDefaultOutput = userReport.DefaultOuput.Split(',').ToList();
var userReportFilterableColumns = userReport.UserFilters.Split(',');
var columnsConfig = new JavaScriptSerializer().Deserialize<List<ReportColumn>>(userReport.OutputConfiguration);
var result = (from column in reportDefaultOutput
let columnConfig = columnsConfig.FirstOrDefault(col => col.Name == column)
select new ReportColumn
{
Name = column,
Level = columnConfig.IsNull() ? 0 : columnConfig.Level,
Selected = userReportOutPut.Contains(column) && userLevel >= (columnConfig.IsNull() ? 0 : columnConfig.Level),
Filterable = userReportFilterableColumns.Contains(column),
Width = columnConfig.IsNull() ? 120 : columnConfig.Width,
Index = columnConfig.IsNull() ? 0 : columnConfig.Index,
Label = Utils.GetColumnLabel(userReport.Labels, column)
}).ToList();
result.Sort((a, b) => a.Index.CompareTo(b.Index));
return result;
}
catch (Exception exception)
{
return null;
}
}
示例3: 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;
}
}