Пример #1
0
        public static EventCSV ExtractEventsFromCSV(FileInfo fi, string TraceIDcolumn, string ActivityIDcolumn, string LabelColumn, string DateColumn)
        {
            EventCSV csv = new EventCSV();

            try {
                StreamReader stream = new StreamReader(fi.FullName);
                bool         first  = true;
                while (!stream.EndOfStream)
                {
                    string        line   = stream.ReadLine();
                    List <string> values = line.Split(';').ToList();
                    if (!first)
                    {
                        Event ev = new Event(csv.Columns, values, TraceIDcolumn, ActivityIDcolumn, LabelColumn, DateColumn);
                        csv.Events.Add(ev);
                    }
                    else
                    {
                        csv.Columns.AddRange(values);
                        first = false;
                    }
                }
                stream.Close();

                csv.TraceIDColumn    = TraceIDcolumn;
                csv.ActivityIDColumn = ActivityIDcolumn;
                csv.LabelColumn      = LabelColumn;
                csv.DateColumn       = DateColumn;
                return(csv);
            } catch (Exception e) {
                Diagnostics.Error(e.Message);
                return(null);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            List <FileInfo> csvfiles = EventCSV.FindCSVs(4);

            if (csvfiles == null)
            {
                Interface.WriteLine("No csv files found at a depth of 3 from .exe");
                Interface.Wait();
                return;
            }

            Interface.WriteLine("Found " + csvfiles.Count + " csv file" + (csvfiles.Count > 1 ? "s" : "") + ":", ConsoleColor.Green);
            foreach (FileInfo fi in csvfiles)
            {
                Interface.WriteLine("  - " + fi.FullName);
            }

            Tuple <string, string> credentials = GetCredentials();
            List <string>          graphs      = GetGraphIDs(credentials.Item1, credentials.Item2);

            foreach (FileInfo logfile in csvfiles)
            {
                Interface.WriteLine("Running over " + logfile.FullName, ConsoleColor.Yellow);
                EventCSV log = EventCSV.ExtractEventsFromCSV(logfile, "ID", "Event", "Title", "Date");
                foreach (string graphID in graphs)
                {
                    Interface.WriteLine("Executing on graph " + graphID, ConsoleColor.Yellow);
                    DCRGraph graph = DCRGraph.GetGraphFromServer(credentials.Item1, credentials.Item2, graphID);
                    graph.LogProgress += WriteProgress;
                    DCRGraph.ExecuteResult results = graph.ExecuteTracesInCSV(log, 5);
                    graph.LogProgress -= WriteProgress;
                    graph.WriteResult(results, logfile);
                    graph.Recover(true);
                }
                log.Events = log.Events.OrderBy(e => e.TraceID).ThenBy(e => e.Date).ToList();
                Diagnostics.Log("Writing a sorted csv back to same folder the log was found");
                log.WriteToCSV(new FileInfo(logfile.FullName.Substring(0, logfile.FullName.Length - 4) + ".scsv"));
            }
            Interface.WriteLine("Done!");
            Interface.Wait();
        }