Beispiel #1
0
        private void IncrementFrequency(ThemeItem theme, XElement entity)
        {
            string     str  = entity.Attribute(BlockAttribute.ROLE);
            EntityRole role = EntityRole.Other;

            if (!str.IsEmpty())
            {
                role = (EntityRole)Enum.Parse(typeof(EntityRole), str);
            }
            switch (role)
            {
            case EntityRole.Adj:
                ++theme.FreqAdj;
                break;

            case EntityRole.Obj:
                ++theme.FreqObj;
                break;

            case EntityRole.Other:
                ++theme.FreqOther;
                break;

            case EntityRole.Subj:
                ++theme.FreqSubj;
                ++_SubjectCount;
                break;
            }
        }
Beispiel #2
0
 public RelationshipAttribute(string targetEntityName, EntityRole role, string navigationPropertyName, string lookupFieldName)
 {
     TargetEntityName       = targetEntityName;
     Role                   = role;
     NavigationPropertyName = navigationPropertyName;
     LookupFieldName        = lookupFieldName;
 }
Beispiel #3
0
 public EntityRoleData Map(EntityRole comment) => new EntityRoleData()
 {
     EntityRoleKey  = comment.EntityRoleKey,
     EntityRoleCode = comment.EntityRoleCode,
     EntityRoleName = comment.EntityRoleName,
     EntityRoleDesc = comment.EntityRoleDesc
 };
Beispiel #4
0
        public EntityRelationship(RelationshipMetadataBase relation, EntityRole role, string originatingEntity, FetchXmlBuilder fxb, string originatingParent = "")
        {
            Relationship = relation;
            Role         = role;

            if (relation is OneToManyRelationshipMetadata om)
            {
                if (role == EntityRole.Referenced)
                {
                    Name = fxb.GetEntityDisplayName(om.ReferencedEntity) + "." + om.ReferencedAttribute + " <- " +
                           fxb.GetEntityDisplayName(om.ReferencingEntity) + "." + om.ReferencingAttribute;
                }
                else
                {
                    Name = fxb.GetEntityDisplayName(om.ReferencingEntity) + "." + om.ReferencingAttribute + " -> " +
                           fxb.GetEntityDisplayName(om.ReferencedEntity) + "." + om.ReferencedAttribute;
                }
            }
            else if (relation is ManyToManyRelationshipMetadata mm)
            {
                if (fxb.NeedToLoadEntity(mm.Entity1LogicalName))
                {
                    fxb.LoadEntityDetails(mm.Entity1LogicalName, null, false);
                }

                if (fxb.NeedToLoadEntity(mm.Entity2LogicalName))
                {
                    fxb.LoadEntityDetails(mm.Entity2LogicalName, null, false);
                }

                var entity1PrimaryKey = fxb.GetPrimaryIdAttribute(mm.Entity1LogicalName);
                var entity2PrimaryKey = fxb.GetPrimaryIdAttribute(mm.Entity2LogicalName);

                if (mm.Entity1LogicalName == originatingEntity && role == EntityRole.Referencing)
                {
                    Name = fxb.GetEntityDisplayName(mm.Entity1LogicalName) + "." + entity1PrimaryKey + " -> " + mm.IntersectEntityName + "." + mm.Entity1IntersectAttribute;
                }
                else if (mm.Entity2LogicalName == originatingEntity && role == EntityRole.Referenced)
                {
                    Name = fxb.GetEntityDisplayName(mm.Entity2LogicalName) + "." + entity2PrimaryKey + " -> " + mm.IntersectEntityName + "." + mm.Entity2IntersectAttribute;
                }
                else if (mm.IntersectEntityName == originatingEntity)
                {
                    if (mm.Entity1LogicalName == originatingParent && role == EntityRole.Referencing)
                    {
                        Name = mm.IntersectEntityName + "." + mm.Entity2IntersectAttribute + " -> " + fxb.GetEntityDisplayName(mm.Entity2LogicalName) + "." + entity2PrimaryKey;
                    }
                    else if (mm.Entity2LogicalName == originatingParent && role == EntityRole.Referenced)
                    {
                        Name = mm.IntersectEntityName + "." + mm.Entity1IntersectAttribute + " -> " + fxb.GetEntityDisplayName(mm.Entity1LogicalName) + "." + entity1PrimaryKey;
                    }
                }
                if (string.IsNullOrEmpty(Name))
                {
                    Name = "? " + mm.IntersectEntityName + ": " + mm.Entity1LogicalName + "." + mm.Entity1IntersectAttribute + " -> " +
                           mm.Entity2LogicalName + "." + mm.Entity2IntersectAttribute;
                }
            }
        }
