public string AddCustomerItem(CoverageItem coverageItem)
        {
            Guid itemId   = Guid.NewGuid();
            bool bChanged = false;

            try
            {
                // Try to find the item
                var itemExisting = _dbContext.CoverageItems
                                   .Where(item => item.CategoryId == coverageItem.CategoryId &&
                                          item.Value == coverageItem.Value &&
                                          string.Compare(item.Name, coverageItem.Name, true) == 0)
                                   .FirstOrDefault();

                if (itemExisting != null)
                {
                    itemId = itemExisting.ItemId;
                }
                else
                {
                    bChanged = true;
                    // Add the new item
                    _dbContext.CoverageItems.Add(new CoverageItem
                    {
                        ItemId     = itemId,
                        Name       = coverageItem.Name,
                        Value      = coverageItem.Value,
                        CategoryId = coverageItem.CategoryId
                    });
                }

                // Duplicate check
                if (!_dbContext.CustomerItems.Any(ci => ci.ItemId == itemId))
                {
                    bChanged = true;
                    // Add the customer reference data
                    _dbContext.CustomerItems.Add(new CustomerItem
                    {
                        CustomerId = 1,
                        ItemId     = itemId
                    });
                }

                // Save if changed
                if (bChanged)
                {
                    _dbContext.SaveChanges();
                }
                else
                {
                    return("");
                }
            }
            catch
            {
                return("");
            }

            return(itemId.ToString());
        }
Ejemplo n.º 2
0
        public TreeItem(QListViewItem parent, String name, CoverageItem model) :
            base(parent, name)
        {
            this.model = model;

            FillColumns();
        }
Ejemplo n.º 3
0
        private static CoverageItem AddResultItem(Dictionary <string, CoverageItem> items, CodeItemKind itemKind, string itemPath, Summary summary, string displayName = null)
        {
            var nameParts  = itemPath.SplitPath(false);
            var parentName = string.Join(".", nameParts.Take(nameParts.Length - 1)).TrimEnd('.'); //Remove dot for .ctor and .cctor
            var itemName   = nameParts[nameParts.Length - 1];

            CoverageItem parent;

            if (!items.TryGetValue(parentName, out parent))
            {
                if (parentName.EndsWith("." + _anonymousGroupName) || parentName == _anonymousGroupName)
                {
                    parent = AddResultItem(items, CodeItemKind.Group, parentName, new Summary());
                }
                else if (itemKind == CodeItemKind.Method)
                {
                    parent = AddResultItem(items, CodeItemKind.Class, parentName, new Summary());
                }
                else
                {
                    parent = AddResultItem(items, CodeItemKind.Namespace, parentName, new Summary());
                }
            }

            var item = new CoverageItem(parent, itemName, itemKind, summary, displayName);

            //Methods cannot be a parent so adding them is unnecessary - also overloads would result in key already exists exceptions
            if (itemKind != CodeItemKind.Method)
            {
                items.Add(itemPath, item);
            }
            return(item);
        }
Ejemplo n.º 4
0
		public TreeItem (TreeStore store, TreeItem parent, CoverageItem model, string title) {
			this.store = store;
			this.parent = parent;
			this.model = model;

			if (parent == null)
				iter = store.AppendValues (title);
			else
				iter = store.AppendValues (parent.Iter, title);
			FillColumns ();
		}
Ejemplo n.º 5
0
            public TreeItem(TreeStore store, TreeItem parent, CoverageItem model, string title)
            {
                this.store  = store;
                this.parent = parent;
                this.model  = model;

                if (parent == null)
                {
                    iter = store.AppendValues(title);
                }
                else
                {
                    iter = store.AppendValues(parent.Iter, title);
                }
                FillColumns();
            }
 private void Update(CoverageItem resultSolution)
 {
     if (resultSolution != null)
     {
         if (ResultSolution == null)
         {
             ResultSolution = new CoverageItemViewModel(null, resultSolution);
         }
         else
         {
             ResultSolution.UpdateItem(resultSolution);
         }
     }
     else
     {
         ResultSolution = null;
     }
 }
Ejemplo n.º 7
0
        private void ContextMenuDelete(object sender, RoutedEventArgs e)
        {
            CoverageItem item = this.coverageFiles.SelectedItem as CoverageItem;

            try
            {
                if (System.IO.File.Exists(item.RealPath))
                {
                    System.IO.File.Delete(item.RealPath);
                }
            }
            catch (System.IO.IOException)
            {
                MessageBox.Show("Impossible to delete file: " + item.RealPath);
            }

            coverageFiles.Items.Remove(item);
        }
