private void testingButton_Click(object sender, EventArgs e) { fileStatistics newFile = new fileStatistics("File path 1."); controlObj.addFileStat(newFile); addRowToViewTable(newFile); }
public void replaceFileStat(fileStatistics file) { int foundPackageID = getPackageId(file.getPackageName()); int foundClassID = getClassId(file.getClassName()); String sql = String.Format(updateFileStatPrefix, statsTable, uniqueKeywords, file.getUniqueKeywords(), uniqueUDIs, file.getUniqueUdis(), uniqueConstants, file.getUniqueConstants(), uniqueSpecialChars, file.getUniqueSpecialChars(), totalKeywords, file.getTotalKeywords(), totalUDIs, file.getTotalUdis(), totalConstants, file.getTotalConstants(), totalSpecialChars, file.getTotalSpecialChars(), totalChars, file.getTotalChars(), totalWhiteSpace, file.getTotalWhiteSpace(), totalComments, file.getTotalCommentChars(), percentWhitespace, file.getTotalWhiteSpace(), percentComments, file.getPercentCommentsChars(), filePath, file.getFilepath(), packageID, foundPackageID, classID, foundClassID); Console.WriteLine("Sql String: " + sql); executeSqlNonQuery(sql); }
public void addFileStat(fileStatistics file) { int foundPackageID = getPackageId(file.getPackageName()); int foundClassID = getClassId(file.getClassName()); if (foundPackageID > 0 && foundClassID > 0) { String sql = String.Format(insertFileStatPrefix, statsTable, packageID, classID, uniqueKeywords, uniqueUDIs, uniqueConstants, uniqueSpecialChars, totalKeywords, totalUDIs, totalConstants, totalSpecialChars, totalChars, totalWhiteSpace, totalComments, percentWhitespace, percentComments, filePath, foundPackageID, foundClassID, file.getUniqueKeywords(), file.getUniqueUdis(), file.getUniqueConstants(), file.getUniqueSpecialChars(), file.getTotalKeywords(), file.getTotalUdis(), file.getTotalConstants(), file.getTotalSpecialChars(), file.getTotalChars(), file.getTotalWhiteSpace(), file.getTotalCommentChars(), file.getPercentWhitespace(), file.getPercentCommentsChars(), file.getFilepath()); Console.WriteLine("Sql String: " + sql); executeSqlNonQuery(sql); } else { Console.WriteLine("ERROR in addFileStat: Package or Class ID are invalid."); } }
public void addFileStat(fileStatistics file) { if (db.doesPackageExist(file.getPackageName()) == false && db.doesClassExist(file.getClassName()) == false) { //entry does not exists b/c its class and package don't exist. db.addPackage(file.getPackageName()); db.addClass(file.getClassName()); db.addFileStat(file); gui.setPackageDDSelection(file.getPackageName()); gui.setClassDDSelection(file.getClassName()); gui.populatePackageDD(file.getClassName()); gui.populateClassDD(file.getPackageName()); gui.rePopulateTable(file); } else if (db.doesPackageExist(file.getPackageName()) == true && db.doesClassExist(file.getClassName()) == false) { db.addClass(file.getClassName()); db.addFileStat(file); gui.setPackageDDSelection(file.getPackageName()); gui.setClassDDSelection(file.getClassName()); gui.populatePackageDD(file.getClassName()); gui.populateClassDD(file.getPackageName()); gui.rePopulateTable(file); } else if (db.doesPackageExist(file.getPackageName()) == false && db.doesClassExist(file.getClassName()) == true) { db.addPackage(file.getPackageName()); db.addFileStat(file); gui.setPackageDDSelection(file.getPackageName()); gui.setClassDDSelection(file.getClassName()); gui.populatePackageDD(file.getClassName()); gui.populateClassDD(file.getPackageName()); gui.rePopulateTable(file); } else //both package and class exist, duplicate DB entry { Boolean askUser = gui.askUserAboutDuplicate(); if (askUser == true) { db.replaceFileStat(file); gui.setPackageDDSelection(file.getPackageName()); gui.setClassDDSelection(file.getClassName()); gui.populatePackageDD(file.getClassName()); gui.populateClassDD(file.getPackageName()); gui.rePopulateTable(file); } } }
private void mainMenuFileImport_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Multiselect = true; DialogResult userSelection = openFile.ShowDialog(); if (userSelection == DialogResult.OK) { String [] filesSelected = openFile.FileNames; for (int i = 0; i < filesSelected.Length; i++) { fileContentsTextBox.Text += filesSelected[i] + "\n"; fileStatistics newFile = new fileStatistics(filesSelected[i]); controlObj.addFileStat(newFile); } } }
public void addRowToViewTable(fileStatistics file) { this.statsViewTable.Rows.Add( file.getPackageName(), file.getClassName(), file.getUniqueKeywords(), file.getUniqueUdis(), file.getUniqueConstants(), file.getUniqueSpecialChars(), file.getTotalKeywords(), file.getTotalUdis(), file.getTotalConstants(), file.getTotalSpecialChars(), file.getTotalChars(), file.getTotalWhiteSpace(), file.getTotalCommentChars(), file.getPercentWhitespace(), file.getPercentCommentsChars(), file.getFilepath()); }
//overload for rePopulateTable public void rePopulateTable(fileStatistics file) { statsViewTable.Rows.Clear(); addRowToViewTable(file); }
public void updateRowInViewTable(fileStatistics file) { removeRowFromViewTable(file.getPackageName(), file.getClassName()); addRowToViewTable(file); }
public List <fileStatistics> getFileStatsForPackageClass(String pckName, String clsName) { List <fileStatistics> results = new List <fileStatistics>(); int pckID = getPackageId(pckName); int clsID = getClassId(clsName); String sql = String.Format("SELECT * FROM {0} WHERE {1} = {2} AND {3} = {4} ORDER BY {1}", statsTable, packageID, pckID, classID, clsID); Console.WriteLine("Sql String: " + sql); using (var connection = new SQLiteConnection(getConnectionString())) { var command = new SQLiteCommand(sql, connection); try { connection.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { Console.WriteLine("Results: " + reader.GetInt32(0) + " | " + reader.GetInt32(1) + " | " + reader.GetInt32(2) + " | " + reader.GetInt32(3) + " | " + reader.GetInt32(4) + " | " + reader.GetInt32(5) + " | " + reader.GetInt32(6) + " | " + reader.GetInt32(7) + " | " + reader.GetInt32(8) + " | " + reader.GetInt32(9) + " | " + reader.GetInt32(10) + " | " + reader.GetInt32(11) + " | " + reader.GetInt32(12) + " | " + reader.GetFloat(13) + " | " + reader.GetFloat(14) + " | " + reader.GetString(15)); fileStatistics temp = new fileStatistics( getPackageName(reader.GetInt32(0)), getClassName(reader.GetInt32(1)), reader.GetInt32(2), reader.GetInt32(3), reader.GetInt32(4), reader.GetInt32(5), reader.GetInt32(6), reader.GetInt32(7), reader.GetInt32(8), reader.GetInt32(9), reader.GetInt32(10), reader.GetInt32(11), reader.GetInt32(12), reader.GetFloat(13), reader.GetFloat(14), reader.GetString(15)); results.Add(temp); } connection.Close(); return(results); } } catch (Exception e) { Console.WriteLine("Error in getStatsForPackageClass functiion.\n" + e.ToString()); return(null); } } }