Esempio n. 1
0
        private static async Task RunInsertOption(InsertToTableOption insertOption)
        {
            var connectionString = insertOption.SqlConnectionString;
            var table            = insertOption.TableName;
            var csvFileName      = insertOption.StatFilePath;
            var sqlClient        = new SqlClient(connectionString);

            sqlClient.Open();
            try
            {
                await CreateTableOption(insertOption);

                int insertSucc = 0;
                foreach (var stat in LoadReportRecords.GetReportRecords(csvFileName))
                {
                    var ts = stat.Timestamp;
                    var id = Convert.ToInt64(ts);
                    var dt = Utils.ConvertFromTimestamp(ts);
                    insertSucc += sqlClient.InsertRecord(table, stat);
                }
                Console.WriteLine($"Finally successfully insert {insertSucc}");
            }
            finally
            {
                sqlClient.Close();
            }
        }
Esempio n. 2
0
        private static Task RunInsertOption(InsertToTableOption insertOption)
        {
            var connectionString = insertOption.SqlConnectionString;
            var table            = insertOption.TableName;
            var csvFileName      = insertOption.StatFilePath;
            var sqlClient        = new SqlClient(connectionString);

            sqlClient.Open();
            try
            {
                sqlClient.CreateTableIfNotExist(table);
                int insertSucc = 0;
                foreach (var stat in LoadReportRecords.GetReportRecords(csvFileName))
                {
                    var ts = stat.Timestamp;
                    var id = Convert.ToInt64(ts);
                    var dt = Utils.ConvertFromTimestamp(ts);
                    insertSucc += sqlClient.InsertRecord(
                        table,
                        $"{id}{stat.Scenario}",
                        dt,
                        stat.Scenario,
                        stat.Unit(),
                        stat.Connections,
                        stat.Sends,
                        stat.SendTPuts,
                        stat.RecvTPuts,
                        stat.Reference);
                }
                Console.WriteLine($"Finally successfully insert {insertSucc}");
            }
            finally
            {
                sqlClient.Close();
            }
            return(Task.CompletedTask);
        }