Beispiel #5
0
        public async Task <bool> Authorize(int id, EntityRole entityRole)
        {
            IUserRelation userRelation = await GetUserRelation(id);

            return(userRelation == null ||
                   userRelation.UserId == httpContextAccessor.HttpContext.User.GetId() &&
                   userRelation.RoleId == (int)entityRole ||
                   entityRole == EntityRole.Viewer && userRelation.RoleId == (int)EntityRole.Owner); // TODO change this
        }
        private void UpdateSpawn(float dt, int waveOrder)
        {
            if (IsFinished())
            {
                return;
            }

            elapsedTimeSinceLastSpawn += dt;
            if (!IsSpawnCompleted() && elapsedTimeSinceLastSpawn >= spawnInterval)
            {
                elapsedTimeSinceLastSpawn = 0;
                spawnCountSoFar++;
                for (int i = 0; i < monsterCount; i++)
                {
                    float x = Random();
                    gameObjectSpawner.SpawnEntity(
                        monsterId,
                        monsterLevel,
                        x,
                        spawnY,
                        spawnZ,
                        new DungeonSystemSpawnSourceInfo(),
                        facingDirection,
                        spawnSkillLevelPool,
                        group
                        ).Then(entity =>
                    {
                        entityRole = entity.GetComponent <StatsComponent>().BasicStatsFromConfig.ShowRole();
                        monsterUniqueIds.Add(entity.UniqueId);

                        foreach (Tracker tracker in trackers)
                        {
                            tracker.AddEntity(entity);
                        }

                        foreach (IAction action in actions)
                        {
                            action.AddEntity(entity);
                        }
                    });
                }
            }

            foreach (Monster m in environment.DeadMonstersSoFar())
            {
                if (!monsterUniqueIds.Contains(m.UniqueId()))
                {
                    continue;
                }
                if (deadMonsters.Contains(m))
                {
                    continue;
                }

                deadMonsters.Add(m);
            }
        }
Beispiel #7
0
 /// <summary>
 /// 初始化一个<see cref="EntityRoleOutputDto"/>类型的新实例
 /// </summary>
 public EntityRoleOutputDto(EntityRole entityRole)
 {
     Id          = entityRole.Id;
     RoleId      = entityRole.RoleId;
     EntityId    = entityRole.EntityId;
     IsLocked    = entityRole.IsLocked;
     Operation   = entityRole.Operation;
     CreatedTime = entityRole.CreatedTime;
     FilterGroup = entityRole.FilterGroupJson.FromJsonString <FilterGroup>();
 }
