コード例 #1
0
        private void AddMembership(FluentQueryBuilder queryBuilder)
        {
            var ownerOfApplication = new ApplicationOwner() { guid = Guid.NewGuid().ToString("N"), name = "RAM" };
            var user = new User() { guid = Guid.NewGuid().ToString("N"), firstName = "Alex", lastName = "Stroukov", email = "*****@*****.**" };
            var membership = new Membership() { guid = Guid.NewGuid().ToString("N"), licence = "asajzjdZKHJXZJKSjsLSlSjjs897JS8shKSJSHLSKS" };




            var userRole = new UserRole() { guid = Guid.NewGuid().ToString("N"), name = "Administrator" };

            





            var hasUserRelationship = new HasUser() { };
            var hasRoleRelationship = new HasAction() { };
            var hasApplicationRelationship = new HasApplication() { };
            var usedByApplicationRelationship = new UsedByApplication() { };
            var userOfApplicationRelationship = new UserOfApplication() { };

            var entityGridBasicTemplate = new Template { guid = Guid.NewGuid().ToString("N"), name = "entityGridBasic", location = string.Format("StagedSpa/templates/{0}", "entity-grid-basic.html") };


            var entityDetailsBasicTemplate = new Template { guid = Guid.NewGuid().ToString("N"), name = "entityDetailsBasic", location = string.Format("StagedSpa/templates/{0}", "entity-details-basic.html") };


            
            var hasEntityGridScreen = new HasScreen{ screenType = Enum.ScreenTypeEnum.EntityGrid};
            var hasEntityDetailsScreen = new HasScreen { screenType = Enum.ScreenTypeEnum.EntityDetails };

            var hasTemplate = new HasTemplate { };



            var hasMembershipRelationship = new HasMembership() { runsOutOnMillis = (long)(DateTime.UtcNow.AddMonths(1) - new DateTime(1970, 1, 1)).TotalMilliseconds };



            queryBuilder
                .Create(ownerOfApplication)
                .Create(user)
                .Create(membership)
                .Create(_application)
                .Create(userRole)
                .Create(assetsScreen)
                .Create(assetDetailsScreen)
                .Create(entityGridBasicTemplate)
                .Create(entityDetailsBasicTemplate)
                .Create(_navigateToEntityDetailsCommand)
                .Create(_navigateToEntityDetailsCommand2)

                .Create(_eGridWidget)
                .Create(_eGridTileWidget)
                .Create(_seGridWidget)
                .Create(_seGridTileWidget)
                .Create(_dpTextWidget)
                .Create(_dpTextWidget2)
                .Create(_dpTextWidget3)
                .Create(_epDropdownWidget)

                .RelateTo(_eGridTileWidget, new HasAction(), _navigateToEntityDetailsCommand)
                .RelateTo(_navigateToEntityDetailsCommand, new RelatedActionScreen(), assetDetailsScreen)


                .RelateTo(_seGridTileWidget, new HasAction(), _navigateToEntityDetailsCommand2)
                .RelateTo(_navigateToEntityDetailsCommand2, new RelatedActionScreen(), assetDetailsScreen)

                .RelateTo(ownerOfApplication, hasMembershipRelationship, membership)
                .RelateTo(ownerOfApplication, hasUserRelationship, user)
                .RelateTo(user, hasRoleRelationship, userRole)
                .RelateTo(ownerOfApplication, hasApplicationRelationship, _application)
                .RelateTo(user, userOfApplicationRelationship, _application)

                .RelateTo(userRole, usedByApplicationRelationship, _application)
                .RelateTo(_application, hasEntityDetailsScreen, assetDetailsScreen)
                .RelateTo(_application, hasEntityGridScreen, assetsScreen)

                .RelateTo(assetsScreen, hasTemplate, entityGridBasicTemplate)
                .RelateTo(entityGridBasicTemplate, new HasWidget (), _eGridWidget)
                .RelateTo(_eGridWidget, new HasWidget(), _eGridTileWidget)
                

                .RelateTo(assetDetailsScreen, hasTemplate, entityDetailsBasicTemplate)
                .RelateTo(entityDetailsBasicTemplate, new HasWidget(), _dpTextWidget)
                .RelateTo(entityDetailsBasicTemplate, new HasWidget(), _epDropdownWidget)
                .RelateTo(entityDetailsBasicTemplate, new HasWidget(), _dpTextWidget2)
                .RelateTo(entityDetailsBasicTemplate, new HasWidget(), _dpTextWidget3)
                .RelateTo(entityDetailsBasicTemplate, new HasWidget(), _seGridWidget)
                .RelateTo(_seGridWidget, new HasWidget(), _seGridTileWidget)
                
                ;

        }
コード例 #2
0
        public IHttpActionResult Insert([FromBody] CreateScreenVm value)
        {
            var queryBuilder = new FluentQueryBuilder();
            var templates = Enum.GetValues(typeof(TemplateEnum)).Cast<TemplateEnum>().ToList().Select(t => t.ToTemplateVm());

            var matchingTemplate = templates.First(t => t.name == value.screen.template.name);

            var screen = new Screen() { guid = Guid.NewGuid().ToString("N"), name = "New Screen" };
            var template = new Template()
            {
                guid = Guid.NewGuid().ToString("N"),
                name = value.screen.template.name,
                location = matchingTemplate.location
            };

            queryBuilder
                .Create(screen)
                .Create(template)
                .RelateTo(screen, new HasTemplate(), template)
                .RelateTo(StagedDbContext._application, new HasScreen { screenType = value.screen.screenType }, screen)
                
                ;


            foreach (var widget in value.screen.template.widgets)
            {
                var widgetNode = new Widget { guid = Guid.NewGuid().ToString("N"), widgetSchema = widget.widget };

                var propertyNode = new Property() { guid = widget.data.guid };


                queryBuilder
                    .Create(widgetNode)
                    .RelateTo(template, new HasWidget(), widgetNode)
                    .RelateTo(widgetNode, new DisplaysValueFor(), propertyNode)
                    ;

                if (widget.data.next == null || widget.data.next.guid == null) continue;


                if (widget.data.next.next == null || widget.data.next.next.guid == null)
                {
                    var entityPropertyNode = new Property() { guid = widget.data.next.guid };
                    queryBuilder
                        .RelateTo(widgetNode, new ForThisHeaderProperty(), entityPropertyNode);
                }
                else
                {
                    var entityPropertyNode = new Property() { guid = widget.data.next.next.guid };
                    queryBuilder
                        .RelateTo(widgetNode, new ForThisHeaderProperty(), entityPropertyNode);
                }





            }
            

            queryBuilder.Execute(StagedDbContext.Instance.GraphClient.Cypher);

            
            return Ok();
        }