/// <summary> /// Registers the specified type. /// </summary> /// <param name="type">The type.</param> /// <returns>Instance of ItemRegistrationBase that allows to specify additional configuration.</returns> public ConcreteItemRegistrationBase Register(Type type) { var registration = new ItemRegistration(this, type); this.typeContainer.Add(registration); return(registration); }
/// <summary> /// Sets the interceptor selector for this component. /// </summary> /// <param name = "selector"></param> /// <returns></returns> public ComponentRegistration <TService> SelectInterceptorsWith(Action <ItemRegistration <IInterceptorSelector> > selector) { var registration = new ItemRegistration <IInterceptorSelector>("interceptor-selector"); selector.Invoke(registration); return(AddDescriptor(new InterceptorSelectorDescriptor(registration.Item))); }
/// <summary> /// Registers the specified assemblies. /// </summary> /// <param name="assemblies">The assemblies.</param> public void Register(params Assembly[] assemblies) { if (assemblies == null) { throw new ArgumentNullException("assemblies"); } if (assemblies.Length == 0) { throw new ArgumentException("At least one assembly should be passed."); } var allTypes = assemblies.SelectMany(assembly => assembly.GetTypes()); foreach (var type in allTypes) { var attributes = GetContainerTypeAttribute(type); if (attributes == null) { continue; } foreach (var containerType in attributes) { var builderItem = new ItemRegistration(this, type); if (containerType.As != null) { builderItem.AsType = containerType.As; } this.typeContainer.Add(builderItem); } } }
public void RegisterExistingItemHasNoRegistration() { try { var activity = _sampleData.NewItem(); var registrationInfo = new ItemRegistration() { AccessURL = activity.Item.ItemRegistration.AccessURL, isRestful = activity.Item.ItemRegistration.isRestful, RegistrationDate = activity.Item.ItemRegistration.RegistrationDate, RegistrationKey = activity.Item.ItemRegistration.RegistrationKey }; activity.Item.ItemRegistration = null; _receiveAdapterRepository.RegisterItem(activity); activity.Item.ItemRegistration = registrationInfo; _receiveAdapterRepository.RegisterItem(activity); Assert.IsTrue(true); } catch (Exception ex) { Assert.IsTrue(false, ex.Message); } }
/// <summary> /// Registers the specified types. /// </summary> /// <param name="types">The types.</param> /// <returns>Instance of ItemRegistrationBase that allows to specify additional configuration.</returns> public ConcreteItemRegistrationBase Register(params Type[] types) { var registration = new ItemRegistration(this, types); this.typeContainer.Add(registration); return(registration); }
public ConcreteItemRegistrationBase Register <TConcreteType>( Func <ActivationContext, TConcreteType> factory) { var registration = new ItemRegistration <TConcreteType>(this, typeof(TConcreteType)); registration.As(factory); this.typeContainer.Add(registration); return(registration); }
public CustomerReply registerItem(VendingItems Itemreg) { Console.WriteLine("In register New Item"); CustomerReply Itemreply = new CustomerReply(); ItemRegistration.GetInstance().Add(Itemreg); Itemreply.Name = Itemreg.Name; Itemreply.Exp = Itemreg.Exp; Itemreply.RegistrationNumber = Itemreg.RegistrationNumber; Itemreply.RegistrationStatus = "Successful"; return(Itemreply); }
public bool AddItemRegistration(string name, string passcode, IList <Tag> itemTags) { var item = new ItemRegistration { PassCode = passcode, Name = name }; if (itemTags != null) { item.Tags = itemTags; } var tenancy = ContextRegistry.ContextsOf("Tenancy").First().Segments[1]; item.TenancyId = tenancy; return(_itemRegistrationManager.SaveItemRegistration(item)); }
/// <summary> /// Registers the specified types from assemblies that meets predicate. /// </summary> /// <param name="predicate">The predicate.</param> /// <param name="assemblies">The assemblies.</param> /// <returns>Instance of ItemRegistrationBase that allows to specify additional configuration.</returns> public ConcreteItemRegistrationBase Register(Predicate <Type> predicate, params Assembly[] assemblies) { if (assemblies == null) { throw new ArgumentNullException("assemblies"); } if (assemblies.Length == 0) { throw new ArgumentException("At least one assembly should be passed."); } var matchingTypes = assemblies.SelectMany(assembly => assembly.GetTypes()) .Where(type => !type.IsInterface && !type.IsAbstract) .Where(type => predicate(type)); var registration = new ItemRegistration(this, matchingTypes.ToArray()); this.typeContainer.Add(registration); return(registration); }
public String DeleteItem() { Console.WriteLine("In delete All Item Record"); return(ItemRegistration.GetInstance().RemoveAllItems()); }
private bool AddNewManualViolationToCDS(ManualViolationDTO manualViolation) { try { if (manualViolation == null) { corruptedRowsCount++; return(true); } var oldManualViolation = GetManualViolationFromCDS(manualViolation.ViolationNumber); if (oldManualViolation != null) { duplicatedRowsCount++; return(true); } var activityReason = context.ActivityReasonDIMs.Where(x => x.Description == manualViolation.Reason.Trim()).FirstOrDefault(); var activityCategory = context.ActivityCategoryDIMs.Where(x => x.Description == "Manual Violation").FirstOrDefault(); var source = context.Sources.Where(x => x.SourceName == "ManualViolation").FirstOrDefault(); var itemRegistrationAuthority = context.ItemRegistrationAuthorityDIMs.Where(x => x.Description == ((manualViolation.PlateSource != null && manualViolation.PlateSource.Trim().Length > 0) ? manualViolation.PlateSource : "Undefined")).FirstOrDefault(); var itemRegistrationKind = context.ItemRegistrationPlateKindDIMs.Where(x => x.Description == ((manualViolation.PlateKind != null && manualViolation.PlateKind.Trim().Length > 0) ? manualViolation.PlateKind : "Undefined")).FirstOrDefault(); var itemRegistrationCategory = context.ItemRegistrationPlateCategoryDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); var itemRegistrationCode = context.ItemRegistrationPlateCodeDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); var itemCategory = context.ItemCategoryDIMs.Where(x => x.Description == (manualViolation.VehicleType.Trim().Length > 0 ? manualViolation.VehicleType : "Undefined")).FirstOrDefault(); var itemInvolvement = context.ItemInvolvementDIMs.Where(x => x.Description == "Manual Violation Vehicle").FirstOrDefault(); var personInvolvement = context.PersonInvolvementDIMs.Where(x => x.Description == "Manual Violation Vehicle").FirstOrDefault(); var locationInvolvement = context.LocationInvolvementDIMs.Where(x => x.Description == "Manual Violation Vehicle").FirstOrDefault(); var personCategory = context.PersonCategoryDIMs.Where(x => x.Description == (manualViolation.AgeClass.Trim().Length > 0 ? manualViolation.AgeClass : "Undefined")).FirstOrDefault(); var personGender = context.PersonGenderDIMs.Where(x => x.Description == (manualViolation.Gender.Trim().Length > 0 ? manualViolation.Gender : "Undefined")).FirstOrDefault(); var location = context.Locations.Where(x => x.LocationName == (manualViolation.StreetName.Trim().Length > 0 ? manualViolation.StreetName : "Undefined")).FirstOrDefault(); var educationCategory = context.EducationCategoryDIMs.Where(x => x.Description == (manualViolation.LevelOfEducation.Trim().Length > 0 ? manualViolation.LevelOfEducation : "Undefined")).FirstOrDefault(); var educationDegree = context.EducationDegreeDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); var organization = context.Organizations.Where(x => x.Name == "Undefined").FirstOrDefault(); var educationStatus = context.EducationStatusDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); var locationDatum = context.LocationDatumDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); var locationCategory = context.LocationCategoryDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); var status = context.StatusDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); if (activityReason == null) { activityReason = new ActivityReasonDIM { Code = "MVR-" + manualViolation.ReasonCode.ToString(), Description = manualViolation.Reason }; activityReason = context.ActivityReasonDIMs.Add(activityReason); context.SaveChanges(); } if (activityCategory == null) { activityCategory = new ActivityCategoryDIM { Description = "Manual Violation", Code = "MANUALVIOLATION" }; activityCategory = context.ActivityCategoryDIMs.Add(activityCategory); context.SaveChanges(); } if (source == null) { source = new Source() { Description = "ManualViolation", SourceName = "ManualViolation", SourcePolicyId = 1, SourceCategoryId = 1 }; source = context.Sources.Add(source); context.SaveChanges(); } if (itemRegistrationAuthority == null) { itemRegistrationAuthority = new ItemRegistrationAuthorityDIM { Description = (manualViolation.PlateSource != null && manualViolation.PlateSource.Trim().Length > 0) ? manualViolation.PlateSource : "Undefined", Code = GetRandomNumber() }; itemRegistrationAuthority = context.ItemRegistrationAuthorityDIMs.Add(itemRegistrationAuthority); context.SaveChanges(); } if (itemRegistrationKind == null) { itemRegistrationKind = new ItemRegistrationPlateKindDIM { Description = (manualViolation.PlateKind != null && manualViolation.PlateKind.Trim().Length > 0) ? manualViolation.PlateKind : "Undefined", Code = GetRandomNumber() }; itemRegistrationKind = context.ItemRegistrationPlateKindDIMs.Add(itemRegistrationKind); context.SaveChanges(); } if (itemRegistrationCategory == null) { itemRegistrationCategory = new ItemRegistrationPlateCategoryDIM { Description = "Undefined", Code = GetRandomNumber() }; itemRegistrationCategory = context.ItemRegistrationPlateCategoryDIMs.Add(itemRegistrationCategory); context.SaveChanges(); } if (itemRegistrationCode == null) { itemRegistrationCode = new ItemRegistrationPlateCodeDIM { Description = "Undefined", Code = GetRandomNumber() }; itemRegistrationCode = context.ItemRegistrationPlateCodeDIMs.Add(itemRegistrationCode); context.SaveChanges(); } if (itemCategory == null) { itemCategory = new ItemCategoryDIM { Description = manualViolation.VehicleType.Trim().Length > 0 ? manualViolation.VehicleType : "Undefined", Code = GetRandomNumber() }; itemCategory = context.ItemCategoryDIMs.Add(itemCategory); context.SaveChanges(); } if (itemInvolvement == null) { itemInvolvement = new ItemInvolvementDIM { Description = "Manual Violation Vehicle", Code = GetRandomNumber() }; itemInvolvement = context.ItemInvolvementDIMs.Add(itemInvolvement); context.SaveChanges(); } if (personInvolvement == null) { personInvolvement = new PersonInvolvementDIM { Description = "Manual Violation Vehicle", Code = GetRandomNumber() }; personInvolvement = context.PersonInvolvementDIMs.Add(personInvolvement); context.SaveChanges(); } if (locationInvolvement == null) { locationInvolvement = new LocationInvolvementDIM { Description = "Manual Violation Vehicle", Code = GetRandomNumber() }; locationInvolvement = context.LocationInvolvementDIMs.Add(locationInvolvement); context.SaveChanges(); } var item = new Item { ItemCategoryId = itemCategory.ItemCategoryId, SourceId = source.SourceId, }; item = context.Items.Add(item); context.SaveChanges(); var itemReg = new ItemRegistration { ItemRegistrationAuthorityId = itemRegistrationAuthority.ItemRegistrationAuthorityId, ItemRegistrationPlateCategoryId = itemRegistrationCategory.ItemRegistrationPlateCategoryId, ItemRegistrationPlateCodeId = itemRegistrationCode.ItemRegistrationPlateCodeId, ItemRegistrationPlateKindId = itemRegistrationKind.ItemRegistrationPlateKindId, SourceId = source.SourceId, PlateIdentification = "Undefiend", ItemId = item.ItemId }; itemReg = context.ItemRegistrations.Add(itemReg); context.SaveChanges(); if (personCategory == null) { personCategory = new PersonCategoryDIM { Code = GetRandomNumber(), Description = manualViolation.AgeClass.Trim().Length > 0 ? manualViolation.AgeClass : "Undefined" }; personCategory = context.PersonCategoryDIMs.Add(personCategory); context.SaveChanges(); } if (personGender == null) { personGender = new PersonGenderDIM { Code = GetRandomNumber(), Description = (manualViolation.Gender.Trim().Length > 0 ? manualViolation.Gender : "Undefined") }; personGender = context.PersonGenderDIMs.Add(personGender); context.SaveChanges(); } if (educationCategory == null) { educationCategory = new EducationCategoryDIM { Code = GetRandomNumber(), Description = manualViolation.LevelOfEducation.Trim().Length > 0 ? manualViolation.LevelOfEducation : "Undefined" }; educationCategory = context.EducationCategoryDIMs.Add(educationCategory); context.SaveChanges(); } if (educationDegree == null) { educationDegree = new EducationDegreeDIM { Code = GetRandomNumber(), Description = "Undefined" }; educationDegree = context.EducationDegreeDIMs.Add(educationDegree); context.SaveChanges(); } if (educationStatus == null) { educationStatus = new EducationStatusDIM { Code = GetRandomNumber(), Description = "Undefined" }; educationStatus = context.EducationStatusDIMs.Add(educationStatus); context.SaveChanges(); } if (organization == null) { organization = new Organization { Name = "Undefined", Description = "Undefined", SourceId = source.SourceId }; organization = context.Organizations.Add(organization); context.SaveChanges(); } Person person = new Person { SourceId = source.SourceId, LastName = manualViolation.OwnerName, OriginalIdent = manualViolation.OwnerTCFNumber, PersonCategoryId = personCategory.PersonCategoryId, PersonGenderId = personGender.PersonGenderId, Age = manualViolation.Age }; person = context.People.Add(person); context.SaveChanges(); var personDriverLicense = new PersonDriverLicense { EffectiveDate = manualViolation.LicenseIssueDate, PersonDriverLicenseDescription = manualViolation.LicenseSource, PersonId = person.PersonId, SourceId = source.SourceId }; personDriverLicense = context.PersonDriverLicenses.Add(personDriverLicense); context.SaveChanges(); var levelOfEducation = new PersonEducation { PersonEducationDescription = manualViolation.LevelOfEducation.Trim().Length > 0 ? manualViolation.LevelOfEducation : "Undefined", PersonId = person.PersonId, SourceId = source.SourceId, EducationCategoryId = educationCategory.EducationCategoryId, EducationDegreeId = educationDegree.EducationDegreeId, EducationStatusId = educationStatus.EducationStatusId, EducationOrganizationId = organization.OrganizationId }; levelOfEducation = context.PersonEducations.Add(levelOfEducation); context.SaveChanges(); if (locationDatum == null) { locationDatum = new LocationDatumDIM { Code = GetRandomNumber(), Description = "Undefined" }; locationDatum = context.LocationDatumDIMs.Add(locationDatum); context.SaveChanges(); } if (locationCategory == null) { locationCategory = new LocationCategoryDIM { Code = GetRandomNumber(), Description = "Undefined" }; locationCategory = context.LocationCategoryDIMs.Add(locationCategory); context.SaveChanges(); } //GeoPoint var geoPoint = DbGeometry.FromText( "POINT(" + (manualViolation.Lon) + " " + (manualViolation.Lat) + ")", 4326); if (location == null) { location = new Location { Latitude = manualViolation.Lat, Longitude = manualViolation.Lon, OrgLat = manualViolation.Lat.ToString(), OrgLong = manualViolation.Lon.ToString(), GeoPoint = geoPoint, Address1 = (manualViolation.StreetName.Trim().Length > 0 ? manualViolation.StreetName : "Undefined"), LocationName = (manualViolation.StreetName.Trim().Length > 0 ? manualViolation.StreetName : "Undefined"), Description = (manualViolation.StreetName.Trim().Length > 0 ? manualViolation.StreetName : "Undefined"), SourceId = source.SourceId, locationDatumId = locationDatum.LocationDatumId, LocationCategoryId = locationCategory.LocationCategoryId }; location = context.Locations.Add(location); context.SaveChanges(); } if (status == null) { status = new StatusDIM { Code = GetRandomNumber(), Description = "Undefined" }; status = context.StatusDIMs.Add(status); context.SaveChanges(); } Activity activity = new Activity() { ActivityDate = manualViolation.ViolationDate, OriginalIdent = manualViolation.ViolationNumber, SourceId = source.SourceId, ActivityReasonId = activityReason.ActivityReasonId, ActivityCategoryId = activityCategory.ActivityCategoryId, StatusId = status.StatusId }; activity = context.Activities.Add(activity); context.SaveChanges(); var activityLocation = new ActivityLocation() { LocationId = location.LocationId, ActivityId = activity.ActivityId, CreateDateTimeStamp = DateTime.Now, ModifiedDateTimeStamp = DateTime.Now, ActivityLocationDescription = "Manual Violation Location", SourceId = source.SourceId, LocationInvolvementId = locationInvolvement.LocationInvolvementId }; context.ActivityLocations.Add(activityLocation); context.SaveChanges(); var activityItem = new ActivityItem { ItemId = item.ItemId, ActivityId = activity.ActivityId, CreateDateTimeStamp = DateTime.Now, ModifiedDateTimeStamp = DateTime.Now, ItemInvolvementId = itemInvolvement.ItemInvolvementId, SourceId = source.SourceId }; context.ActivityItems.Add(activityItem); context.SaveChanges(); var activityPerson = new ActivityPerson { PersonId = person.PersonId, ActivityId = activity.ActivityId, CreateDateTimeStamp = DateTime.Now, ModifiedDateTimeStamp = DateTime.Now, SourceId = source.SourceId, PersonInvolvementId = personInvolvement.PersonInvolvementId }; context.ActivityPersons.Add(activityPerson); context.SaveChanges(); insertedRowsCount++; return(true); } catch (DbEntityValidationException ex) { Utility.WriteLog(ex); corruptedRowsCount++; return(false); } catch (DbUpdateException ex) { Utility.WriteLog(ex); corruptedRowsCount++; return(false); } catch (EntityCommandCompilationException ex) { Utility.WriteLog(ex); corruptedRowsCount++; return(false); } catch (EntityCommandExecutionException ex) { Utility.WriteLog(ex); corruptedRowsCount++; return(false); } catch (Exception ex) { Utility.WriteLog(ex); corruptedRowsCount++; return(false); } }
public List <VendingItems> GetAllItemss() { return(ItemRegistration.GetInstance().GetAllItems()); }
public IDevice RegisterItem(ItemRegistrationResult itemRegistrationResult, ItemRegistration itemRegistration) { var net = new NetworkConfig { IpAddress = "128.0.0.1", MacAddress = "macAddress", MachineName = "name", DefaultGateway = "198.0.0.2", SubnetMask = "200.200.200.1" }; var os = new OSInfo { OsName = "nameOS", OsType = "Win", OsVersion = "10", OsBits = 64, OsDate = "34-34-34" }; var dev = new DeviceInfo { Processor = "proc", MemoryInBytes = "123", PrinterName = "canon", NumberOfMonitors = 3, PrimaryMonitorName = "primary mon" }; var path = string.Format( "{0}{1}/{2}", DocumentStoreLocator.SchemeRavenRoute, DocumentStoreLocator.GetStoreType(), itemRegistration.TenancyId); IDevice device; using (var session = DocumentStoreLocator.Resolve(path)) { var tagsDevRegistration = itemRegistration.Tags.Where(tag => tag.Category.Color != KnownColor.Transparent).ToList(); var name = string.Format("Device {0}", DateTime.UtcNow.ToShortTimeString()); tagsDevRegistration.Add( new Tag { Id = Guid.NewGuid(), Type = TagType.Device, Attribute = name, Value = itemRegistration.Id.ToString(), CreateDate = DateTime.UtcNow, Category = new TagCategory { Name = name, Color = KnownColor.Transparent } }); device = new Kiosk { Id = itemRegistrationResult.ItemId, Name = name, Description = string.Format("Kiosk Device Created {0}", DateTime.UtcNow.ToShortDateString()), Model = DeviceType.Kiosk.ToString(), TimeRegistered = DateTime.UtcNow, CurrentStatus = HealthStatus.Green, Tags = tagsDevRegistration, Inventory = new WindowsInventory { NetworkConfig = net, OSInfo = os, DeviceInfo = dev }, }; session.Store(device); var ev = new DeviceAuthorizationEvent { DeviceId = itemRegistrationResult.ItemId, InitialTags = tagsDevRegistration, IpAddress = HttpContext.Current == null ? string.Empty : HttpContext.Current.Request.UserHostAddress, PasscodeUsed = itemRegistrationResult.PassCodeName, TimeRegistered = DateTime.UtcNow }; session.Store(ev); session.SaveChanges(); } return(device); }
public VendingItems DeleteItem(String regnum) { Console.WriteLine("In searching Item Record"); return(ItemRegistration.GetInstance().GetItems(regnum)); }
public String PutStudentRecord(VendingItems item) { Console.WriteLine("In update item informations"); return(ItemRegistration.GetInstance().UpdateItem(item)); }
public String DeleteItem(String regnum) { Console.WriteLine("In delete Item Record"); return(ItemRegistration.GetInstance().Remove(regnum)); }