protected override Assembly Mapping(AssemblyType sObject, Assembly tObject) { //do basic mapping of the object base.Mapping(sObject, tObject); //add assembly to asset types (which is a nonsense but it is how it is defined in the COBieLite schema for now) if (sObject.AggregationOfAssetTypes != null && sObject.AggregationOfAssetTypes.Any()) { var assetMap = Exchanger.GetOrCreateMappings <MappingAssetTypeToAssetType>(); foreach (var id in sObject.AggregationOfAssetTypes) { AssetTypeInfoType tAsset; if (!assetMap.GetTargetObject(id.ToString(), out tAsset)) { continue; } if (tAsset.AssemblyAssignments == null) { tAsset.AssemblyAssignments = new AssemblyAssignmentCollectionType(); } tAsset.AssemblyAssignments.Add(tObject); } } //do specific mappings return(tObject); }
protected override Space Mapping(IIfcSpatialStructureElement ifcSpatialElement, Space target) { var helper = ((IfcToCOBieLiteUkExchanger)Exchanger).Helper; target.ExternalEntity = helper.ExternalEntityName(ifcSpatialElement); target.ExternalId = helper.ExternalEntityIdentity(ifcSpatialElement); target.AltExternalId = ifcSpatialElement.GlobalId; target.ExternalSystem = helper.ExternalSystemName(ifcSpatialElement); target.Name = ifcSpatialElement.Name; target.Categories = helper.GetCategories(ifcSpatialElement); target.Description = ifcSpatialElement.LongName; if (string.IsNullOrWhiteSpace(target.Description)) { target.Description = ifcSpatialElement.Description; } target.CreatedBy = helper.GetCreatedBy(ifcSpatialElement); target.CreatedOn = helper.GetCreatedOn(ifcSpatialElement); target.RoomTag = helper.GetCoBieAttribute <StringAttributeValue>("SpaceSignageName", ifcSpatialElement).Value; target.UsableHeight = helper.GetCoBieAttribute <DecimalAttributeValue>("SpaceUsableHeightValue", ifcSpatialElement).Value; target.GrossArea = helper.GetCoBieAttribute <DecimalAttributeValue>("SpaceGrossAreaValue", ifcSpatialElement).Value; target.NetArea = helper.GetCoBieAttribute <DecimalAttributeValue>("SpaceNetAreaValue", ifcSpatialElement).Value; //Attributes target.Attributes = helper.GetAttributes(ifcSpatialElement); //Documents var docsMappings = Exchanger.GetOrCreateMappings <MappingIfcDocumentSelectToDocument>(); helper.AddDocuments(docsMappings, target, ifcSpatialElement as IIfcSpace); //TODO: //Space Issues return(target); }
protected override TToObject Mapping(AssetInfoType assetInfoType, TToObject ifcElement) { ifcElement.Name = assetInfoType.AssetName; ifcElement.Description = assetInfoType.AssetDescription; #region Attributes if (assetInfoType.AssetAttributes != null) { foreach (var attribute in assetInfoType.AssetAttributes) { Exchanger.ConvertAttributeTypeToIfcObjectProperty(ifcElement, attribute); } } #endregion #region Space Assignments if (assetInfoType.AssetSpaceAssignments != null && assetInfoType.AssetSpaceAssignments.Any()) { foreach (var spaceAssignment in assetInfoType.AssetSpaceAssignments) { var ifcSpace = Exchanger.GetIfcSpace(spaceAssignment); if (ifcSpace == null) { throw new Exception("Space " + spaceAssignment.FloorName + " - " + spaceAssignment.SpaceName + " cannot be found"); } ifcSpace.AddElement(ifcElement); } } #endregion return(ifcElement); }
private void ConvertSpaces(IEnumerable <SpaceType> spaces, FacilityType target) { var spaceTypes = spaces as IList <SpaceType> ?? spaces.ToList(); if (spaces == null || !spaceTypes.Any()) { return; } var tFloor = new Floor { Name = "Default floor", Spaces = new List <Space>(), ExternalId = Guid.NewGuid().ToString(), ExternalSystem = "DPoW" }; target.Floors = new List <Floor> { tFloor }; var sMap = Exchanger.GetOrCreateMappings <MappingSpaceTypeToZone>(); foreach (var spaceType in spaceTypes) { var tType = sMap.GetOrCreateTargetObject(spaceType.Id.ToString()); sMap.AddMapping(spaceType, tType); if (target.Zones == null) { target.Zones = new List <Zone>(); } target.Zones.Add(tType); } }
private void ConvertSpaces(IEnumerable <SpaceType> spaces, FacilityType target) { var spaceTypes = spaces as IList <SpaceType> ?? spaces.ToList(); if (spaces == null || !spaceTypes.Any()) { return; } var tFloor = new FloorType { FloorName = "Default floor", Spaces = new SpaceCollectionType(), externalID = Guid.NewGuid().ToString() }; target.Floors = new FloorCollectionType(); target.Floors.Add(tFloor); var sMap = Exchanger.GetOrCreateMappings <MappingSpaceTypeToSpaceType>(); foreach (var spaceType in spaceTypes) { var tType = sMap.GetOrCreateTargetObject(spaceType.Id.ToString()); sMap.AddMapping(spaceType, tType); tFloor.Spaces.Add(tType); } }
private void ConvertContacts(PlanOfWork source, FacilityType target) { if (source.Contacts == null || !source.Contacts.Any()) { return; } var mappings = Exchanger.GetOrCreateMappings <MappingContactToContact>(); if (target.Contacts == null) { target.Contacts = new ContactCollectionType(); } var clientId = source.Client != null ? source.Client.Id : new Guid(); foreach (var sContact in source.Contacts) { var key = sContact.Id.ToString(); var tContact = mappings.GetOrCreateTargetObject(key); //set client role as a contact category if (sContact.Id == clientId) { tContact.ContactCategory = "Client"; } mappings.AddMapping(sContact, tContact); target.Contacts.Add(tContact); } }
protected override IfcSpace Mapping(Space spaceType, IfcSpace ifcSpace) { ifcSpace.Name = spaceType.Name; ifcSpace.Description = spaceType.Description; ifcSpace.CompositionType = IfcElementCompositionEnum.ELEMENT; Exchanger.TryCreatePropertySingleValue(ifcSpace, new DecimalAttributeValue { Value = spaceType.GrossArea }, "SpaceGrossAreaValue", Exchanger.DefaultAreaUnit); Exchanger.TryCreatePropertySingleValue(ifcSpace, new DecimalAttributeValue { Value = spaceType.NetArea }, "SpaceNetAreaValue", Exchanger.DefaultAreaUnit); Exchanger.TryCreatePropertySingleValue(ifcSpace, spaceType.RoomTag, "SpaceSignageName"); Exchanger.TryCreatePropertySingleValue(ifcSpace, new DecimalAttributeValue { Value = spaceType.UsableHeight }, "SpaceUsableHeightValue", Exchanger.DefaultAreaUnit); #region Attributes if (spaceType.Attributes != null) { foreach (var attribute in spaceType.Attributes) { Exchanger.ConvertAttributeTypeToIfcObjectProperty(ifcSpace, attribute); } } #endregion #region Documents if (spaceType.Documents != null && spaceType.Documents.Any()) { Exchanger.ConvertDocumentsToDocumentSelect(ifcSpace, spaceType.Documents); } #endregion return(ifcSpace); }
public override ContactType CreateTargetObject() { var obj = base.CreateTargetObject(); obj.externalID = Exchanger.GetStringIdentifier(); return(obj); }
private void SetUpDataExchange(AppFields appFields) { _ProductName = appFields.ProductName; _ProductPreparation = appFields.ProductPreparation; _ProductExpiration = appFields.ProductExpiration; _ComercialProductGroupName = appFields.ComercialProductGroupName; _ComercialProductGroupPurchasePrice = appFields.ComercialProductGroupPurchasePrice; _ComercialProductGroupSellPrice = appFields.ComercialProductGroupSellPrice; _ComercialProductGroupDeliveryTime = appFields.ComercialProductGroupDeliveryTime; _ComercialProductGroupTermOfUse = appFields.ComercialProductGroupTermOfUse; _CommercialProductGroups = appFields.CommercialProductGroups; _Products = appFields.Products; _IndexOfSelectedProduct = appFields.IndexOfSelectedProduct; _IndexOfSelectedComercialProductGroup = appFields.IndexOfSelectedComercialProductGroup; appFields.CreateProduct.Subscribe(CreateProduct); appFields.CreateCommertialProductGroup.Subscribe(CreateCommertialProductGroup); appFields.IndexOfSelectedComercialProductGroup.Subscribe(UpdateProducts); appFields.DeleteCommertialProductGroup.Subscribe(DeleteCommertialProductGroup); appFields.DeleteProduct.Subscribe(DeleteProduct); appFields.UpdateProduct.Subscribe(UpdateProductData); appFields.UpdateCommertialProductGroup.Subscribe(UpdateCommertialProductGroupData); appFields.MarkAsEnds.Subscribe(MarkAsEnds); appFields.MarkAsNotEnds.Subscribe(MarkAsNotEnds); }
protected override TTargetType Mapping(TSourceType source, TTargetType target) { if (Exchanger.SourceRepository.Client == null) { var client = new Contact { Email = "*****@*****.**" }; Exchanger.SourceRepository.ClientContactId = client.Id; if (Exchanger.SourceRepository.Contacts == null) { Exchanger.SourceRepository.Contacts = new List <Contact>(); } Exchanger.SourceRepository.Contacts.Add(client); } //set CreatedBy to Client // ReSharper disable once PossibleNullReferenceException var cKey = Exchanger.SourceRepository.Client.Id.ToString(); var cMapping = Exchanger.GetOrCreateMappings <MappingContactToContact>(); var tContact = cMapping.GetOrCreateTargetObject(cKey); target.CreatedBy = new ContactKey { Email = tContact.Email }; //set CreatedOn target.CreatedOn = Exchanger.SourceRepository.CreatedOn; return(target); }
protected override Document Mapping(Documentation sObject, Document tObject) { //perform base mapping where free attributes are converted base.Mapping(sObject, tObject); tObject.ExternalId = sObject.Id.ToString(); tObject.Name = sObject.Name; tObject.Description = sObject.Description; tObject.Reference = sObject.URI; if (tObject.Categories == null) { tObject.Categories = new List <Category>(); } tObject.Categories.AddRange(Exchanger.SourceRepository.GetEncodedClassification(sObject.ClassificationReferenceIds)); //Issues from Jobs + Responsibilities if (sObject.Jobs != null && sObject.Jobs.Any()) { if (tObject.Issues == null) { tObject.Issues = new List <Issue>(); } var jMap = Exchanger.GetOrCreateMappings <MappingJobToIssueType>(); foreach (var job in sObject.Jobs) { var issue = jMap.GetOrCreateTargetObject(job.Id.ToString()); jMap.AddMapping(job, issue); tObject.Issues.Add(issue); } } return(tObject); }
public void SetUpDataExchange(AppFields appFields) { _ProductName = appFields.ProductName; _ProductPreparation = appFields.ProductPreparation; _ProductExpiration = appFields.ProductExpiration; _ComercialProductGroupName = appFields.ComercialProductGroupName; _ComercialProductGroupPurchasePrice = appFields.ComercialProductGroupPurchasePrice; _ComercialProductGroupSellPrice = appFields.ComercialProductGroupSellPrice; _ComercialProductGroupDeliveryTime = appFields.ComercialProductGroupDeliveryTime; _ComercialProductGroupTermOfUse = appFields.ComercialProductGroupTermOfUse; _CommercialProductGroups = appFields.CommercialProductGroups; _Products = appFields.Products; _IndexOfSelectedProduct = appFields.IndexOfSelectedProduct; _IndexOfSelectedComercialProductGroup = appFields.IndexOfSelectedComercialProductGroup; _CreateProduct = appFields.CreateProduct; _DeleteProduct = appFields.DeleteProduct; _UpdateProduct = appFields.UpdateProduct; _CreateCommertialProductGroup = appFields.CreateCommertialProductGroup; _DeleteCommertialProductGroup = appFields.DeleteCommertialProductGroup; _UpdateCommertialProductGroup = appFields.UpdateCommertialProductGroup; _MarkAsEnds = appFields.MarkAsEnds; _MarkAsNotEnds = appFields.MarkAsNotEnds; _CommercialProductGroups.Subscribe(UpdateCommercialProductGroups); _Products.Subscribe(UpdateProducts); _ProductPreparation.Set(ProductPreparation.Value); _ProductExpiration.Set(ProductExpiration.Value); }
protected override Assembly Mapping(AssemblyType sObject, Assembly tObject) { //do basic mapping of the object base.Mapping(sObject, tObject); //add assembly to asset types (which is a nonsense but it is how it is defined in the COBieLite schema for now) if (sObject.AggregationOfAssetTypes != null && sObject.AggregationOfAssetTypes.Any()) { var assetMap = Exchanger.GetOrCreateMappings <MappingAssetTypeToAssetType>(); tObject.ChildAssetsOrTypes = new List <EntityKey>(); foreach (var id in sObject.AggregationOfAssetTypes) { AssetType tAsset; if (!assetMap.GetTargetObject(id.ToString(), out tAsset)) { continue; } tObject.ChildAssetsOrTypes.Add(new EntityKey { Name = tAsset.Name, KeyType = EntityType.AssetType }); } } return(tObject); }
/** * @param result */ public override void Finish(int result) { Output.Message("Total Evaluations " + Evaluations); Statistics.FinalStatistics(this, result); Finisher.FinishPopulation(this, result); Exchanger.CloseContacts(this, result); Evaluator.CloseContacts(this, result); }
public void EuroToDollar_EuroAndExchangeRate_ReturnDollar() { double euro = 81; double exchangeRateInEuro = 137.51; double dollar = Exchanger.EuroToDollar(euro, exchangeRateInEuro); Assert.That(dollar, Is.EqualTo(111.38)); }
protected override IfcDocumentInformation Mapping(Document document, IfcDocumentInformation ifcDocumentInformation) { ifcDocumentInformation.Name = document.Name; if (document.CreatedBy != null) { ifcDocumentInformation.DocumentOwner = Exchanger.SetEmailUser(document.CreatedBy.Email); } if (document.CreatedOn != null) { DateTime createOn = (DateTime)document.CreatedOn; var ifcCalanderDate = Exchanger.TargetRepository.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = createOn.Day; cd.MonthComponent = createOn.Month; cd.YearComponent = createOn.Year; }); var ifcLocalTime = Exchanger.TargetRepository.Instances.New <IfcLocalTime>(lt => { lt.HourComponent = createOn.Hour; lt.MinuteComponent = createOn.Minute; lt.SecondComponent = createOn.Second; }); ifcDocumentInformation.CreationTime = Exchanger.TargetRepository.Instances.New <IfcDateAndTime>(dt => { dt.DateComponent = ifcCalanderDate; dt.TimeComponent = ifcLocalTime; }); } if (document.Categories != null && document.Categories.Any()) { ifcDocumentInformation.Purpose = document.Categories.First().Code; } ifcDocumentInformation.IntendedUse = document.ApprovalBy; ifcDocumentInformation.Scope = document.Stage; var ifcDocumentReference = Exchanger.TargetRepository.Instances.New <IfcDocumentReference>(dr => { dr.Location = document.Directory; dr.Name = document.File; }); ifcDocumentInformation.DocumentReferences.Add(ifcDocumentReference); ifcDocumentInformation.Description = document.Description; ifcDocumentInformation.DocumentId = document.Reference; //child docs so set up relationship if (document.Documents != null && document.Documents.Any()) { var ifcDocumentInformationRelationship = Exchanger.TargetRepository.Instances.New <IfcDocumentInformationRelationship>(); ifcDocumentInformationRelationship.RelatingDocument = ifcDocumentInformation; foreach (var doc in document.Documents) { IfcDocumentInformation ifcDoc = Exchanger.TargetRepository.Instances.New <IfcDocumentInformation>(); ifcDoc = Mapping(doc, ifcDoc); ifcDocumentInformationRelationship.RelatedDocuments.Add(ifcDoc); } } //using statement will set the Model.OwnerHistoryAddObject to IfcConstructionProductResource.OwnerHistory as OwnerHistoryAddObject is used to reset user history on any property changes, //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement to keep user history set in line above SetUserHistory //using (OwnerHistoryEditScope context = new OwnerHistoryEditScope(Exchanger.TargetRepository, ifcRelAssociatesDocument.OwnerHistory)) //{ //} return(ifcDocumentInformation); }
protected override IfcZone Mapping(Zone zone, IfcZone ifcZone) { ifcZone.Name = zone.Name; ifcZone.Description = zone.Description; #region Properties #endregion #region Categories if (zone.Categories != null) { foreach (var category in zone.Categories) { Exchanger.ConvertCategoryToClassification(category, ifcZone); } } #endregion #region Attributes if (zone.Attributes != null) { foreach (var attribute in zone.Attributes) { Exchanger.ConvertAttributeTypeToIfcObjectProperty(ifcZone, attribute); } } #endregion #region Spaces if (zone.Spaces != null) { foreach (var spaceKey in zone.Spaces) { Exchanger.AddSpaceToZone(spaceKey, ifcZone); } } #endregion #region Documents if (zone.Documents != null && zone.Documents.Any()) { Exchanger.ConvertDocumentsToDocumentSelect(ifcZone, zone.Documents); } #endregion return(ifcZone); }
/// <summary> /// /// </summary> /// <param name="floor"></param> /// <param name="buildingStorey"></param> /// <returns></returns> protected override IfcBuildingStorey Mapping(Floor floor, IfcBuildingStorey buildingStorey) { buildingStorey.Name = floor.Name; buildingStorey.Description = floor.Description; buildingStorey.CompositionType = IfcElementCompositionEnum.ELEMENT; buildingStorey.Elevation = floor.Elevation; #region Categories if (floor.Categories != null) { foreach (var category in floor.Categories) { Exchanger.ConvertCategoryToClassification(category, buildingStorey); } } #endregion Exchanger.TryCreatePropertySingleValue(buildingStorey, new DecimalAttributeValue { Value = floor.Height }, "FloorHeightValue", Exchanger.DefaultLinearUnit); //write out the spaces if (floor.Spaces != null) { var spaceMapping = Exchanger.GetOrCreateMappings <MappingSpaceToIfcSpace>(); foreach (var space in floor.Spaces) { var ifcSpace = spaceMapping.AddMapping(space, spaceMapping.GetOrCreateTargetObject(space.ExternalId)); buildingStorey.AddToSpatialDecomposition(ifcSpace); Exchanger.AddToSpaceMap(ifcSpace); } } #region Attributes if (floor.Attributes != null) { foreach (var attribute in floor.Attributes) { Exchanger.ConvertAttributeTypeToIfcObjectProperty(buildingStorey, attribute); } } #endregion #region Documents if (floor.Documents != null && floor.Documents.Any()) { Exchanger.ConvertDocumentsToDocumentSelect(buildingStorey, floor.Documents); } #endregion return(buildingStorey); }
public MainViewModel() { CommandInitialize(); Notificate = new ToastViewModel(); ExchangerModel = new Exchanger(this); Authorization = new AuthorizationService(); DisplayTextModel = new ScanCodeHandler(); DecryptedSide = true; EncryptedSide = true; }
protected override TToObject Mapping(Asset asset, TToObject ifcElement) { ifcElement.Name = asset.Name; ifcElement.Description = asset.Description; #region Categories if (asset.Categories != null) { foreach (var category in asset.Categories) { Exchanger.ConvertCategoryToClassification(category, ifcElement); } } #endregion #region Attributes if (asset.Attributes != null) { foreach (var attribute in asset.Attributes) { Exchanger.ConvertAttributeTypeToIfcObjectProperty(ifcElement, attribute); } } #endregion #region Space Assignments if (asset.Spaces != null && asset.Spaces.Any()) { foreach (var spaceAssignment in asset.Spaces) { var ifcSpace = Exchanger.GetIfcSpace(spaceAssignment); if (ifcSpace != null) { //throw new Exception("Space " + spaceAssignment.Name + " - " + spaceAssignment.Name+" cannot be found"); ifcSpace.AddElement(ifcElement); } } } #endregion #region Documents if (asset.Documents != null && asset.Documents.Any()) { Exchanger.ConvertDocumentsToDocumentSelect(ifcElement, asset.Documents); } #endregion return(ifcElement); }
public ExchangerTest() { var mock = new Mock <IExchangeRateProvider>(); mock .Setup(x => x.GetExchangeRateAsync( It.Is <ExchangeRateRequest>(m => Equals(m.From, Currency.EUR) && Equals(m.To, Currency.BYN)))) .Returns(Task.FromResult( new ExchangeResult(Currency.BYN, SampleExchangeRate))); _exchanger = new Exchanger(new RoundCalculator(), mock.Object); }
public override void StartFresh() { Output.Message("Setting up"); Setup(this, null); // a garbage Parameter // POPULATION INITIALIZATION Output.Message("Initializing Generation 0"); Statistics.PreInitializationStatistics(this); Population = Initializer.InitialPopulation(this, 0); // unthreaded Statistics.PostInitializationStatistics(this); // Compute generations from evaluations if necessary if (NumEvaluations > UNDEFINED) { // compute a generation's number of individuals int generationSize = 0; for (int sub = 0; sub < Population.Subpops.Count; sub++) { generationSize += Population.Subpops[sub].Individuals .Count; // so our sum total 'generationSize' will be the initial total number of individuals } if (NumEvaluations < generationSize) { NumEvaluations = generationSize; NumGenerations = 1; Output.Warning("Using evaluations, but evaluations is less than the initial total population size (" + generationSize + "). Setting to the populatiion size."); } else { if (NumEvaluations % generationSize != 0) { Output.Warning( "Using evaluations, but initial total population size does not divide evenly into it. Modifying evaluations to a smaller value (" + ((NumEvaluations / generationSize) * generationSize) + ") which divides evenly."); // note integer division } NumGenerations = (int)(NumEvaluations / generationSize); // note integer division NumEvaluations = NumGenerations * generationSize; } Output.Message("Generations will be " + NumGenerations); } // INITIALIZE CONTACTS -- done after initialization to allow // a hook for the user to do things in Initializer before // an attempt is made to connect to island models etc. Exchanger.InitializeContacts(this); Evaluator.InitializeContacts(this); }
protected override Zone Mapping(IIfcZone ifcZone, Zone target) { var helper = ((IfcToCOBieLiteUkExchanger)Exchanger).Helper; target.ExternalEntity = helper.ExternalEntityName(ifcZone); target.ExternalId = helper.ExternalEntityIdentity(ifcZone); target.AltExternalId = ifcZone.GlobalId; target.ExternalSystem = helper.ExternalSystemName(ifcZone); target.Description = ifcZone.Description; target.Categories = helper.GetCategories(ifcZone); if (target.Categories == CoBieLiteUkHelper.UnknownCategory) { if (!string.IsNullOrWhiteSpace(ifcZone.ObjectType)) { target.Categories = new List <Category>(new [] { new Category { Code = ifcZone.ObjectType } }); } } target.CreatedBy = helper.GetCreatedBy(ifcZone); target.CreatedOn = helper.GetCreatedOn(ifcZone); target.Name = ifcZone.Name; //Attributes target.Attributes = helper.GetAttributes(ifcZone); //Documents var docsMappings = Exchanger.GetOrCreateMappings <MappingIfcDocumentSelectToDocument>(); helper.AddDocuments(docsMappings, target, ifcZone); //get spaces in zones var spaces = helper.GetSpaces(ifcZone); var ifcSpaces = spaces as IList <IIfcSpace> ?? spaces.ToList(); if (ifcSpaces.Any()) { target.Spaces = new List <SpaceKey>(); foreach (var space in ifcSpaces) { var spaceKey = new SpaceKey { Name = space.Name }; target.Spaces.Add(spaceKey); } } //TODO: //Space Issues return(target); }
private void ConvertContacts(PlanOfWork source, FacilityType target) { if (source.Contacts == null || !source.Contacts.Any()) { return; } var mappings = Exchanger.GetOrCreateMappings <MappingContactToContact>(); if (target.Contacts == null) { target.Contacts = new List <Contact>(); } var clientId = source.Client != null ? source.Client.Id : new Guid(); //Set the Client to be the first if (clientId != default(Guid)) { var client = source.Contacts.FirstOrDefault(c => c.Id == clientId); if (client != null) { source.Contacts.Remove(client); source.Contacts.Insert(0, client); } } foreach (var sContact in source.Contacts) { var key = sContact.Id.ToString(); var tContact = mappings.GetOrCreateTargetObject(key); mappings.AddMapping(sContact, tContact); //set client role as a contact category if (sContact.Id == clientId) { tContact.Categories = new List <Category> { new Category() { Classification = "DPoW", Code = "Client" } }; tContact.CreatedBy = new ContactKey { Email = tContact.Email }; } target.Contacts.Add(tContact); } }
private void ConvertAssemblyTypes(IEnumerable <Xbim.DPoW.AssemblyType> assemblyTypes, ProjectStage stage) { if (assemblyTypes == null || !assemblyTypes.Any()) { return; } var assemplyMap = Exchanger.GetOrCreateMappings <MappingAssemblyTypeToAssemblyType>(); foreach (var assemblyType in stage.AssemblyTypes) { var tType = assemplyMap.GetOrCreateTargetObject(assemblyType.Id.ToString()); assemplyMap.AddMapping(assemblyType, tType); } }
protected override Xbim.CobieLiteUk.System Mapping(IIfcPropertySet pSet, Xbim.CobieLiteUk.System target) { var helper = ((IfcToCOBieLiteUkExchanger)Exchanger).Helper; //Add Assets var systemAssignments = helper.GetSystemAssignments(pSet); var ifcObjectDefinitions = systemAssignments as IList <IIfcObjectDefinition> ?? systemAssignments.ToList(); string name = string.Empty; if (ifcObjectDefinitions.Any()) { name = GetSystemName(helper, ifcObjectDefinitions); target.Components = new List <AssetKey>(); foreach (var ifcObjectDefinition in ifcObjectDefinitions) { var assetKey = new AssetKey { Name = ifcObjectDefinition.Name }; if (!target.Components.Contains(assetKey)) { target.Components.Add(assetKey); } } } target.ExternalEntity = helper.ExternalEntityName(pSet); target.ExternalId = helper.ExternalEntityIdentity(pSet); target.ExternalSystem = helper.ExternalSystemName(pSet); target.Name = string.IsNullOrEmpty(name) ? "Unknown" : name; target.Description = string.IsNullOrEmpty(pSet.Description) ? name : pSet.Description.ToString(); target.CreatedBy = helper.GetCreatedBy(pSet); target.CreatedOn = helper.GetCreatedOn(pSet); target.Categories = helper.GetCategories(pSet); //Attributes, no attributes from PSet as Pset is the attributes, assume that component attributes are extracted by each component anyway //target.Attributes = helper.GetAttributes(pSet); //Documents var docsMappings = Exchanger.GetOrCreateMappings <MappingIfcDocumentSelectToDocument>(); helper.AddDocuments(docsMappings, target, pSet); //TODO: //System Issues return(target); }
protected override IfcPersonAndOrganization Mapping(Contact contact, IfcPersonAndOrganization ifcPersonAndOrganization) { IfcPerson ifcPerson = Exchanger.TargetRepository.Instances.New <IfcPerson>(); IfcOrganization ifcOrganization = Exchanger.TargetRepository.Instances.New <IfcOrganization>(); //add Organization code if (Exchanger.StringHasValue(contact.OrganizationCode)) { ifcOrganization.Id = contact.OrganizationCode; } if (Exchanger.StringHasValue(contact.Company)) { ifcOrganization.Name = contact.Company; } //add GivenName if (Exchanger.StringHasValue(contact.GivenName)) { ifcPerson.GivenName = contact.GivenName; } //add Family Name if (Exchanger.StringHasValue(contact.FamilyName)) { ifcPerson.FamilyName = contact.FamilyName; } if (contact.Categories != null && contact.Categories.Any()) { SetRoles(contact, ifcPerson); } //add addresses into IfcPerson object //add Telecom Address IfcTelecomAddress ifcTelecomAddress = SetTelecomAddress(contact); ifcPerson.Addresses.Add(ifcTelecomAddress);//add to existing collection // Add postal address IfcPostalAddress ifcPostalAddress = SetAddress(contact); ifcPerson.Addresses.Add(ifcPostalAddress);//add to existing collection //add the person and the organization objects ifcPersonAndOrganization.ThePerson = ifcPerson; ifcPersonAndOrganization.TheOrganization = ifcOrganization; return(ifcPersonAndOrganization); }
/// <summary> </summary> public override void StartFresh() { Output.Message("Setting up"); Setup(this, null); // a garbage Parameter // POPULATION INITIALIZATION Output.Message("Initializing Generation 0"); Statistics.PreInitializationStatistics(this); Population = Initializer.InitialPopulation(this, 0); // unthreaded Statistics.PostInitializationStatistics(this); // INITIALIZE CONTACTS -- done after initialization to allow // a hook for the user to do things in Initializer before // an attempt is made to connect to island models etc. Exchanger.InitializeContacts(this); Evaluator.InitializeContacts(this); }
private IfcTelecomAddress SetTelecomAddress(Contact contact) { IfcTelecomAddress ifcTelecomAddress = Exchanger.TargetRepository.Instances.New <IfcTelecomAddress>(); //add email if (Exchanger.StringHasValue(contact.Email)) { ifcTelecomAddress.ElectronicMailAddresses.Add(contact.Email); //add to existing collection } //add Phone if (Exchanger.StringHasValue(contact.Phone)) { ifcTelecomAddress.TelephoneNumbers.Add(contact.Phone);//add to existing collection } return(ifcTelecomAddress); }
private IfcPostalAddress SetAddress(Contact contact) { IfcPostalAddress ifcPostalAddress = Exchanger.TargetRepository.Instances.New <IfcPostalAddress>(); //add Department if (Exchanger.StringHasValue(contact.Department)) { ifcPostalAddress.InternalLocation = contact.Department; } //add Street if (Exchanger.StringHasValue(contact.Street)) { foreach (var line in contact.Street.Split(new char[] { ',', ':' })) { ifcPostalAddress.AddressLines.Add(line); } } //add PostalBox if (Exchanger.StringHasValue(contact.PostalBox)) { ifcPostalAddress.PostalBox = contact.PostalBox; } //add Town if (Exchanger.StringHasValue(contact.Town)) { ifcPostalAddress.Town = contact.Town; } //add StateRegion if (Exchanger.StringHasValue(contact.StateRegion)) { ifcPostalAddress.Region = contact.StateRegion; } //add PostalCode if (Exchanger.StringHasValue(contact.PostalCode)) { ifcPostalAddress.PostalCode = contact.PostalCode; } //add Country if (Exchanger.StringHasValue(contact.Country)) { ifcPostalAddress.Country = contact.Country; } return(ifcPostalAddress); }
public static void exchangeString(Exchanger<String> exchanger, String myString) { Console.WriteLine(Thread.CurrentThread.Name + " about to exchange: " + myString); String newString = exchanger.Exchange(myString); Console.WriteLine(Thread.CurrentThread.Name + " received: " + newString); }
private static bool ExchangeTest() { const int RUN_TIME = 10000; const int SETUP_TIME = 20; const int THREADS = 50; Thread[] tthrs = new Thread[THREADS]; int[] privateCounters = new int[THREADS]; int[] results = new int[THREADS]; ManualResetEventSlim startEvent = new ManualResetEventSlim(false); Exchanger<int> exchange = new Exchanger<int>(); for (int i = 0; i < THREADS; i++) { int tid = i; tthrs[i] = new Thread(() => { // Wait until start event is set startEvent.Wait(); int endTime = Environment.TickCount + RUN_TIME; do { int aux = exchange.Exchange(tid , tid +1); results[aux] = +1; Thread.Yield(); if ((++privateCounters[tid] % 100) == 0) { Console.Write("[#{0}]", tid); } } while (Environment.TickCount < endTime); }); tthrs[i].Start(); } // Wait until all test threads have been started and then set the // start event. Thread.Sleep(SETUP_TIME); startEvent.Set(); // Wait until all threads have been terminated. for (int i = 0; i < THREADS; i++) tthrs[i].Join(); // Show results Console.WriteLine("\nPrivate counters:"); for (int i = 0; i < THREADS; i++) { if ((i % 5) == 0) Console.WriteLine(); Console.Write("#{0}: {1,4}]", i, privateCounters[i]); } Console.WriteLine(); foreach(int i in results){ if (i == 0) return false; Console.Write(i + " " ); } return true; }
static void Main(string[] args) { Console.WriteLine("Enter the utility class you would like to test:\n" + "OPTIONS:\n" + "\tsemaphore\n" + "\tchannel\n" + "\tboundedchannel\n" + "\tlightswitch\n" + "\tlatch\n" + "\trwlock\n" + "\tmutex\n" + "\tFIFOSemaphore\n" + "\tExchanger"); Console.Write("> "); String command = Console.ReadLine(); command = command.ToLower(); if (command.Length > 0) { switch (command) { case "semaphore": ConcurrencyUtils.Semaphore testSemaphore = new ConcurrencyUtils.Semaphore(0); List<Thread> threads = new List<Thread>(); for (int i = 0; i < TEST_THREADS; i++) { Thread newThread = new Thread(() => SemaphoreTest(testSemaphore)); newThread.Name = i.ToString(); // Console.WriteLine(newThread.Name + " created"); newThread.Start(); threads.Add(newThread); } Thread releaserThread = new Thread(() => SemaphoreTestReleaser(testSemaphore)); releaserThread.Name = "R"; releaserThread.Start(); break; case "mutex": ConcurrencyUtils.Mutex testMutex = new ConcurrencyUtils.Mutex(); List<Thread> mutexThreads = new List<Thread>(); for (int i = 0; i < TEST_THREADS; i++) { Thread newThread = new Thread(() => SemaphoreTest(testMutex)); newThread.Name = i.ToString(); newThread.Start(); mutexThreads.Add(newThread); } Thread mutexReleaserThread = new Thread(() => MutexTestReleaser(testMutex)); mutexReleaserThread.Name = "R"; mutexReleaserThread.Start(); break; case "channel": Channel<String> testChannel = new Channel<String>(); List<Thread> grabberThreads = new List<Thread>(); Thread putterThread = new Thread(() => putData(testChannel)); putterThread.Name = "Putter"; putterThread.Start(); for (int i = 0; i < TEST_THREADS; i++) { Thread newThread = new Thread(() => grabData(testChannel)); newThread.Name = "Thread" + i; Console.WriteLine(newThread.Name + " created"); newThread.Start(); grabberThreads.Add(newThread); } break; case "boundedchannel": BoundChannel<String> testBoundChannel = new BoundChannel<String>(CHANNEL_SIZE); List<Thread> putterThreads = new List<Thread>(); Thread grabberThread = new Thread(() => grabData(testBoundChannel)); grabberThread.Name = "Grabber"; grabberThread.Start(); for (int i = 0; i < TEST_THREADS; i++) { Thread newThread = new Thread(() => putData(testBoundChannel)); newThread.Name = "Thread" + i; Console.WriteLine(newThread.Name + " created"); newThread.Start(); putterThreads.Add(newThread); } break; case "lightswitch": ConcurrencyUtils.Semaphore semaphore = new ConcurrencyUtils.Semaphore(1); LightSwitch writeSwitch = new LightSwitch(semaphore); List<Thread> writerThreads = new List<Thread>(); Thread lonelyThread = new Thread(() => lonelyThreadWrite( semaphore ) ); lonelyThread.Start(); for (int i = 0; i < 10; i++) { Thread newThread = new Thread(() => groupThreadWrite(writeSwitch)); newThread.Name = "Thread" + i; newThread.Start(); writerThreads.Add(newThread); } break; case "latch": Latch latch = new Latch(); List<Thread> waiters = new List<Thread>(); for (int i = 0; i < 100; i++) { Thread newThread = new Thread(() => latchAcquire(latch)); newThread.Name = "Thread" + i; newThread.Start(); } Thread unlocker = new Thread(() => latchRelease(latch)); unlocker.Start(); break; case "rwlock": ConcurrencyUtils.ReaderWriterLock RWLock = new ConcurrencyUtils.ReaderWriterLock(); for (int i = 0; i < 10; i++) { Thread newThread = new Thread(() => readLots(RWLock)); newThread.Name = "Reader Thread" + i; newThread.Start(); } for (int i = 0; i < 2; i++) { Thread newThread = new Thread(() => writeLots(RWLock)); newThread.Name = "Writer Thread" + i; newThread.Start(); } break; case "fifosemaphore": FIFOSemaphore fifoSemaphore = new FIFOSemaphore(1); for (int i = 0; i < 4; i++) { Thread t = new Thread(() => acquireWaitRelease(fifoSemaphore)); t.Name = "Thread" + i; t.Start(); Thread.Sleep(1000); } break; case "exchanger": Exchanger<String> exchanger = new Exchanger<String>(); String string1 = "String 1"; String string2 = "String 2"; Thread thread1 = new Thread(() => exchangeString(exchanger, string1)); Thread thread2 = new Thread(() => exchangeString(exchanger, string2)); thread1.Name = "Thread 1"; thread2.Name = "Thread 2"; thread1.Start(); thread2.Start(); thread1.Join(); thread2.Join(); break; default: Console.WriteLine("Test for '" + args[0] + "' not implemented"); break; } } else { Console.WriteLine("No argument provided"); } }