Beispiel #8
0
        internal Entity GetDbEntityWithRelatedEntities(EntityReference reference, EntityRole primaryEntityRole, EntityReference userRef)
        {
            var entity = db.GetEntityOrNull(reference);

            if (entity == null)
            {
                return(null);
            }

            var metadata = this.metadata.EntityMetadata.GetMetadata(entity.LogicalName);

            if (entity.RelatedEntities.Count() > 0)
            {
                var clone = entity.CloneEntity(metadata, new ColumnSet(true));
                db.Update(clone);
                entity = clone;
            }
            var relationQuery     = new RelationshipQueryCollection();
            var relationsMetadata =
                primaryEntityRole == EntityRole.Referenced
                ? metadata.OneToManyRelationships
                : metadata.ManyToOneRelationships;

            foreach (var relationshipMeta in relationsMetadata)
            {
                var query = new QueryExpression(
                    primaryEntityRole == EntityRole.Referenced
                    ? relationshipMeta.ReferencingEntity
                    : relationshipMeta.ReferencedEntity)
                {
                    ColumnSet = new ColumnSet(true)
                };
                relationQuery.Add(new Relationship()
                {
                    SchemaName = relationshipMeta.SchemaName, PrimaryEntityRole = primaryEntityRole
                }, query);
            }

            foreach (var relationshipMeta in metadata.ManyToManyRelationships)
            {
                var query = new QueryExpression(relationshipMeta.IntersectEntityName)
                {
                    ColumnSet = new ColumnSet(true)
                };
                relationQuery.Add(new Relationship()
                {
                    SchemaName = relationshipMeta.SchemaName
                }, query);
            }
            AddRelatedEntities(entity, relationQuery, userRef);
            return(entity);
        }
        public DungeonFactory(DungeonConfig dungeonConfig, EntitySpawner entitySpawner,
                              CharacterId heroId, List <SsarTuple <int, GameObject> > gateAndId,
                              DamageSystem damageSystem, PromiseWorld world, ConfigManager configManager)
        {
            notNullReference.Check(dungeonConfig, "dungeonConfig");
            notNullReference.Check(entitySpawner, "entitySpawner");
            notNullReference.Check(heroId, "heroId");
            notNullReference.Check(gateAndId, "gateAndId");
            notNullReference.Check(damageSystem, "damageSystem");
            notNullReference.Check(configManager, "configManager");

            heroAndMonsterConfig = configManager.GetConfig <HeroAndMonsterConfig>();
            defaultEnvironment   = new DefaultDungeonEnvironment(entitySpawner, gateAndId);
            this.dungeonConfig   = dungeonConfig;

            world.EntityCreationEventHandler += (sender, arg) =>
            {
                Entity entity = arg.Entity;
                if (arg.EntityType != EntityType.Creature)
                {
                    return;
                }

                if (entity.GetComponent <SkillComponent>().CharacterId.Equals(heroId))
                {
                    defaultEnvironment.SetHero(new DefaultDungeonCharacter(entity, damageSystem));
                }
            };

            damageSystem.EntityDeathEventHandler_Late += (sender, args) =>
            {
                CacheTemplateArgsComponent argsComponent = args.Entity.GetComponent <CacheTemplateArgsComponent>();
                SpawnSourceInfo            source        = argsComponent?.TemplateArgs.GetEntry <SpawnSourceInfo>(TemplateArgsName.SpawnSource) ?? new DungeonSystemSpawnSourceInfo();
                EntityRole role = args.Entity.GetComponent <StatsComponent>().BasicStatsFromConfig.ShowRole();
                defaultEnvironment.AddDeadMonster(new EntityMonster(Time.timeSinceLevelLoad,
                                                                    args.Entity.GetComponent <SkillComponent>().CharacterId, args.Entity.UniqueId, source, role));
            };

            entitySpawner.EntitySpawnEventHandler += (sender, args) =>
            {
                if (args.Entity.Group == EntityGroup.GROUP_A)
                {
                    return;
                }
                defaultEnvironment.AddSpawnedMonster(args.UniqueId, args.BasicStats, args.Entity);
            };
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            string senha;

            if (txtUsuario.Text != string.Empty && txtNome.Text != string.Empty && txtCpf.Text != string.Empty && txtCnh.Text != string.Empty && txtRg.Text != string.Empty && txtSenha.Text != string.Empty && txtConfSenha.Text != string.Empty)
            {
                if (!ValidaDigitoCPF.ValidaCPF(txtCpf.Text))
                {
                    MessageBox.Show("Cpf digitado é invávlido!", "Sistema ABC");
                    return;
                }

                if (!ValidaCNH.ValidacaoCNH(txtCnh.Text))
                {
                    MessageBox.Show("CNH digitado é invávlido!", "Sistema ABC");
                    return;
                }

                if (txtSenha.Text != txtConfSenha.Text)
                {
                    MessageBox.Show("Senha digitadas estão incorretas!", "Sistema ABC");
                    return;
                }
                else
                {
                    senha = Descrypt.RetornarMD5(txtConfSenha.Text);
                }
            }
            else
            {
                MessageBox.Show("Todos os campos são obrigatorios, preencha de forma correta.", "Sistema ABC");
                return;
            }


            entityRole = (EntityRole)Enum.Parse(typeof(EntityRole), cmbRole.Text);

            string[] enderecoArray = cmbEndereco.Text.Split(',');
            string   endereco      = enderecoArray[0];

            TblUsuarioModel usuarioModel = new TblUsuarioModel(txtUsuario.Text, txtNome.Text, txtCpf.Text, txtRg.Text, txtCnh.Text, senha, txtEmail.Text, entityRole, int.Parse(endereco), true)
            {
                State = EntityState.Add
            };

            MessageBox.Show(usuarioModel.saveChange(), "Sistema ABC", MessageBoxButtons.OKCancel);
        }
        public LocalEntity(Guid id, IEntityLogic logic, SimultaneousSim sim, EntityRole role, float updatePeriod = 100f)
        {
            Id     = id;
            _logic = logic;
            _sim   = sim;
            Role   = role;

            _recordedFrameSnapshots = new List <FrameSnapshot>();
            _recordedFrameCommands  = new List <FrameCommands>();
            _recievedEnvelopes      = new List <RecievedCmdEnvelope>();

            _clientEntities = new List <IEntity>();

            UpdatePeriod = updatePeriod;

            NetworkEntityAdded(this);
        }