Ejemplo n.º 8
0
 public MethodItem(QListViewItem parent, String name, CoverageItem model)
     : base(parent, name, model)
 {
 }
Ejemplo n.º 9
0
        private static CoverageItem GetCoverage(CoverageSession report)
        {
            if (report == null)
            {
                return(null);
            }

            var solutionResult = new CoverageItem(null, Resources.Assemblies, CodeItemKind.Solution);

            foreach (var moduleReport in report.Modules)
            {
                if (!moduleReport.Classes.Any())
                {
                    continue;
                }

                var projectResult = new CoverageItem(solutionResult, moduleReport.ModuleName, CodeItemKind.Project);
                var results       = new Dictionary <string, CoverageItem>()
                {
                    { "", projectResult }
                };

                foreach (var classReport in moduleReport.Classes)
                {
                    if (classReport.Methods.Length == 0)
                    {
                        continue;
                    }
                    var classResult = AddResultItem(results, CodeItemKind.Class,
                                                    PreparePath(classReport.FullName), classReport.Summary ?? new Summary());

                    foreach (var methodReport in classReport.Methods)
                    {
                        if (methodReport.SequencePoints.Length == 0)
                        {
                            continue;
                        }

                        var sourceFile = methodReport.FileRef != null?moduleReport.Files.Where(p => p.Id == methodReport.FileRef.Id).Select(p => p.FullPath).FirstOrDefault() : null;

                        var sourceLine = methodReport.SequencePoints.Select(p => p.StartLine).FirstOrDefault();

                        var methodNameMatch = _methodNameRegex.Match(methodReport.Name);
                        if (!methodNameMatch.Success)
                        {
                            continue;
                        }

                        var returnType   = methodNameMatch.Groups["returnType"].Value;
                        var methodName   = methodNameMatch.Groups["methodName"].Value;
                        var argumentList = methodNameMatch.Groups["argumentList"].Value;

                        var name         = $"{methodName}({argumentList}) : {returnType}";
                        var methodResult = AddResultItem(results, CodeItemKind.Method,
                                                         PreparePath(classResult.FullName + "." + methodName.Replace(".", "-")), methodReport.Summary ?? new Summary(), name);
                        methodResult.SourceFile = sourceFile;
                        methodResult.SourceLine = sourceLine;
                    }

                    var firstSource = classResult.Children
                                      .Where(p => p.SourceFile != null)
                                      .OrderBy(p => p.SourceLine)
                                      .FirstOrDefault();
                    if (firstSource != null)
                    {
                        classResult.SourceFile = firstSource.SourceFile;
                        classResult.SourceLine = firstSource.SourceLine;
                    }
                }
            }

            return(solutionResult);
        }
Ejemplo n.º 10
0
 public string Add([FromBody] CoverageItem item)
 {
     return(_service.AddCustomerItem(item));
 }
Ejemplo n.º 11
0
        public TreeItem(QListView parent, String name, CoverageItem model)
            : base(parent, name)
        {
            this.model = model;

            FillColumns ();
        }
Ejemplo n.º 12
0
 public MethodItem(QListViewItem parent, String name, CoverageItem model) :
     base(parent, name, model)
 {
 }
Ejemplo n.º 13
0
 public NamespaceItem(QListViewItem parent, String name, CoverageItem model) :
     base(parent, name, model)
 {
 }
Ejemplo n.º 14
0
		public ClassItem (TreeStore store, TreeItem parent, CoverageItem model, string title)
			: base (store, parent, model, title)
		{
		}
Ejemplo n.º 15
0
		public MethodItem (TreeStore store, TreeItem parent, ClassItem parent_class, CoverageItem model, string title)
			: base (store, parent, model, title)
		{
			ParentClass = parent_class;
		}
Ejemplo n.º 16
0
 public NamespaceItem(QListViewItem parent, String name, CoverageItem model)
     : base(parent, name, model)
 {
 }
Ejemplo n.º 17
0
 public ClassItem(TreeStore store, TreeItem parent, CoverageItem model, string title)
     : base(store, parent, model, title)
 {
 }
Ejemplo n.º 18
0
 public MethodItem(TreeStore store, TreeItem parent, ClassItem parent_class, CoverageItem model, string title)
     : base(store, parent, model, title)
 {
     ParentClass = parent_class;
 }