Пример #1
0
        public void NewBudgets()
        {
            //Arrange
            ProjectionContext projectionContext = new ProjectionContext();
            SapDataContext    sapDataContext    = new SapDataContext();
            Check             check             = new Check(projectionContext, sapDataContext);
            SessionViewModel  sessionView       = new SessionViewModel();
            //Act
            IEnumerable <ProjectionViewModel> newBudgets = check.NewBudgets(sessionView);

            if (String.IsNullOrEmpty(newBudgets.ToString()))
            {
                //Assert
                projectionContext.Dispose();
                sapDataContext.Dispose();
                Assert.Inconclusive("Inconcluso: La lista no pudo traer ningun dato");
            }
            else
            {
                //Assert
                projectionContext.Dispose();
                sapDataContext.Dispose();
                Assert.IsNotNull(newBudgets, "La lista falló en traer datos");
            }
        }
Пример #2
0
 public IEnumerable <IUserResult> GetAll()
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         return(context.Users.ToList().Select(a => new UserResult(a)));
     }
 }
Пример #3
0
 public bool Exists(Guid companyId)
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         return(context.Companies.Any(a => a.CompanyId == companyId));
     }
 }
Пример #4
0
 public IEnumerable <ICompanyResult> GetAll()
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         return(context.Companies.Where(a => a.Removed == false).ToList().Select(a => new CompanyResult(a)));
     }
 }
Пример #5
0
 public void Handle(NotificationRemoved @event)
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         context.Database.ExecuteSqlCommand($"DELETE FROM dbo.Notification WHERE Id = '{@event.NotificationId}'");
     }
 }
Пример #6
0
 public bool Exists(string login)
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         return(context.Users.Any(a => a.Login == login));
     }
 }
 public IReadOnlyList <ITrainingResult> GetAll()
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         return(context.Trainings.Where(a => a.Removed == false).ToList().Select(entity => new TrainingResult(entity)).ToList());
     }
 }
Пример #8
0
        /// <summary>
        /// Projections require a new resolved attribute to be created multiple times
        /// This function allows us to create new resolved attributes based on a input attribute
        /// </summary>
        /// <param name="projCtx"></param>
        /// <param name="attrCtxUnder"></param>
        /// <param name="oldResolvedAttribute">
        /// For some attributes obtained from the previous projection operation, they may have a different set of traits comparing to the resolved attribute target.
        /// We would want to take the set of traits from the resolved attribute.
        /// </param>
        /// <param name="overrideDefaultName"></param>
        /// <param name="addedSimpleRefTraits"></param>
        /// <returns></returns>
        internal static ResolvedAttribute CreateNewResolvedAttribute(
            ProjectionContext projCtx,
            CdmAttributeContext attrCtxUnder,
            ResolvedAttribute oldResolvedAttribute,
            string overrideDefaultName         = null,
            List <string> addedSimpleRefTraits = null)
        {
            var targetAttr = oldResolvedAttribute.Target.Copy() as CdmAttribute;

            ResolvedAttribute newResAttr = new ResolvedAttribute(
                projCtx.ProjectionDirective.ResOpt,
                targetAttr,
                !string.IsNullOrWhiteSpace(overrideDefaultName) ? overrideDefaultName : targetAttr.GetName(), attrCtxUnder);

            targetAttr.InDocument = projCtx.ProjectionDirective.Owner.InDocument;

            newResAttr.ResolvedTraits = oldResolvedAttribute.ResolvedTraits.DeepCopy();

            if (addedSimpleRefTraits != null)
            {
                foreach (string trait in addedSimpleRefTraits)
                {
                    var tr = new CdmTraitReference(targetAttr.Ctx, trait, true, false);
                    newResAttr.ResolvedTraits = newResAttr.ResolvedTraits.MergeSet(tr.FetchResolvedTraits());
                }
            }


            return(newResAttr);
        }
 public IEnumerable <string> GetAllLocation()
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         return(context.Locations.Select(a => a.Name).ToList());
     }
 }
 public Guid?GetTrainingId(string trainingName)
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         return(context.Trainings.FirstOrDefault(a => a.Removed == false && a.Name.ToLower() == trainingName.ToLower())?.TrainingId);
     }
 }
        protected virtual async Task Create(TIdentity key, ProjectionContext context, Func <TProjection, Task> projector,
                                            Func <TProjection, bool> shouldoverwite)
        {
            await projector(await _repository.Create(context, key, shouldoverwite));

            await _repository.Commit(context, key);
        }