Beispiel #12
0
        public void EntityRoleModelTest1()
        {
            var data = new EntityRoleData
            {
                EntityRoleKey       = 1,
                EntityRoleCode      = "TEST",
                EntityRoleName      = "TEST",
                EntityRoleDesc      = "TEST",
                AuditAddUserId      = "TEST",
                AuditAddDatetime    = new System.DateTime(2018, 1, 1),
                AuditUpdateUserId   = "TEST",
                AuditUpdateDatetime = new System.DateTime(2018, 1, 1),
            };
            var sut = new EntityRole(data);

            Assert.True(sut.EntityRoleKey == 1);
            Assert.True(sut.EntityRoleCode == "TEST");
            Assert.True(sut.EntityRoleName == "TEST");
            Assert.True(sut.EntityRoleDesc == "TEST");
        }
Beispiel #13
0
 public String GetNameForRelationship(
     EntityMetadata entityMetadata, RelationshipMetadataBase relationshipMetadata,
     EntityRole? reflexiveRole, IServiceProvider services)
 {
     return DefaultNamingService.GetNameForRelationship(
         entityMetadata, relationshipMetadata, reflexiveRole, services);
 }
Beispiel #14
0
        //TODO: update to also take in cascading filtering on Assign, Delete, Merge, reparent, rollup
        internal Entity GetDbEntityWithRelatedEntities(EntityReference reference, EntityRole primaryEntityRole, EntityReference userRef, CascadeSelection cascadeSelection = null, params Relationship[] relations)
        {
            var entity = db.GetEntityOrNull(reference);

            if (entity == null)
            {
                return(null);
            }

            var metadata = this.metadata.EntityMetadata.GetMetadata(entity.LogicalName);

            if (entity.RelatedEntities.Count() > 0)
            {
                var clone = entity.CloneEntity(metadata, new ColumnSet(true));
                db.Update(clone);
                entity = clone;
            }
            var relationQuery     = new RelationshipQueryCollection();
            var relationsMetadata =
                primaryEntityRole == EntityRole.Referenced
                ? metadata.OneToManyRelationships
                : metadata.ManyToOneRelationships;

            if (cascadeSelection != null)
            {
                relationsMetadata.Where(x => CascadeCompare(x.CascadeConfiguration, cascadeSelection));
            }

            if (relations.Any())
            {
                relationsMetadata = relationsMetadata.Join(relations, x => x.SchemaName, y => y.SchemaName, (r1, r2) => r1).ToArray();
            }
            relationQuery.AddRange(
                relationsMetadata
                .Select(relationshipMeta =>
            {
                var rel = new Relationship()
                {
                    SchemaName        = relationshipMeta.SchemaName,
                    PrimaryEntityRole = primaryEntityRole
                };
                var query = new QueryExpression()
                {
                    EntityName =
                        primaryEntityRole == EntityRole.Referenced
                            ? relationshipMeta.ReferencingEntity
                            : relationshipMeta.ReferencedEntity,
                    ColumnSet = new ColumnSet(true)
                };
                return(new KeyValuePair <Relationship, QueryBase>(rel, query));
            }));


            foreach (var relationshipMeta in relationsMetadata)
            {
            }

            if (cascadeSelection == null)
            {
                var relationShipManyMetadata = metadata.ManyToManyRelationships;
                if (relations.Any())
                {
                    relationShipManyMetadata = relationShipManyMetadata.Join(relations, x => x.SchemaName, y => y.SchemaName, (r1, r2) => r1).ToArray();
                }
                relationQuery.AddRange(relationShipManyMetadata
                                       .Select(relationshipMeta =>
                {
                    var rel = new Relationship()
                    {
                        SchemaName = relationshipMeta.SchemaName
                    };
                    var query = new QueryExpression(relationshipMeta.IntersectEntityName)
                    {
                        ColumnSet = new ColumnSet(true)
                    };
                    return(new KeyValuePair <Relationship, QueryBase>(rel, query));
                }));
            }

            AddRelatedEntities(entity, relationQuery, userRef);
            return(entity);
        }
 static CodeStatementCollection BuildRelationshipSet(string methodName, RelationshipMetadataBase relationship, CodeTypeReference targetType, EntityRole? entityRole)
 {
     var statements = new CodeStatementCollection();
     var expression = entityRole.HasValue ? (FieldRef(typeof (EntityRole), entityRole.ToString())) : ((CodeExpression) Null());
     statements.Add(ThisMethodInvoke(methodName, targetType, new[] {StringLiteral(relationship.SchemaName), expression, VarRef("value")}));
     return statements;
 }
 static CodeAttributeDeclaration BuildRelationshipSchemaNameAttribute(string relationshipSchemaName, EntityRole? entityRole)
 {
     if (entityRole.HasValue)
     {
         return Attribute(RelationshipSchemaNameAttribute, new[] {AttributeArg(relationshipSchemaName), AttributeArg(FieldRef(typeof (EntityRole), entityRole.ToString()))});
     }
     return Attribute(RelationshipSchemaNameAttribute, new[] {AttributeArg(relationshipSchemaName)});
 }
 static CodeStatement BuildRelationshipGet(string methodName, RelationshipMetadataBase relationship, CodeTypeReference targetType, EntityRole? entityRole)
 {
     var expression = entityRole.HasValue ? (FieldRef(typeof (EntityRole), entityRole.ToString())) : ((CodeExpression) Null());
     return Return(ThisMethodInvoke(methodName, targetType, new[] {StringLiteral(relationship.SchemaName), expression}));
 }
 static CodeTypeMember BuildManyToMany(EntityMetadata entity, EntityMetadata otherEntity, ManyToManyRelationshipMetadata manyToMany, string propertyName, EntityRole? entityRole, ServiceProvider serviceProvider)
 {
     Trace.TraceInformation("Entering {0}", new object[] {MethodBase.GetCurrentMethod().Name});
     var typeParameter = serviceProvider.TypeMappingService.GetTypeForRelationship(manyToMany, otherEntity, serviceProvider);
     var property = PropertyGet(IEnumerable(typeParameter), propertyName, new CodeStatement[0]);
     property.GetStatements.Add(BuildRelationshipGet("GetRelatedEntities", manyToMany, typeParameter, entityRole));
     property.SetStatements.AddRange(BuildRelationshipSet("SetRelatedEntities", manyToMany, typeParameter, entityRole));
     property.CustomAttributes.Add(BuildRelationshipSchemaNameAttribute(manyToMany.SchemaName, entityRole));
     property.Comments.AddRange(CommentSummary("N:N " + manyToMany.SchemaName));
     Trace.TraceInformation("Exiting {0}: {1}.ManyToMany {2} defined", new object[] {MethodBase.GetCurrentMethod().Name, entity.LogicalName, propertyName});
     return property;
 }
 public bool HasRole(int entityId, EntityRole role)
 {
     return(true);
 }
