private void CreateCloseNodeAction() { PopupActionsList.Add( new JournalAction( "Закрыть", selectedItems => canUpdate && selectedItems.OfType <FinancialDistrictsSetsJournalNode>().FirstOrDefault()?.Status == DistrictsSetStatus.Draft, selectedItems => true, selectedItems => { var selectedNodes = selectedItems.OfType <FinancialDistrictsSetsJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode != null) { var districtsSet = UoW.GetById <FinancialDistrictsSet>(selectedNode.Id); if (districtsSet != null) { districtsSet.Status = DistrictsSetStatus.Closed; districtsSet.DateClosed = DateTime.Now; districtsSet.DateActivated = null; UoW.Save(districtsSet); UoW.Commit(); Refresh(); } } } ) ); }
private void CreateActivateNodeAction() { PopupActionsList.Add( new JournalAction( "Активировать", selectedItems => canActivateDistrictsSet && canUpdate && selectedItems.OfType <DistrictsSetJournalNode>().FirstOrDefault()?.Status == DistrictsSetStatus.Draft, selectedItems => true, selectedItems => { var selectedNodes = selectedItems.OfType <DistrictsSetJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode == null) { return; } var activeDistrictsSet = UoW.Session.QueryOver <DistrictsSet>().Where(x => x.Status == DistrictsSetStatus.Active).Take(1).SingleOrDefault(); if (activeDistrictsSet?.DateCreated > selectedNode.DateCreated) { commonServices.InteractiveService.ShowMessage(ImportanceLevel.Warning, "Нельзя активировать, так как дата создания выбранной версии меньше чем дата создания активной версии"); return; } var selectedDistrictsSet = UoW.GetById <DistrictsSet>(selectedNode.Id); if (selectedDistrictsSet.Districts.All(x => x.CopyOf == null) && !commonServices.InteractiveService.Question("Для выбранной версии невозможно перенести все приоритеты работы водителей\nПродолжить?")) { return; } TabParent.AddSlaveTab(this, new DistrictsSetActivationViewModel(EntityUoWBuilder.ForOpen(selectedNode.Id), QS.DomainModel.UoW.UnitOfWorkFactory.GetDefaultFactory, commonServices) ); } ) ); }
private void CreateActivateNodeAction() { PopupActionsList.Add( new JournalAction( "Активировать", selectedItems => canActivateDistrictsSet && canUpdate && selectedItems.OfType <FinancialDistrictsSetsJournalNode>().FirstOrDefault()?.Status == DistrictsSetStatus.Draft, selectedItems => true, selectedItems => { var selectedNodes = selectedItems.OfType <FinancialDistrictsSetsJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode == null) { return; } var activeFinancialDistrictsSet = UoW.Session.QueryOver <FinancialDistrictsSet>() .Where(x => x.Status == DistrictsSetStatus.Active) .Take(1) .SingleOrDefault(); if (activeFinancialDistrictsSet?.DateCreated > selectedNode.DateCreated) { commonServices.InteractiveService.ShowMessage(ImportanceLevel.Warning, "Нельзя активировать, так как дата создания выбранной версии меньше чем дата создания активной версии"); return; } var selectedFinancialDistrictsSet = UoW.GetById <FinancialDistrictsSet>(selectedNode.Id); FinancialDistrictSetActivation(selectedFinancialDistrictsSet, activeFinancialDistrictsSet); } ) ); }
private void CreateToDraftNodeAction() { PopupActionsList.Add( new JournalAction( "В черновик", selectedItems => canUpdate && selectedItems.OfType <DistrictsSetJournalNode>().FirstOrDefault()?.Status == DistrictsSetStatus.Closed, selectedItems => true, selectedItems => { var selectedNodes = selectedItems.OfType <DistrictsSetJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode != null) { var districtsSet = UoW.GetById <DistrictsSet>(selectedNode.Id); if (districtsSet != null) { districtsSet.Status = DistrictsSetStatus.Draft; districtsSet.DateClosed = null; districtsSet.DateActivated = null; UoW.Save(districtsSet); UoW.Commit(); Refresh(); } } } ) ); }
protected override void CreatePopupActions() { PopupActionsList.Add(new JournalAction("Копировать норму", (arg) => arg.Length == 1, (arg) => true, CopyNorm)); PopupActionsList.Add(new JournalAction("Сотрудники использующие норму", (arg) => arg.Length == 1, (arg) => true, ShowEmployees)); PopupActionsList.Add(new JournalAction("Обновить потребности у использующих норму", (nodes) => nodes.Cast <NormJournalNode>().Any(x => x.UsagesWorked > 0), (arg) => true, UpdateWearItems)); }
protected override void CreatePopupActions() { base.CreatePopupActions(); NodeActionsList.Add(new JournalAction( "Экспорт", x => true, x => true, selectedItems => { var selectedNodes = selectedItems.Cast <IncomeCategoryJournalNode>(); StringBuilder CSVbuilder = new StringBuilder(); foreach (IncomeCategoryJournalNode incomeCategoryJournalNode in Items) { CSVbuilder.Append(incomeCategoryJournalNode.Level1 + ", "); CSVbuilder.Append(incomeCategoryJournalNode.Level2 + ", "); CSVbuilder.Append(incomeCategoryJournalNode.Level3 + ", "); CSVbuilder.Append(incomeCategoryJournalNode.Level4 + ", "); CSVbuilder.Append(incomeCategoryJournalNode.Level5 + ", "); CSVbuilder.Append(incomeCategoryJournalNode.Subdivision + "\n"); } var fileChooserPath = fileChooserProvider.GetExportFilePath(); var res = CSVbuilder.ToString(); if (fileChooserPath == "") { return; } Stream fileStream = new FileStream(fileChooserPath, FileMode.Create); using (StreamWriter writer = new StreamWriter(fileStream, System.Text.Encoding.GetEncoding("Windows-1251"))) { writer.Write("\"sep=,\"\n"); writer.Write(res.ToString()); } fileChooserProvider.CloseWindow(); }) ); PopupActionsList.Add(new JournalAction( "Архивировать", x => true, x => true, selectedItems => { var selectedNodes = selectedItems.Cast <IncomeCategoryJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode != null) { selectedNode.IsArchive = true; using (var uow = UnitOfWorkFactory.CreateForRoot <IncomeCategory>(selectedNode.Id)) { uow.Root.SetIsArchiveRecursively(true); uow.Save(); uow.Commit(); } } }) ); }
protected override void CreatePopupActions() { base.CreatePopupActions(); var resetPassAction = new JournalAction( "Сбросить пароль", x => x.FirstOrDefault() != null, 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); }
protected override void CreatePopupActions() { object GetTask(object[] objs) { var selectedNodes = objs.Cast <BusinessTaskJournalNode>(); if (selectedNodes.Count() != 1) { return(null); } var node = selectedNodes.FirstOrDefault(); var task = UoW.GetById(node.NodeType, node.Id); return(null); } bool HasTask(object[] objs) => GetTask(objs) != null; PopupActionsList.Add( new JournalAction( "Отметить как важное", HasTask, n => true, n => { var task = GetTask(n); if (task != null) { if (task is ClientTask) { UoW.Save(task as ClientTask); } //else // SaveTask(task as PaymentTask); } } ) ); }
protected void InitPopupActions() { if (UserHasOnlyAccessToWarehouseAndComplaints) { return; } PopupActionsList.Add(CreateOpenTrackAction()); PopupActionsList.Add(CreateOpenCreateDialogAction()); PopupActionsList.Add(CreateOpenRouteListControlDlg()); PopupActionsList.Add(CreateSendRouteListToLoadingAndPrintAction()); PopupActionsList.Add(CreateSendRouteListToLoadingAction()); PopupActionsList.Add(CreateOpenKeepingDialogAction()); PopupActionsList.Add(CreateReturnToEnRouteAction()); PopupActionsList.Add(CreateOpenClosingDialogAction()); PopupActionsList.Add(CreateOpenAnalysisDialogAction()); PopupActionsList.Add(CreateOpenMileageCheckDialogAction()); PopupActionsList.Add(CreateDeleteRouteListAction()); PopupActionsList.Add(CreateGiveFuelAction()); PopupActionsList.Add(CreateTransferTerminalAction()); }
protected override void CreatePopupActions() { Complaint GetComplaint(object[] objs) { var selectedNodes = objs.Cast <ComplaintJournalNode>(); if (selectedNodes.Count() != 1) { return(null); } var complaint = UoW.GetById <Complaint>(selectedNodes.FirstOrDefault().Id); return(complaint); } Order GetOrder(object[] objs) { var complaint = GetComplaint(objs); return(GetComplaint(objs)?.Order); } RouteList GetRouteList(object[] objs) { var order = GetOrder(objs); if (order == null) { return(null); } var rl = routeListItemRepository.GetRouteListItemForOrder(UoW, order)?.RouteList; return(rl); } bool HasOrder(object[] objs) => GetOrder(objs) != null; bool HasRouteList(object[] objs) => GetRouteList(objs) != null; PopupActionsList.Add( new JournalAction( "Открыть заказ", HasOrder, n => true, n => gtkDlgOpener.OpenOrderDlg(this, GetOrder(n).Id) ) ); PopupActionsList.Add( new JournalAction( "Открыть маршрутный лист", HasRouteList, n => true, n => gtkDlgOpener.OpenCreateRouteListDlg(this, GetRouteList(n).Id) ) ); PopupActionsList.Add( new JournalAction( "Создать штраф", n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate, n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate, n => { var currentComplaintId = n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Id; ComplaintViewModel currentComplaintVM = null; if (currentComplaintId.HasValue) { currentComplaintVM = new ComplaintViewModel( EntityUoWBuilder.ForOpen(currentComplaintId.Value), unitOfWorkFactory, commonServices, undeliveriesViewOpener, employeeService, employeeSelectorFactory, counterpartySelectorFactory, filePickerService, subdivisionRepository, nomenclatureSelectorFactory, nomenclatureRepository, userRepository ); currentComplaintVM.AddFineCommand.Execute(this); } } ) ); PopupActionsList.Add( new JournalAction( "Закрыть рекламацию", n => n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Status != ComplaintStatuses.Closed && canCloseComplaint, n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate && canCloseComplaint, n => { var currentComplaintId = n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Id; ComplaintViewModel currentComplaintVM = null; if (currentComplaintId.HasValue) { currentComplaintVM = new ComplaintViewModel( EntityUoWBuilder.ForOpen(currentComplaintId.Value), unitOfWorkFactory, commonServices, undeliveriesViewOpener, employeeService, employeeSelectorFactory, counterpartySelectorFactory, filePickerService, subdivisionRepository, nomenclatureSelectorFactory, nomenclatureRepository, userRepository ); string msg = string.Empty; if (!currentComplaintVM.Entity.Close(ref msg)) { ShowWarningMessage(msg, "Не удалось закрыть"); } else { currentComplaintVM.Save(); } } } ) ); }
protected override void CreatePopupActions() { PopupActionsList.Add( new JournalAction( "Скопировать заявку", n => EntityConfigs[typeof(RequestToSupplier)].PermissionResult.CanCreate, n => true, n => { var currentRequestId = n.OfType <RequestToSupplierJournalNode>().FirstOrDefault()?.Id; if (currentRequestId.HasValue) { var currentRequest = UoW.GetById <RequestToSupplier>(currentRequestId.Value); RequestToSupplierViewModel newRequestVM = new RequestToSupplierViewModel( EntityUoWBuilder.ForCreate(), unitOfWorkFactory, commonServices, employeeService, supplierPriceItemsRepository, counterpartySelectorFactory, nomenclatureSelectorFactory, nomenclatureRepository, userRepository ); newRequestVM.Entity.Name = currentRequest.Name; newRequestVM.Entity.WithDelayOnly = currentRequest.WithDelayOnly; foreach (ILevelingRequestNode item in currentRequest.ObservableRequestingNomenclatureItems) { if (item is RequestToSupplierItem requestItem) { var newItem = new RequestToSupplierItem { Nomenclature = requestItem.Nomenclature, Quantity = requestItem.Quantity, RequestToSupplier = newRequestVM.Entity }; newRequestVM.Entity.ObservableRequestingNomenclatureItems.Add(newItem); } } TabParent.AddSlaveTab(this, newRequestVM); } } ) ); PopupActionsList.Add( new JournalAction( "Закрыть заявку", n => { var currentRequestId = n.OfType <RequestToSupplierJournalNode>().FirstOrDefault()?.Id; if (currentRequestId.HasValue) { var currentRequest = UoW.GetById <RequestToSupplier>(currentRequestId.Value); return(currentRequest.Status == RequestStatus.InProcess); } return(false); }, n => true, n => { var currentRequestId = n.OfType <RequestToSupplierJournalNode>().FirstOrDefault()?.Id; if (currentRequestId.HasValue) { var currentRequest = UoW.GetById <RequestToSupplier>(currentRequestId.Value); currentRequest.Status = RequestStatus.Closed; UoW.Save(currentRequest); UoW.Commit(); } } ) ); }
protected override void CreatePopupActions() { PopupActionsList.Add( new JournalAction( "Перевести в обрабатывается", selectedItems => selectedItems.All(x => (x as ApplicationDevelopmentProposalsJournalNode).Status == ApplicationDevelopmentProposalStatus.Sent), selectedItems => canChangeProposalsStatus, selectedItems => { foreach (var item in selectedItems) { var proposal = UoW.GetById <ApplicationDevelopmentProposal>((item as ApplicationDevelopmentProposalsJournalNode).Id); proposal?.ChangeStatus(ApplicationDevelopmentProposalStatus.Processing); UoW.Save(proposal); } UoW.Commit(); } ) ); PopupActionsList.Add( new JournalAction( "Перевести в формирование задач", selectedItems => selectedItems.All(x => (x as ApplicationDevelopmentProposalsJournalNode).Status == ApplicationDevelopmentProposalStatus.Processing), selectedItems => canChangeProposalsStatus, selectedItems => { foreach (var item in selectedItems) { var proposal = UoW.GetById <ApplicationDevelopmentProposal>((item as ApplicationDevelopmentProposalsJournalNode).Id); proposal?.ChangeStatus(ApplicationDevelopmentProposalStatus.CreatingTasks); UoW.Save(proposal); } UoW.Commit(); } ) ); PopupActionsList.Add( new JournalAction( "Перевести в выполнение задач", selectedItems => selectedItems.All(x => (x as ApplicationDevelopmentProposalsJournalNode).Status == ApplicationDevelopmentProposalStatus.CreatingTasks), selectedItems => canChangeProposalsStatus, selectedItems => { foreach (var item in selectedItems) { var proposal = UoW.GetById <ApplicationDevelopmentProposal>((item as ApplicationDevelopmentProposalsJournalNode).Id); proposal?.ChangeStatus(ApplicationDevelopmentProposalStatus.TasksExecution); UoW.Save(proposal); } UoW.Commit(); } ) ); PopupActionsList.Add( new JournalAction( "Перевести в задачи выполнены", selectedItems => selectedItems.All(x => (x as ApplicationDevelopmentProposalsJournalNode).Status == ApplicationDevelopmentProposalStatus.TasksExecution), selectedItems => canChangeProposalsStatus, selectedItems => { foreach (var item in selectedItems) { var proposal = UoW.GetById <ApplicationDevelopmentProposal>((item as ApplicationDevelopmentProposalsJournalNode).Id); proposal?.ChangeStatus(ApplicationDevelopmentProposalStatus.TasksCompleted); UoW.Save(proposal); } UoW.Commit(); } ) ); }
protected override void CreatePopupActions() { bool IsOrder(object[] objs) { var selectedNodes = objs.Cast <OrderForRouteListJournalNode>(); if (selectedNodes.Count() != 1) { return(false); } return(selectedNodes.FirstOrDefault().EntityType == typeof(VodovozOrder)); } PopupActionsList.Add( new JournalAction( "Перейти в маршрутный лист", selectedItems => selectedItems.Any( x => CheckAccessRouteListKeeping((x as OrderForRouteListJournalNode).Id)) && IsOrder(selectedItems), selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <OrderForRouteListJournalNode>(); var addresses = UoW.Session.QueryOver <RouteListItem>() .Where(x => x.Order.Id.IsIn(selectedNodes.Select(n => n.Id).ToArray())).List(); var routes = addresses.GroupBy(x => x.RouteList.Id); var tdiMain = MainClass.MainWin.TdiMain; foreach (var route in routes) { tdiMain.OpenTab( DialogHelper.GenerateDialogHashName <RouteList>(route.Key), () => new RouteListKeepingDlg(route.Key, route.Select(x => x.Order.Id).ToArray()) ); } } ) ); PopupActionsList.Add( new JournalAction( "Перейти в недовоз", (selectedItems) => selectedItems.Any( o => UndeliveredOrdersRepository.GetListOfUndeliveriesForOrder(UoW, (o as OrderForRouteListJournalNode).Id).Any()) && IsOrder(selectedItems), selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <OrderForRouteListJournalNode>(); var order = UoW.GetById <VodovozOrder>(selectedNodes.FirstOrDefault().Id); UndeliveriesView dlg = new UndeliveriesView(); dlg.HideFilterAndControls(); dlg.UndeliveredOrdersFilter.SetAndRefilterAtOnce( x => x.ResetFilter(), x => x.RestrictOldOrder = order, x => x.RestrictOldOrderStartDate = order.DeliveryDate, x => x.RestrictOldOrderEndDate = order.DeliveryDate ); MainClass.MainWin.TdiMain.AddTab(dlg); } ) ); PopupActionsList.Add( new JournalAction( "Открыть диалог закрытия", (selectedItems) => selectedItems.Any( x => CheckAccessToRouteListClosing((x as OrderForRouteListJournalNode).Id)) && IsOrder(selectedItems), selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <OrderForRouteListJournalNode>(); var routeListIds = selectedNodes.Select(x => x.Id).ToArray(); var addresses = UoW.Session.QueryOver <RouteListItem>() .Where(x => x.Order.Id.IsIn(routeListIds)).List(); var routes = addresses.GroupBy(x => x.RouteList.Id); var tdiMain = MainClass.MainWin.TdiMain; foreach (var rl in routes) { tdiMain.OpenTab( DialogHelper.GenerateDialogHashName <RouteList>(rl.Key), () => new RouteListClosingDlg(rl.Key) ); } } ) ); PopupActionsList.Add( new JournalAction( "Открыть на Yandex картах(координаты)", IsOrder, selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <OrderForRouteListJournalNode>(); foreach (var sel in selectedNodes) { var order = UoW.GetById <VodovozOrder>(sel.Id); if (order.DeliveryPoint == null || order.DeliveryPoint.Latitude == null || order.DeliveryPoint.Longitude == null) { continue; } System.Diagnostics.Process.Start( string.Format( CultureInfo.InvariantCulture, "https://maps.yandex.ru/?ll={0},{1}&z=17", order.DeliveryPoint.Longitude, order.DeliveryPoint.Latitude ) ); } } ) ); PopupActionsList.Add( new JournalAction( "Открыть на Yandex картах(адрес)", IsOrder, selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <OrderForRouteListJournalNode>(); foreach (var sel in selectedNodes) { var order = UoW.GetById <VodovozOrder>(sel.Id); if (order.DeliveryPoint == null) { continue; } System.Diagnostics.Process.Start( string.Format(CultureInfo.InvariantCulture, "https://maps.yandex.ru/?text={0} {1} {2}", order.DeliveryPoint.City, order.DeliveryPoint.Street, order.DeliveryPoint.Building ) ); } } ) ); PopupActionsList.Add( new JournalAction( "Открыть на карте OSM", IsOrder, selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <OrderForRouteListJournalNode>(); foreach (var sel in selectedNodes) { var order = UoW.GetById <VodovozOrder>(sel.Id); if (order.DeliveryPoint == null || order.DeliveryPoint.Latitude == null || order.DeliveryPoint.Longitude == null) { continue; } System.Diagnostics.Process.Start(string.Format(CultureInfo.InvariantCulture, "http://www.openstreetmap.org/#map=17/{1}/{0}", order.DeliveryPoint.Longitude, order.DeliveryPoint.Latitude)); } } ) ); }
protected void InitPopupActions() { var callTaskWorker = new CallTaskWorker( CallTaskSingletonFactory.GetInstance(), callTaskRepository, new OrderRepository(), new EmployeeRepository(), baseParametersProvider, commonServices.UserService, SingletonErrorReporter.Instance); PopupActionsList.Add(new JournalAction( "Закрытие МЛ", (selectedItems) => selectedItems.Any(x => closingDlgStatuses.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => selectedItems.Any(x => closingDlgStatuses.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => { var selectedNode = selectedItems.FirstOrDefault() as RouteListJournalNode; if (selectedNode != null && closingDlgStatuses.Contains(selectedNode.StatusEnum)) { TabParent.OpenTab( DialogHelper.GenerateDialogHashName <RouteList>(selectedNode.Id), () => new RouteListClosingDlg(selectedNode.Id) ); } } )); PopupActionsList.Add(new JournalAction( "Создание талона погрузки", (selectedItems) => selectedItems.Any(x => createCarLoadDocument.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => selectedItems.Any(x => createCarLoadDocument.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => { var selectedNode = selectedItems.FirstOrDefault() as RouteListJournalNode; if (selectedNode != null) { TabParent.OpenTab(() => new CarLoadDocumentDlg(selectedNode.Id, null)); } } )); PopupActionsList.Add(new JournalAction( "Создание талона разгрузки", (selectedItems) => selectedItems.Any(x => createCarUnloadDocument.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => selectedItems.Any(x => createCarUnloadDocument.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => { var selectedNode = selectedItems.FirstOrDefault() as RouteListJournalNode; if (selectedNode != null) { TabParent.OpenTab(() => new CarUnloadDocumentDlg(selectedNode.Id, null)); } } )); PopupActionsList.Add(new JournalAction( "Выдать топливо", (selectedItems) => selectedItems.Any(x => fuelIssuingStatuses.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => selectedItems.Any(x => fuelIssuingStatuses.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => { var selectedNode = selectedItems.FirstOrDefault() as RouteListJournalNode; if (selectedNode != null) { var RouteList = UoW.GetById <RouteList>(selectedNode.Id); TabParent.OpenTab( DialogHelper.GenerateDialogHashName <RouteList>(selectedNode.Id), () => new FuelDocumentViewModel( RouteList, commonServices, subdivisionRepository, new EmployeeRepository(), fuelRepository, NavigationManagerProvider.NavigationManager, new TrackRepository(), new CategoryRepository(new ParametersProvider()) ) ); } } )); PopupActionsList.Add(new JournalAction( "Вернуть в статус Сдается", (selectedItems) => selectedItems.Any(x => canReturnToOnClosing.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => selectedItems.Any(x => canReturnToOnClosing.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => { var selectedNode = selectedItems.FirstOrDefault() as RouteListJournalNode; bool isSlaveTabActive = false; if (selectedNode != null) { using (var uowLocal = UnitOfWorkFactory.CreateWithoutRoot()) { var routeList = uowLocal.Session.QueryOver <RouteList>() .Where(x => x.Id == selectedNode.Id) .List().FirstOrDefault(); if (canReturnToOnClosing.Contains(routeList.Status)) { if (TabParent.FindTab(DialogHelper.GenerateDialogHashName <RouteList>(routeList.Id)) != null) { MessageDialogHelper.RunInfoDialog("Требуется закрыть подчиненную вкладку"); isSlaveTabActive = true; return; } routeList.ChangeStatusAndCreateTask(RouteListStatus.OnClosing, callTaskWorker); uowLocal.Save(routeList); if (isSlaveTabActive) { return; } } uowLocal.Commit(); } } } )); }
protected override void CreatePopupActions() { Complaint GetComplaint(object[] objs) { var selectedNodes = objs.Cast <ComplaintJournalNode>().ToList(); if (selectedNodes.Count != 1) { return(null); } var complaint = UoW.GetById <Complaint>(selectedNodes.First().Id); return(complaint); } Order GetOrder(object[] objs) { return(GetComplaint(objs)?.Order); } RouteList GetRouteList(object[] objs) { var order = GetOrder(objs); if (order == null) { return(null); } var rl = _routeListItemRepository.GetRouteListItemForOrder(UoW, order)?.RouteList; return(rl); } bool HasOrder(object[] objs) => GetOrder(objs) != null; bool HasRouteList(object[] objs) => GetRouteList(objs) != null; PopupActionsList.Add( new JournalAction( "Открыть заказ", HasOrder, n => true, n => _gtkDlgOpener.OpenOrderDlg(this, GetOrder(n).Id) ) ); PopupActionsList.Add( new JournalAction( "Открыть маршрутный лист", HasRouteList, n => true, n => _gtkDlgOpener.OpenRouteListCreateDlg(this, GetRouteList(n).Id) ) ); PopupActionsList.Add( new JournalAction( "Открыть диалог закрытия МЛ", n => GetRouteList(n)?.CanBeOpenedInClosingDlg ?? false, n => true, n => _gtkDlgOpener.OpenRouteListClosingDlg(this, GetRouteList(n).Id) ) ); PopupActionsList.Add( new JournalAction( "Создать штраф", n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate, n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate, n => { var currentComplaintId = n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Id; ComplaintViewModel currentComplaintVM = null; if (currentComplaintId.HasValue) { currentComplaintVM = new ComplaintViewModel( EntityUoWBuilder.ForOpen(currentComplaintId.Value), _unitOfWorkFactory, _commonServices, _undeliveredOrdersJournalOpener, _employeeService, _counterpartySelectorFactory.CreateCounterpartyAutocompleteSelectorFactory(), _fileDialogService, _subdivisionRepository, _nomenclatureRepository, _userRepository, _orderSelectorFactory, _employeeJournalFactory, _counterpartyJournalFactory, _deliveryPointJournalFactory, _subdivisionJournalFactory, _gtkDlgOpener, _undeliveredOrdersJournalOpener, _salesPlanJournalFactory, _nomenclatureSelector, _undeliveredOrdersRepository, _employeeSettings, new ComplaintResultsRepository() ); currentComplaintVM.AddFineCommand.Execute(this); } } ) ); PopupActionsList.Add( new JournalAction( "Закрыть рекламацию", n => n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Status != ComplaintStatuses.Closed && canCloseComplaint, n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate && canCloseComplaint, n => { var currentComplaintId = n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Id; ComplaintViewModel currentComplaintVM = null; if (currentComplaintId.HasValue) { currentComplaintVM = new ComplaintViewModel( EntityUoWBuilder.ForOpen(currentComplaintId.Value), _unitOfWorkFactory, _commonServices, _undeliveredOrdersJournalOpener, _employeeService, _counterpartySelectorFactory.CreateCounterpartyAutocompleteSelectorFactory(), _fileDialogService, _subdivisionRepository, _nomenclatureRepository, _userRepository, _orderSelectorFactory, _employeeJournalFactory, _counterpartyJournalFactory, _deliveryPointJournalFactory, _subdivisionJournalFactory, _gtkDlgOpener, _undeliveredOrdersJournalOpener, _salesPlanJournalFactory, _nomenclatureSelector, _undeliveredOrdersRepository, _employeeSettings, new ComplaintResultsRepository() ); string msg = string.Empty; if (!currentComplaintVM.Entity.Close(ref msg)) { ShowWarningMessage(msg, "Не удалось закрыть"); } else { currentComplaintVM.Save(); } } } ) ); }
protected override void CreatePopupActions() { PopupActionsList.Add( new JournalAction( "Перейти в недовезённый заказ", selectedItems => true, selectedItems => true, selectedItems => { var selectedNodes = selectedItems.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode != null) { _gtkDlgOpener.OpenOrderDlg(this, selectedNode.OldOrderId); } } ) ); PopupActionsList.Add( new JournalAction( "Перейти в новый заказ", selectedItems => { var selectedNodes = selectedItems.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); return(selectedNode != null && selectedNode.NewOrderId > 0); }, selectedItems => true, selectedItems => { var selectedNodes = selectedItems.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode != null) { _gtkDlgOpener.OpenOrderDlg(this, selectedNode.NewOrderId); } } ) ); PopupActionsList.Add( new JournalAction( "Закрыть недовоз", selectedItems => { var selectedNodes = selectedItems.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); return(selectedNode != null && selectedNode.UndeliveryStatus != UndeliveryStatus.Closed && _canCloseUndeliveries); }, selectedItems => true, selectedItems => { var selectedNodes = selectedItems.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode == null) { return; } UndeliveredOrder undeliveredOrder = UoW.GetById <UndeliveredOrder>(selectedNode.Id); undeliveredOrder.Close(CurrentEmployee); UoW.Save(undeliveredOrder); UoW.Commit(); } ) ); PopupActionsList.Add( new JournalAction( "Создать штраф", selectedItems => true, selectedItems => true, selectedItems => { var selectedNodes = selectedItems.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode == null) { return; } FineViewModel fineViewModel = new FineViewModel( EntityUoWBuilder.ForCreate(), UnitOfWorkFactory, _undeliveryViewOpener, _employeeService, _driverEmployeeJournalFactory.CreateWorkingDriverEmployeeAutocompleteSelectorFactory(), _employeeSettings, _commonServices ); var undeliveredOrder = UoW.GetById <UndeliveredOrder>(selectedNode.Id); fineViewModel.UndeliveredOrder = undeliveredOrder; fineViewModel.RouteList = new RouteListItemRepository().GetRouteListItemForOrder(UoW, undeliveredOrder.OldOrder)?.RouteList; TabParent.AddSlaveTab(this, fineViewModel); } ) ); }
protected override void CreatePopupActions() { PopupActionsList.Add( new JournalAction( "Открыть заказ", selectedItems => { var selectedNodes = selectedItems.Cast <SelfDeliveryJournalNode>(); return(selectedNodes.Count() == 1); }, selectedItems => true, selectedItems => { var selectedNodes = selectedItems.Cast <SelfDeliveryJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); MainClass.MainWin.TdiMain.OpenTab( DialogHelper.GenerateDialogHashName <VodovozOrder>(selectedNode.Id), () => new OrderDlg(selectedNode.Id) ); } ) ); PopupActionsList.Add( new JournalAction( "Создать кассовые ордера", selectedItems => true, selectedItems => { var selectedNodes = selectedItems.Cast <SelfDeliveryJournalNode>(); return(selectedNodes.Count() == 1 && selectedNodes.First().StatusEnum == OrderStatus.WaitForPayment); }, selectedItems => { var selectedNodes = selectedItems.Cast <SelfDeliveryJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode != null) { CreateSelfDeliveryCashInvoices(selectedNode.Id); } } ) ); PopupActionsList.Add( new JournalAction( "Оплата по карте", selectedItems => { var selectedNodes = selectedItems.Cast <SelfDeliveryJournalNode>().ToList(); var selectedNode = selectedNodes.First(); return(selectedNodes.Count() == 1 && selectedNode.PaymentTypeEnum == PaymentType.cash && selectedNode.StatusEnum != OrderStatus.Closed); }, selectedItems => _userCanChangePayTypeToByCard, selectedItems => { var selectedNodes = selectedItems.Cast <SelfDeliveryJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode != null) { TabParent.AddTab( new PaymentByCardViewModel( EntityUoWBuilder.ForOpen(selectedNode.Id), UnitOfWorkFactory, commonServices, _callTaskWorker, _orderPaymentSettings, _orderParametersProvider, _currentEmployee), this ); } } ) ); }
protected override void CreatePopupActions() { bool IsOrder(object[] objs) { var selectedNodes = objs.Cast <RetailOrderJournalNode>(); if (selectedNodes.Count() != 1) { return(false); } return(selectedNodes.FirstOrDefault().EntityType == typeof(VodovozOrder)); } PopupActionsList.Add( new JournalAction( "Перейти в маршрутный лист", selectedItems => selectedItems.Any( x => AccessRouteListKeeping((x as RetailOrderJournalNode).Id)) && IsOrder(selectedItems), selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); var addresses = UoW.Session.QueryOver <RouteListItem>() .Where(x => x.Order.Id.IsIn(selectedNodes.Select(n => n.Id).ToArray())).List(); var routes = addresses.GroupBy(x => x.RouteList.Id); var tdiMain = MainClass.MainWin.TdiMain; foreach (var route in routes) { tdiMain.OpenTab( DialogHelper.GenerateDialogHashName <RouteList>(route.Key), () => new RouteListKeepingDlg(route.Key, route.Select(x => x.Order.Id).ToArray()) ); } } ) ); PopupActionsList.Add( new JournalAction( "Перейти в недовоз", (selectedItems) => selectedItems.Any( o => _undeliveredOrdersRepository.GetListOfUndeliveriesForOrder( UoW, (o as RetailOrderJournalNode).Id).Any()) && IsOrder(selectedItems), selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); var order = UoW.GetById <VodovozOrder>(selectedNodes.FirstOrDefault().Id); var undeliveredOrdersFilter = new UndeliveredOrdersFilterViewModel( _commonServices, _orderSelectorFactory, _employeeJournalFactory, _counterpartyJournalFactory, _deliveryPointJournalFactory, _subdivisionJournalFactory) { HidenByDefault = true, RestrictOldOrder = order, RestrictOldOrderStartDate = order.DeliveryDate, RestrictOldOrderEndDate = order.DeliveryDate }; var dlg = new UndeliveredOrdersJournalViewModel( undeliveredOrdersFilter, UnitOfWorkFactory, _commonServices, _gtkDialogsOpener, _employeeJournalFactory, _employeeService, _undeliveredOrdersJournalOpener, _orderSelectorFactory, _undeliveredOrdersRepository ); MainClass.MainWin.TdiMain.AddTab(dlg); } ) ); PopupActionsList.Add( new JournalAction( "Открыть диалог закрытия", (selectedItems) => selectedItems.Any( x => AccessToRouteListClosing((x as RetailOrderJournalNode).Id)) && IsOrder(selectedItems), selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); var routeListIds = selectedNodes.Select(x => x.Id).ToArray(); var addresses = UoW.Session.QueryOver <RouteListItem>() .Where(x => x.Order.Id.IsIn(routeListIds)).List(); var routes = addresses.GroupBy(x => x.RouteList.Id); var tdiMain = MainClass.MainWin.TdiMain; foreach (var rl in routes) { tdiMain.OpenTab( DialogHelper.GenerateDialogHashName <RouteList>(rl.Key), () => new RouteListClosingDlg(rl.Key) ); } } ) ); PopupActionsList.Add( new JournalAction( "Открыть на Yandex картах(координаты)", IsOrder, selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); foreach (var sel in selectedNodes) { var order = UoW.GetById <VodovozOrder>(sel.Id); if (order.DeliveryPoint == null || order.DeliveryPoint.Latitude == null || order.DeliveryPoint.Longitude == null) { continue; } System.Diagnostics.Process.Start( string.Format( CultureInfo.InvariantCulture, "https://maps.yandex.ru/?ll={0},{1}&z=17", order.DeliveryPoint.Longitude, order.DeliveryPoint.Latitude ) ); } } ) ); PopupActionsList.Add( new JournalAction( "Открыть на Yandex картах(адрес)", IsOrder, selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); foreach (var sel in selectedNodes) { var order = UoW.GetById <VodovozOrder>(sel.Id); if (order.DeliveryPoint == null) { continue; } System.Diagnostics.Process.Start( string.Format(CultureInfo.InvariantCulture, "https://maps.yandex.ru/?text={0} {1} {2}", order.DeliveryPoint.City, order.DeliveryPoint.Street, order.DeliveryPoint.Building ) ); } } ) ); PopupActionsList.Add( new JournalAction( "Открыть на карте OSM", IsOrder, selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); foreach (var sel in selectedNodes) { var order = UoW.GetById <VodovozOrder>(sel.Id); if (order.DeliveryPoint == null || order.DeliveryPoint.Latitude == null || order.DeliveryPoint.Longitude == null) { continue; } System.Diagnostics.Process.Start(string.Format(CultureInfo.InvariantCulture, "http://www.openstreetmap.org/#map=17/{1}/{0}", order.DeliveryPoint.Longitude, order.DeliveryPoint.Latitude)); } } ) ); PopupActionsList.Add( new JournalAction( "Повторить заказ", IsOrder, selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); var order = UoW.GetById <VodovozOrder>(selectedNodes.FirstOrDefault().Id); var dlg = new OrderDlg(); dlg.CopyLesserOrderFrom(order.Id); var tdiMain = MainClass.MainWin.TdiMain; tdiMain.OpenTab( DialogHelper.GenerateDialogHashName <Domain.Orders.Order>(65656), () => dlg ); } ) ); }
private void MakePopup() { PopupActionsList.Add(new JournalAction("Открыть складские движения", n => true, n => true, OpenMovements)); }