Пример #12
0
        private static ProjectionAttributeStateSet CreateNewProjectionAttributeStateSet(
            ProjectionContext projCtx,
            ProjectionAttributeStateSet projOutputSet,
            ResolvedAttribute newResAttrFK,
            string refAttrName)
        {
            List <ProjectionAttributeState> pasList = ProjectionResolutionCommonUtil.GetLeafList(projCtx, refAttrName);

            if (pasList != null)
            {
                // update the new foreign key resolved attribute with trait param with reference details
                ResolvedTrait reqdTrait = newResAttrFK.ResolvedTraits.Find(projCtx.ProjectionDirective.ResOpt, "is.linkedEntity.identifier");
                if (reqdTrait != null)
                {
                    CdmEntityReference traitParamEntRef = ProjectionResolutionCommonUtil.CreateForeignKeyLinkedEntityIdentifierTraitParameter(projCtx.ProjectionDirective, projOutputSet.Ctx.Corpus, pasList);
                    reqdTrait.ParameterValues.SetParameterValue(projCtx.ProjectionDirective.ResOpt, "entityReferences", traitParamEntRef);
                }

                // Create new output projection attribute state set for FK and add prevPas as previous state set
                ProjectionAttributeState newProjAttrStateFK = new ProjectionAttributeState(projOutputSet.Ctx)
                {
                    CurrentResolvedAttribute = newResAttrFK,
                    PreviousStateList        = pasList
                };

                projOutputSet.Add(newProjAttrStateFK);
            }
            else
            {
                // Log error & return projOutputSet without any change
                Logger.Error(TAG, projOutputSet.Ctx, $"Unable to locate state for reference attribute \"{refAttrName}\".", nameof(CreateNewProjectionAttributeStateSet));
            }

            return(projOutputSet);
        }
Пример #13
0
 public Guid?GetLocation(string name)
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         return(context.Locations.FirstOrDefault(a => a.Enabled && a.Name == name)?.Id);
     }
 }
Пример #14
0
 public IReadOnlyList <ILocationResult> GetAll()
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         return(context.Locations.Where(a => a.Enabled).ToList().Select(entity => new LocationResult(entity)).ToList());
     }
 }
        public async Task Then_the_projection_processed_the_next_events_as_subscription()
        {
            ProjectionManager.Start(_projection);

            _waitForProjection.WaitOne();
            _waitForProjection.Reset();
            _waitForProjection.WaitOne();
            await Task.Delay(1000);

            ProjectionManager
            .GetRegisteredProjections()
            .Should()
            .Contain(connectedProjection =>
                     connectedProjection.Name.Equals(_projection) &&
                     connectedProjection.State == ConnectedProjectionState.Subscribed);

            await PushToStream(Fixture.CreateMany <SomethingHappened>(4));

            await Task.Delay(500);

            var assertionContext = new ProjectionContext(CreateContextOptionsFor <ProjectionContext>());

            assertionContext.ProcessedEvents
            .Should()
            .ContainAll(
                PushedMessages,
                (processedMessage, message, i) => processedMessage.Position == i && processedMessage.Event == message.GetType().Name&& processedMessage.EvenTime == message.On);
        }
Пример #16
0
 public Guid GetNotificationManagerId(Guid sessionId)
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         return(context.NotificationManagers.First(a => a.SessionId == sessionId).Id);
     }
 }
 public void Handle(TrainingDeleted @event)
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         context.Database.ExecuteSqlCommand($"DELETE FROM dbo.SESSION WHERE TrainerId = '{@event.AggregateId}'");
     }
 }
 public IEnumerable <ISessionResult> GetAll(Guid trainingId)
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         return(context.Sessions.Where(a => a.TrainingId == trainingId).ToList().Select(a => new SessionResult(a)).ToList());
     }
 }
