public static void MultipleDataSets(string strSQL) { DataSetSerialization ser = new DataSetSerialization(); using (System.Data.Common.DbDataReader dr = SQL.ExecuteReader(strSQL , System.Data.CommandBehavior.CloseConnection | System.Data.CommandBehavior.SequentialAccess ) ) { Table tbl = null; do { tbl = new Table(); for (int i = 0; i < dr.FieldCount; ++i) { tbl.Columns.Add( new ColumnInfo() { ColumnName = dr.GetName(i), FieldType = dr.GetFieldType(i) } ); } // Next i if (dr.HasRows) { while (dr.Read()) { object[] thisRow = new object[dr.FieldCount]; for (int i = 0; i < dr.FieldCount; ++i) { thisRow[i] = dr.GetValue(i); } // Next i tbl.Rows.Add(thisRow); } // Whend } // End if (dr.HasRows) ser.Tables.Add(tbl); } while (dr.NextResult()); } // End Using dr string str = EasyJSON.JsonHelper.SerializePretty(ser); System.Console.WriteLine(str); DataSetSerialization ser2 = EasyJSON.JsonHelper.Deserialize <DataSetSerialization>(str); System.Console.WriteLine(ser2); } // End Sub MultipleDataSets
public static void DeserializeMultipleLargeDataSets(HttpContext context) { bool debug = true; string input = null; DataSetSerialization thisDataSet = null; if (context.Request.InputStream != null) { using (System.IO.StreamReader sr = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding)) { if (debug) { input = sr.ReadToEnd(); } if (context.Request.InputStream.CanSeek) { context.Request.InputStream.Position = 0; } // WARNING: Positioning thisDataSet outside the using-clause would dispose of the inputstream on debug=true... thisDataSet = Deserialize <DataSetSerialization>(sr); } // End Using sr } // End if (context.Request.InputStream != null) System.Console.WriteLine(input); System.Console.WriteLine(thisDataSet); context.Response.Write("SUCCESS"); if (!string.IsNullOrEmpty(context.Request.ContentType)) { context.Response.Write("\r\nClient data content type " + context.Request.ContentType); } } // End Sub DeserializeMultipleLargeDataSets
public void FunctionsShouldHaveExpectedSignatures(NamespaceSymbol @namespace) { var knownOverloads = @namespace.Type.MethodResolver.GetKnownFunctions().Values .SelectMany(function => function.Overloads) .OrderBy(overload => overload.Name) .Select(Convert); var actual = JToken.FromObject(knownOverloads, DataSetSerialization.CreateSerializer()); var actualLocation = FileHelper.SaveResultFile(this.TestContext, $"{this.TestContext.TestName}_{@namespace.Name}.json", actual.ToString(Formatting.Indented)); var fileName = $"{@namespace.Name}.json"; var expectedStr = DataSets.Functions.TryGetValue(fileName); if (expectedStr == null) { throw new AssertFailedException($"The function baseline file for namespace '{@namespace.Name}' does not exist."); } var expected = JToken.Parse(expectedStr); var expectedPath = Path.Combine("src", "Bicep.Core.Samples", "Files", DataSet.TestFunctionsDirectory, fileName); actual.Should().EqualWithJsonDiffOutput(TestContext, expected, expectedPath, actualLocation); }
public static void MultipleLargeDataSets() { System.Net.Http.HttpMethod meth = System.Net.Http.HttpMethod.Post; string fn = "lobster.json.txt"; using (System.IO.Stream strm = new System.IO.FileStream(fn, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None)) { MultipleLargeDataSets(strm, GetMultipleDataSetsSQL()); } // End Using strm string endpointUrl = "http://localhost:53417/ajax/dataReceiver.ashx"; using (System.Net.WebClient client = new System.Net.WebClient()) { client.Headers.Add("Content-Type", "application/json"); // client.OpenWriteCompleted += (sender, e) => client.OpenWriteCompleted += delegate(object sender, System.Net.OpenWriteCompletedEventArgs e) { // System.Net.WebClient that = (System.Net.WebClient) sender; if (e.Error != null) { throw e.Error; } using (System.IO.Stream postStream = e.Result) { MultipleLargeDataSets(postStream, GetMultipleDataSetsSQL()); postStream.Flush(); postStream.Close(); } }; client.OpenWriteAsync(new System.Uri(endpointUrl)); using (System.IO.Stream postStream = client.OpenWrite(endpointUrl, meth.Method)) { // postStream.Write(fileContent, 0, fileContent.Length); MultipleLargeDataSets(postStream, GetMultipleDataSetsSQL()); } // End Using postStream using (System.IO.Stream postStream = client.OpenRead(endpointUrl)) { using (System.IO.StreamReader sr = new System.IO.StreamReader(postStream)) { string output = sr.ReadToEnd(); System.Console.WriteLine(output); } // End Using sr } // End Using postStream // client.ResponseHeaders } // End Using client DataSetSerialization thisDataSet = EasyJSON.JsonHelper.DeserializeFromFile <DataSetSerialization>(fn); System.Console.WriteLine(thisDataSet); } // End Sub MultipleLargeDataSets