示例#1
0
 private void SaveMessage(string folder, string path)
 {
     Directory.CreateDirectory(folder);
     using (CsvFileWriter writer = new CsvFileWriter(path))
     {
         if (messagesListview.Items.Count != 0)
         {
             foreach (ListViewItem item in messagesListview.Items)
             {
                 writer.WriteLine(item.Text + ",");
             }
             saveDiff = true;
         }
         else
         {
             writer.WriteLine("Comparasión exitosa");
         }
     }
 }
示例#2
0
        static int Main(string[] args)
        {
            var options = new Options();

            if (!CommandLine.Parser.Default.ParseArguments(args, options))
            {
                return(4);
            }

            if (options.Args.Count != 3)
            {
                Console.Write(options.GetUsage());
                return(5);
            }

            String sinterconf  = options.Args[0];
            String infilename  = options.Args[1];
            String outfilename = options.Args[2];

            String workingDir      = Path.GetDirectoryName(sinterconf);
            String filenameBase    = Path.GetFileNameWithoutExtension(sinterconf);
            String performanceFile = Path.Combine(workingDir, filenameBase + "._time.txt");

            JArray inputsArray  = parseCSVInputs(infilename);
            JArray outputsArray = new JArray();

            List <sinter_AppError> runStatuses    = null;
            List <List <object> >  ts_byRunNumber = null;

            SinterProcess sp = new SinterProcess();

            sp.runSeries(sinterconf, null, inputsArray, options.Relaunch, options.Timelimit, ref outputsArray, ref runStatuses, ref ts_byRunNumber);

            writeOutCsv(outfilename, outputsArray);

            CsvFileWriter csvWriter    = new CsvFileWriter(performanceFile);
            string        headerString = "Open Time, Sinter Sent Time, Send Time, Run Time, Receive Time, Sinter Recieve Time";

            csvWriter.WriteLine(headerString);

            for (int ii = 0; ii < inputsArray.Count; ++ii)
            {
                csvWriter.WriteRow((List <object>)ts_byRunNumber[ii]);
            }
            csvWriter.Close();

            Console.WriteLine("FINISHED. PRESS ENTER KEY TO EXIT PROGRAM.");
            Console.ReadLine();
            return(0);
        }
示例#3
0
        /// <summary>
        /// Main
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        static int Main(string[] args)
        {
            var options = new Options();

            if (!CommandLine.Parser.Default.ParseArguments(args, options))
            {
                return(4);
            }

            if (options.Args.Count != 3)
            {
                Console.Write(options.GetUsage());
                return(5);
            }

            String sinterconf  = options.Args[0];
            String infilename  = options.Args[1];
            String outfilename = options.Args[2];

            String workingDir      = Path.GetDirectoryName(sinterconf);
            String filenameBase    = Path.GetFileNameWithoutExtension(sinterconf);
            String performanceFile = Path.Combine(workingDir, filenameBase + "._time.txt");

            StreamReader inStream = new StreamReader(infilename);

            //So, at the end of this we should have 1 or more input sets in the JArray inputsArray
            //The console version reads in json, the actual version just pulls the dictionary from the database
            string injson       = "";
            JToken inputJToken  = null;
            JArray inputsArray  = null; //Will be set if the input file is a set of runs
            JArray outputsArray = new JArray();

            try
            {
                injson      = inStream.ReadToEnd();
                inputJToken = JToken.Parse(injson);
                if (inputJToken is JArray)
                {
                    inputsArray = (JArray)inputJToken;
                }
                else if (inputJToken is JObject)
                {   //Console Sinter is expecting a JArray in the same format as the Gateway takes.  [ { Input = {...} }, { { Inputs = {...} } ]
                    inputsArray = new JArray();
                    JObject singleInputDict = (JObject)inputJToken;
                    JObject outterDict      = new JObject();
                    outterDict.Add("inputs", singleInputDict);
                    inputsArray.Add(outterDict);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception while running simulation: " + ex.Message);
            }
            finally
            {
                inStream.Close();
            }


            List <sinter_AppError> runStatuses    = null;
            List <List <object> >  ts_byRunNumber = null;

            //
            // NOTE: Implementation Detail WORKING DIRECTORY MUST CONTAIN SinterConfig File
            //
            SinterProcess sp = new SinterProcess();

            sp.runSeries(sinterconf, null, inputsArray,
                         options.Relaunch, options.Timelimit, ref outputsArray, ref runStatuses, ref ts_byRunNumber);

            JsonSerializerSettings jss = new JsonSerializerSettings();

            jss.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            string       jsonOutput = JsonConvert.SerializeObject(outputsArray, Formatting.Indented, jss);
            StreamWriter outStream  = new StreamWriter(outfilename);

            outStream.WriteLine(jsonOutput);
            outStream.Close();

            CsvFileWriter csvWriter    = new CsvFileWriter(performanceFile);
            string        headerString = "Open Time, Sinter Sent Time, Send Time, Run Time, Receive Time, Sinter Recieve Time";

            csvWriter.WriteLine(headerString);

            for (int ii = 0; ii < inputsArray.Count; ++ii)
            {
                csvWriter.WriteRow((List <object>)ts_byRunNumber[ii]);
            }
            csvWriter.Close();

            Console.WriteLine("FINISHED. PRESS ENTER KEY TO EXIT PROGRAM.");
            Console.ReadLine();
            return(0);
        }