Пример #19
0
        public IEnumerable <ISeatValidatedResult> GetValidatedSeats(Guid sessionId)
        {
            using (var context = new ProjectionContext(ConnectionString.Get()))
            {
                var querie = from p in context.Seats
                             join agreement in context.Agreements on p.AssociatedAgreementId equals agreement.AgreementId
                             join contact in context.Contacts on agreement.ContactId equals contact.ContactId
                             join student in context.Students on p.StudentId equals student.StudentId into s
                             from student in s.DefaultIfEmpty()
                             join company in context.Companies on p.CompanyId equals company.CompanyId
                             where p.SessionId == sessionId && p.Status == SeatStatus.Valid //&& agreement.DocumentId.HasValue
                             select new
                {
                    p.SeatId,
                    StudentId        = student == null ? (Guid?)null : student.StudentId,
                    StudentLastname  = student == null ? string.Empty : student.Lastname,
                    StudentFirstname = student == null ? string.Empty : student.Firstname,
                    CompanyName      = company.Name,
                    company.Address,
                    company.ZipCode,
                    company.City,
                    ContactLastname  = contact.Lastname,
                    ContactFirstname = contact.Firstname,
                    contact.Telephone,
                    contact.Email,
                    Missing = p.StudentMissing,
                    p.CertificateOfAttendanceId,
                    agreement.DocumentId,
                };

                return(querie.ToList().Select(a => new SeatValidatedResult(a.SeatId, a.StudentId.Value, a.StudentLastname, a.StudentFirstname, a.CompanyName, a.ContactLastname, a.ContactFirstname, a.Telephone, a.Email, a.Missing, a.CertificateOfAttendanceId, a.DocumentId, a.Address, a.ZipCode, a.City)));
            }
        }
        /// <inheritdoc />
        internal override ProjectionAttributeStateSet AppendProjectionAttributeState(
            ProjectionContext projCtx,
            ProjectionAttributeStateSet projOutputSet,
            CdmAttributeContext attrCtx)
        {
            // Create a new attribute context for the operation
            AttributeContextParameters attrCtxOpAddAttrGroupParam = new AttributeContextParameters
            {
                under = attrCtx,
                type  = CdmAttributeContextType.OperationAddAttributeGroup,
                Name  = $"operation/index{Index}/{this.GetName()}"
            };
            CdmAttributeContext attrCtxOpAddAttrGroup = CdmAttributeContext.CreateChildUnder(projCtx.ProjectionDirective.ResOpt, attrCtxOpAddAttrGroupParam);

            // Create a new attribute context for the attribute group we will create
            AttributeContextParameters attrCtxAttrGroupParam = new AttributeContextParameters
            {
                under = attrCtxOpAddAttrGroup,
                type  = CdmAttributeContextType.AttributeDefinition,
                Name  = this.AttributeGroupName
            };
            CdmAttributeContext attrCtxAttrGroup = CdmAttributeContext.CreateChildUnder(projCtx.ProjectionDirective.ResOpt, attrCtxAttrGroupParam);

            // Create a new resolve attribute set builder that will be used to combine all the attributes into one set
            ResolvedAttributeSetBuilder rasb = new ResolvedAttributeSetBuilder();

            // Iterate through all the projection attribute states generated from the source's resolved attributes
            // Each projection attribute state contains a resolved attribute that it is corresponding to
            foreach (ProjectionAttributeState currentPAS in projCtx.CurrentAttributeStateSet.States)
            {
                // Create a copy of the resolved attribute
                ResolvedAttribute resolvedAttribute = currentPAS.CurrentResolvedAttribute.Copy();

                // Add the attribute to the resolved attribute set
                rasb.ResolvedAttributeSet.Merge(resolvedAttribute);

                // Add each attribute's attribute context to the resolved attribute set attribute context
                AttributeContextParameters AttrParam = new AttributeContextParameters
                {
                    under = attrCtxAttrGroup,
                    type  = CdmAttributeContextType.AttributeDefinition,
                    Name  = resolvedAttribute.ResolvedName
                };
                resolvedAttribute.AttCtx = CdmAttributeContext.CreateChildUnder(projCtx.ProjectionDirective.ResOpt, AttrParam);
                resolvedAttribute.AttCtx.AddLineage(currentPAS.CurrentResolvedAttribute.AttCtx);
            }

            // Create a new resolved attribute that will hold the attribute set containing all the attributes
            ResolvedAttribute resAttrNew = new ResolvedAttribute(projCtx.ProjectionDirective.ResOpt, rasb.ResolvedAttributeSet, this.AttributeGroupName, attrCtxAttrGroup);

            // Create a new projection attribute state pointing to the resolved attribute set that represents the attribute group
            ProjectionAttributeState newPAS = new ProjectionAttributeState(this.Ctx)
            {
                CurrentResolvedAttribute = resAttrNew
            };

            projOutputSet.Add(newPAS);

            return(projOutputSet);
        }
