/// <summary> /// Merges the map. /// </summary> /// <param name="config">The configuration.</param> /// <exception cref="GoliathDataException"> /// </exception> public void MergeMap(MapConfig config) { foreach (var entity in config.EntityConfigs) { if (EntityConfigs.Contains(entity.FullName)) { continue; } EntityConfigs.Add(entity); } foreach (var complexType in config.ComplexTypes) { if (ComplexTypes.Contains(complexType.FullName)) { continue; } ComplexTypes.Add(complexType); } config.MapStatements(config.Settings.Platform); MapStatements(Settings.Platform); LoadMappedStatements(config.MappedStatements); }
private void CreateCustomEditAction() { var editAction = new JournalAction("Изменить", (selected) => { var selectedNodes = selected.OfType <EmployeeJournalNode>(); if (selectedNodes == null || selectedNodes.Count() != 1) { return(false); } EmployeeJournalNode selectedNode = selectedNodes.First(); if (!EntityConfigs.ContainsKey(selectedNode.EntityType)) { return(false); } var config = EntityConfigs[selectedNode.EntityType]; return(config.PermissionResult.CanRead); }, (selected) => true, (selected) => { var selectedNodes = selected.OfType <EmployeeJournalNode>(); if (selectedNodes == null || selectedNodes.Count() != 1) { return; } EmployeeJournalNode selectedNode = selectedNodes.First(); if (!EntityConfigs.ContainsKey(selectedNode.EntityType)) { return; } var config = EntityConfigs[selectedNode.EntityType]; var foundDocumentConfig = config.EntityDocumentConfigurations.FirstOrDefault(x => x.IsIdentified(selectedNode)); TabParent.OpenTab(() => foundDocumentConfig.GetOpenEntityDlgFunction().Invoke(selectedNode), this); if (foundDocumentConfig.JournalParameters.HideJournalForOpenDialog) { HideJournal(TabParent); } } ); if (SelectionMode == JournalSelectionMode.None) { RowActivatedAction = editAction; } NodeActionsList.Add(editAction); }
/// <summary> /// Gets the entity map. /// </summary> /// <param name="entityMapFullName">Full name of the entity map.</param> /// <returns></returns> public EntityMap GetEntityMap(string entityMapFullName) { EntityMap ent; if (!EntityConfigs.TryGetValue(entityMapFullName, out ent)) { throw new MappingException(string.Format("{0} was not found. Probably not mapped", entityMapFullName)); } return(ent); }
void CreateDeleteAction() { var deleteAction = new JournalAction("Удалить", (selected) => { var selectedNodes = selected.OfType <CashRequestJournalNode>(); if (selectedNodes == null || selectedNodes.Count() != 1) { return(false); } CashRequestJournalNode selectedNode = selectedNodes.First(); if (selectedNode.State != CashRequest.States.New) { return(false); } if (!EntityConfigs.ContainsKey(selectedNode.EntityType)) { return(false); } var config = EntityConfigs[selectedNode.EntityType]; return(config.PermissionResult.CanDelete); }, (selected) => true, (selected) => { var selectedNodes = selected.OfType <CashRequestJournalNode>(); if (selectedNodes == null || selectedNodes.Count() != 1) { return; } CashRequestJournalNode selectedNode = selectedNodes.First(); if (!EntityConfigs.ContainsKey(selectedNode.EntityType)) { return; } var config = EntityConfigs[selectedNode.EntityType]; if (config.PermissionResult.CanDelete) { DeleteHelper.DeleteEntity(selectedNode.EntityType, selectedNode.Id); } }, "Delete" ); NodeActionsList.Add(deleteAction); }
protected void CreateDeleteAction() { var deleteAction = new JournalAction("Удалить", (selected) => { var selectedNodes = selected.OfType <DeliveryPointJournalNode>().ToList(); if (!selectedNodes.Any()) { return(false); } var selectedNode = selectedNodes.First(); if (!EntityConfigs.ContainsKey(selectedNode.EntityType)) { return(false); } var config = EntityConfigs[selectedNode.EntityType]; return(config.PermissionResult.CanDelete && _canDeleteClientAndDp); }, (selected) => true, (selected) => { var selectedNodes = selected.OfType <DeliveryPointJournalNode>().ToList(); if (!selectedNodes.Any()) { return; } var selectedNode = selectedNodes.First(); if (!EntityConfigs.ContainsKey(selectedNode.EntityType)) { return; } var config = EntityConfigs[selectedNode.EntityType]; if (config.PermissionResult.CanDelete) { DeleteHelper.DeleteEntity(selectedNode.EntityType, selectedNode.Id); } }, "Delete" ); NodeActionsList.Add(deleteAction); }
private void CreateCustomDeleteAction() { var deleteAction = new JournalAction("Удалить", (selected) => { var selectedNodes = selected.OfType <PremiumJournalNode>(); if (selectedNodes == null || selectedNodes.Count() != 1) { return(false); } PremiumJournalNode selectedNode = selectedNodes.First(); if (selectedNode.EntityType == typeof(PremiumRaskatGAZelle)) { return(false); } if (!EntityConfigs.ContainsKey(selectedNode.EntityType)) { return(false); } var config = EntityConfigs[selectedNode.EntityType]; return(config.PermissionResult.CanDelete); }, (selected) => true, (selected) => { var selectedNodes = selected.OfType <PremiumJournalNode>(); if (selectedNodes == null || selectedNodes.Count() != 1) { return; } PremiumJournalNode selectedNode = selectedNodes.First(); if (!EntityConfigs.ContainsKey(selectedNode.EntityType)) { return; } var config = EntityConfigs[selectedNode.EntityType]; if (config.PermissionResult.CanDelete) { DeleteHelper.DeleteEntity(selectedNode.EntityType, selectedNode.Id); } }, "Delete" ); NodeActionsList.Add(deleteAction); }
private void CreateCustomEditAction() { var editAction = new JournalAction("Изменить", (selected) => { var selectedNodes = selected.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode == null || !EntityConfigs.ContainsKey(selectedNode.EntityType)) { return(false); } var config = EntityConfigs[selectedNode.EntityType]; return(config.PermissionResult.CanUpdate); }, (selected) => true, (selected) => { var selectedNodes = selected.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode == null || !EntityConfigs.ContainsKey(selectedNode.EntityType)) { return; } var config = EntityConfigs[selectedNode.EntityType]; var foundDocumentConfig = config.EntityDocumentConfigurations.FirstOrDefault(x => x.IsIdentified(selectedNode)); foundDocumentConfig?.GetOpenEntityDlgFunction().Invoke(selectedNode); } ); if (SelectionMode == JournalSelectionMode.None) { RowActivatedAction = editAction; } NodeActionsList.Add(editAction); }
protected void CreateDeleteAction() { var deleteAction = new JournalAction("Удалить", (selected) => { var selectedNodes = selected.OfType <DeliveryPointJournalNode>(); if (selectedNodes == null || selectedNodes.Count() != 1) { return(false); } DeliveryPointJournalNode selectedNode = selectedNodes.First(); if (!EntityConfigs.ContainsKey(selectedNode.EntityType)) { return(false); } var config = EntityConfigs[selectedNode.EntityType]; return(config.PermissionResult.CanDelete && commonServices.CurrentPermissionService.ValidatePresetPermission("can_delete_counterparty_and_deliverypoint")); }, (selected) => true, (selected) => { var selectedNodes = selected.OfType <DeliveryPointJournalNode>(); if (selectedNodes == null || selectedNodes.Count() != 1) { return; } DeliveryPointJournalNode selectedNode = selectedNodes.First(); if (!EntityConfigs.ContainsKey(selectedNode.EntityType)) { return; } var config = EntityConfigs[selectedNode.EntityType]; if (config.PermissionResult.CanDelete) { DeleteHelper.DeleteEntity(selectedNode.EntityType, selectedNode.Id); } } ); NodeActionsList.Add(deleteAction); }
private void CreateDefaultAddAction() { var entityConfig = EntityConfigs.First().Value; var addAction = new JournalAction("Добавить", selected => entityConfig.PermissionResult.CanCreate, selected => entityConfig.PermissionResult.CanCreate, selected => { var docConfig = entityConfig.EntityDocumentConfigurations.First(); ITdiTab tab = docConfig.GetCreateEntityDlgConfigs().First().OpenEntityDialogFunction(); TabParent.OpenTab(() => tab, this); if (docConfig.JournalParameters.HideJournalForCreateDialog) { if (TabParent is ITdiSliderTab slider) { slider.IsHideJournal = true; } } }); NodeActionsList.Add(addAction); }
public override ITdiTab GetTabToOpen(Type subjectType, int subjectId) { var constructorInfos = typeof(CommonJournalNode <TEntity>) .GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance); var node = constructorInfos.First().Invoke(new object[] {}) as CommonJournalNode; if (node == null) { return(null); } node.Id = subjectId; EntityConfigs.TryGetValue(subjectType, out var config); var foundDocumentConfig = (config ?? throw new InvalidOperationException($"Не найдена конфигурация для {subjectType.Name}")) .EntityDocumentConfigurations.FirstOrDefault(x => x.IsIdentified(node)); return((foundDocumentConfig?.GetOpenEntityDlgFunction() ?? throw new InvalidOperationException( $"Не найдена конфигурация для открытия диалога в {nameof(foundDocumentConfig)}")) .Invoke(node)); }
protected override void CreatePopupActions() { base.CreatePopupActions(); var resetPassAction = new JournalAction( "Сбросить пароль", (selected) => { var selectedNodes = selected.OfType <EmployeeJournalNode>(); if (selectedNodes == null || selectedNodes.Count() != 1) { return(false); } EmployeeJournalNode selectedNode = selectedNodes.First(); if (!EntityConfigs.ContainsKey(selectedNode.EntityType)) { return(false); } var config = EntityConfigs[selectedNode.EntityType]; return(config.PermissionResult.CanUpdate); }, x => true, selectedItems => { var selectedNodes = selectedItems.Cast <EmployeeJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode != null) { using (var uow = UnitOfWorkFactory.CreateWithoutRoot("Сброс пароля пользователю")) { var employee = uow.GetById <Employee>(selectedNode.Id); if (employee.User == null) { commonServices.InteractiveService.ShowMessage(ImportanceLevel.Error, "К сотруднику не привязан пользователь!"); return; } if (string.IsNullOrEmpty(employee.User.Login)) { commonServices.InteractiveService.ShowMessage(ImportanceLevel.Error, "У пользователя не заполнен логин!"); return; } if (commonServices.InteractiveService.Question("Вы уверены?")) { ResetPasswordForEmployee(employee); } } } }); PopupActionsList.Add(resetPassAction); NodeActionsList.Add(resetPassAction); }