Beispiel #20
0
 string INamingService.GetNameForRelationship(EntityMetadata entityMetadata, RelationshipMetadataBase relationshipMetadata, EntityRole? reflexiveRole, IServiceProvider services)
 {
     var str = reflexiveRole.HasValue ? reflexiveRole.Value.ToString() : string.Empty;
     if (_knowNames.ContainsKey(entityMetadata.MetadataId.Value.ToString() + relationshipMetadata.MetadataId.Value + str))
     {
         return _knowNames[entityMetadata.MetadataId.Value.ToString() + relationshipMetadata.MetadataId.Value + str];
     }
     var name = !reflexiveRole.HasValue ? relationshipMetadata.SchemaName : (((reflexiveRole.Value) == EntityRole.Referenced) ? ("Referenced" + relationshipMetadata.SchemaName) : ("Referencing" + relationshipMetadata.SchemaName));
     name = CreateValidName(name);
     var service = (INamingService) services.GetService(typeof (INamingService));
     if (_reservedAttributeNames.Contains(name) || (name == service.GetNameForEntity(entityMetadata, services)))
     {
         name = name + "1";
     }
     _knowNames.Add(entityMetadata.MetadataId.Value.ToString() + relationshipMetadata.MetadataId.Value + str, name);
     return name;
 }