Пример #21
0
        /// <summary>
        /// Projections require a new resolved attribute to be created multiple times
        /// This function allows us to create new resolved attributes based on a input attribute
        /// </summary>
        /// <param name="projCtx"></param>
        /// <param name="attrCtxUnder"></param>
        /// <param name="targetAttr"></param>
        /// <param name="overrideDefaultName"></param>
        /// <param name="addedSimpleRefTraits"></param>
        /// <returns></returns>
        internal static ResolvedAttribute CreateNewResolvedAttribute(
            ProjectionContext projCtx,
            CdmAttributeContext attrCtxUnder,
            CdmAttribute targetAttr,
            string overrideDefaultName         = null,
            List <string> addedSimpleRefTraits = null)
        {
            ResolvedAttribute newResAttr = new ResolvedAttribute(
                projCtx.ProjectionDirective.ResOpt,
                targetAttr,
                !string.IsNullOrWhiteSpace(overrideDefaultName) ? overrideDefaultName : targetAttr.GetName(), attrCtxUnder);

            if (addedSimpleRefTraits != null)
            {
                foreach (string trait in addedSimpleRefTraits)
                {
                    if (targetAttr.AppliedTraits.Item(trait) == null)
                    {
                        targetAttr.AppliedTraits.Add(trait, true);
                    }
                }
            }

            ResolvedTraitSet resTraitSet = targetAttr.FetchResolvedTraits(projCtx.ProjectionDirective.ResOpt);

            // Create deep a copy of traits to avoid conflicts in case of parameters
            if (resTraitSet != null)
            {
                newResAttr.ResolvedTraits = resTraitSet.DeepCopy();
            }

            return(newResAttr);
        }
 public long GetNextAgreementNumber()
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         return(context.Database.SqlQuery <long>("select next value for CompteurConvention").First());
     }
 }
 public void Handle(AgreementRevoked @event)
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         context.Database.ExecuteSqlCommand($"UPDATE Seat SET AssociatedAgreementId = NULL, AgreementRevoked = 1 WHERE AssociatedAgreementId = '{@event.AggregateId}'");
     }
 }
Пример #24
0
        internal string SearchTreeTraversal(ProjectionContext pc, string val)
        {
            SearchResult result = new SearchResult();

            foreach (var top in pc.CurrentAttributeStateSet.States)
            {
                SearchStructure st = new SearchStructure();
                st = SearchStructure.BuildStructure(top, top, val, st, false, 0);
                if (st?.Result.FoundFlag == true)
                {
                    if (result.FoundFlag == false)
                    {
                        result = st.Result;
                    }
                    else if (result.FoundDepth > st?.Result.FoundDepth)
                    {
                        result = st.Result;
                    }
                    else if (result.FoundDepth == st?.Result.FoundDepth)
                    {
                        foreach (var newTops in st?.Result.Top)
                        {
                            result.Top.Add(newTops);
                        }
                    }
                }
            }

            return(result.FoundFlag ? GetResult(val, result) : string.Empty);
        }
 public IReadOnlyList <ITrainerResult> GetAll()
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         return(context.Trainers.Where(a => a.Enabled).ToList().Select(a => new TrainerResult(a)).ToList());
     }
 }
