public void HistoryWithCastMember() { SetActiveCastMember(); Demo3Character leadCharacter = castLead.GetComponent<Demo3Character>(); Demo3Character activeCharacter = activeCastMember.GetComponent<Demo3Character>(); Relationship checkRelationship = new Relationship(activeRelationshipType); string text; if(graph.HaveRelationshipHistory(leadCharacter, activeCharacter, checkRelationship)) { RelationshipType recentRelationshipType = graph.GetConnection(leadCharacter, activeCharacter).Relationship.RelationshipType; if (recentRelationshipType == activeRelationshipType) { text = "Yes, " + activeCastMember.name + " is my " + activeRelationshipType; } else { text = "Yes, " + activeCastMember.name + " used to be my " + activeRelationshipType; } } else { text = "I have no history like that with " + activeCastMember.name; } gs.SetResponse(Responses.MESSAGE, text); }
public Link(string name, Relationship relationship, Source source, string target) { this.name = name; this.relationship = relationship; this.source = source; this.target = target; }
protected void Page_Load(object sender, EventArgs e) { this.RenderHeader(); this.StripeRows(); cloudRelationship = getCloudRelationship(); if (!Page.IsPostBack) { tbIPAddress.Text = GetServerIP(); tbLocalSQL.Text = _siteApi.RequestInformationRef.ConnectionString; tbLocalSitePath.Text = _siteApi.RequestInformationRef.SitePath; if (cloudRelationship != null) { cloudRelationshipId = cloudRelationship.Id; tbLocalSitePath.Text = cloudRelationship.LocalSite.SitePath; tbSQLServer.Text = cloudRelationship.RemoteSite.ConnectionString; string[] data = cloudRelationship.RemoteSite.Address.Split('|'); tbIPAddress.Text = "";// data[0]; tbBlobStorage.Text = "";//data[1]; tbAccountName.Text = data[1]; tbContainerName.Text = data[0]; tbAccountKey.Text = data[2]; tbCloudDomain.Text = "";//data[5]; } } }
protected void SetupBase(string resourcePath) { loader = new EntityLoader(MockRepository.GenerateStub<IFileController>()); database = new Database("DB1"); table1 = new Table("Table1"); table1.AddColumn(new Column("ID") { Datatype = "int" }); table1.AddColumn(new Column("BasicClass2_Index") { Datatype = "int" }); database.AddEntity(table1); table2 = new Table("Table2"); table2.AddColumn(new Column("ID") { Datatype = "int" }); table2.AddColumn(new Column("BASIC_CLASS_1_ID")); database.AddEntity(table2); tableManyToMany = new Table("Class1Class2"); tableManyToMany.AddColumn(new Column("Class1ID") { Datatype = "int" }); tableManyToMany.AddColumn(new Column("Class2ID") { Datatype = "int" }); database.AddTable(tableManyToMany); relationship = table1.CreateRelationshipTo(table2); relationship.PrimaryKey.AddColumn("ID"); relationship.ForeignKey.AddColumn("BASIC_CLASS_1_ID"); // Call we are testing mappingSet = loader.GetEntities(new[] { Path.Combine("Resources", resourcePath) }, database); }
/// <summary> /// </summary> /// <param name="entityName"></param> /// <param name="entityId"></param> /// <param name="relationship"></param> /// <param name="relatedEntities"></param> /// <exception cref="NotImplementedException"></exception> public void Associate(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities) { if (this.Original != null) { this.Original.Associate(entityName, entityId, relationship, relatedEntities); } }
public Relationship GetRelationship() { var relationship = new Relationship(RelationshipName); relationship.PrimaryEntityRole = Role; return relationship; }
void Awake() { graph = Graph.Instance; enemyR = new Relationship(RelationshipType.ENEMY); friendlyR = new Relationship(RelationshipType.FRIEND); thisEntity = GetComponent<Entity>(); }
/// <summary> /// Accepts IMessage's sent to the GRoup /// </summary> /// <param name="message"></param> /// <returns>true if successfully broadcasted to RelationshipType.MEMBER's</returns> /// <remarks> /// Overrides the default HandleMessage Behaviour for Group-like behaviour /// </remarks> public override bool HandleMessage(IMessage message) { // Check the message type if (message.GetType() == typeof(StringMessage)) { // pass the message on Relationship members = new Relationship(RelationshipType.MEMBER); // broadcast the message using Graph methods Connections.Instance.SendMessageTo(this, members, message); return true; } // if it's a connection message, try to learn about the connection if (message.GetType() == typeof(ConnectionMessage)) { // convert the message ConnectionMessage msg = message as ConnectionMessage; // pass the message Learn(msg.Connection); return true; } // didn't do anything. return false; }
public virtual void Disassociate(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities) { CapturedInput.EntityId = entityId; CapturedInput.EntityName = entityName; CapturedInput.Relationship = relationship; CapturedInput.RelatedEntities = relatedEntities; }
public static bool UnderEAControl(Relationship ths) { SimDescription simA = ths.SimDescriptionA; SimDescription simB = ths.SimDescriptionB; if ((((simA != null) && (simB != null)) && (SimTypes.IsSelectable(simA) || SimTypes.IsSelectable(simB))) && (simA.IsHuman && simB.IsHuman)) { if ((simA.Service is GrimReaper) || (simB.Service is GrimReaper)) { return true; } else { switch (ths.LTR.CurrentLTR) { case LongTermRelationshipTypes.Spouse: case LongTermRelationshipTypes.Fiancee: return false; } if (simA.CanHaveRomanceWith(simB) && simA.CheckAutonomousGenderPreference(simB)) { return true; } } } return false; }
/// <summary> /// Represents an <see cref="AtomLink"/> instance initialized with the given <see cref="Uri"/>, /// title, <see cref="Relationship"/> and <see cref="Type"/>. /// </summary> /// <param name="href">The <see cref="Uri"/> of the link.</param> /// <param name="rel">The <see cref="Relationship"/> of the link.</param> /// <param name="type">The <see cref="Type"/> of the link.</param> /// <param name="title">The <see cref="Title"/> of the link.</param> public AtomLink(Uri href, Relationship rel, MediaType type, string title) { this.HRef = href; this.Title = title; this.Rel = rel; this.Type = type; }
public void SetRelationsValue(Relationship relations) { float trustValue = relations.Trust; string relationshipType = relations.RelationshipState.ToString().ToUpper(); //ButtonText.text = trustValue.ToString("N0"); if (trustValue > 70) ButtonText.color = Color.green; else if (trustValue < 30) ButtonText.color = Color.red; else ButtonText.color = Color.yellow; // set color and text of relationship text RelationsText.text = relationshipType; switch (relations.RelationshipState) { case Relationship.eRelationshipState.Neutral: RelationsText.color = Color.white; break; case Relationship.eRelationshipState.Allies: RelationsText.color = Color.green; break; case Relationship.eRelationshipState.Friends: RelationsText.color = Color.green; break; case Relationship.eRelationshipState.Superior: RelationsText.color = new Color(.9f, .67f, .15f); // orange break; case Relationship.eRelationshipState.Inferior: RelationsText.color = Color.yellow; break; case Relationship.eRelationshipState.Challenger: RelationsText.color = Color.magenta; break; case Relationship.eRelationshipState.Challengee: RelationsText.color = Color.yellow; break; case Relationship.eRelationshipState.Rivals: RelationsText.color = Color.red; break; case Relationship.eRelationshipState.Vengeance: RelationsText.color = Color.red; break; case Relationship.eRelationshipState.VengeanceUpon: RelationsText.color = Color.yellow; break; case Relationship.eRelationshipState.Vendetta: RelationsText.color = Color.red; break; case Relationship.eRelationshipState.HangerOn: RelationsText.color = Color.cyan; break; case Relationship.eRelationshipState.HungUpon: RelationsText.color = Color.cyan; break; default: RelationsText.color = Color.white; break; } }
internal RelationMap(Relationship relationship, string member, string field, string type, string alias, bool queryOnly, bool lazy, bool cascade, string filter, string sortOrder, string selectSP, CustomProvider provider) : base(member, field) { if (type == null || type.Length == 0) { throw new MappingException("Mapping: Relation type was Missing"); } if (alias == null || alias.Length == 0) { // Should never happend since alias defaults to member throw new MappingException("Mapping: Relation alias was Missing"); } this.fields = field.Replace(", ", ",").Split(','); this.relationship = relationship; this.type = type; this.alias = alias; this.queryOnly = queryOnly; this.lazy = lazy; this.cascade = cascade; this.filter = filter; this.sortOrder = sortOrder; this.selectSP = selectSP; if (selectSP != null && selectSP.Length > 0) { for (int index = 0; index < this.fields.Length; index++) { this.fields[index] = provider.GetParameterDefault(this.fields[index]); } } }
public Relationship Add(Person person) { person.Family = this; var relationship = new Relationship { A = person }; _relationships.Add(relationship); return relationship; }
public void Setup() { var mappingSet = ModelSetup.SetupModel(); database = mappingSet.Database; table = database.Tables[0]; relationship = table.Relationships[0]; reference = relationship.MappedReferences().First(); }
/// <summary> /// 初始化 /// </summary> /// <param name="value">神经元的值</param> /// <param name="pos">神经元所在位置</param> public Neural(dynamic value = null, int pos = 0) { this.Value = value; this.Position = new List<int>() { pos }; this.ConnectedTo = new Dictionary<string, List<Neural>>(); this.ConnectedFrom = new Dictionary<string, List<Neural>>(); this.Guid = System.Guid.NewGuid(); }
void Start() { display = canvas.GetComponent<Display>(); career = canvas.GetComponent<Career>(); relationship = canvas.GetComponent<Relationship>(); obituary = canvas.GetComponent<Obituary>(); panel.SetActive(false); }
/// <summary> /// Registers any member with a RelationshipAttribute as a relationship. /// </summary> /// <param name="entityType">The entity that is being mapped.</param> /// <param name="member">The current member that is being inspected.</param> /// <param name="relationshipAtt">A RelationshipAttribute (is null if one does not exist).</param> /// <param name="relationships">A list of Relationships.</param> protected override void CreateRelationship(Type entityType, MemberInfo member, RelationshipAttribute relationshipAtt, RelationshipCollection relationships) { if (relationshipAtt != null) { Relationship relationship = new Relationship(member, relationshipAtt); relationships.Add(relationship); } }
public void Setup() { var mappingSet = ModelSetup.SetupModel(); var entitySet = mappingSet.EntitySet; entity = entitySet.Entities[0]; reference = entity.References[0]; relationship = reference.MappedRelationship(); }
public Association(string name, Entity parent, Entity child, Relationship relationship, bool isRequired) : base(name) { this.parent = parent; this.child = child; this.relationship = relationship; this.isRequired = isRequired; }
public override void DetachFromModel() { if (Detached || relationship == null) return; relationship.PropertyChanged -= Entity_PropertyChanged; relationship = null; Detached = true; SetupForm(); }
public Relationship AddRelationship(string destination, string description) { var relationship = new Relationship(); relationship.Source = this; relationship.DestinationTag = destination; relationship.Description = description; _relationships.Add(relationship); return relationship; }
public void AttachToModel(Relationship rel) { if (!Detached) DetachFromModel(); relationship = rel; relationship.PropertyChanged += Entity_PropertyChanged; Detached = false; SetupForm(); }
public static void FromRelationship(Relationship rel, RelEntity entity) { entity.id = rel.id; entity.username = rel.username; entity.orgID = rel.orgID; entity.pageId = rel.pageId; entity.relText = rel.relText; entity.relTypeId = rel.relTypeId; }
// get my neighbor along a given relationship public Person GetMyNeighbor(Relationship _rel, Person _self) { foreach (Person _per in _rel.relationshipMembers) { if (_per != _self) { return _per; } } return null; }
public void Setup() { relationship = new RelationshipImpl(new Guid("21111111-1111-1111-1111-111111111111")); reference = new ReferenceImpl(new Guid("11111111-1111-1111-1111-111111111111")); database = MockRepository.GenerateMock<IDatabase>(); database.Stub(d => d.Relationships).Return(new List<Relationship>{relationship}); entitySet = MockRepository.GenerateMock<EntitySet>(); entitySet.Stub(e => e.References).Return(new List<Reference>{ reference }.AsReadOnly()); }
public static float GetAttractionScore(Relationship ths, bool forceUpdate) { if (ths == null) return 0; if ((forceUpdate) || (ths.AttractionScore == float.PositiveInfinity)) { CalculateAttractionScore(ths, false); if (ths.AttractionScore == float.PositiveInfinity) return 0; } return ths.AttractionScore; }
void Start() { careerCoolDown = 0; countdown = 0; button.GetComponent<Button>().interactable = true; buttonImage.SetActive(false); options = canvas.GetComponent<Options>(); display = canvas.GetComponent<Display>(); relationship = canvas.GetComponent<Relationship>(); talk = canvas.GetComponent<Talk>(); CareerFocus = false; }
public static void ProcessRelationshipInternal(MappingSet set, Relationship relationship, EntityProcessor processor) { Reference reference = processor.CreateReference(relationship, set.EntitySet); if (reference == null) return; RelationshipReferenceMapping mapping = new RelationshipReferenceMappingImpl(); mapping.FromRelationship = relationship; mapping.ToReference = reference; //set.EntitySet.AddReference(reference); set.AddMapping(mapping); }
public bool Evaluate(Node node, Relationship relationship, Descriptor descriptor) { Guid searchId = Guid.Empty; bool? evaluation = new bool?(); switch (Context) { case ConditionContext.Node: searchId = node.NodeUid; break; case ConditionContext.Relationship: searchId = relationship.RelationshipUid; break; case ConditionContext.Descriptor: searchId = descriptor.DescriptorUid; break; case ConditionContext.NodeType: searchId = node.NodeTypeUid.Value; break; case ConditionContext.RelationshipType: searchId = relationship.RelationshipTypeUid.Value; break; case ConditionContext.DescriptorType: searchId = descriptor.DescriptorTypeUid.Value; break; default: break; } switch (Operator) { case ComparisonOperators.Equal: evaluation = SearchValue == searchId; break; case ComparisonOperators.NotEqual: evaluation = SearchValue != searchId; break; default: evaluation = false; break; } return evaluation.Value; }
/// <summary> /// Get the list of users authenticated user is followed by. /// </summary> /// <param name="accessToken"></param> /// <param name="max_user_id"></param> /// <returns></returns> public InstagramResponse <User[]> GetCurrentUserFollowedBy(string accessToken, string max_user_id) { Relationship objRelation = new Relationship(); return(objRelation.CurrentUserFollowedBy(accessToken, max_user_id)); }
/// <summary> /// Serialize to a JSON object /// </summary> public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } if (!string.IsNullOrEmpty(ResourceType)) { writer.WriteString("resourceType", (string)ResourceType !); } ((Fhir.R4.Models.DomainResource) this).SerializeJson(writer, options, false); if ((Identifier != null) && (Identifier.Count != 0)) { writer.WritePropertyName("identifier"); writer.WriteStartArray(); foreach (Identifier valIdentifier in Identifier) { valIdentifier.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((InstantiatesCanonical != null) && (InstantiatesCanonical.Count != 0)) { writer.WritePropertyName("instantiatesCanonical"); writer.WriteStartArray(); foreach (string valInstantiatesCanonical in InstantiatesCanonical) { writer.WriteStringValue(valInstantiatesCanonical); } writer.WriteEndArray(); } if ((_InstantiatesCanonical != null) && (_InstantiatesCanonical.Count != 0)) { writer.WritePropertyName("_instantiatesCanonical"); writer.WriteStartArray(); foreach (Element val_InstantiatesCanonical in _InstantiatesCanonical) { val_InstantiatesCanonical.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((InstantiatesUri != null) && (InstantiatesUri.Count != 0)) { writer.WritePropertyName("instantiatesUri"); writer.WriteStartArray(); foreach (string valInstantiatesUri in InstantiatesUri) { writer.WriteStringValue(valInstantiatesUri); } writer.WriteEndArray(); } if ((_InstantiatesUri != null) && (_InstantiatesUri.Count != 0)) { writer.WritePropertyName("_instantiatesUri"); writer.WriteStartArray(); foreach (Element val_InstantiatesUri in _InstantiatesUri) { val_InstantiatesUri.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (!string.IsNullOrEmpty(Status)) { writer.WriteString("status", (string)Status !); } if (_Status != null) { writer.WritePropertyName("_status"); _Status.SerializeJson(writer, options); } if (DataAbsentReason != null) { writer.WritePropertyName("dataAbsentReason"); DataAbsentReason.SerializeJson(writer, options); } if (Patient != null) { writer.WritePropertyName("patient"); Patient.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(Date)) { writer.WriteString("date", (string)Date !); } if (_Date != null) { writer.WritePropertyName("_date"); _Date.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(Name)) { writer.WriteString("name", (string)Name !); } if (_Name != null) { writer.WritePropertyName("_name"); _Name.SerializeJson(writer, options); } if (Relationship != null) { writer.WritePropertyName("relationship"); Relationship.SerializeJson(writer, options); } if (Sex != null) { writer.WritePropertyName("sex"); Sex.SerializeJson(writer, options); } if (BornPeriod != null) { writer.WritePropertyName("bornPeriod"); BornPeriod.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(BornDate)) { writer.WriteString("bornDate", (string)BornDate !); } if (_BornDate != null) { writer.WritePropertyName("_bornDate"); _BornDate.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(BornString)) { writer.WriteString("bornString", (string)BornString !); } if (_BornString != null) { writer.WritePropertyName("_bornString"); _BornString.SerializeJson(writer, options); } if (AgeAge != null) { writer.WritePropertyName("ageAge"); AgeAge.SerializeJson(writer, options); } if (AgeRange != null) { writer.WritePropertyName("ageRange"); AgeRange.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(AgeString)) { writer.WriteString("ageString", (string)AgeString !); } if (_AgeString != null) { writer.WritePropertyName("_ageString"); _AgeString.SerializeJson(writer, options); } if (EstimatedAge != null) { writer.WriteBoolean("estimatedAge", (bool)EstimatedAge !); } if (DeceasedBoolean != null) { writer.WriteBoolean("deceasedBoolean", (bool)DeceasedBoolean !); } if (DeceasedAge != null) { writer.WritePropertyName("deceasedAge"); DeceasedAge.SerializeJson(writer, options); } if (DeceasedRange != null) { writer.WritePropertyName("deceasedRange"); DeceasedRange.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(DeceasedDate)) { writer.WriteString("deceasedDate", (string)DeceasedDate !); } if (_DeceasedDate != null) { writer.WritePropertyName("_deceasedDate"); _DeceasedDate.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(DeceasedString)) { writer.WriteString("deceasedString", (string)DeceasedString !); } if (_DeceasedString != null) { writer.WritePropertyName("_deceasedString"); _DeceasedString.SerializeJson(writer, options); } if ((ReasonCode != null) && (ReasonCode.Count != 0)) { writer.WritePropertyName("reasonCode"); writer.WriteStartArray(); foreach (CodeableConcept valReasonCode in ReasonCode) { valReasonCode.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((ReasonReference != null) && (ReasonReference.Count != 0)) { writer.WritePropertyName("reasonReference"); writer.WriteStartArray(); foreach (Reference valReasonReference in ReasonReference) { valReasonReference.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((Note != null) && (Note.Count != 0)) { writer.WritePropertyName("note"); writer.WriteStartArray(); foreach (Annotation valNote in Note) { valNote.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((Condition != null) && (Condition.Count != 0)) { writer.WritePropertyName("condition"); writer.WriteStartArray(); foreach (FamilyMemberHistoryCondition valCondition in Condition) { valCondition.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }
public void Disassociate(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities) { }
/// <summary> /// Generates required data for a OneToMany relationship without embedded documents /// </summary> /// <returns></returns> public static RequiredDataContainer OneToManyNotEmbedded() { // Create ER Stuff Entity Person = new Entity("Person"); Person.AddAttribute("personId", true); Person.AddAttribute("name"); Entity Car = new Entity("Car"); Car.AddAttribute("carId", true); Car.AddAttribute("name"); Car.AddAttribute("year"); Car.AddAttribute("personId"); Relationship Drives = new Relationship("Drives"); Drives.AddRelationshipEnd(new RelationshipEnd(Person)); Drives.AddRelationshipEnd(new RelationshipEnd(Car)); ERModel Model = new ERModel("PersonCarModel", new List <BaseERElement> { Person, Car, Drives }); // Create MongoDB schema MongoDBCollection PersonCollection = new MongoDBCollection("Person"); PersonCollection.DocumentSchema.AddAttribute("_id"); PersonCollection.DocumentSchema.AddAttribute("name"); MongoDBCollection CarCollection = new MongoDBCollection("Car"); CarCollection.DocumentSchema.AddAttribute("_id"); CarCollection.DocumentSchema.AddAttribute("name"); CarCollection.DocumentSchema.AddAttribute("year"); CarCollection.DocumentSchema.AddAttribute("personId"); MongoSchema Schema = new MongoSchema("PersonCarSchema", new List <MongoDBCollection> { PersonCollection, CarCollection }); // Create Map MapRule PersonRule = new MapRule(Model.FindByName("Person"), Schema.FindByName("Person")); PersonRule.AddRule("personId", "_id"); PersonRule.AddRule("name", "name"); MapRule CarRule = new MapRule(Model.FindByName("Car"), Schema.FindByName("Car")); CarRule.AddRule("carId", "_id"); CarRule.AddRule("name", "name"); CarRule.AddRule("year", "year"); CarRule.AddRule("personId", "personId"); MapRule PersonCarRule = new MapRule(Model.FindByName("Person"), Schema.FindByName("Car"), false); PersonCarRule.AddRule("personId", "personId"); ModelMapping Map = new ModelMapping("PersonCarMap", new List <MapRule> { PersonRule, CarRule, PersonCarRule }); return(new RequiredDataContainer(Model, Schema, Map)); }
public static float GetAttractionScore(SimDescription simA, SimDescription simB, bool forceUpdate) { return(GetAttractionScore(Relationship.Get(simA, simB, false), forceUpdate)); }
public AIEVSawRelationshipUpdate(GameObject observed, Relationship r) { ObservedObj = observed; MyRelationship = r; ToBroadCastSawEvent = false; }
protected virtual bool TryGetCrmEntityWebLinkSetDataServiceUri(IEditableCrmEntityControl control, Entity entity, Relationship relationship, out string serviceUri) { var serviceBaseUri = string.IsNullOrEmpty(control.CmsServiceBaseUri) ? GetCmsServiceBaseUri(PortalName) : control.CmsServiceBaseUri; var context = GetServiceContext(PortalName); var uri = GetCrmEntitySetDataServiceUri(context.GetType(), "adx_weblink", serviceBaseUri, "adx_weblinksetid", entity.Id); serviceUri = AddWebsitePathToQuerystring(uri); return(!string.IsNullOrEmpty(serviceUri)); }
protected override bool TryGetDataServiceCrmAssocationSetUri(string portalName, IEditableCrmEntityControl control, Entity entity, Relationship relationship, out string serviceUri) { string uri; return(TryGetServiceUriWithWebsitePath(base.TryGetDataServiceCrmAssocationSetUri(portalName, control, entity, relationship, out uri), uri, out serviceUri)); }
public override Operation <AssociateResponse> AssociateAsOperation(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities, ExecuteParams executeParams = null) { using var service = GetService(); return(((IEnhancedOrgService)service).AssociateAsOperation(entityName, entityId, relationship, relatedEntities, executeParams)); }
public override void Disassociate(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities) { using var service = GetService(); ((IEnhancedOrgService)service).Disassociate(entityName, entityId, relationship, relatedEntities); }
/// <summary> /// List the users who have requested the authenticated user's permission to follow. /// </summary> /// <param name="accessToken"></param> /// <returns></returns> public InstagramResponse <User[]> GetCurrentUserRequestedBy(string accessToken) { Relationship objRelation = new Relationship(); return(objRelation.CurrentUserRequestedBy(accessToken)); }
protected override void InDatastoreLogic(Relationship Relationship) { PersistenceProvider.Add(Relationship, InItem, OutItem, Moment, true); }
internal TimeDependentAddRelationshipAction(RelationshipPersistenceProvider persistenceProvider, Relationship relationship, OGM inItem, OGM outItem, DateTime?moment) : base(persistenceProvider, relationship, inItem, outItem, moment) { }
protected override void AddEntityAssocationSetServiceReferenceForWebLinkSet(IEditableCrmEntityControl control, Entity entity, Relationship relationship, Control container) { string serviceUri; if (TryGetCrmEntityWebLinkSetDataServiceUri(control, entity, relationship, out serviceUri)) { AddServiceReference(control, serviceUri, "xrm-entity-{0}-ref".FormatWith(relationship.ToSchemaName("_")), container); } }
public static void CalculateAttractionScore(Relationship ths, bool displayNotice) { if (Common.AssemblyCheck.IsInstalled("NRaasChemistry")) { return; } if (ths == null) { return; } ths.AttractionScore = 0; //if (ths.AttractionScore == float.PositiveInfinity) { SimDescription simA = ths.SimDescriptionA; SimDescription simB = ths.SimDescriptionB; if ((simA != null) && (simB != null) && (simA.IsHuman) && (simB.IsHuman)) { string reason; GreyedOutTooltipCallback greyedOutTooltipCallback = null; if (CommonSocials.CanGetRomantic(simA, simB, true, false, true, ref greyedOutTooltipCallback, out reason)) { float score = RandomUtil.GetFloat(Relationship.kBaseRandomAttraction[0x0], Relationship.kBaseRandomAttraction[0x1]); score += Woohooer.Settings.mAttractionBaseChanceScoringV3[PersistedSettings.GetSpeciesIndex(simA)]; float origScore = score; float highScore = 0f; float newScore = 0f; switch (ths.LTR.CurrentLTR) { case LongTermRelationshipTypes.Spouse: case LongTermRelationshipTypes.Fiancee: if (score > 0) { score *= 2; } else { score = 0; } break; } newScore = score - origScore; origScore = score; Relationship.AttractionType attractionType = Relationship.AttractionType.None; foreach (Trait traitA in simA.TraitManager.List) { if (traitA.IsReward) { continue; } foreach (Trait traitB in simB.TraitManager.List) { if (traitB.IsReward) { continue; } if (traitA.TraitGuid == traitB.TraitGuid) { score += Relationship.kTraitModifier; } else if (TraitManager.DoTraitsConflict(traitA.Guid, traitB.Guid)) { score -= Relationship.kTraitModifier; } } } newScore = score - origScore; origScore = score; if (ths.TestWasNewHighScore(Relationship.AttractionType.Trait, newScore, ref highScore)) { attractionType = Relationship.AttractionType.Trait; } Occupation occupation = simA.Occupation; if (occupation != null) { score += occupation.CareerLevel * Relationship.kCareerBonusPerLevel; } Occupation occupation2 = simB.Occupation; if (occupation2 != null) { score += occupation2.CareerLevel * Relationship.kCareerBonusPerLevel; } newScore = score - origScore; origScore = score; if (ths.TestWasNewHighScore(Relationship.AttractionType.Career, newScore, ref highScore)) { attractionType = Relationship.AttractionType.Career; } foreach (Skill skill in simA.SkillManager.List) { score += skill.SkillLevel * Relationship.kSkillBonusPerLevel; } foreach (Skill skill2 in simB.SkillManager.List) { score += skill2.SkillLevel * Relationship.kSkillBonusPerLevel; } newScore = score - origScore; origScore = score; if (ths.TestWasNewHighScore(Relationship.AttractionType.Skill, newScore, ref highScore)) { attractionType = Relationship.AttractionType.Skill; } List <OccultTypes> listA = OccultTypeHelper.CreateList(simA); List <OccultTypes> listB = OccultTypeHelper.CreateList(simB); foreach (OccultTypes typeA in listA) { if (listB.Contains(typeA)) { score += Relationship.kBonusForMatchingOccult; } } newScore = score - origScore; origScore = score; if (ths.TestWasNewHighScore(Relationship.AttractionType.Occult, newScore, ref highScore)) { attractionType = Relationship.AttractionType.Occult; } CelebrityManager celebrityManagerA = simA.CelebrityManager; if (celebrityManagerA != null) { score += celebrityManagerA.Level * Relationship.kCelebrityBonusPerLevel; } CelebrityManager celebrityManagerB = simB.CelebrityManager; if (celebrityManagerB != null) { score += celebrityManagerB.Level * Relationship.kCelebrityBonusPerLevel; } newScore = score - origScore; origScore = score; if (ths.TestWasNewHighScore(Relationship.AttractionType.Celebrity, newScore, ref highScore)) { attractionType = Relationship.AttractionType.Celebrity; } if (simA.Zodiac == simB.Zodiac) { score += Relationship.kMatchingSignsBonus; } if (simA.FavoriteColor == simB.FavoriteColor) { score += Relationship.kMatchingSignsBonus / 2; } if (simA.FavoriteFood == simB.FavoriteFood) { score += Relationship.kMatchingSignsBonus / 2; } if (simA.FavoriteMusic == simB.FavoriteMusic) { score += Relationship.kMatchingSignsBonus / 2; } newScore = score - origScore; origScore = score; if (ths.TestWasNewHighScore(Relationship.AttractionType.Astro, newScore, ref highScore)) { attractionType = Relationship.AttractionType.Astro; } int familyFundsA = 0; Household house = simA.Household; if (house != null) { familyFundsA = house.FamilyFunds; } if (familyFundsA >= Relationship.kAttractedMoneyAmounts[0x2]) { score += Relationship.kAttractedMoneyBonuses[0x2]; } else if (familyFundsA >= Relationship.kAttractedMoneyAmounts[0x1]) { score += Relationship.kAttractedMoneyBonuses[0x1]; } else if (familyFundsA >= Relationship.kAttractedMoneyAmounts[0x0]) { score += Relationship.kAttractedMoneyBonuses[0x0]; } int familyFundsB = 0; house = simB.Household; if (house != null) { familyFundsB = house.FamilyFunds; } if (familyFundsB >= Relationship.kAttractedMoneyAmounts[0x2]) { score += Relationship.kAttractedMoneyBonuses[0x2]; } else if (familyFundsB >= Relationship.kAttractedMoneyAmounts[0x1]) { score += Relationship.kAttractedMoneyBonuses[0x1]; } else if (familyFundsB >= Relationship.kAttractedMoneyAmounts[0x0]) { score += Relationship.kAttractedMoneyBonuses[0x0]; } newScore = score - origScore; origScore = score; if (ths.TestWasNewHighScore(Relationship.AttractionType.Money, newScore, ref highScore)) { attractionType = Relationship.AttractionType.Money; } foreach (TraitNames trait in sAttractionTraits) { if (simA.HasTrait(trait)) { score += Relationship.kAttractionLifetimeRewardBonus; } if (simB.HasTrait(trait)) { score += Relationship.kAttractionLifetimeRewardBonus; } } newScore = score - origScore; origScore = score; if (ths.TestWasNewHighScore(Relationship.AttractionType.Attractive, newScore, ref highScore)) { attractionType = Relationship.AttractionType.Attractive; } BuffManager buffManagerA = null; if (simA.CreatedSim != null) { buffManagerA = simA.CreatedSim.BuffManager; } BuffManager buffManagerB = null; if (simB.CreatedSim != null) { buffManagerB = simB.CreatedSim.BuffManager; } foreach (BuffNames posBuff in Relationship.kPositiveBuffList) { if ((buffManagerA != null) && (buffManagerA.HasElement(posBuff))) { score += Relationship.kPerBuffModifier; } if ((buffManagerB != null) && (buffManagerB.HasElement(posBuff))) { score += Relationship.kPerBuffModifier; } } foreach (BuffNames negBuff in Relationship.kNegativeBuffList) { if ((buffManagerA != null) && (buffManagerA.HasElement(negBuff))) { score -= Relationship.kPerBuffModifier; } if ((buffManagerB != null) && (buffManagerB.HasElement(negBuff))) { score -= Relationship.kPerBuffModifier; } } newScore = score - origScore; origScore = score; if (ths.TestWasNewHighScore(Relationship.AttractionType.Buffs, newScore, ref highScore)) { attractionType = Relationship.AttractionType.Buffs; } score += simA.Fitness * 25; score += simB.Fitness * 25; if (simA.Weight < 0) { score += 25 - simA.Weight * -25; } else { score += 25 - simA.Weight * 25; } if (simB.Weight < 0) { score += 25 - simB.Weight * -25; } else { score += 25 - simB.Weight * 25; } int ageA = 0; switch (simA.Age) { case CASAgeGenderFlags.Teen: ageA = 1; break; case CASAgeGenderFlags.YoungAdult: ageA = 2; break; case CASAgeGenderFlags.Adult: ageA = 3; break; case CASAgeGenderFlags.Elder: ageA = 4; break; } int ageB = 0; switch (simB.Age) { case CASAgeGenderFlags.Teen: ageB = 1; break; case CASAgeGenderFlags.YoungAdult: ageB = 2; break; case CASAgeGenderFlags.Adult: ageB = 3; break; case CASAgeGenderFlags.Elder: ageB = 4; break; } score -= Math.Abs(ageA - ageB) * 25; newScore = score - origScore; origScore = score; if (ths.TestWasNewHighScore(Relationship.AttractionType.Physical, newScore, ref highScore)) { attractionType = Relationship.AttractionType.Physical; } ths.AttractionScore = score; if (Common.kDebugging) { Common.DebugNotify(simA.FullName + Common.NewLine + simB.FullName + Common.NewLine + "Attraction: " + score + Common.NewLine + attractionType); } if ((ths.AreAttracted) && ((SimTypes.IsSelectable(simA)) || (SimTypes.IsSelectable(simB)))) { if (AttractionHelper.TestEnableAttractionNPCController(ths)) { if (ths.AttractionNPCController == null) { ths.AttractionNPCController = new AttractionNPCBehaviorController(ths); } } else { if (ths.AttractionNPCController != null) { ths.AttractionNPCController.Dispose(); } } switch (ths.LTR.CurrentLTR) { case LongTermRelationshipTypes.Spouse: case LongTermRelationshipTypes.Fiancee: case LongTermRelationshipTypes.Ex: case LongTermRelationshipTypes.ExSpouse: case LongTermRelationshipTypes.Partner: case LongTermRelationshipTypes.RomanticInterest: break; default: if (displayNotice) { Sim createdSimA = simA.CreatedSim; Sim createdSimB = simB.CreatedSim; if ((createdSimA != null) && (createdSimB != null)) { if ((createdSimA.LotCurrent == createdSimB.LotCurrent) && (createdSimA.RoomId == createdSimB.RoomId)) { VisualEffect effect = VisualEffect.Create("ep8AttractionSystem"); createdSimB.ParentHeadlineFx(effect); effect.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition); VisualEffect effect2 = VisualEffect.Create("ep8AttractionSystem"); createdSimA.ParentHeadlineFx(effect2); effect2.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition); ThoughtBalloonManager.BalloonData bd = new ThoughtBalloonManager.BalloonData(createdSimA.GetThumbnailKey()); bd.BalloonType = ThoughtBalloonTypes.kSpeechBalloon; createdSimB.ThoughtBalloonManager.ShowBalloon(bd); ThoughtBalloonManager.BalloonData data2 = new ThoughtBalloonManager.BalloonData(createdSimB.GetThumbnailKey()); data2.BalloonType = ThoughtBalloonTypes.kSpeechBalloon; createdSimA.ThoughtBalloonManager.ShowBalloon(data2); TNSNames reasonTNS = ths.GetReasonTNS(attractionType); if (reasonTNS != TNSNames.None) { Sim target = createdSimB.IsSelectable ? createdSimB : createdSimA; Sim actor = (createdSimB == target) ? createdSimA : createdSimB; target.ShowTNSIfSelectable(reasonTNS, actor, target, new object[] { actor, target }); } EventTracker.SendEvent(EventTypeId.kMeetAttractiveSim, createdSimB); EventTracker.SendEvent(EventTypeId.kMeetAttractiveSim, createdSimA); Audio.StartObjectSound(createdSimB.IsSelectable ? createdSimB.ObjectId : createdSimA.ObjectId, "sting_attraction", false); } } } break; } } else if (ths.AttractionNPCController != null) { ths.AttractionNPCController.Dispose(); } } else { if (greyedOutTooltipCallback != null) { Common.DebugNotify(simA.FullName + Common.NewLine + simB.FullName + Common.NewLine + greyedOutTooltipCallback()); } } } } if (ths.AttractionNPCController != null) { ths.AttractionNPCController.Dispose(); } }
private List <SourceDescription> CiteGeorgeMarthaAndMarriage(Person george, Person martha, Relationship relationship) { SourceDescription georgeSource = new SourceDescription(); georgeSource.SetId("EEE-EEEE"); georgeSource.SetAbout("http://en.wikipedia.org/wiki/George_washington"); SourceCitation georgeCitation = new SourceCitation(); georgeCitation.SetValue("\"George Washington.\" Wikipedia, The Free Encyclopedia. Wikimedia Foundation, Inc. 24 October 2012."); georgeSource.SetCitation(georgeCitation); SourceDescription marthaSource = new SourceDescription(); marthaSource.SetId("FFF-FFFF"); marthaSource.SetAbout("http://en.wikipedia.org/wiki/Martha_washington"); SourceCitation marthaCitation = new SourceCitation(); marthaCitation.SetValue("\"Martha Washington.\" Wikipedia, The Free Encyclopedia. Wikimedia Foundation, Inc. 24 October 2012."); marthaSource.SetCitation(marthaCitation); SourceReference reference = new SourceReference(); reference.SetDescriptionRef("#" + georgeSource.Id); george.SetSource(reference); reference = new SourceReference(); reference.SetDescriptionRef("#" + marthaSource.Id); martha.SetSource(reference); relationship.SetSource(reference); return(new List <SourceDescription>() { georgeSource, marthaSource }); }
/// <summary>Add a relationship between two NPCs.</summary> /// <param name="left">The left NPC.</param> /// <param name="leftType">The left relationship type (i.e. <paramref name="left"/> is the _____ of <paramref name="right"/>).</param> /// <param name="right">The right NPC.</param> /// <param name="rightType">The right relationship type (i.e. <paramref name="right"/> is the _____ of <paramref name="left"/>).</param> private void AddRelationship(CharacterInfo left, Relationship leftType, CharacterInfo right, Relationship rightType) { left.AddRelationship(rightType, right); right.AddRelationship(leftType, left); }
public void Test_OneToOne_Import_27716( ) { EntityType type1 = null; EntityType type2 = null; ImportConfig config = null; Relationship rel; try { // Define schema type1 = new EntityType( ); type1.Save( ); type2 = new EntityType( ); type2.Save( ); rel = new Relationship { Cardinality_Enum = CardinalityEnum_Enumeration.OneToOne, FromType = type1, ToType = type2 }; rel.Save( ); // Existing instance IEntity instance2 = Entity.Create(type2.Id); instance2.SetField(Resource.Name_Field, "Target"); instance2.Save( ); // Define import config config = new ImportConfig { ImportFileType_Enum = ImportFileTypeEnum_Enumeration.ImportFileTypeCsv, ImportConfigMapping = new ApiResourceMapping { ImportHeadingRow = 0, ImportDataRow = 1, MappedType = type1, ResourceMemberMappings = { new ApiRelationshipMapping { Name = "1", MappedRelationship = rel, MapRelationshipInReverse = false }.As <ApiMemberMapping>( ) } } }; string csvData = "Target"; // Run import a first time ImportRun importRun = ImportTestHelper.CsvImport(config, csvData); Assert.That(importRun.ImportRunStatus_Enum, Is.EqualTo(WorkflowRunState_Enumeration.WorkflowRunCompleted), importRun.ImportMessages); // Check that instance and relationship got created IEntity instance1 = Entity.GetInstancesOfType(type1).FirstOrDefault( ); Assert.That(instance1, Is.Not.Null); var relValues = instance1.GetRelationships(rel.Id, Direction.Forward).ToList( ); Assert.That(relValues, Has.Count.EqualTo(1)); Assert.That(relValues[0].Id, Is.EqualTo(instance2.Id)); // Run import a second time importRun = ImportTestHelper.CsvImport(config, csvData); Assert.That(importRun.ImportRunStatus_Enum, Is.EqualTo(WorkflowRunState_Enumeration.WorkflowRunFailed), importRun.ImportMessages); var instances = Entity.GetInstancesOfType(type1).ToList(); Assert.That(importRun.ImportMessages, Contains.Substring("Line 1: The source item cannot be associated with Target because it is already associated with another record")); Assert.That(instances, Has.Count.EqualTo(1), "Final instance count"); } finally { type1?.Delete( ); type2?.Delete( ); config?.Delete( ); } }
/// <summary>Add a relationship to another NPC.</summary> /// <param name="relationship">The target character's relationship to the original character (like 'Mother').</param> /// <param name="character">The target character.</param> public void AddRelationship(Relationship relationship, CharacterInfo character) { this.Relationships.Add(new CharacterRelationship(relationship, character)); }
private static Workspace Create(bool usePaidFeatures) { Workspace workspace = new Workspace("Big Bank plc", "This is an example workspace to illustrate the key features of Structurizr, based around a fictional online banking system."); Model model = workspace.Model; ViewSet views = workspace.Views; model.Enterprise = new Enterprise("Big Bank plc"); // people and software systems Person customer = model.AddPerson(Location.External, "Personal Banking Customer", "A customer of the bank, with personal bank accounts."); SoftwareSystem internetBankingSystem = model.AddSoftwareSystem(Location.Internal, "Internet Banking System", "Allows customers to view information about their bank accounts, and make payments."); customer.Uses(internetBankingSystem, "Uses"); SoftwareSystem mainframeBankingSystem = model.AddSoftwareSystem(Location.Internal, "Mainframe Banking System", "Stores all of the core banking information about customers, accounts, transactions, etc."); mainframeBankingSystem.AddTags(ExistingSystemTag); internetBankingSystem.Uses(mainframeBankingSystem, "Uses"); SoftwareSystem emailSystem = model.AddSoftwareSystem(Location.Internal, "E-mail System", "The internal Microsoft Exchange e-mail system."); emailSystem.AddTags(ExistingSystemTag); emailSystem.Delivers(customer, "Sends e-mails to"); SoftwareSystem atm = model.AddSoftwareSystem(Location.Internal, "ATM", "Allows customers to withdraw cash."); atm.AddTags(ExistingSystemTag); atm.Uses(mainframeBankingSystem, "Uses"); customer.Uses(atm, "Withdraws cash using"); Person customerServiceStaff = model.AddPerson(Location.Internal, "Customer Service Staff", "Customer service staff within the bank."); customerServiceStaff.AddTags(BankStaffTag); customerServiceStaff.Uses(mainframeBankingSystem, "Uses"); customer.InteractsWith(customerServiceStaff, "Asks questions to", "Telephone"); Person backOfficeStaff = model.AddPerson(Location.Internal, "Back Office Staff", "Administration and support staff within the bank."); backOfficeStaff.AddTags(BankStaffTag); backOfficeStaff.Uses(mainframeBankingSystem, "Uses"); // containers Container singlePageApplication = internetBankingSystem.AddContainer("Single-Page Application", "Provides all of the Internet banking functionality to customers via their web browser.", "JavaScript and Angular"); singlePageApplication.AddTags(WebBrowserTag); Container mobileApp = internetBankingSystem.AddContainer("Mobile App", "Provides a limited subset of the Internet banking functionality to customers via their mobile device.", "Xamarin"); mobileApp.AddTags(MobileAppTag); Container webApplication = internetBankingSystem.AddContainer("Web Application", "Delivers the static content and the Internet banking single page application.", "Java and Spring MVC"); Container apiApplication = internetBankingSystem.AddContainer("API Application", "Provides Internet banking functionality via a JSON/HTTPS API.", "Java and Spring MVC"); Container database = internetBankingSystem.AddContainer("Database", "Stores user registration information, hashed authentication credentials, access logs, etc.", "Relational Database Schema"); database.AddTags(DatabaseTag); customer.Uses(webApplication, "Uses", "HTTPS"); customer.Uses(singlePageApplication, "Uses", ""); customer.Uses(mobileApp, "Uses", ""); webApplication.Uses(singlePageApplication, "Delivers", ""); apiApplication.Uses(database, "Reads from and writes to", "JDBC"); apiApplication.Uses(mainframeBankingSystem, "Uses", "XML/HTTPS"); apiApplication.Uses(emailSystem, "Sends e-mail using", "SMTP"); // components // - for a real-world software system, you would probably want to extract the components using // - static analysis/reflection rather than manually specifying them all Component signinController = apiApplication.AddComponent("Sign In Controller", "Allows users to sign in to the Internet Banking System.", "Spring MVC Rest Controller"); Component accountsSummaryController = apiApplication.AddComponent("Accounts Summary Controller", "Provides customers with a summary of their bank accounts.", "Spring MVC Rest Controller"); Component securityComponent = apiApplication.AddComponent("Security Component", "Provides functionality related to signing in, changing passwords, etc.", "Spring Bean"); Component mainframeBankingSystemFacade = apiApplication.AddComponent("Mainframe Banking System Facade", "A facade onto the mainframe banking system.", "Spring Bean"); apiApplication.Components.Where(c => "Spring MVC Rest Controller".Equals(c.Technology)).ToList().ForEach(c => singlePageApplication.Uses(c, "Uses", "HTTPS")); apiApplication.Components.Where(c => "Spring MVC Rest Controller".Equals(c.Technology)).ToList().ForEach(c => mobileApp.Uses(c, "Uses", "HTTPS")); signinController.Uses(securityComponent, "Uses"); accountsSummaryController.Uses(mainframeBankingSystemFacade, "Uses"); securityComponent.Uses(database, "Reads from and writes to", "JDBC"); mainframeBankingSystemFacade.Uses(mainframeBankingSystem, "Uses", "XML/HTTPS"); model.AddImplicitRelationships(); // deployment nodes and container instances DeploymentNode developerLaptop = model.AddDeploymentNode("Developer Laptop", "A developer laptop.", "Microsoft Windows 10 or Apple macOS"); DeploymentNode apacheTomcat = developerLaptop.AddDeploymentNode("Docker Container - Web Server", "A Docker container.", "Docker") .AddDeploymentNode("Apache Tomcat", "An open source Java EE web server.", "Apache Tomcat 8.x", 1, DictionaryUtils.Create("Xmx=512M", "Xms=1024M", "Java Version=8")); apacheTomcat.Add(webApplication); apacheTomcat.Add(apiApplication); developerLaptop.AddDeploymentNode("Docker Container - Database Server", "A Docker container.", "Docker") .AddDeploymentNode("Database Server", "A development database.", "Oracle 12c") .Add(database); developerLaptop.AddDeploymentNode("Web Browser", "", "Google Chrome, Mozilla Firefox, Apple Safari or Microsoft Edge").Add(singlePageApplication); DeploymentNode customerMobileDevice = model.AddDeploymentNode("Customer's mobile device", "", "Apple iOS or Android"); customerMobileDevice.Add(mobileApp); DeploymentNode customerComputer = model.AddDeploymentNode("Customer's computer", "", "Microsoft Windows or Apple macOS"); customerComputer.AddDeploymentNode("Web Browser", "", "Google Chrome, Mozilla Firefox, Apple Safari or Microsoft Edge").Add(singlePageApplication); DeploymentNode bigBankDataCenter = model.AddDeploymentNode("Big Bank plc", "", "Big Bank plc data center"); DeploymentNode liveWebServer = bigBankDataCenter.AddDeploymentNode("bigbank-web***", "A web server residing in the web server farm, accessed via F5 BIG-IP LTMs.", "Ubuntu 16.04 LTS", 4, DictionaryUtils.Create("Location=London and Reading")); liveWebServer.AddDeploymentNode("Apache Tomcat", "An open source Java EE web server.", "Apache Tomcat 8.x", 1, DictionaryUtils.Create("Xmx=512M", "Xms=1024M", "Java Version=8")) .Add(webApplication); DeploymentNode liveApiServer = bigBankDataCenter.AddDeploymentNode("bigbank-api***", "A web server residing in the web server farm, accessed via F5 BIG-IP LTMs.", "Ubuntu 16.04 LTS", 8, DictionaryUtils.Create("Location=London and Reading")); liveApiServer.AddDeploymentNode("Apache Tomcat", "An open source Java EE web server.", "Apache Tomcat 8.x", 1, DictionaryUtils.Create("Xmx=512M", "Xms=1024M", "Java Version=8")) .Add(apiApplication); DeploymentNode primaryDatabaseServer = bigBankDataCenter.AddDeploymentNode("bigbank-db01", "The primary database server.", "Ubuntu 16.04 LTS", 1, DictionaryUtils.Create("Location=London")) .AddDeploymentNode("Oracle - Primary", "The primary, live database server.", "Oracle 12c"); primaryDatabaseServer.Add(database); DeploymentNode secondaryDatabaseServer = bigBankDataCenter.AddDeploymentNode("bigbank-db02", "The secondary database server.", "Ubuntu 16.04 LTS", 1, DictionaryUtils.Create("Location=Reading")) .AddDeploymentNode("Oracle - Secondary", "A secondary, standby database server, used for failover purposes only.", "Oracle 12c"); ContainerInstance secondaryDatabase = secondaryDatabaseServer.Add(database); model.Relationships.Where(r => r.Destination.Equals(secondaryDatabase)).ToList().ForEach(r => r.AddTags(FailoverTag)); Relationship dataReplicationRelationship = primaryDatabaseServer.Uses(secondaryDatabaseServer, "Replicates data to", ""); secondaryDatabase.AddTags(FailoverTag); // views/diagrams SystemLandscapeView systemLandscapeView = views.CreateSystemLandscapeView("SystemLandscape", "The system landscape diagram for Big Bank plc."); systemLandscapeView.AddAllElements(); systemLandscapeView.PaperSize = PaperSize.A5_Landscape; SystemContextView systemContextView = views.CreateSystemContextView(internetBankingSystem, "SystemContext", "The system context diagram for the Internet Banking System."); systemContextView.EnterpriseBoundaryVisible = false; systemContextView.AddNearestNeighbours(internetBankingSystem); systemContextView.PaperSize = PaperSize.A5_Landscape; ContainerView containerView = views.CreateContainerView(internetBankingSystem, "Containers", "The container diagram for the Internet Banking System."); containerView.Add(customer); containerView.AddAllContainers(); containerView.Add(mainframeBankingSystem); containerView.Add(emailSystem); containerView.PaperSize = PaperSize.A5_Landscape; ComponentView componentView = views.CreateComponentView(apiApplication, "Components", "The component diagram for the API Application."); componentView.Add(mobileApp); componentView.Add(singlePageApplication); componentView.Add(database); componentView.AddAllComponents(); componentView.Add(mainframeBankingSystem); componentView.PaperSize = PaperSize.A5_Landscape; if (usePaidFeatures) { // dynamic diagrams and deployment diagrams are not available with the Free Plan DynamicView dynamicView = views.CreateDynamicView(apiApplication, "SignIn", "Summarises how the sign in feature works in the single-page application."); dynamicView.Add(singlePageApplication, "Submits credentials to", signinController); dynamicView.Add(signinController, "Calls isAuthenticated() on", securityComponent); dynamicView.Add(securityComponent, "select * from users where username = ?", database); dynamicView.PaperSize = PaperSize.A5_Landscape; DeploymentView developmentDeploymentView = views.CreateDeploymentView(internetBankingSystem, "DevelopmentDeployment", "An example development deployment scenario for the Internet Banking System."); developmentDeploymentView.Environment = "Development"; developmentDeploymentView.Add(developerLaptop); developmentDeploymentView.PaperSize = PaperSize.A5_Landscape; DeploymentView liveDeploymentView = views.CreateDeploymentView(internetBankingSystem, "LiveDeployment", "An example live deployment scenario for the Internet Banking System."); liveDeploymentView.Environment = "Live"; liveDeploymentView.Add(bigBankDataCenter); liveDeploymentView.Add(customerMobileDevice); liveDeploymentView.Add(customerComputer); liveDeploymentView.Add(dataReplicationRelationship); liveDeploymentView.PaperSize = PaperSize.A5_Landscape; } // colours, shapes and other diagram styling Styles styles = views.Configuration.Styles; styles.Add(new ElementStyle(Tags.Element) { Color = "#ffffff" }); styles.Add(new ElementStyle(Tags.SoftwareSystem) { Background = "#1168bd" }); styles.Add(new ElementStyle(Tags.Container) { Background = "#438dd5" }); styles.Add(new ElementStyle(Tags.Component) { Background = "#85bbf0", Color = "#000000" }); styles.Add(new ElementStyle(Tags.Person) { Background = "#08427b", Shape = Shape.Person, FontSize = 22 }); styles.Add(new ElementStyle(ExistingSystemTag) { Background = "#999999" }); styles.Add(new ElementStyle(BankStaffTag) { Background = "#999999" }); styles.Add(new ElementStyle(WebBrowserTag) { Shape = Shape.WebBrowser }); styles.Add(new ElementStyle(MobileAppTag) { Shape = Shape.MobileDeviceLandscape }); styles.Add(new ElementStyle(DatabaseTag) { Shape = Shape.Cylinder }); styles.Add(new ElementStyle(FailoverTag) { Opacity = 25 }); styles.Add(new RelationshipStyle(FailoverTag) { Opacity = 25, Position = 70 }); // documentation // - usually the documentation would be included from separate Markdown/AsciiDoc files, but this is just an example StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace); template.AddContextSection(internetBankingSystem, Format.Markdown, "Here is some context about the Internet Banking System...\n" + "![](embed:SystemLandscape)\n" + "![](embed:SystemContext)\n" + "### Internet Banking System\n...\n" + "### Mainframe Banking System\n...\n"); template.AddContainersSection(internetBankingSystem, Format.Markdown, "Here is some information about the containers within the Internet Banking System...\n" + "![](embed:Containers)\n" + "### Web Application\n...\n" + "### Database\n...\n"); template.AddComponentsSection(webApplication, Format.Markdown, "Here is some information about the API Application...\n" + "![](embed:Components)\n" + "### Sign in process\n" + "Here is some information about the Sign In Controller, including how the sign in process works...\n" + "![](embed:SignIn)"); template.AddDevelopmentEnvironmentSection(internetBankingSystem, Format.AsciiDoc, "Here is some information about how to set up a development environment for the Internet Banking System...\n" + "image::embed:DevelopmentDeployment[]"); template.AddDeploymentSection(internetBankingSystem, Format.AsciiDoc, "Here is some information about the live deployment environment for the Internet Banking System...\n" + "image::embed:LiveDeployment[]"); return(workspace); }
public static bool CreateActiveHouseholdAndActiveActor() { if (GameStates.IsGameShuttingDown || PlumbBob.Singleton == null) { return(false); } if (/*PlumbBob.SelectedActor != null &&*/ PlumbBob.Singleton.mSelectedActor != null) { return(true); } List <Lot> lieast = new List <Lot>(); Lot lot = null; //foreach (object obj in LotManager.AllLotsWithoutCommonExceptions) foreach (object obj in LotManager.AllLots) { //Lot lot2 = (Lot)obj; //if (lot2.IsResidentialLot && lot2.Household == null) Lot lot2 = (Lot)obj; if (!lot2.IsWorldLot && !lot2.IsCommunityLotOfType(CommercialLotSubType.kEP10_Diving) && !UnchartedIslandMarker.IsUnchartedIsland(lot2) && lot2.IsResidentialLot && lot2.Household == null && !World.LotIsEmpty(lot2.LotId) && !lot2.IsLotEmptyFromObjects()) { lieast.Add(lot2); } if (lieast.Count == 0) { if (!lot2.IsWorldLot && !lot2.IsCommunityLotOfType(CommercialLotSubType.kEP10_Diving) && !UnchartedIslandMarker.IsUnchartedIsland(lot2) && lot2.IsResidentialLot && lot2.Household == null) { lieast.Add(lot2); } } } if (lieast.Count > 0) { string simlastnamehousehold = "No Name"; lot = RandomUtil.GetRandomObjectFromList <Lot>(lieast); List <Sim> siml = new List <Sim>(); Sim sim = null; Sim sim2 = null; Sim sim3 = null; Sim sim4 = null; if (AssemblyCheckByNiec.IsInstalled("DGSCore")) { try { CommandSystem.ExecuteCommandString("dgspx false"); } catch { } sim4 = DGSMakeSim.DGSMakeRandomSimNoCheck(lot.Position, CASAgeGenderFlags.Child, CASAgeGenderFlags.Female, GameUtils.GetCurrentWorld()); sim = DGSMakeSim.DGSMakeRandomSimNoCheck(lot.Position, CASAgeGenderFlags.YoungAdult, CASAgeGenderFlags.Male, WorldName.RiverView); sim2 = DGSMakeSim.DGSMakeRandomSimNoCheck(lot.Position, CASAgeGenderFlags.YoungAdult, CASAgeGenderFlags.Female, WorldName.IslaParadiso); sim3 = DGSMakeSim.DGSMakeRandomSimNoCheck(lot.Position, CASAgeGenderFlags.Child, CASAgeGenderFlags.Male, GameUtils.GetCurrentWorld()); } else { sim = DGSMakeSim.DGSMakeRandomSimNoCheck(lot.Position, CASAgeGenderFlags.YoungAdult, CASAgeGenderFlags.Male, GameUtils.GetCurrentWorld()); sim2 = DGSMakeSim.DGSMakeRandomSimNoCheck(lot.Position, CASAgeGenderFlags.YoungAdult, CASAgeGenderFlags.Female, GameUtils.GetCurrentWorld()); sim3 = DGSMakeSim.DGSMakeRandomSimNoCheck(lot.Position, CASAgeGenderFlags.Child, CASAgeGenderFlags.Male, GameUtils.GetCurrentWorld()); sim4 = DGSMakeSim.DGSMakeRandomSimNoCheck(lot.Position, CASAgeGenderFlags.Child, CASAgeGenderFlags.Female, GameUtils.GetCurrentWorld()); } if (sim != null) { simlastnamehousehold = sim.SimDescription.LastName; siml.Add(sim); } if (sim2 != null) { simlastnamehousehold = sim2.SimDescription.LastName; siml.Add(sim2); } if (sim3 != null) { siml.Add(sim3); } if (sim4 != null) { siml.Add(sim4); } try { Relationship relation = Relationship.Get(sim.SimDescription, sim2.SimDescription, true); if (relation != null) { NFinalizeDeath.ForceChangeState(relation, LongTermRelationshipTypes.Spouse); } /* * try * { * sim.Genealogy.RemoveDirectRelation(sim2.Genealogy); * sim2.Genealogy.RemoveDirectRelation(sim.Genealogy); * } * catch * { } * * * sim2.Genealogy.AddSibling(sim.Genealogy); */ } catch { } try { Relationship childfrined = Relationship.Get(sim3.SimDescription, sim4.SimDescription, true); if (childfrined != null) { NFinalizeDeath.ForceChangeState(childfrined, LongTermRelationshipTypes.GoodFriend); } Relationship relation2 = Relationship.Get(sim.SimDescription, sim3.SimDescription, true); if (relation2 != null) { NFinalizeDeath.ForceChangeState(relation2, LongTermRelationshipTypes.GoodFriend); } Relationship relation3 = Relationship.Get(sim.SimDescription, sim4.SimDescription, true); if (relation3 != null) { NFinalizeDeath.ForceChangeState(relation3, LongTermRelationshipTypes.GoodFriend); } Relationship relation4 = Relationship.Get(sim2.SimDescription, sim3.SimDescription, true); if (relation4 != null) { NFinalizeDeath.ForceChangeState(relation4, LongTermRelationshipTypes.GoodFriend); } Relationship relation5 = Relationship.Get(sim2.SimDescription, sim4.SimDescription, true); if (relation5 != null) { NFinalizeDeath.ForceChangeState(relation5, LongTermRelationshipTypes.GoodFriend); } Relationship relation6 = Relationship.Get(sim3.SimDescription, sim.SimDescription, true); if (relation6 != null) { NFinalizeDeath.ForceChangeState(relation6, LongTermRelationshipTypes.GoodFriend); } Relationship relation7 = Relationship.Get(sim3.SimDescription, sim2.SimDescription, true); if (relation7 != null) { NFinalizeDeath.ForceChangeState(relation7, LongTermRelationshipTypes.GoodFriend); } Relationship relation8 = Relationship.Get(sim4.SimDescription, sim.SimDescription, true); if (relation8 != null) { NFinalizeDeath.ForceChangeState(relation8, LongTermRelationshipTypes.GoodFriend); } Relationship relation9 = Relationship.Get(sim4.SimDescription, sim2.SimDescription, true); if (relation9 != null) { NFinalizeDeath.ForceChangeState(relation9, LongTermRelationshipTypes.GoodFriend); } } catch { } try { if (sim.SimDescription != null && sim.SimDescription.Genealogy != null) { sim.SimDescription.Genealogy.AddChild(sim3.SimDescription.Genealogy); } if (sim2.SimDescription != null && sim2.SimDescription.Genealogy != null) { sim2.SimDescription.Genealogy.AddChild(sim3.SimDescription.Genealogy); } } catch { } try { if (sim.SimDescription != null && sim.SimDescription.Genealogy != null) { sim.SimDescription.Genealogy.AddChild(sim4.SimDescription.Genealogy); } if (sim2.SimDescription != null && sim2.SimDescription.Genealogy != null) { sim2.SimDescription.Genealogy.AddChild(sim4.SimDescription.Genealogy); } } catch { } if (siml.Count > 0) { bool checknullsim = false; try { if (sim4 != null) { PlumbBob.ForceSelectActor(sim4); } else { checknullsim = true; } sim2.SimDescription.Household.SetName(sim2.SimDescription.LastName); } catch { } try { foreach (Sim sitem in siml) { if (sitem == null) { continue; } try { if (checknullsim) { PlumbBob.ForceSelectActor(sitem); checknullsim = false; } sitem.SimDescription.LastName = simlastnamehousehold; sitem.SimDescription.Household.SetName(sim.SimDescription.LastName); try { if (sitem.SimDescription.Child || sitem.SimDescription.Teen) { sitem.SimDescription.AssignSchool(); } GlobalFunctions.PlaceAtGoodLocation(sitem, new World.FindGoodLocationParams(lot.Position), false); } catch { } try { if (sitem.IsSelectable) { sitem.OnBecameSelectable(); } } catch { } } catch (Exception ex2) { NiecMod.Nra.NiecException.WriteLog("SetName Household" + " SetName: " + NiecMod.Nra.NiecException.NewLine + NiecMod.Nra.NiecException.LogException(ex2), true, true); } try { if (sitem.SimDescription.TraitManager.HasElement(TraitNames.Evil)) { sitem.SimDescription.TraitManager.RemoveElement(TraitNames.Evil); sitem.SimDescription.TraitManager.AddElement(TraitNames.Good); } sitem.AddInitialObjects(sitem.IsSelectable); } catch { } } } catch { } } } else if (lieast.Count == 0) { return(false); } return(true); }
protected override void ExecuteWorkflowLogic() { List<Entity> records; var recordUrl = Record.Get(Context.ExecutionContext); if (!string.IsNullOrEmpty(recordUrl)) { var record = ConvertToEntityReference(Record.Get(Context.ExecutionContext)); var relationshipName = RelationshipName.Get(Context.ExecutionContext); if (string.IsNullOrEmpty(relationshipName)) { throw new InvalidPluginExecutionException("Reationship Name Parameter is empty!"); } var relationship = new Relationship(relationshipName); var retrieveEntityRequest = new RetrieveEntityRequest() { LogicalName = record.LogicalName, EntityFilters = EntityFilters.Relationships, RetrieveAsIfPublished = true }; var retrieveEntityResponse = (RetrieveEntityResponse) Context.SystemService.Execute(retrieveEntityRequest); string childEntityName = null; var ntonRelationship = retrieveEntityResponse.EntityMetadata.ManyToManyRelationships.FirstOrDefault( r => r.SchemaName == relationshipName); if (ntonRelationship != null) { childEntityName = ntonRelationship.Entity1LogicalName == record.LogicalName ? ntonRelationship.Entity2LogicalName : ntonRelationship.Entity1LogicalName; } else { var onetonRelationship = retrieveEntityResponse.EntityMetadata.OneToManyRelationships.FirstOrDefault( r => r.SchemaName == relationshipName); if (onetonRelationship == null) throw new Exception( $"Relationship {relationshipName} is not available for {record.LogicalName} entity"); childEntityName = onetonRelationship.ReferencingEntity; } FetchXml = $@" <fetch> <entity name='{childEntityName}'> <all-attributes />"; var additionalConditions = AdditionalFilterArgument.Get(Context.ExecutionContext); if (!string.IsNullOrEmpty(additionalConditions)) FetchXml += $"<filter type='and'>{additionalConditions.Replace('"', '\'')}</filter>"; FetchXml += @" </entity> </fetch>"; var retrieveRequest = new RetrieveRequest() { ColumnSet = new ColumnSet(false), Target = record, RelatedEntitiesQuery = new RelationshipQueryCollection { {relationship, new FetchExpression(FetchXml)} } }; var retrieveResponse = (RetrieveResponse) Context.UserService.Execute(retrieveRequest); records = retrieveResponse.Entity.RelatedEntities[relationship].Entities.ToList(); } else { var publicView = PublicView.Get(Context.ExecutionContext); var privateView = PrivateView.Get(Context.ExecutionContext); FetchXml = FetchXmlQuery.Get(Context.ExecutionContext); if (publicView == null && privateView == null && FetchXml == null) throw new InvalidPluginExecutionException("One of 'Record Reference'/'Relationship Name', 'Public View', 'Private View' or 'Fetch Xml Query' inputs has to be populated!"); if (publicView != null) { FetchXml = Context.SystemService.Retrieve(publicView.LogicalName, publicView.Id, new ColumnSet("fetchxml")).GetAttributeValue<string>("fetchxml"); } else if (privateView != null) { FetchXml = Context.SystemService.Retrieve(privateView.LogicalName, privateView.Id, new ColumnSet("fetchxml")).GetAttributeValue<string>("fetchxml"); } records = QueryWithPaging(new FetchExpression(FetchXml)); } var isContinueOnError = IsContinueOnError.Get(Context.ExecutionContext); PerformOperation(records, isContinueOnError); }
public static List <PhoneSimPicker.SimPickerInfo> ListOfAllSims(Sim me, bool allowChildren, bool allowMe) { List <PhoneSimPicker.SimPickerInfo> sims = new List <PhoneSimPicker.SimPickerInfo>(); List <Sim> list = new List <Sim>(Sims3.Gameplay.Queries.GetObjects <Sim>()); foreach (Sim sim in list) { if (sim.LotCurrent != me.LotCurrent) { continue; } if (!allowMe) { if (sim == me) { continue; } } if (!allowChildren) { if (sim.SimDescription.ChildOrBelow) { continue; } } PhoneSimPicker.SimPickerInfo item = new PhoneSimPicker.SimPickerInfo(); item.FirstName = sim.SimDescription.LastName + ","; item.LastName = sim.SimDescription.FirstName; item.Thumbnail = sim.SimDescription.GetThumbnailKey(ThumbnailSize.Large, 0); item.SimDescription = sim.SimDescription; Relationship relation = Relationship.Get(sim.SimDescription, me.SimDescription, false); if (relation != null) { item.RelationShip = relation.LTR.Liking; item.RelationshipImage = relation.LTR.CurrentLTR; item.Friend = relation.AreFriends(); } else if (sim == me) { item.RelationShip = 100f; item.RelationshipImage = "Best Friend"; item.Friend = true; } else { item.RelationShip = 0f; item.RelationshipImage = "Stranger"; item.Friend = false; } item.RelationshipText = LTRData.Get(item.RelationshipImage).GetName(me.SimDescription, sim.SimDescription); item.RelationshipWithFirstName = me.SimDescription.FirstName; item.CoWorker = false; if ((me.CareerManager != null) && (me.CareerManager.Job != null)) { if (sim.SimDescription == me.CareerManager.Job.Boss) { item.CoWorker = true; } else { foreach (SimDescription description2 in me.CareerManager.Job.Coworkers) { if (description2 == sim.SimDescription) { item.CoWorker = true; break; } } } } sims.Add(item); } return(sims); }
public CitizenDependents(string t, int CID) { type = t; ID = CID; InitializeComponent(); DataTable dt = controllerObj.SelectDependentsByCitizen(ID); dataGridView1.DataSource = dt; NameRemove.DataSource = dt; NameRemove.ValueMember = "Name"; NameRemove.DisplayMember = "Name"; NameSalary.DataSource = dt; NameSalary.ValueMember = "Name"; NameSalary.DisplayMember = "Name"; NameName.DataSource = dt; NameName.ValueMember = "Name"; NameName.DisplayMember = "Name"; NameBirth.DataSource = dt; NameBirth.ValueMember = "Name"; NameBirth.DisplayMember = "Name"; if (type != "Admin") { Confirm2.Hide(); Confirm3.Hide(); label12.Hide(); label13.Hide(); label14.Hide(); label15.Hide(); label16.Hide(); label17.Hide(); NameName.Hide(); NameNew.Hide(); NameBirth.Hide(); BirthdateNew.Hide(); } if (type == "Employee") { label2.Hide(); label3.Hide(); label4.Hide(); label5.Hide(); label6.Hide(); label7.Hide(); label8.Hide(); label9.Hide(); label10.Hide(); label11.Hide(); Confirm.Hide(); Remove.Hide(); Add.Hide(); NameAdd.Hide(); NameRemove.Hide(); NameSalary.Hide(); Salary.Hide(); SalaryNew.Hide(); Birthdate.Hide(); Relationship.Hide(); } DataTable C = controllerObj.SelectCitizenByID(ID); CitizenID.Text = Convert.ToString(C.Rows[0]["First Name"]) + Convert.ToString(C.Rows[0]["Last Name"]); }
public string Test_Secured_By_Relationship(string settings) { // Note: ExpectedResult is null when we expect no grant Definition typeExplicitlyGranted = null; // needs to be definition, otherwise gets filtered from the report. Definition typeToBeChecked = null; Definition fromType = null; Definition toType = null; Relationship rel = null; Role role = null; List <IEntity> cleanup = new List <IEntity>( ); try { EntityType editableResource = UserResource.UserResource_Type; // Setup scenario typeExplicitlyGranted = Entity.Create <Definition>( ); typeExplicitlyGranted.Name = "ExplicitType"; typeExplicitlyGranted.Inherits.Add(editableResource); typeExplicitlyGranted.Save( ); cleanup.Add(typeExplicitlyGranted); typeToBeChecked = Entity.Create <Definition>( ); typeToBeChecked.Name = "CheckedType"; typeToBeChecked.Inherits.Add(editableResource); typeToBeChecked.Save( ); cleanup.Add(typeToBeChecked); // Set up relationship rel = Entity.Create <Relationship>( ); rel.Cardinality_Enum = CardinalityEnum_Enumeration.ManyToMany; rel.Name = "RelName"; rel.ToName = "ToName"; rel.FromName = "FromName"; cleanup.Add(rel); if (settings.Contains("fwd")) { fromType = typeExplicitlyGranted; toType = typeToBeChecked; } else if (settings.Contains("rev")) { fromType = typeToBeChecked; toType = typeExplicitlyGranted; } if (settings.Contains("fromAncestor") || settings.Contains("fromDerived")) { var oldFrom = fromType; fromType = new Definition( ); if (settings.Contains("fromAncestor")) { fromType.Name = "FromAncestor"; fromType.Inherits.Add(editableResource); fromType.DerivedTypes.Add(oldFrom.Cast <EntityType>( )); } else { fromType.Name = "FromDerived"; fromType.Inherits.Add(oldFrom.Cast <EntityType>( )); } fromType.Save( ); cleanup.Add(fromType); } if (settings.Contains("toAncestor") || settings.Contains("toDerived")) { var oldTo = toType; toType = new Definition( ); if (settings.Contains("toAncestor")) { toType.Name = "ToAncestor"; toType.Inherits.Add(editableResource); toType.DerivedTypes.Add(oldTo.Cast <EntityType>( )); } else { toType.Name = "ToDerived"; toType.Inherits.Add(oldTo.Cast <EntityType>( )); } toType.Save( ); cleanup.Add(toType); } rel.FromType = fromType.Cast <EntityType>( ); rel.ToType = toType.Cast <EntityType>( ); rel.SecuresTo = settings.Contains("securesTo"); rel.SecuresFrom = settings.Contains("securesFrom"); rel.Save( ); // Set up role role = new Role { Name = "Role1" }; role.Save( ); cleanup.Add(role); new AccessRuleFactory( ).AddAllowReadQuery(role.As <Subject>( ), typeExplicitlyGranted.As <SecurableEntity>( ), TestQueries.Entities(typeExplicitlyGranted).ToReport( )); // Tests ITypeAccessReasonService service = Factory.Current.Resolve <ITypeAccessReasonService>( ); var reasons = service.GetTypeAccessReasons(role.Id, TypeAccessReasonSettings.Default); // Sanity check for the type we explicitly grant accses Assert.That(reasons.Where(r => r.TypeId == typeExplicitlyGranted.Id).Count( ), Is.EqualTo(1), "typeExplicitlyGranted"); AccessReason reason1 = reasons.Single(r => r.TypeId == typeExplicitlyGranted.Id); Assert.That(reason1.AccessRuleScope, Is.EqualTo(AccessRuleScope.AllInstances), "rule1 scope"); Assert.That(reason1.PermissionsText, Is.EqualTo("Read"), "rule1 perms"); Assert.That(reason1.SubjectId, Is.EqualTo(role.Id), "rule1 subject"); Assert.That(reason1.Description, Is.EqualTo("Access rule: 'Role1' accessing 'ExplicitType'"), "rule1 desc"); AccessReason reason2 = reasons.FirstOrDefault(r => r.TypeId == typeToBeChecked.Id); if (reason2 != null) { Assert.That(reason2.AccessRuleScope, Is.EqualTo(AccessRuleScope.SecuredRelationship), "rule2 scope"); Assert.That(reason2.PermissionsText, Is.EqualTo("Read"), "rule2 perms"); Assert.That(reason2.SubjectId, Is.EqualTo(role.Id), "rule2 subject"); } return(reason2?.Description); // actual string being tested } finally { Entity.Delete(cleanup.Select(e => new EntityRef(e))); } }
/// <summary> /// Get the list of users this user follows. /// </summary> /// <param name="userid"></param> /// <param name="accessToken"></param> /// <param name="max_user_id"></param> /// <returns></returns> public InstagramResponse <User[]> GetUserFollows(string userid, string accessToken, string max_user_id) { Relationship objRelation = new Relationship(); return(objRelation.UserFollows(userid, accessToken, max_user_id)); }
public void Test_Secured_By_Relationship_Chained( ) { // Note: ExpectedResult is null when we expect no grant Definition typeExplicitlyGranted = null; // needs to be definition, otherwise gets filtered from the report. Definition typeMiddle = null; Definition typeToBeChecked = null; Relationship rel = null; Relationship rel2 = null; Role role = null; List <IEntity> cleanup = new List <IEntity>( ); try { EntityType editableResource = UserResource.UserResource_Type; // Setup scenario typeExplicitlyGranted = Entity.Create <Definition>( ); typeExplicitlyGranted.Name = "ExplicitType"; typeExplicitlyGranted.Inherits.Add(editableResource); typeExplicitlyGranted.Save( ); cleanup.Add(typeExplicitlyGranted); typeMiddle = Entity.Create <Definition>( ); typeMiddle.Name = "MiddleType"; typeMiddle.Inherits.Add(editableResource); typeMiddle.Save( ); cleanup.Add(typeMiddle); typeToBeChecked = Entity.Create <Definition>( ); typeToBeChecked.Name = "CheckedType"; typeToBeChecked.Inherits.Add(editableResource); typeToBeChecked.Save( ); cleanup.Add(typeToBeChecked); // Set up relationship rel = Entity.Create <Relationship>( ); rel.Cardinality_Enum = CardinalityEnum_Enumeration.ManyToMany; rel.Name = "RelName1"; rel.ToName = "ToName1"; rel.FromName = "FromName1"; rel.FromType = typeExplicitlyGranted.Cast <EntityType>( ); rel.ToType = typeMiddle.Cast <EntityType>( ); rel.SecuresTo = true; rel.Save( ); cleanup.Add(rel); rel2 = Entity.Create <Relationship>( ); rel2.Cardinality_Enum = CardinalityEnum_Enumeration.ManyToMany; rel2.Name = "RelName2"; rel2.ToName = "ToName2"; rel2.FromName = "FromName2"; rel2.ToType = typeMiddle.Cast <EntityType>( ); rel2.FromType = typeToBeChecked.Cast <EntityType>( ); rel2.SecuresFrom = true; rel2.Save( ); cleanup.Add(rel2); // Set up role role = new Role { Name = "Role1" }; role.Save( ); cleanup.Add(role); new AccessRuleFactory( ).AddAllowReadQuery(role.As <Subject>( ), typeExplicitlyGranted.As <SecurableEntity>( ), TestQueries.Entities(typeExplicitlyGranted).ToReport( )); // Tests ITypeAccessReasonService service = Factory.Current.Resolve <ITypeAccessReasonService>( ); var reasons = service.GetTypeAccessReasons(role.Id, TypeAccessReasonSettings.Default); // Sanity check for the type we explicitly grant accses Assert.That(reasons.Where(r => r.TypeId == typeExplicitlyGranted.Id).Count( ), Is.EqualTo(1), "typeExplicitlyGranted"); AccessReason reason1 = reasons.Single(r => r.TypeId == typeExplicitlyGranted.Id); AccessReason reason2 = reasons.Single(r => r.TypeId == typeMiddle.Id); AccessReason reason3 = reasons.Single(r => r.TypeId == typeToBeChecked.Id); Assert.That(reason1.Description, Is.EqualTo("Access rule: 'Role1' accessing 'ExplicitType'"), "rule1 desc"); Assert.That(reason2.Description, Is.EqualTo("Secured via 'ExplicitType' object: 'ToName1' relationship"), "rule2 desc"); Assert.That(reason3.Description, Is.EqualTo("Secured via 'ExplicitType' object: 'ToName1' -> 'FromName2' relationships"), "rule3 desc"); } finally { Entity.Delete(cleanup.Select(e => new EntityRef(e))); } }
public void Disassociate(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities) { throw new NotImplementedException(); }
/// <summary> /// Get information about a relationship to another user. /// </summary> /// <param name="recipient_userid"></param> /// <param name="accessToken"></param> /// <returns></returns> public InstagramResponse <Relation> GetCurrentUserRelationshipWith(string recipient_userid, string accessToken) { Relationship objRelation = new Relationship(); return(objRelation.CurrentUserRelationshipWith(recipient_userid, accessToken)); }
private bool IsSelectionValidForEntityRequestor(Entity selectedEntity) { List <ITable> selectedEntitiesTables = selectedEntity.MappedTables().ToList(); List <Relationship> validRelationships = new List <Relationship>(); List <ITable> validAssociationTables = new List <ITable>(); if (selectedEntitiesTables.Count == 1 && Entity.MappedTables().Count() == 1 && selectedEntitiesTables[0] == Entity.MappedTables().ElementAt(0)) { // Table Per Hierarchy inheritance return(true); } if (RequestorType == RequestorTypes.Entity_Select_Parent && selectedEntitiesTables.Count == 0) { bool isOk = true; foreach (Property property in selectedEntity.Properties) { if (Entity.Properties.Count(p => p.Name == property.Name && p.Type == property.Type) == 0) { isOk = false; break; } } // This is OK for Table Per Concrete Class inheritance - the Base is totally virtual and doesn't have // a mapped table in the database, and all of it's properties exist in the child class. if (isOk) { return(true); } } else if (RequestorType == RequestorTypes.Entity_Select_Child && selectedEntitiesTables.Count > 0) { bool isOk = true; foreach (Property property in Entity.Properties) { if (selectedEntity.Properties.Count(p => p.Name == property.Name && p.Type == property.Type) == 0) { isOk = false; break; } } // This is OK for Table Per Concrete Class inheritance - the Base is totally virtual and doesn't have // a mapped table in the database, and all of it's properties exist in the child class. if (isOk) { return(true); } } // Check that a relationship or association table exists between the entity and the new selected entity foreach (ITable table in Entity.MappedTables()) { foreach (Relationship relationship in table.Relationships) { if (selectedEntitiesTables.Contains(relationship.PrimaryTable) || selectedEntitiesTables.Contains(relationship.ForeignTable)) { validRelationships.Add(relationship); SelectedRelationship = relationship; if (table == relationship.PrimaryTable) { CardinalityPrimary = relationship.PrimaryCardinality; CardinalityForeign = relationship.ForeignCardinality; } else { CardinalityPrimary = relationship.ForeignCardinality; CardinalityForeign = relationship.PrimaryCardinality; } break; } } if (SelectedRelationship != null) { break; } } IKey primaryKey = null; IKey foreignKey = null; ITable associationTable = null; if (validRelationships.Count == 0) { associationTable = Entity.GetAssociationTable(selectedEntity, out CardinalityPrimary, out CardinalityForeign, out primaryKey, out foreignKey); } if (validRelationships.Count == 0 && associationTable == null) { //MessageBox.Show(this, string.Format("No relationships or association tables exist between {0} and {1}.{2}You need to add a relationship (or association table) between the tables in the database, or add a virtual relationship between these tables in the table-diagrammer.", // Entity.Name, // selectedEntity.Name, // Environment.NewLine), "No valid relationships", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); //Close(); //return; return(false); } if (associationTable != null) { AssociationTable = associationTable; } return(true); }