private static void fillRow(SvodDdr.DdrDataContext dc, int rowIndex, RowData totalRow, Worksheet ws, List<SourceData> sqlData) { var rowData = new RowData(); var row = (Range) ws.Rows[rowIndex]; string serviceCode = ((Range)row.Cells[1, serviceCodeColumn]).Value2.ToString(); rowData.Select(sqlData, serviceCode); rowData.Fill(ws, rowIndex); totalRow.Accumulate(rowData); }
private static void fillSection(SvodDdr.DdrDataContext dc, Worksheet ws, int minAge, int maxAge, int rowIndex, List<SourceData> sourceDataList, RowData itogLine) { foreach (var age in ddrAges.Where(x => x >= minAge && x <= maxAge)) { var lineData = new RowData(); lineData.Age = age; lineData.Select(sourceDataList, dc); lineData.Fill(dc, ws, rowIndex); itogLine.Accumulate(lineData); rowIndex++; } }
//public ContentResult Save(FormCollection Model, string Table, ListTypes ListType, string ListName) // public ContentResult Save(SaveModel Model) public ContentResult Save(string rowData, string Table, ListTypes ListType, string ListName) { RowData row = SerializationExtensions.FromJson <RowData>(rowData); row.LoadMetadata(); row.LoadMissingColumns <bool>(); SqlBuilder builder = row.Update(false, true); ResultTable result = builder.Execute(); if (result.Count == 1) { builder = row.Select(ListType != ListTypes.Custom ? ListType.ToString() : ListName); //builder = row.Metadata.ToSqlBuilder(ListType != ListTypes.Custom ? ListType.ToString() : ListName); //builder.WhereConditions = row.PrimaryKey(builder); result = builder.Execute(30, false, ResultTable.DateHandlingEnum.ConvertToDate); if (result.Count == 1) { return(Content(SerializationExtensions.ToJson <dynamic>(result.First()), "application/json")); } //// object PK = result.First().Column(mt.PrimaryKey.Columns.First().Name); //Builder.BaseTable().WithMetadata().WherePrimaryKey(new object[] { (object)PK }); //ResultTable updated = Builder.Execute(30, false, ResultTable.DateHandlingEnum.ConvertToDate); //if (updated.Count == 1) //{ // return Content(SerializationExtensions.ToJson<dynamic>(updated.First()), "application/json"); //} } //// Retrieve by Primary key //MetadataTable mt = SqlBuilder.DefaultMetadata.FindTable(Table); //List<object> PKs = new List<object>(); //foreach (MetadataColumn mc in mt.PrimaryKey.Columns) //{ // PKs.Add(Model[Table + "_" + mc.Name]); //} //// Create an empty row with the primary key set //RowData row = RowData.Create(mt, true, PKs.ToArray()); //// Change the row //foreach (string key in Model.Keys) //{ // if (!key.StartsWith("__")) // { // string ColumnName = key.Replace(Table, "").Replace("_", ""); // MetadataColumn mc; // if (mt.Columns.TryGetValue(ColumnName, out mc)) // { // if (!mc.IsReadOnly) // { // // row.Column(mc.Name, (object)Model[key]); // row.Column(mc.Name, Model[key]); // } // } // } //} //// Build SQL and update //SqlBuilder builder = row.Update(true, true); //ResultTable result = builder.Execute(30, false); //if (result.Count == 1) //{ // object PK = result.First().Column(mt.PrimaryKey.Columns.First().Name); // SqlBuilder Builder = mt.ToSqlBuilder(ListType != ListTypes.Custom ? ListType.ToString() : ListName); // Builder.BaseTable().WithMetadata().WherePrimaryKey(new object[] { (object)PK }); // ResultTable updated = Builder.Execute(30, false, ResultTable.DateHandlingEnum.ConvertToDate); // if (updated.Count == 1) // { // return Content(SerializationExtensions.ToJson<dynamic>(updated.First()), "application/json"); // } //} return(Content("")); }
/// <summary> /// Adds new rows. /// </summary> /// <param name="RowData">The row data.</param> public virtual void AddRow(params string[][] RowData) { data = data?.Concat(RowData.Select(x => new Row(this, x)))?.ToArray() ?? RowData.Select(x => new Row(this, x)).ToArray(); }