/// <summary> /// Generate KLOC report document /// </summary> /// <param name="workbook">Workbook name</param> /// <param name="sheetName">Sheet Name</param> /// <param name="reason">Reason for change</param> /// <returns></returns> /// 2019/07/13, Vinoth N, Initial Version private void PrepareKLOCReport(Excel.Workbook workbook, string sheetName, string reason) { List <string> files = new List <string>(); try { Excel.Worksheet worksheet = null; var ChangeCollection = LineCollection.Where(p => (p.AllCount > 0)).ToList(); foreach (var collecion in ChangeCollection) { collecion.ModType = "N"; } worksheet = workbook.Sheets[2]; Excel.Range usedrange = worksheet.UsedRange; usedrange.Rows.AutoFit(); var sheet = (Excel.Worksheet)workbook.Worksheets.Item[2]; try { sheet.Name = sheetName; } catch (Exception ex) { MessageBox.Show("Sheet name has unsupported format: " + sheetName + ". Please change the project name"); LogModel.Log(ex.Message); LogModel.Log(ex.StackTrace); } //Get the rows and fill the data if (worksheet.Rows != null) { int colNo = worksheet.UsedRange.Columns.Count; int rowNo = worksheet.UsedRange.Rows.Count; object[,] array = worksheet.UsedRange.Rows.Value; int rowCount = LineCollection.Count(); if (rowCount > 0) { int rowInx = 6; foreach (CounterModel lines in ChangeCollection) { //append new row RunProgressbar(ChangeCollection.IndexOf(lines) + 1, ChangeCollection.Count - 1, lines); Excel.Range line = (Excel.Range)worksheet.Rows[rowInx]; worksheet.UsedRange.Cells[rowInx, 3] = lines.FileName.ToString(); if (lines.FunctionName != null) { worksheet.UsedRange.Cells[rowInx, 4] = ParseFunctionName(lines.FunctionName.ToString()); } worksheet.UsedRange.Cells[rowInx, 7] = reason != null?reason.ToString() : ""; worksheet.UsedRange.Cells[rowInx, 6] = "-"; worksheet.UsedRange.Cells[rowInx, 5] = lines.Description != null?lines.Description.ToString() : ""; worksheet.UsedRange.Cells[rowInx, 8] = "-"; worksheet.UsedRange.Cells[rowInx, 9] = "-"; worksheet.UsedRange.Cells[rowInx, 12] = "-"; worksheet.UsedRange.Cells[rowInx, 13] = "-"; worksheet.UsedRange.Cells[rowInx, 12] = "N"; if (lines.IsGUI == true) { worksheet.UsedRange.Cells[rowInx, 13] = "G"; } else { worksheet.UsedRange.Cells[rowInx, 13] = "L"; } worksheet.UsedRange.Cells[rowInx, 14] = lines.AllCount; worksheet.UsedRange.Cells[rowInx, 15] = lines.AddCount; worksheet.UsedRange.Cells[rowInx, 16] = lines.ModCount; worksheet.UsedRange.Cells[rowInx, 17] = lines.DelCount; rowInx++; } } } } catch (Exception ex) { LogModel.Log(ex.Message); LogModel.Log(ex.StackTrace); throw new FileNotFoundException("Couldn't find your folder ! "); } }
/// <summary> /// Run the verification /// </summary> /// <param name="sender">Button object details</param> /// <param name="e">Event Arguments</param> /// <returns>Bind LOC count to view</returns> /// 2019/07/13, Vinoth N, Initial Version private async void Counter_Click(object sender, RoutedEventArgs e) { Clear(); DisableControls(); try { results = new GetFileDetail(); string location = t_Location.Text; string tag = t_POTag.Text; int i = 1; var count = 0; if (StartingFlag()) { if (Directory.Exists(location)) { Loadgif.Visibility = Visibility.Visible; b_Download.IsEnabled = true; counterStatus.Content = "Processing.."; counterStatus.Foreground = Brushes.Green; await Task.Run(() => results = ViewModel.StartCounter(location, tag)); if (results.JavaFunctionDetails != null) { foreach (var counter in results.JavaFunctionDetails) { Dispatcher.Invoke(() => { LineCollection.Add(new CounterModel { Total = results.JavaFunctionDetails.IndexOf(counter) + 1, FileName = counter.FileName, FunctionName = counter.FunctionName, Description = counter.Description, AllCount = counter.AllCount, AddCount = counter.AddCount, ModCount = counter.ModCount, NewCount = counter.NewCount, DelCount = counter.DelCount, Error = counter.Error, IsGUI = counter.IsGUI }); }); Dispatcher.Invoke(() => DetailCollection.Add("<<<" + counter.FunctionName + ">>>")); if (counter.FullFunctionLine != null) { foreach (var line in counter.FullFunctionLine) { Dispatcher.Invoke(() => DetailCollection.Add(line)); } } count += counter.AllCount; } } var counterValue = $"{count}"; tbk_counter.Text = counterValue; errorCount = LineCollection.Where(p => p.Error == true).Count(); FinishVerification(true); } else { b_Download.IsEnabled = false; MessageBox.Show("Location Not Found !"); } } } catch (Exception ex) { LogModel.Log(ex.Message); LogModel.Log(ex.StackTrace); } }