Exemple #1
0
        public void CreateBulkOfMatches(List<IMatch> matches)
        {
            if (matches == null)
                throw new ArgumentNullException("matches");

            // Get the overall batch identification from the Mediator.
            IBatch batchId = ProxyHome.Instance.RetrieveExecutionIdentification(DataAccessKeyKeeper.Instance.AccessKey);

            using (CodeAnalyzerContainer ctx = new CodeAnalyzerContainer())
            {
                Model.Batch batch = new Model.Batch { TimeStamp = batchId.TimeStamp };

                foreach (IMatch match in matches)
                {
                    // Mapping: Domain Model => Entity Model.
                    Model.Match m = new Model.Match()
                    {
                        LineNumber        = match.LineNumber,
                        CodeExtract       = match.CodeExtract,
                        RootDirectoryPath = match.RootDirectoryPath,
                        Filename          = match.Filename,
                        Batch             = batch,
                        Status            = (int)match.Result,
                        RuleDeclaration   = ToEntityModelMapper.RuleDeclarationMapper(match.RuleDeclarationRef, ctx),
                    };

                    // Do the actual DB update.
                    ctx.Match.Add(m);
                }
                ctx.SaveChanges();
            }
        }
 public static Model.Batch BatchMapper(IBatch batch, CodeAnalyzerContainer context)
 {
     Model.Batch modelBatch = context.Batch.SingleOrDefault(b => b.Id == batch.Id);
     if (modelBatch == null)
     {
         return new Model.Batch {
                    TimeStamp = batch.TimeStamp
         }
     }
     ;
     return(modelBatch);
 }
Exemple #3
0
        public void CreateBulkOfMatches(List <IMatch> matches)
        {
            if (matches == null)
            {
                throw new ArgumentNullException("matches");
            }

            // Get the overall batch identification from the Mediator.
            IBatch batchId = ProxyHome.Instance.RetrieveExecutionIdentification(DataAccessKeyKeeper.Instance.AccessKey);

            using (CodeAnalyzerContainer ctx = new CodeAnalyzerContainer())
            {
                Model.Batch batch = new Model.Batch {
                    TimeStamp = batchId.TimeStamp
                };

                foreach (IMatch match in matches)
                {
                    // Mapping: Domain Model => Entity Model.
                    Model.Match m = new Model.Match()
                    {
                        LineNumber        = match.LineNumber,
                        CodeExtract       = match.CodeExtract,
                        RootDirectoryPath = match.RootDirectoryPath,
                        Filename          = match.Filename,
                        Batch             = batch,
                        Status            = (int)match.Result,
                        RuleDeclaration   = ToEntityModelMapper.RuleDeclarationMapper(match.RuleDeclarationRef, ctx),
                    };

                    // Do the actual DB update.
                    ctx.Match.Add(m);
                }
                ctx.SaveChanges();
            }
        }