Beispiel #21
0
 protected CrmRelationshipAttribute(string relationshipName, EntityRole role)
 {
     RelationshipName = relationshipName;
     Role             = role;
 }
Beispiel #22
0
        static private void ResolveConjunctionAnaphora(XElement conjunction, XElement entityChain, XElement sentence)
        {
            if ((entityChain == null) || !entityChain.Name.IsEqual(UnitTextType.ENTITY))
            {
                return;
            }

            XElement   consistency   = null;
            EntityRole role          = EntityRole.Other;
            bool       isNeedSetRole = true;
            string     value         = conjunction.Attribute(BlockAttribute.VALUE);

            switch (value)
            {
            case "который":
                /// морфологические свойства союза
                var conjMorpho =
                    (from info in conjunction.GetMorphoInfo()
                     where !info.IsEmpty()
                     select new {
                    _case = info[MorphoInfo.Case],
                    _gender = info[MorphoInfo.Gender],
                    _number = info[MorphoInfo.Number]
                }).ToArray();
                /// минимальная согласованная с союзом цепочка
                XElement[] consistElements = entityChain.DescendantsAndSelf().Where(
                    element =>
                {
                    if (element.Attribute(BlockAttribute.MI).IsEmpty() || !element.Name.IsEqual(UnitTextType.ENTITY))
                    {
                        return(false);
                    }
                    var morpho =
                        from info in element.GetMorphoInfo()
                        select new { _gender = info[MorphoInfo.Gender], _number = info[MorphoInfo.Number] };
                    var intersect =
                        from conj in conjMorpho
                        from info in morpho
                        where
                        (info._number == conj._number) &&
                        /// множественное число
                        (conj._number.IsEqualCode(Number.Plural) ||
                         /// единственное число
                         (info._gender == conj._gender))
                        select info;
                    return(intersect.Any());
                }).ToArray();
                bool isHomogeneous = entityChain.Attribute(BlockAttribute.TYPE).IsEqual(EntityType.Homogeneous);
                if ((consistElements.Length == 1) || ((isHomogeneous && consistElements.FirstOrDefault() == entityChain)))
                /// удалось разрешить
                {
                    consistency   = consistElements.First();
                    isNeedSetRole = false;
                    var info =
                        from morpho in conjMorpho
                        where !morpho._case.IsEqualCode(Case.Nominative) && !morpho._case.IsEqualCode(Case.Accusative)
                        select morpho;
                    XElement previos = conjunction.ElementsBeforeSelf().LastOrDefault(
                        element => !element.GetFullValue().Trim().IsEmpty());
                    if (info.Any() && (previos != null) && previos.Name.IsEqual(UnitTextType.ENTITY) &&
                        !previos.Attribute(BlockAttribute.TYPE).IsEqual(EntityType.Adverb))
                    /// формирование новой сущности
                    {
                        List <XElement> elements = sentence.Elements().ToList();
                        elements.UnionEntity(elements.IndexOf(previos), conjunction);
                        sentence.ReplaceNodes(elements);
                    }
                }
                break;

                /*case "что":
                 *      if(!sentence.IsContainAttribute(BlockAttribute.SUBJ))
                 *      /// минимальная согласованная с глаголом цепочка становится субъектом
                 *      {
                 *              var verbList =
                 *                      (from entity in conjunction.ElementsAfterSelf()
                 *                       from child in entity.DescendantsAndSelf()
                 *                       where child.Attribute(BlockAttribute.TYPE).IsEqual(EntityType.Verb)
                 *                       select child).ToArray();
                 *              /// минимальная согласованная с глаголом цепочка
                 *              consistency = entityChain.DescendantsAndSelf().LastOrDefault(
                 *                      element =>
                 *                      {
                 *                              foreach (var verb in verbList)
                 *                                      if (!verb.IsConsistWithNoun(element))
                 *                                              return false;
                 *                              return true;
                 *                      });
                 *              if (consistency != null)
                 *              /// удалось разрешить
                 *              {
                 *                      role = EntityRole.Subj;
                 *                      sentence.SetAttributeValue(BlockAttribute.SUBJ.ToString(),
                 *                              consistency.Attribute(BlockAttribute.ID));
                 *              }
                 *      }
                 *      break;
                 * case "где":
                 * case "куда":
                 * case "откуда":
                 *      /// первая цепочка географии
                 *      consistency = entityChain.DescendantsAndSelf().FirstOrDefault(
                 *              element =>
                 *              {
                 *                      string type = element.Attribute(BlockAttribute.TYPE);
                 *                      if (type.IsEqual(EntityType.PlaceName) ||
                 *                              type.IsEqual(EntityType.PlaceNoInfo))
                 *                      {
                 *                              return true;
                 *                      }
                 *                      return false;
                 *              });
                 *      role = EntityRole.Adj;
                 *      break;
                 * case "когда":
                 *      /// первая дата
                 *      consistency = entityChain.DescendantsAndSelf().FirstOrDefault(
                 *              element => element.Attribute(BlockAttribute.TYPE).IsEqual(EntityType.Date));
                 *      role = EntityRole.Adj;
                 *      break;*/
            }
            if (consistency != null)
            {
                conjunction.SetLinkToElement(consistency);
                if (isNeedSetRole)
                {
                    conjunction.SetRole(role);
                }
            }
            else
            {
                conjunction.DeleteAttribute(BlockAttribute.ROLE);
            }
        }
 //public CrmRelationshipAttribute(string relationshipName)
 //{
 //    RelationshipName = relationshipName;
 //    Role = EntityRole.Referencing;
 //}
 public CrmRelationshipAttribute(string relationshipName, EntityRole role)
 {
     RelationshipName = relationshipName;
     Role = role;
 }
        protected void ExecuteWorkflowOnSourceAndSubscribers(string entityDisplayName, string eventName, string subscriberAssociationName, EntityRole entityRole, string entityPrimaryKeyName)
        {
            var entityName = Source.LogicalName;

            ExecuteWorkflow("Adxstudio.Xrm {0} {1} (Master)".FormatWith(entityDisplayName, eventName), entityName, Source.Id);

            var entity = Context.CreateQuery(entityName).FirstOrDefault(e => e.GetAttributeValue <Guid>(entityPrimaryKeyName) == Source.Id);

            if (entity == null)
            {
                ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format(@"Entity type ""{0}"" with primary key {1} not found.", EntityNamePrivacy.GetEntityName(entityName), Source.Id));

                return;
            }

            var subscribers = entity.GetRelatedEntities(Context, subscriberAssociationName, entityRole);

            foreach (var subscriber in subscribers)
            {
                var subscriberEntityName = subscriber.LogicalName;

                ExecuteWorkflow("Adxstudio.Xrm {0} {1} (Subscriber)".FormatWith(entityDisplayName, eventName), subscriberEntityName, subscriber.Id);
            }
        }
 public RemoteEntity(Guid id, EntityRole role, RemoteSim sim)
 {
     Id   = id;
     Role = role;
     _sim = sim;
 }
Beispiel #26
0
 /// <summary>Initializes a new instance of the  <see cref="T:Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute"></see> class</summary>
 /// <param name="primaryEntityRole">Type: <see cref="T:Microsoft.Xrm.Sdk.EntityRole"></see>The entity role for the entity.</param>
 /// <param name="schemaName">Type: Returns_String
 /// The schema name for the entity relationship.</param>
 public RelationshipSchemaNameAttribute(string schemaName, EntityRole primaryEntityRole)
     : this(schemaName, new EntityRole?(primaryEntityRole))
 {
 }
Beispiel #27
0
 public static bool IsInRole(this EntityRole role, EntityRole otherRole)
 {
     return((role & otherRole) == otherRole);
 }