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


C# Script.Serialization.JavaScriptSerializer.FirstOrDefault方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:hansel0691,项目名称:VirtualOffice,代码行数:26,代码来源:ReportsController.cs

示例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;
            }
        }
开发者ID:hansel0691,项目名称:VirtualOffice,代码行数:38,代码来源:ReportsController.cs

示例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;
            }
        }
开发者ID:hansel0691,项目名称:VirtualOffice,代码行数:41,代码来源:ReportsController.cs


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