public override BUSField Init(TContext context) { BUSField businessEntity = base.Init(context); BusinessComponent busComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, table = bc.Table, tableId = bc.TableId }) .Select(bc => new BusinessComponent { Id = bc.id, Table = bc.table, TableId = bc.tableId }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Business Component")); if (busComp != null) { businessEntity.BusComp = busComp; businessEntity.BusCompId = busComp.Id; businessEntity.Table = busComp.Table; businessEntity.TableId = busComp.TableId; } return(businessEntity); }
public bool DeleteCreditCardServiceInfo(Guid Id) { BusinessComponent _businessComp = new BusinessComponent(); return(_businessComp.deleteCreditServiceModel(Id)); //return _businessComponent.deleteCreditServiceModel(Id); }
public void CriarEAprovarReservaComCarroDisponivelDeveAtribuirStatusReservado() { using (var transaction = new TransactionContext()) { // Arrange var gerenciador = BusinessComponent.CreateInstance <IGerenciadorReservas>(); var reservasDao = ReservasDao.CreateInstance(); IReservas reserva = reservasDao.Create(); reserva.PlanoHandle = 1; reserva.PessoaHandle = 1; reserva.Status = ReservasStatusListaItens.ItemAguardandoAprovacao; reserva.ModeloCarroHandle = 10; // Na nossa base Fiat 147 reserva.DataInicio = DateTime.Now.AddMonths(1); reserva.DataFim = DateTime.Now.AddMonths(1).AddDays(5); // Act gerenciador.AprovarReserva(reserva); // Assert reserva = reservasDao.Get(reserva.Handle); // Buscar da base Assert.AreEqual(ReservasStatusListaItens.ItemReservado, reserva.Status); Assert.AreEqual(10, reserva.CarroInstance.ModeloHandle); //transaction.Complete();// Rollback } }
public KundeDto GetKundeById(int id) { WriteActualMethod(); Kunde k = BusinessComponent.GetKundeById(id); return(k.ConvertToDto()); }
public List <CreditServiceModel> GetCreditCardInfo() { BusinessComponent _businessComp = new BusinessComponent(); return(_businessComp.GetCreditServiceModelList()); //return _businessComponent.GetCreditServiceModelList(); }
public override void AfterLoad() { var bc = new BusinessComponent(env, "Associates"); var idInput = (InputField)page.FindControl("ID"); bc.Edit(idInput.Value); var input = (InputField)page.FindControl("advSendEmail"); if (input != null && input.Value != null && input.Value.ToString() == "send") { try { var email = bc["email"]; if (email == null || string.IsNullOrEmpty(email.ToString())) { page.AddErrorMessage("Email is empty"); return; } var name = bc["TavoMama"]; SendEmail(email.Value.ToString(), name.ToString()); input.Value = null; } catch (Exception) { page.AddErrorMessage("Failed to send email"); } } }
public bool UpdateCreditCardInfo(CreditServiceModel model) { BusinessComponent _businessComp = new BusinessComponent(); return(_businessComp.updateCreditServiceModel(model)); //return _businessComponent.updateCreditServiceModel(model); }
public override BUSApplet UIToBusiness(UIApplet UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSApplet businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); // BusComp BusinessComponent busComp = context.BusinessComponents.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.BusCompName); if (busComp != null) { businessEntity.BusComp = busComp; businessEntity.BusCompId = busComp.Id; businessEntity.BusCompName = busComp.Name; } // PhysicalRender PhysicalRender PR = context.PhysicalRenders.FirstOrDefault(n => n.Name == UIEntity.PhysicalRenderName); if (PR != null) { businessEntity.PhysicalRender = PR; businessEntity.PhysicalRenderId = PR.Id; businessEntity.PhysicalRenderName = PR.Name; } businessEntity.Virtual = UIEntity.Virtual; businessEntity.Header = UIEntity.Header; businessEntity.Type = UIEntity.Type; businessEntity.Initflag = UIEntity.InitFlag; businessEntity.DisplayLines = Convert.ToInt32(UIEntity.DisplayLines); businessEntity.EmptyState = UIEntity.EmptyState; return(businessEntity); }
public override BUSJoinSpecification Init(TContext context) { BUSJoinSpecification businessEntity = base.Init(context); BusinessComponent busComp = context.BusinessComponents.AsNoTracking().FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Business Component")); Join join = context.Joins .AsNoTracking() .Select(j => new { id = j.Id, table = j.Table, tableId = j.TableId }) .Select(j => new Join { Id = j.id, Table = j.table, TableId = j.tableId }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Join")); businessEntity.BusComp = busComp; businessEntity.BusCompId = busComp.Id; businessEntity.Table = join.Table; businessEntity.TableId = join.TableId; return(businessEntity); }
public override BUSBusinessObjectComponent DataToBusiness(BusinessObjectComponent dataEntity, TContext context) { BUSBusinessObjectComponent businessEntity = base.DataToBusiness(dataEntity, context); // BusObject BusinessObject busObject = context.BusinessObjects.AsNoTracking().FirstOrDefault(i => i.Id == dataEntity.BusObjectId); businessEntity.BusObject = busObject; businessEntity.BusObjectId = busObject.Id; businessEntity.BusObjectName = busObject.Name; // BusComp BusinessComponent busComp = context.BusinessComponents.AsNoTracking().FirstOrDefault(i => i.Id == dataEntity.BusCompId); if (busComp != null) { businessEntity.BusCompId = busComp.Id; businessEntity.BusCompName = busComp.Name; } // Link Link link = context.Links.AsNoTracking().FirstOrDefault(i => i.Id == dataEntity.LinkId); if (link != null) { businessEntity.Link = link; businessEntity.LinkId = link.Id; businessEntity.LinkName = link.Name; } return(businessEntity); }
private void BtnContinueSave_Click(object sender, EventArgs e) { try { //string EditText = "\n Author :" + userName + "\n" + richTextBox1.Text; string contents = richTextBox1.Text.ToString(); dict = new Dictionary <string, string>(); int pos1 = contents.IndexOf("/*"); int pos2 = contents.IndexOf("*/"); contents = contents.Substring(pos1 + 2, pos2 - 2); string[] a = contents.Split(new Char[] { ':' }); for (int j = 0; j < a.Length - 1; j++) { dict.Add(a[j].Trim(), null); } dict["Last Modified By"] = userName; dict["Last Modified Date and Time"] = DateTime.Now.ToString(); //string path = @"C:\Users\Alchemy.DESKTOP-V8A10HM\Desktop\CSharp\New folder\LicenceUpdate"; var businessObject = new BusinessComponent(); businessObject.MonitorDirectory(folder, dict, userName); } catch (Exception ex) { throw ex; } }
public override BUSJoin UIToBusiness(UIJoin UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSJoin businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); BusinessComponent busComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name, joins = bc.Joins.Select(join => new { id = join.Id, name = join.Name }) }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name, Joins = bc.joins.Select(join => new Join { Id = join.id, Name = join.name }).ToList() }) .FirstOrDefault(i => i.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Business Component")); if (busComp == null) { businessEntity.ErrorMessage = "First you need create business component."; } else { // Если запись новая и она не уникальна, записывается ошибка Join join = busComp.Joins?.FirstOrDefault(n => n.Name == UIEntity.Name); if (join != null && join.Id != UIEntity.Id) { businessEntity.ErrorMessage = $"Join with this name is already exists in business component {busComp.Name}."; } else { // BusComp businessEntity.BusComp = busComp; businessEntity.BusCompId = busComp.Id; // Table Table table = context.Tables.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.TableName); if (table != null) { businessEntity.Table = table; businessEntity.TableId = table.Id; businessEntity.TableName = table.Name; } } } return(businessEntity); }
public void WhenGETIsInvokedOnTheBusinessComponentsApiWithASpecifiedId() { try { _businessComponentSpecifiedByIdFromGet = BusinessComponentsClient.GetBusinessComponent(_specifiedBusinessComponentId ?? _businessComponentsFromGet.First().Id).Result; } catch (HttpRequestException ex) { _exception = ex; } }
private void RegisterComponents() { _container = new UnityContainer(); var businessComponent = new BusinessComponent(); var dataComponent = new DataComponent(); var serviceComponent = new ServiceComponent(); _container = businessComponent.Register(_container); _container = dataComponent.Register(_container); _container = serviceComponent.Register(_container); }
public override BUSBusinessObject UIToBusiness(UIBusinessObject UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSBusinessObject businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); BusinessComponent primaryBusComp = context.BusinessComponents.FirstOrDefault(n => n.Name == UIEntity.PrimaryBusCompName); if (primaryBusComp != null) { businessEntity.PrimaryBusComp = primaryBusComp; businessEntity.PrimaryBusCompId = primaryBusComp.Id; businessEntity.PrimaryBusCompName = primaryBusComp.Name; } return(businessEntity); }
public static void Start() { //Register the file repository to use LocalFileRepository. BusinessComponent.Kernel.Bind <IFileRepository>().To <LocalFileRepository>(); LocalFileRepository.LocalFileRepositoryPath = ConfigurationManager.AppSettings["LocalFileRepository.LocalFileRepositoryPath"]; //TODO: Register your business components here. BusinessComponent.RegisterComponent(SampleDomainBusinessComponent.Current); BusinessComponent.StartAll(); //Defines the user context the shared UserContext will use UserContext.CreateDefaultContext = () => new Sample.Domain.UserContext(); }
public override BUSBusinessObject DataToBusiness(BusinessObject dataEntity, TContext context) { BUSBusinessObject businessEntity = base.DataToBusiness(dataEntity, context); BusinessComponent primaryBusComp = context.BusinessComponents.AsNoTracking().FirstOrDefault(i => i.Id == dataEntity.PrimaryBusCompId); if (primaryBusComp != null) { businessEntity.PrimaryBusComp = primaryBusComp; businessEntity.PrimaryBusCompId = primaryBusComp.Id; businessEntity.PrimaryBusCompName = primaryBusComp.Name; } return(businessEntity); }
public async Task <IActionResult> GetInfoAsync() { Statuses statuses = null; try { statuses = await BusinessComponent.GetInfo(); } catch (System.Exception ex) { return(BadRequest($"Exception occurred while trying to get health informations.")); } return(Ok(statuses)); }
public override IEnumerable <ValidationResult> UIValidate(TContext context, IViewInfo viewInfo, UIBusinessComponent UIEntity, bool isNewRecord) { List <ValidationResult> result = base.UIValidate(context, viewInfo, UIEntity, isNewRecord).ToList(); BusinessComponent businessComponent = context.BusinessComponents.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.Name); if (businessComponent != null && businessComponent.Id != UIEntity.Id) { result.Add(new ValidationResult("Business component with this name is already exists.", new List <string>() { "Name" })); } return(result); }
public void UpdateAuto(AutoDto modified, AutoDto original) { try { WriteActualMethod(); BusinessComponent.UpdateAuto(modified.ConvertToEntity(), original.ConvertToEntity()); } catch (LocalOptimisticConcurrencyException <Auto> ex) { OptimisticConcurrencyException <AutoDto> enThrow = new OptimisticConcurrencyException <AutoDto>(); enThrow.Entity = ex.Entity.ConvertToDto(); throw new FaultException <OptimisticConcurrencyException <AutoDto> >(enThrow); } }
public override BUSPickList UIToBusiness(UIPickList UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSPickList businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); BusinessComponent busComp = context.BusinessComponents.AsNoTracking().FirstOrDefault(n => n.Name == UIEntity.BusCompName); if (busComp != null) { businessEntity.BusComp = busComp; businessEntity.BusCompId = busComp.Id; businessEntity.BusCompName = busComp.Name; } businessEntity.SearchSpecification = UIEntity.SearchSpecification; businessEntity.Bounded = UIEntity.Bounded; return(businessEntity); }
public override BUSPickList DataToBusiness(PickList dataEntity, TContext context) { BUSPickList businessEntity = base.DataToBusiness(dataEntity, context); BusinessComponent busComp = context.BusinessComponents.AsNoTracking().FirstOrDefault(i => i.Id == dataEntity.BusCompId); if (busComp != null) { businessEntity.BusComp = busComp; businessEntity.BusCompId = busComp.Id; businessEntity.BusCompName = busComp.Name; } businessEntity.SearchSpecification = dataEntity.SearchSpecification; businessEntity.Bounded = dataEntity.Bounded; return(businessEntity); }
public void UpdateReservation(ReservationDto modified, ReservationDto original) { try { WriteActualMethod(); BusinessComponent.UpdateReservation(modified.ConvertToEntity(), original.ConvertToEntity()); } catch (LocalOptimisticConcurrencyException <Reservation> ex) { var enThrow = new OptimisticConcurrencyException <ReservationDto> { Entity = ex.Entity.ConvertToDto() }; throw new FaultException <OptimisticConcurrencyException <ReservationDto> >(enThrow); } }
public virtual ActionResult <object> UpdateViewInfo([FromBody] RequestViewModel model) { Applet applet = viewInfo.ViewApplets.FirstOrDefault(n => n.Name == model.TargetApplet); viewInfo.ActionType = (ActionType)Enum.Parse(typeof(ActionType), model.ActionType); if (applet != null) { BusinessComponent component = viewInfo.ViewBCs.FirstOrDefault(i => i.Id == applet.BusCompId); // Текущий апплет viewInfo.CurrentApplet = applet; // Текущий контрол viewInfo.CurrentControl = applet.Controls.FirstOrDefault(n => n.Name == model.CurrentControl); viewInfo.CurrentColumn = applet.Columns.FirstOrDefault(n => n.Name == model.CurrentColumn); // При выборе из списка устанавливается выбранная запись if (model.CurrentRecord != null) { viewInfo.CurrentRecord = model.CurrentRecord; ComponentsRecordsInfo.SetSelectedRecord(component.Name, model.CurrentRecord); } } // В процессе работы с попапом if (viewInfo.CurrentPopupApplet != null) { // Текущий контрол на попапе viewInfo.CurrentPopupControl = viewInfo.CurrentPopupApplet?.Controls.FirstOrDefault(n => n.Name == model.CurrentPopupControl); } // Открытие/закрытие попапа if (model.OpenPopup) { viewInfo.AddPopupApplet(context); } if (model.ClosePopup && viewInfo.CurrentPopupApplet != null) { viewInfo.RemovePopupApplet(context); } // В случае отмены создания записи, проставление null в контексте бизнес компоненты апплета if (viewInfo.ActionType == ActionType.UndoRecord) { TBUSFactory busFactory = new TBUSFactory(); busFactory.SetRecord(null, context, viewInfo, viewInfo.CurrentPopupApplet?.BusComp ?? viewInfo.CurrentApplet.BusComp, null); } viewInfoUI.Initialize(context); return(viewInfoUI.Serialize()); }
// Возвращает текущие отображаемые записи для апплетов public static Dictionary <string, string> GetUIRecords(MainContext context, IViewInfo viewInfo) { Dictionary <string, string> UIRecords = new Dictionary <string, string>(); SelectedRecords.ToList().ForEach(record => { BusinessComponent busComp = context.BusinessComponents.FirstOrDefault(n => n.Name == record.Key); viewInfo.ViewApplets.Where(i => i.BusCompId == busComp.Id).ToList().ForEach(applet => { if (!UIRecords.ContainsKey(applet.Name)) { UIRecords.Add(applet.Name, record.Value); } }); }); return(UIRecords); }
public override Dictionary <string, object> CopyRecord() { Dictionary <string, object> result = base.CopyRecord(); if (result["ErrorMessages"] == null) { BusinessComponent businessComponent = (BusinessComponent)result["NewRecord"]; businessComponent.Fields.ForEach(field => { context.Entry(field).State = EntityState.Added; field.PickMaps.ForEach(pickMap => { context.Entry(pickMap).State = EntityState.Added; }); }); businessComponent.Joins.ForEach(join => { context.Entry(join).State = EntityState.Added; join.JoinSpecifications.ForEach(joinSpecification => { context.Entry(joinSpecification).State = EntityState.Added; }); }); context.SaveChanges(); DataBUSBusCompFR <TContext> dataBUSBusCompFR = new DataBUSBusCompFR <TContext>(); BUSUIBusCompFR <TContext> busUIBusCompFR = new BUSUIBusCompFR <TContext>(); result["NewRecord"] = busUIBusCompFR.BusinessToUI(dataBUSBusCompFR.DataToBusiness((BusinessComponent)result["NewRecord"], context)); } return(result); }
public async Task <BusinessComponent> UpdateBusinessComponent(BusinessComponent businessComponent) { return(await ApiInvoker.Update(Constants.BusinessComponentsEndpointKey, Constants.BaseBusinessComponentsRoutePrefix, businessComponent)); }
// Проходится по бк, формируя список апплетов для обновления private List <Applet> AppletListBuilding(List <BusinessObjectComponent> checkedComponents, BusinessObjectComponent masterBusComp, BusinessObjectComponent currentBusComp, List <Applet> appletsToUpdate) { // Формирование списка дочерних бк List <BusinessObjectComponent> childComponents = new List <BusinessObjectComponent>(); viewInfo .BOComponents .Except(checkedComponents) .ToList() .ForEach(component => { // Связь Link link = context.Links.FirstOrDefault(i => i.Id == component.LinkId); // Если у связи в БКО Id родительской компоненты совпадает с id текущей, добавляю эту БКО в список дочерних if (link != null && link.ParentBCId == currentBusComp.BusCompId) { childComponents.Add(component); } }); // До тех пор, пока есть дочерние компоненты while (childComponents.Count > 0) { // Получение всех необходимых сущностей BusinessObjectComponent component = childComponents.FirstOrDefault(); Applet applet = viewInfo.ViewApplets .Where(bcId => bcId.BusCompId == component.BusCompId) .Where(type => type.Type != "Popup") .FirstOrDefault(); // Если в списке апплетов для обновления нет текущего, его надо добавить if (!appletsToUpdate.Contains(applet)) { appletsToUpdate.Add(applet); } // Добавление всех апплетов, основанных на той же компоненте и не являющихся попапми в список для обновления viewInfo.ViewApplets.ForEach(viewApplet => { if (viewApplet.BusCompId == applet.BusCompId && viewApplet.Id != applet.Id && viewApplet.Type != "Popup" && !appletsToUpdate.Contains(viewApplet)) { appletsToUpdate.Add(viewApplet); } }); // Запустить заново return(AppletListBuilding(checkedComponents, masterBusComp, component, appletsToUpdate)); } // Если дочерних не осталось, значит дошли до низа иерархии, либо связи изначально отсутствовали if (masterBusComp != currentBusComp) { // Добавляю бк в список проверенных, делаю текущей бк верхнюю, запускаю заново checkedComponents.Add(currentBusComp); return(AppletListBuilding(checkedComponents, masterBusComp, masterBusComp, appletsToUpdate)); } else { if (appletsToUpdate.Count > 0) { List <Applet> sortedApplets = new List <Applet>(); List <Applet> formApplets = new List <Applet>(); BusinessComponent businessComponent = appletsToUpdate.FirstOrDefault().BusComp; appletsToUpdate.ForEach(applet => { if (businessComponent.Id == applet.BusCompId) { if (applet.Type == "Tile") { sortedApplets.Add(applet); } else { formApplets.Add(applet); } } else { businessComponent = applet.BusComp; sortedApplets.AddRange(formApplets); formApplets.Clear(); if (applet.Type == "Tile") { sortedApplets.Add(applet); } else { formApplets.Add(applet); } } }); sortedApplets.AddRange(formApplets); return(sortedApplets); } else { return(appletsToUpdate); } } }
public virtual ActionResult <string> UpdateContext() { // Список проверенных бк, список с верхними в иерархии бк и список с апплетами для обновления List <Applet> appletsToUpdate = new List <Applet>(); List <BusinessObjectComponent> topComponents = new List <BusinessObjectComponent>(); viewInfo.AppletsSortedByLinks.Clear(); // Необходимо выбрать те компоненты, у которых нет связей, либо те, которые являются верхними в иерархии viewInfo.BOComponents.ForEach(component => { // Если у компоненты нет линки, то она добавляется в список верхних в иерархии if (component.Link == null) { topComponents.Add(component); } // Иначе находится ее родительская компонента из связи else { BusinessObjectComponent parentComponent = viewInfo.BOComponents.FirstOrDefault(i => i.BusCompId == component.Link.ParentBCId); // Если родительской бк нет в представлении, текущая компонента добавляется в список верхних в иерархии if (parentComponent == null) { topComponents.Add(component); } // Иначе до тех пор пока по связям можно подниматься наверх в списке бк текущего представления else { while (viewInfo.BOComponents.IndexOf(parentComponent) != -1) { // Если у родительской компоненты нет ссылки она добавляется в список верхних в иерархии if (parentComponent.Link == null) { if (topComponents.IndexOf(parentComponent) == -1) { topComponents.Add(parentComponent); } break; } // Иначе компонента становится равной родительской компоненте из линки parentComponent = viewInfo.BOComponents.FirstOrDefault(i => i.BusCompId == parentComponent.Link.ParentBCId); } } } }); /* Для каждой компоненты, верхней в иерархии, запускается формирование списка апплетов, необходимых для обновления * И для всех компонент, отсутствующих в представлении, но являющихся верхними в иерархии для списка topComponents необходимо установить контекст */ topComponents.ForEach(component => { List <BusinessObjectComponent> boComponents = viewInfo.ViewBO.BusObjectComponents; List <BusinessObjectComponent> parentComponents = new List <BusinessObjectComponent>(); if (component.Link != null) { BusinessObjectComponent parentComponent = boComponents.FirstOrDefault(i => i.BusCompId == component.Link.ParentBCId); parentComponents.Add(parentComponent); while (parentComponent?.Link != null) { parentComponent = boComponents.FirstOrDefault(i => i.BusCompId == parentComponent.Link.ParentBCId); parentComponents.Add(parentComponent); } parentComponents.AsEnumerable().Reverse().ToList().ForEach(item => { BusinessComponent busComp = context.BusinessComponents .Include(f => f.Fields) .FirstOrDefault(i => i.Id == item.BusCompId); TBUSFactory busFactory = new TBUSFactory(); if (!ComponentsRecordsInfo.IsInitComponent(busComp.Name)) { busFactory.InitializeComponentsRecords(null, context, viewInfo, new FilterEntitiesModel() { BOComponents = boComponents, Link = item.Link, BusComp = busComp }); } }); } // Добавление всех апплетов не являющихся попапами в список для обновления viewInfo.ViewApplets.ForEach(viewApplet => { if (viewApplet.Type != "Popup") { appletsToUpdate.Add(viewApplet); } }); viewInfo.AppletsSortedByLinks.AddRange(AppletListBuilding(new List <BusinessObjectComponent>(), component, component, appletsToUpdate)); }); return(Ok()); }
public ActionResult Drilldown() { Applet currentApplet = viewInfo.CurrentPopupApplet ?? viewInfo.CurrentApplet; currentApplet = context.Applets .AsNoTracking() .Select(a => new { id = a.Id, name = a.Name, type = a.Type, busComp = new { id = a.BusComp.Id, name = a.BusComp.Name, routing = a.BusComp.Routing }, drilldowns = a.Drilldowns.Select(d => new { id = d.Id, name = d.Name, hyperLinkFieldId = d.HyperLinkFieldId, sourceField = new { id = d.SourceField.Id, name = d.SourceField.Name }, destinationBusinessComponent = new { id = d.DestinationBusinessComponent.Id, name = d.DestinationBusinessComponent.Name, routing = d.DestinationBusinessComponent.Routing }, destinationField = new { id = d.DestinationField.Id, name = d.DestinationField.Name }, destinationScreenId = d.DestinationScreenId, destinationScreenItemId = d.DestinationScreenItemId, destinationScreenItem = new { id = d.DestinationScreenItem.Id, view = new { id = d.DestinationScreenItem.View.Id, busObjectId = d.DestinationScreenItem.View.BusObjectId } } }) }) .Select(a => new Applet { Id = a.id, Name = a.name, Type = a.type, BusComp = new BusinessComponent { Id = a.busComp.id, Name = a.busComp.name, Routing = a.busComp.routing }, Drilldowns = a.drilldowns.Select(d => new Drilldown { Id = d.id, Name = d.name, HyperLinkFieldId = d.hyperLinkFieldId, SourceField = new Field { Id = d.sourceField.id, Name = d.sourceField.name }, DestinationBusinessComponent = new BusinessComponent { Id = d.destinationBusinessComponent.id, Name = d.destinationBusinessComponent.name, Routing = d.destinationBusinessComponent.routing }, DestinationField = new Field { Id = d.destinationField.id, Name = d.destinationField.name }, DestinationScreenId = d.destinationScreenId, DestinationScreenItem = new ScreenItem { Id = d.destinationScreenItem.id, View = new View { Id = d.destinationScreenItem.view.id, BusObjectId = d.destinationScreenItem.view.busObjectId } } }).ToList() }) .FirstOrDefault(i => i.Id == currentApplet.Id); if (currentApplet != null) { string controlName; Field field; switch (currentApplet.Type) { case "Tile": controlName = viewInfo.CurrentColumn.Name; field = viewInfo.CurrentColumn.Field; break; default: controlName = viewInfo.CurrentPopupControl?.Name ?? viewInfo.CurrentControl?.Name; field = viewInfo.CurrentPopupControl?.Field ?? viewInfo.CurrentControl?.Field; break; } if (field != null) { TBUSFactory BUSFactory = new TBUSFactory(); Drilldown drilldown = currentApplet.Drilldowns.FirstOrDefault(i => i.HyperLinkFieldId == field.Id); if (drilldown != null && drilldown.DestinationBusinessComponent?.Name != null && drilldown.DestinationField?.Name != null && drilldown.SourceField?.Name != null) { // Целевой экран Screen destinationScreen = context.Screens.AsNoTracking().FirstOrDefault(i => i.Id == drilldown.DestinationScreenId); if (destinationScreen != null) { applicationInfo.CurrentScreen = destinationScreen; // Целевыое представление View destinationView = context.Views.AsNoTracking().FirstOrDefault(i => i.Id == drilldown.DestinationScreenItem.View.Id); if (destinationView != null) { applicationInfo.CurrentView = destinationView; // Исходное поле dynamic sourceRecord = BUSFactory.GetRecord(null, context, viewInfo, currentApplet.BusComp, "Id", viewInfo.CurrentRecord); PropertyInfo sourceProperty = sourceRecord.GetType().GetProperty(drilldown.SourceField.Name); if (sourceProperty != null) { // Очистка старой информации о выбранных записях if (screenInfo.Screen.Name != destinationScreen.Name) { ComponentsRecordsInfo.Dispose(); } // Установка текущей выбранной записи на целевой бизнес компоненте var sourcePropertyValue = sourceProperty.GetValue(sourceRecord); if (sourcePropertyValue != null) { dynamic destinationRecord = BUSFactory.GetRecord(null, context, viewInfo, drilldown.DestinationBusinessComponent, drilldown.DestinationField.Name, sourcePropertyValue.ToString()); if (destinationRecord != null) { ComponentsRecordsInfo.SetSelectedRecord(drilldown.DestinationBusinessComponent.Name, destinationRecord.Id.ToString()); } // Установка текущих выбранных записей на всех родительских бизнес компонентах целевой компоненты BusinessObject destinationBO = context.BusinessObjects .AsNoTracking() .Include(boc => boc.BusObjectComponents) .ThenInclude(l => l.Link) .ThenInclude(cf => cf.ChildField) .Include(boc => boc.BusObjectComponents) .ThenInclude(l => l.Link) .ThenInclude(pf => pf.ParentField) .FirstOrDefault(i => i.Id == destinationView.BusObjectId); BusinessObjectComponent destinationComponent = destinationBO.BusObjectComponents.FirstOrDefault(i => i.BusCompId == drilldown.DestinationBusinessComponent.Id); dynamic childRecord = destinationRecord; if (destinationComponent.Link != null) { BusinessComponent parentBusComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name, table = new { id = bc.Table.Id, name = bc.Table.Name } }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name, Table = new Table { Id = bc.table.id, Name = bc.table.name } }) .FirstOrDefault(i => i.Id == destinationComponent.Link.ParentBCId); BusinessComponent childBusComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name }) .FirstOrDefault(i => i.Id == destinationComponent.Link.ChildBCId); string childFieldValue = childRecord.GetType().GetProperty(destinationComponent.Link.ChildField.Name).GetValue(childRecord).ToString(); string parentFieldName = destinationComponent.Link.ParentField.Name; IEnumerable <dynamic> parentRecords = (IEnumerable <dynamic>)(context.GetType().GetProperty(parentBusComp.Table.Name).GetValue(context)); string searchSpecificationByParent = $"{parentFieldName} = \"{childFieldValue}\""; dynamic parentRecord = parentRecords.AsQueryable().Where(searchSpecificationByParent).FirstOrDefault(); ComponentsRecordsInfo.SetSearchSpecification(childBusComp.Name, SearchSpecTypes.SearchSpecificationByParent, searchSpecificationByParent); ComponentsRecordsInfo.SetSelectedRecord(parentBusComp.Name, parentRecord.Id.ToString()); destinationComponent = destinationBO.BusObjectComponents.FirstOrDefault(i => i.BusCompId == destinationComponent.Link.ParentBCId); childRecord = parentRecord; } // Установка хлебных крошек ScreenItem crumb = screenInfo.Screen.ScreenItems.FirstOrDefault(n => n.View != null && n.View.Name == screenInfo.CurrentView.Name); ComponentsRecordsInfo.AppendCrumb(crumb); if (screenInfo.Screen.Name == destinationScreen.Name) { screenInfo.Initialize(screenInfo.Screen.Name, destinationView.Name, context); screenInfoUI.Initialize(screenInfo, context); viewInfo.View = destinationView; } viewInfo.ActionType = ActionType.Drilldown; } } } } } } } return(Ok()); }