Ejemplo n.º 1
0
 //Convert first block of code - starting at "ChangedPaths:"
 private static int ConvertBlock1(int linecount, ListClass cl, string[] lines, string[] commitprop,
                                  int noOfComms, StringBuilder cp, StringBuilder cp1)
 {
     linecount++;
     while (lines[linecount] != "" && cp.Length < 30000)
     {
         lines[linecount] = lines[linecount].Trim();
         lines[linecount] = lines[linecount].Replace(",", "");//removing any commas for csv output
         //adding " between lines to allow for multiline separation in the future
         cp.Append(string.Format($"\"{lines[linecount]}\""));
         linecount++;
     }
     if (cp.Length >= 30000)
     {
         while (lines[linecount] != "")
         {
             lines[linecount] = lines[linecount].Trim();
             cp1.Append(string.Format($"\"{lines[linecount]}\""));
             linecount++;
         }
         cl.AddItemsToList(string.Format($"{commitprop[0]}a"), commitprop[1], commitprop[2], noOfComms, cp1.ToString(),
                           string.Format($"{commitprop[0]}:Additional record - ChangedPaths cellsize_OverCapacity"));
     }
     return(linecount);
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            try
            {
                //Variables
                int linecount = 0;
                //Instantiating listclass
                ListClass cl = new ListClass();

                //Reading the file and creating an array of lines.
                string[] lines = File.ReadAllLines(filePathSrc);

                //Adding file headings
                cl.AddItemsToList("Revision_No", "Author_Name", "Date_Time", 0, "Changed_Paths", "Comments");

                while (linecount < lines.Length)
                {
                    if ((lines[linecount].LastIndexOf("-") == 71) && (linecount + 1 < lines.Length))
                    {
                        linecount++; //moving to the next line
                        string[] commitprop = ConvertLine1(lines[linecount]);
                        int      noOfComms  = GetNumber(commitprop[3]);

                        linecount++; //moving to the next line

                        //Instantiating stringbuilder objects to hold the data
                        StringBuilder cp    = new StringBuilder(); //1st changepaths object
                        StringBuilder cp1   = new StringBuilder(); //2nd changepaths object - limited cell capacity in excel
                        StringBuilder comms = new StringBuilder(); //comments object

                        if (lines[linecount].IndexOf(':') == 13)   //validating linecount is @ changedPaths:
                        {
                            linecount = ConvertBlock1(linecount, cl, lines, commitprop, noOfComms, cp, cp1);
                        }
                        else
                        {
                            cp.Append($"File format has changed_review file source: {filePathSrc}");
                            while (lines[linecount] != string.Empty && noOfComms > 0)
                            {
                                linecount++;
                            }
                        }
                        linecount++;//moving to the next line

                        //creating the comments datablock
                        ConvertBlock2(linecount, lines, noOfComms, comms);

                        //adding data to the commitList
                        cl.AddItemsToList(commitprop[0], commitprop[1], commitprop[2], noOfComms, cp.ToString(), comms.ToString());
                    }
                    else
                    {
                        linecount++;
                    }
                }
                //Write the list out to a new file "Commit-Output_datatime.csv"
                CreateCommitFile(cl.commitList);
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine($"File not found error: {filePathSrc}");
            }
        }