Exemplo n.º 1
0
        public static TimeSpan GetDuration(this IOptionReader reader, string name)
        {
            var value = reader.GetMilliseconds(name);

            // TODO: TBD: the "get" direction is fine. But we should be careful of the "set" direction because TimeSpan works in Double, whereas NNG works in Int32.
            return(TimeSpan.FromMilliseconds(value));
        }
Exemplo n.º 2
0
 private string ReadExportInput(IConnection sqlServer, string table, int index, IOptionReader optionMemoryFile)
 {
     var key = "TableSelection"+table;
     if (!optionMemoryFile.ContainsOption(key)){
         long count = -1;
         try{
             DataTable executeQuery = sqlServer.ExecuteQuery("Select count(*) from " + table, null);
             count = Convert.ToInt64(executeQuery.Rows[0][0]);
             Console.Out.Write("Table {0} [{1}]", table, count);
         }
         catch (Exception e){
             Log.Error("Program:ReadExportInput Could not determine table size [" + e.Message + "]");
             Console.Out.Write("Table {0} ", table);
         }
     }
     string readLine = optionMemoryFile.ReadLine(key);
     if (readLine.ToUpper() == "M"){
         DataTable sampleData = sqlServer.ExecuteQuery("Select top 5 * from " + table, null);
         foreach (DataColumn column in sampleData.Columns){
             string[] results = GetResults(sampleData, column.ColumnName).Distinct().ToArray();
             Console.Out.WriteLine("Column : {0} [{1}] ", column.ColumnName, String.Join(",", results));
         }
         return ReadExportInput(sqlServer, table, index, optionMemoryFile);
     }
     if (readLine.ToUpper() == "T")
     {
         optionMemoryFile.SaveValue(key, readLine);
         Console.Out.WriteLine("Saving to test sql");
         IBulkExporterImporter exporter = new SqlServerBulkExporterImporter(sqlServer, null);
         var filenameSql = CalculateFileName("_TD_" + Regex.Replace(table,@"[^A-z^0-9^_]","") + ".csv");
         if (!AppParam.SkipSchemaExport || !File.Exists(filenameSql))
         {
             exporter.ExportTable(table, filenameSql);
         }
         return TemplateHelper.GetTestDataTemplate(index, table, filenameSql, table);
     }
     if (readLine.ToUpper() == "S")
     {
         optionMemoryFile.SaveValue(key, readLine);
         Console.Out.WriteLine("Saving to command sql");
         IBulkExporterImporter exporter = new SqlServerBulkExporterImporter(sqlServer, null);
         var filenameSql = CalculateFileName("_Data_" + Regex.Replace(table, @"[^A-z^0-9^_]", "") + ".csv");
         if (!AppParam.SkipSchemaExport || !File.Exists(filenameSql))
         {
             exporter.ExportTable(table, filenameSql);
         }
         return TemplateHelper.GetCommandDataTemplate(index, table, filenameSql,table);
     }
     if (readLine.ToUpper() == "I")
     {
         optionMemoryFile.SaveValue(key, readLine);
         return null;
     }
     return ReadExportInput(sqlServer, table, index, optionMemoryFile);
 }
Exemplo n.º 3
0
 public MessagePipe(Message message)
 {
     Options        = PrivateOptions = new OptionReader();
     Configure(_pid = InvokeWithResult(__GetPipe, _msgPtr = message.MsgPtr));
 }