Ejemplo n.º 1
0
        /// <summary>
        /// Get KLOC Details
        /// </summary>
        /// <param name="Location">Project source loaction details</param>
        /// <param name="poTag">Tag Name</param>
        /// <returns>Return LOC count</returns>
        /// 2019/07/13, Vinoth N,  Initial Version
        public static GetFileDetail StartCounter(string location, string poTag)
        {
            var output = new GetFileDetail();

            try
            {
                List <FileDetail>         collectionCSharp     = new List <FileDetail>();
                List <JavaFunctionDetail> collectionJava       = new List <JavaFunctionDetail>();
                List <string>             _excludedDirectories = new List <string>()
                {
                    "without_tag"
                };
                var filteredDirs = Directory.GetDirectories(location).Where(d => !IsExcluded(_excludedDirectories, d));
                foreach (var dir in filteredDirs)
                {
                    var items = Directory.GetFiles(dir, "*", SearchOption.AllDirectories).Where(name => name.EndsWith(".java") || name.EndsWith(".js"));
                    foreach (var item in items)
                    {
                        var result = GetLOCDetails(item, location);
                        if (result.Count > 0)
                        {
                            foreach (var res in result)
                            {
                                collectionJava.Add(new JavaFunctionDetail
                                {
                                    FileName         = res.FileName.Replace(location + @"\", String.Empty),
                                    Description      = res.Description,
                                    FunctionName     = res.FunctionName,
                                    BodyLine         = res.BodyLine,
                                    HeaderLine       = res.HeaderLine,
                                    AllCount         = res.AllCount,
                                    NewCount         = res.NewCount,
                                    ModCount         = res.ModCount,
                                    AddCount         = res.AddCount,
                                    DelCount         = res.DelCount,
                                    Error            = res.Error,
                                    FullFunctionLine = res.FullFunctionLine,
                                    ErrorLine        = res.ErrorLine,
                                    IsGUI            = res.IsGUI
                                });
                            }
                        }
                        RemoveComments(item, location);
                    }
                }
                output.JavaFunctionDetails = collectionJava.ToList();
            }
            catch (Exception ex)
            {
                LogModel.Log(ex.Message);
                LogModel.Log(ex.StackTrace);
            }
            return(output);
        }
Ejemplo n.º 2
0
        /// <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);
            }
        }