public JsonResult TableDesignSave(string data, int id = 0) { JavaScriptSerializer js = new JavaScriptSerializer(); //实例化一个能够序列化数据的类 TableDesignModel myModel = js.Deserialize <TableDesignModel>(data); ScadaTableRowsModel model = new ScadaTableRowsModel(); model.Id = 0; model.TableId = id; model.CreateTime = DateTime.Now; model.CreateUserId = Operator.UserId; model.UpdateTime = DateTime.Now; model.UpdateUserId = Operator.UserId; model.FieldBackColors = js.Serialize(myModel.backcolor); model.FieldColors = js.Serialize(myModel.fontcolor); model.FieldFontSizes = js.Serialize(myModel.fontsize); model.FieldWeights = js.Serialize(myModel.fontweight); model.FieldIOPaths = js.Serialize(myModel.data); var rowModes = TableRowService.GetByWhere("where TableId=" + id); var result = "保存失败"; if (rowModes.Count() > 0) { var TableModel = TableService.GetById(id); if (TableModel != null) { TableModel.ColimnWidths = myModel.columnwidth; TableModel.ColumnTitles = myModel.columntitle; TableService.UpdateById(TableModel); } model.Id = rowModes.First().Id; result = TableRowService.UpdateById(model) ? "保存设计成功" : "保存失败"; } else { var TableModel = TableService.GetById(id); if (TableModel != null) { TableModel.ColimnWidths = myModel.columnwidth; TableModel.ColumnTitles = myModel.columntitle; TableService.UpdateById(TableModel); model.Id = 0; model.TableId = TableModel.Id; result = TableRowService.Insert(model) ? "保存设计成功" : "保存失败"; } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult GetExcelData(int id = 0) { var rowModes = TableRowService.GetByWhere("where TableId=" + id); List <ExcelModel> models = new List <ExcelModel>(); List <List <string> > backcolormodels = new List <List <string> >(); List <List <string> > fontcolormodels = new List <List <string> >(); List <List <string> > fontsizemodels = new List <List <string> >(); List <List <string> > fontweightmodels = new List <List <string> >(); for (int i = 0; i < 100; i++) { models.Add(new ExcelModel()); } for (int i = 0; i < 100; i++) { List <string> row = new List <string>(); for (int j = 0; j < 26; j++) { row.Add("#ffffff"); } backcolormodels.Add(row); } for (int i = 0; i < 100; i++) { List <string> row = new List <string>(); for (int j = 0; j < 26; j++) { row.Add("#000000"); } fontcolormodels.Add(row); } for (int i = 0; i < 100; i++) { List <string> row = new List <string>(); for (int j = 0; j < 26; j++) { row.Add("120"); } fontsizemodels.Add(row); } for (int i = 0; i < 100; i++) { List <string> row = new List <string>(); for (int j = 0; j < 26; j++) { row.Add("normal"); } fontweightmodels.Add(row); } ScadaTableRowsModel rowmodel = null; if (rowModes.Count() > 0) { rowmodel = rowModes.First(); } if (rowmodel != null) { try { JavaScriptSerializer js = new JavaScriptSerializer(); //实例化一个能够序列化数据的类 backcolormodels = js.Deserialize <List <List <string> > >(rowmodel.FieldBackColors); fontcolormodels = js.Deserialize <List <List <string> > >(rowmodel.FieldColors); fontsizemodels = js.Deserialize <List <List <string> > >(rowmodel.FieldFontSizes); models = js.Deserialize <List <ExcelModel> >(rowmodel.FieldIOPaths); fontweightmodels = js.Deserialize <List <List <string> > >(rowmodel.FieldWeights); } catch { } } var result = Pager.ExcelPaging(models, backcolormodels, fontcolormodels, fontsizemodels, fontweightmodels, null, 100); return(Json(result, JsonRequestBehavior.AllowGet)); }