public virtual object Any(StoreMobileBOSEntity request) { MobileBOSEntityResponse response = new MobileBOSEntityResponse(); IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); if (request.BOSEntity != null) { BOSEntity old = _repository.GetById(request.BOSEntity.Id); BOSEntity updt = old.PopulateWith(request.BOSEntity); updt = _repository.CreateUpdate(updt, CurrentSessionUsername); response.BOSEntity = updt.ConvertTo <MobileBOSEntityDto>(); TrySendStoreNotificationToChannel(typeof(BOSEntity).Name, new List <BOSEntity> { updt }.ToJson()); } return(new HttpResult(response) { ResultScope = () => JsConfig.With(new Config { DateHandler = DateHandler.ISO8601 }) }); //using (JsConfig.With(new Config { DateHandler = DateHandler.ISO8601 })) //{ // return response; //} }
/// <summary> /// Update or create a single BOSRecord or a list of BOSRecords, depending on whether the BOSRecord or BOSRecords property has got a value set. /// If the BOSRecord property is set the BOSRecord will be created or updated and the BOSRecords property will be ignored. /// To create or update more than one BOSRecord, assign a list to the BOSRecords property and make sure BOSRecord is set to nothing/null. /// </summary> /// <param name="request">The request containing the BOSRecord or BOSRecords that needs to be created or updated</param> /// <returns>depending on the values supplied, the updated BOSRecord or BOSRecords will be returned.</returns> public virtual BOSEntitiesResponse Any(StoreBOSEntities request) { BOSEntitiesResponse response = new BOSEntitiesResponse(); IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); response.BOSEntities = _repository.CreateUpdateList(request.BOSEntities.ConvertAllTo <BOSEntity>().ToList(), CurrentSessionUsername).ConvertAllTo <BOSEntityDto>().ToList(); return(response); }
/// <summary> /// Returns a single BOSRecord where the id in the request matches the record ID in the database. /// </summary> /// <param name="request">The request used for requesting the record from the database.</param> /// <returns>If FetchLazy was set to false, the JarsBOSRecord item will be populated, if not then the JarsBOSRecordBase record will be filled with data.</returns> public virtual BOSEntityResponse Any(GetBOSEntity request) { BOSEntityResponse response = new BOSEntityResponse(); IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); response.BOSEntity = _repository.GetById(request.Id, true).ConvertTo <BOSEntityDto>(); return(response); }
public void obtain_generic_base_repository_using_MEF_and_read_and_create_records() { //now only using mef test the obtainment IGenericEntityRepositoryBase <JarsJob, IDataContextNhJars> jarsRep = _repFactory.GetDataRepository <IGenericEntityRepositoryBase <JarsJob, IDataContextNhJars> >(); //assert creation Assert.IsNotNull(jarsRep); }
public virtual BOSEntityResponse Any(StoreBOSEntity request) { BOSEntityResponse response = new BOSEntityResponse(); IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); if (request.BOSEntity != null) { response.BOSEntity = _repository.CreateUpdate(request.BOSEntity.ConvertTo <BOSEntity>(), CurrentSessionUsername).ConvertTo <BOSEntityDto>(); } return(response); }
/// <summary> /// Update or create a list of EntityRules. /// </summary> /// <param name="request">The request containing the EntityRules that needs to be created or updated</param> /// <returns>the list of values updated or created will be returned.</returns> public virtual JarsRulesResponse Any(StoreJarsRules request) { //return ExecuteFaultHandledMethod(() => //{ JarsRulesResponse response = new JarsRulesResponse(); IGenericEntityRepositoryBase <JarsRule, IDataContextNhJars> _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <JarsRule, IDataContextNhJars> >(); response.Rules = _repository.CreateUpdateList(request.Rules, CurrentSessionUsername).ToList(); return(response); // }); }
public void Create_Generic_Repository_Objects_With_Mef() { //IGenericEntityReadOnlyRepositoryBase<BOSExternalEntity, IDataContextExternalBOS> _ro_repository = _DataRepositoryFactory.GetDataRepository<IGenericEntityReadOnlyRepositoryBase<BOSExternalEntity, IDataContextExternalBOS>>(); //var ro = _ro_repository.GetAll(); IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); var crud = _repository.CreateUpdate(new BOSEntity(), "TEST"); Assert.IsNotNull(_bosContext); //Assert.IsNotNull(_bosExternalContext); }
public SimpleSchedForm(Core.Interfaces.Repositories.IDataRepositoryFactory _repFactory) { InitializeComponent(); _repoFactory = _repFactory; processor = new StandardAppointmentProcessor(); IGenericEntityRepositoryBase <JarsResource, IDataContextNhJars> jarsRepo = _repFactory.GetDataRepository <IGenericEntityRepositoryBase <JARS.Entities.JarsResource, IDataContextNhJars> >(); List <JarsResource> ResList = jarsRepo.GetAll().ToList(); resourceBindingSource.DataSource = ResList; }
/// <summary> /// Send CRUD notifications for a BOSRecord Entity or Entities /// Note! : /// This Method is a special method used by the service when ServerEvents are being used.(serviceStack). /// If the service does not implement serverEvents this will throw an error. /// This will send a notification to all subscribed clients (including the client the request originated from) where the chanel name is the name of the entity type. /// This will only process SelectorTypes.store and SelectorTypes.delete notifications. /// The notification sent to subscribers will also be a JarsSyncEventStore or JarsSyncEventStore Dto object. /// </summary> /// <param name="crud">The notification request indicating a store or delete event that will be sent to other subscribers.</param> public virtual void Any(BOSEntitiesNotification crud) { //do some BOSRecord updates here using the info from the the crud IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); if (crud.Selector == SelectorTypes.store) { List <BOSEntityDto> notifyList = _repository.Where(d => crud.Ids.Contains(d.Id)).ConvertAllTo <BOSEntityDto>().ToList(); TrySendStoreNotificationToChannel(typeof(BOSEntity).Name, notifyList.ToJson()); } if (crud.Selector == SelectorTypes.delete) { TrySendDeleteNotificationToChannel(typeof(BOSEntity).Name, crud.Ids.ConvertTo <List <string> >().ToArray());//, true); } }
/// <summary> /// Find a BOSRecord by specifying values for the properties available in the request. /// Date values: Start date will go from date forward, end date will be from end date back, and if both has values, /// it will be used as from (between) start to end /// </summary> /// <param name="request">The request used for building the find parameters</param> /// <returns>If LoadLazy was true, then a list of JarsBOSRecordBase items, otherwise a list of fully loaded JarsBOSRecords</returns> public virtual BOSEntitiesResponse Any(FindBOSEntities request) { BOSEntitiesResponse response = new BOSEntitiesResponse(); if (request != null) { Expression <Func <BOSEntity, bool> > query = LinqExpressionBuilder.True <BOSEntity>(); //Id if (request.ResourceId != null) { query = query.And(a => a.ResourceId == int.Parse(request.ResourceId)); } //StartDateTime if (request.StartDate.HasValue && request.StartDate != DateTime.MinValue) { query = query.And(a => a.StartDate.Date >= request.StartDate.Value.Date); } //EndDateTime (unlike the mobile version we dont set the end date = start date if the end date is empty) if (request.EndDate.HasValue && request.EndDate != DateTime.MinValue) { query = query.And(a => a.EndDate.Date <= request.EndDate.Value.Date); } //statuses if (!request.Statuses.IsNullOrEmpty()) { //if the status value contains a , then split it, otherwise just use as is if (request.Statuses.Contains(',')) { string[] arrStatus = request.Statuses.Split(new[] { ',' }); query = query.And(a => arrStatus.Contains(a.ProgressStatus)); } else { query = query.And(a => a.ProgressStatus == request.Statuses); } } IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); response.BOSEntities = _repository.Where(query, true).ConvertAllTo <BOSEntityDto>().ToList(); } return(response); }
void CreateDefaultRecord(FindApptLabels request, IGenericEntityRepositoryBase <ApptLabel, IDataContextNhJars> repository) { ApptLabel lbl = new ApptLabel() { UseInterfaceType = request.InterfaceTypeName, ViewName = request.ViewType, LabelCriteria = "" }; lbl = repository.CreateUpdate(lbl, "SYSTEM"); Type t = Type.GetType(request.InterfaceTypeName); if (t == typeof(IEntityWithStatusLabels)) { lbl.LabelCriteria = $"([LabelKey] = '{lbl.Id}')"; lbl = repository.CreateUpdate(lbl, "SYSTEM"); } }
void CreateDefaultRecord(FindApptStatuses request, IGenericEntityRepositoryBase <ApptStatus, IDataContextNhJars> repository) { ApptStatus sts = new ApptStatus() { UseInterfaceType = request.InterfaceTypeName, ViewName = request.ViewType, StatusCriteria = "" }; sts = repository.CreateUpdate(sts, "SYSTEM"); Type t = Type.GetType(request.InterfaceTypeName); if (t == typeof(IEntityWithStatusLabels)) { sts.StatusCriteria = $"([StatusKey] = '{sts.Id}')"; repository.CreateUpdate(sts, "SYSTEM"); } }
public void query_information_using_queryover_method_generic_repositories() { IGenericEntityRepositoryBase <JarsJob, IDataContextNhJars> jarsRepo = _repFactory.GetDataRepository <IGenericEntityRepositoryBase <JarsJob, IDataContextNhJars> >(); IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> extRepo = _repFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); //var jQry = QueryOver.Of<JarsJob>().Where(j => j.Id > 0).And(j => j.CreatedBy.IsLike("MEF",MatchMode.Anywhere)).OrderBy(j => j.CreatedDate).Asc; //IList<JarsJob> jList = jarsRepo.QueryOverOf(jQry); IList <JarsJob> jList = jarsRepo.Where(j => j.Id > 0 && j.CreatedBy.IsLike("MEF", MatchMode.Anywhere)).OrderBy(j => j.CreatedBy).ToList(); Assert.IsTrue(jList.Count > 0); jList = jarsRepo.Where(j => j.Id > 1 && j.Id < 3); Assert.IsTrue(jList.Count == 1); //var xQry = QueryOver.Of<ExternalJobHeader>().Where(j => j.Id > 0).And(j => j.ExtRefID == "123").OrderBy(j => j.Priority).Desc; IList <BOSEntity> xList = extRepo.Where(j => j.Id > 0 && j.ExtRefId == "123").OrderByDescending(j => j.Priority).ToList(); Assert.IsTrue(xList.Count > 0); }
public void obtain_generic_repository_using_MEF_and_read_and_create_records() { //now only using mef test the obtainment IGenericEntityRepositoryBase <JarsJob, IDataContextNhJars> jarsRep = _repFactory.GetDataRepository <IGenericEntityRepositoryBase <JarsJob, IDataContextNhJars> >(); IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> extRep = _repFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); //assert creation //Assert.IsNotNull(qlRep); Assert.IsNotNull(jarsRep); Assert.IsNotNull(extRep); //list the jobs from each repository IList <JarsJob> jarsJobs = jarsRep.GetAll(); Assert.IsTrue(jarsJobs != null); IList <BOSEntity> extHeads = extRep.GetAll(); Assert.IsTrue(extHeads != null); //greate a record JarsJob jj = jarsRep.CreateUpdate(new JarsJob(), "MEF_GEN_TEST"); Assert.IsTrue(jj.Id > 0); BOSEntity xj = extRep.CreateUpdate(new BOSEntity(), "MEF_GEN_TEST"); Assert.IsTrue(xj.Id > 0); //get a record from each repository JarsJob job = jarsRep.GetById((long)1); Assert.IsTrue(job.Id == 1); BOSEntity header = extRep.GetById(1); Assert.IsTrue(header.Id == 1); }
/// <summary> /// Update or create a single BOSRecord or a list of BOSRecords, depending on whether the BOSRecord or BOSRecords property has got a value set. /// If the BOSRecord property is set the BOSRecord will be created or updated and the BOSRecords property will be ignored. /// To create or update more than one BOSRecord, assign a list to the BOSRecords property and make sure BOSRecord is set to nothing/null. /// </summary> /// <param name="request">The request containing the BOSRecord or BOSRecords that needs to be created or updated</param> /// <returns>depending on the values supplied, the updated BOSRecord or BOSRecords will be returned.</returns> public virtual object Any(StoreMobileBOSEntities request) { MobileBOSEntitiesResponse response = new MobileBOSEntitiesResponse(); if (request.BOSEntities.Any()) { IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); List <int> ids = request.BOSEntities.Select(e => e.Id).ToList(); IList <BOSEntity> oldies = _repository.Where(e => ids.Contains(e.Id)).ToList(); foreach (var reqEntity in request.BOSEntities) { BOSEntity old = oldies.SingleOrDefault(o => o.Id == reqEntity.Id); if (old != null) { old.PopulateWith(reqEntity); } } List <BOSEntity> updtList = _repository.CreateUpdateList(oldies, CurrentSessionUsername).ToList(); response.BOSEntities = updtList.ConvertAllTo <MobileBOSEntityDto>().ToList(); TrySendStoreNotificationToChannel(typeof(BOSEntity).Name, updtList.ToJson()); //response.BOSEntities = _repository.MergeList(request.BOSEntities.ConvertAllTo<BOSEntity>().ToList(), CurrentSessionUsername).ConvertAllTo<MobileBOSEntityDto>().ToList(); } return(new HttpResult(response) { ResultScope = () => JsConfig.With(new Config { DateHandler = DateHandler.ISO8601 }) }); //using (JsConfig.With(new Config { DateHandler = DateHandler.ISO8601 })) //{ // return response; //} }
/// <summary> /// Find a BOSRecord by specifying values for the properties available in the request. /// Date values: Start date will go from date forward, end date will be from end date back, and if both has values, /// it will be used as from (between) start to end /// </summary> /// <param name="request">The request used for building the find parameters</param> /// <returns>If LoadLazy was true, then a list of JarsBOSRecordBase items, otherwise a list of fully loaded JarsBOSRecords</returns> public virtual object Any(FindMobileBOSEntities request) { //https://github.com/ServiceStack/ServiceStack.Text#global-default-json-configuration MobileBOSEntitiesResponse response = new MobileBOSEntitiesResponse(); if (request != null) { Expression <Func <BOSEntity, bool> > query = LinqExpressionBuilder.True <BOSEntity>(); //Id if (request.ResourceId != null) { query = query.And(a => a.ResourceId == int.Parse(request.ResourceId)); } //StartDateTime if (request.StartDate.HasValue && request.StartDate != DateTime.MinValue) { query = query.And(a => a.StartDate.Date >= request.StartDate.Value.Date); } //EndDateTime if (request.EndDate.HasValue && request.EndDate != DateTime.MinValue) { query = query.And(a => a.EndDate.Date <= request.EndDate.Value.Date); } else { //set end date to start date so that we only get one day by default if (request.StartDate.HasValue && request.StartDate != DateTime.MinValue) { query = query.And(a => a.EndDate.Date <= request.StartDate.Value.Date); } } //statuses if (!request.Statuses.IsNullOrEmpty()) { //if the status value contains a , then split it, otherwise just use as is if (request.Statuses.Contains(',')) { string[] arrStatus = request.Statuses.Split(new[] { ',' }); query = query.And(a => arrStatus.Contains(a.ProgressStatus)); } else { query = query.And(a => a.ProgressStatus == request.Statuses); } } IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <BOSEntity, IDataContextBOS> >(); response.BOSEntities = _repository.Where(query, true).ConvertAllTo <MobileBOSEntityDto>().ToList(); } return(new HttpResult(response) { ResultScope = () => JsConfig.With(new Config { AssumeUtc = true, DateHandler = DateHandler.ISO8601DateTime }) }); //using (JsConfig.With(new Config { DateHandler = DateHandler.ISO8601 })) //{ // return response; //} }
/// <summary> /// Find a list of appointments depending on the criteria given in the Find request. /// If the request does not contain any values for filtering all the records will be returned. /// </summary> /// <param name="request">The request containing the search criteria.</param> /// <returns>a list of StandardAppointmentDefault entities.</returns> public JarsDefaultAppointmentsResponse Any(FindJarsDefaultAppointments request) { IGenericEntityRepositoryBase <JarsDefaultAppointment, IDataContextNhJars> repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <JarsDefaultAppointment, IDataContextNhJars> >(); JarsDefaultAppointmentsResponse response = new JarsDefaultAppointmentsResponse(); if (request.DescriptionLike != null) { response.Appointments = repository.Where(d => d.Description.IsLike(request.DescriptionLike)).ToList().ConvertAll(s => s.ConvertTo <JarsDefaultAppointmentDto>()); } else { response.Appointments = repository.GetAll().ToList().ConvertAll(s => s.ConvertTo <JarsDefaultAppointmentDto>()); } return(response); }
public void Any(DeleteJarsDefaultAppointment request) { IGenericEntityRepositoryBase <JarsDefaultAppointment, IDataContextNhJars> repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <JarsDefaultAppointment, IDataContextNhJars> >(); repository.Delete(request.Id); TrySendDeleteNotificationToChannel(typeof(JarsDefaultAppointment).Name, new string[] { request.Id.ToString() });//, request.IsAppointment); }
/// <summary> /// Send CRUD notifications for an Entity or Entities /// Note! : /// If the service does not implement serverEvents this will throw an error. /// This will send a notification to all subscribed clients (including the client the request originated from) where the chanel name is the name of the entity type. /// This will only process SelectorTypes.store and SelectorTypes.delete notifications. /// The notification sent to subscribers will be a ServerEventMessage (serviceStack) where the data(json) is set as ServerEventMessageData (Jars) object. /// </summary> /// <param name="crud">The notification request indicating a store or delete event that will be sent to other subscribers.</param> public virtual void Any(JarsDefaultAppointmentNotification crud) { //ExecuteFaultHandledMethod(() => //{ //check that the sender has subscribed to the service //SubscriptionInfo subscriber = ServerEvents.GetSubscriptionInfo(crud.From); List <SubscriptionInfo> subscriber = ServerEvents.GetSubscriptionInfosByUserId(crud.FromUserName); if (subscriber == null) { throw HttpError.NotFound($"Subscriber {crud.FromUserName} does not exist."); } //do some job updates here using the info from the the crud IGenericEntityRepositoryBase <JarsDefaultAppointment, IDataContextNhJars> _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <JarsDefaultAppointment, IDataContextNhJars> >(); if (crud.Selector == SelectorTypes.store) { List <JarsDefaultAppointmentDto> storeList = _repository.Where(a => crud.Ids.Contains(a.Id)).ConvertAllTo <JarsDefaultAppointmentDto>().ToList(); TrySendStoreNotificationToChannel(typeof(JarsDefaultAppointment).Name, storeList.ToJson()); } if (crud.Selector == SelectorTypes.delete) { TrySendDeleteNotificationToChannel(typeof(JarsDefaultAppointment).Name, crud.Ids.ConvertTo <List <string> >().ToArray());//, true); } //}); }
/// <summary> /// Save or update aa list of records. /// </summary> /// <param name="request">The request containing the entities that needs to be stored (created or updated)</param> /// <returns></returns> public JarsDefaultAppointmentsResponse Any(StoreJarsDefaultAppointments request) { return(ExecuteFaultHandledMethod(() => { IGenericEntityRepositoryBase <JarsDefaultAppointment, IDataContextNhJars> repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <JarsDefaultAppointment, IDataContextNhJars> >(); var appts = repository.CreateUpdateList(request.Appointments.ConvertAllTo <JarsDefaultAppointment>().ToList(), CurrentSessionUsername); JarsDefaultAppointmentsResponse response = new JarsDefaultAppointmentsResponse { Appointments = appts.ConvertAllTo <JarsDefaultAppointmentDto>().ToList() }; return response; })); }