Пример #26
0
        /// <inheritdoc />
        internal override ProjectionAttributeStateSet AppendProjectionAttributeState(
            ProjectionContext projCtx,
            ProjectionAttributeStateSet projOutputSet,
            CdmAttributeContext attrCtx)
        {
            // Create a new attribute context for the operation
            AttributeContextParameters attrCtxOpExcludeAttrsParam = new AttributeContextParameters
            {
                under = attrCtx,
                type  = CdmAttributeContextType.OperationExcludeAttributes,
                Name  = $"operation/index{Index}/operationExcludeAttributes"
            };
            CdmAttributeContext attrCtxOpExcludeAttrs = CdmAttributeContext.CreateChildUnder(projCtx.ProjectionDirective.ResOpt, attrCtxOpExcludeAttrsParam);

            // Get the top-level attribute names of the attributes to exclude
            // We use the top-level names because the exclude list may contain a previous name our current resolved attributes had
            Dictionary <string, string> topLevelExcludeAttributeNames = ProjectionResolutionCommonUtil.GetTopList(projCtx, this.ExcludeAttributes);

            // Initialize a projection attribute context tree builder with the created attribute context for the operation
            ProjectionAttributeContextTreeBuilder attrCtxTreeBuilder = new ProjectionAttributeContextTreeBuilder(attrCtxOpExcludeAttrs);

            // Iterate through all the projection attribute states generated from the source's resolved attributes
            // Each projection attribute state contains a resolved attribute that it is corresponding to
            foreach (ProjectionAttributeState currentPAS in projCtx.CurrentAttributeStateSet.States)
            {
                // Check if the current projection attribute state's resolved attribute is in the list of attributes to exclude
                // If this attribute is not in the exclude list, then we are including it in the output
                if (!topLevelExcludeAttributeNames.ContainsKey(currentPAS.CurrentResolvedAttribute.ResolvedName))
                {
                    // Create the attribute context parameters and just store it in the builder for now
                    // We will create the attribute contexts at the end
                    attrCtxTreeBuilder.CreateAndStoreAttributeContextParameters(null, currentPAS, currentPAS.CurrentResolvedAttribute, CdmAttributeContextType.AttributeDefinition);

                    // Create a projection attribute state for the included attribute by creating a copy of the current state
                    // Copy() sets the current state as the previous state for the new one
                    // We only create projection attribute states for attributes that are not in the exclude list
                    ProjectionAttributeState newPAS = currentPAS.Copy();

                    projOutputSet.Add(newPAS);
                }
                else
                {
                    // The current projection attribute state's resolved attribute is in the exclude list

                    // Get the attribute name the way it appears in the exclude list
                    string excludeAttributeName = null;
                    topLevelExcludeAttributeNames.TryGetValue(currentPAS.CurrentResolvedAttribute.ResolvedName, out excludeAttributeName);

                    // Create the attribute context parameters and just store it in the builder for now
                    // We will create the attribute contexts at the end
                    attrCtxTreeBuilder.CreateAndStoreAttributeContextParameters(excludeAttributeName, currentPAS, currentPAS.CurrentResolvedAttribute, CdmAttributeContextType.AttributeDefinition);
                }
            }

            // Create all the attribute contexts and construct the tree
            attrCtxTreeBuilder.ConstructAttributeContextTree(projCtx);

            return(projOutputSet);
        }
 /// <summary>
 /// Pass through all the input projection attribute states if there are any.
 /// </summary>
 /// <param name="projCtx">The projection context.</param>
 /// <param name="projOutputSet">The projection attribute state set.</param>
 /// <returns></returns>
 private void AddAllPreviousAttributeStates(ProjectionContext projCtx, ProjectionAttributeStateSet projOutputSet)
 {
     // Pass through all the input projection attribute states if there are any
     foreach (ProjectionAttributeState currentPAS in projCtx.CurrentAttributeStateSet.States)
     {
         projOutputSet.Add(currentPAS);
     }
 }
Пример #28
0
 /// <inheritdoc />
 internal override ProjectionAttributeStateSet AppendProjectionAttributeState(
     ProjectionContext projCtx,
     ProjectionAttributeStateSet projOutputSet,
     CdmAttributeContext attrCtx)
 {
     Logger.Error(TAG, this.Ctx, "Projection operation not implemented yet.", nameof(AppendProjectionAttributeState));
     return(null);
 }
 public IAgreementDocumentResult GetAgreementDocument(Guid agreementId)
 {
     using (var context = new ProjectionContext(ConnectionString.Get()))
     {
         var entity = context.GetEntity <AgreementSqlEntity>(agreementId);
         return(new AgreementDocumentResult(entity.DocumentId, entity.AgreementTypeAgreement));
     }
 }
        public string TransformString(ProjectionContext targetContext, ProjectionInput input, string outputPathRule)
        {
            var hash     = PrepareHash(input);
            var template = Template.Parse(outputPathRule);
            var output   = template.Render(hash);

            return(output);
        }
        public void should_just_use_IProjectMyself_Project_in_accessor_projection()
        {
            var projection = AccessorProjection<ComplexValueHolder, ComplexValue>.For(x => x.Value);
            var target = new ComplexValueHolder
            {
                Value = new ComplexValue {Name = "Jeremy", Age = 38}
            };

            var context = new ProjectionContext<ComplexValueHolder>(new InMemoryServiceLocator(), target);

            var node = new DictionaryMediaNode();
            projection.As<IProjection<ComplexValueHolder>>().Write(context, node);

            node.Values["Value"].As<IDictionary<string, object>>()["Name"].ShouldEqual("Jeremy");
            node.Values["Value"].As<IDictionary<string, object>>()["Age"].ShouldEqual(38);
        }