private bool loadModels() { CRMSettingViewModel.instance(); ComplectationItemViewModel.instance(); EquipmentViewModel.instance(); ModificationViewModel.instance(); SellerViewModel.instance(); BuyerViewModel.instance(); BidStatusViewModel.instance(); PaymentStatusViewModel.instance(); MessageTemplatesViewModel.instance(); RoleViewModel.instance(); ManagerViewModel.instance(); BidViewModel.instance(); //EquipmentBidViewModel.instance(); //ComplectationViewModel.instance(); //ComplectationItemViewModel.instance(); return(true); }
//Конструктор при редактировании комплектации в заявке public EquipmentBidSaveWindow(EquipmentBid equipmentBid) { InitializeComponent(); Title = "Редактирование комплектации в заявке №" + equipmentBid.Id_bid.ToString(); setViewSources(); Equipment equipment = EquipmentViewModel.instance().getById(equipmentBid.Id_equipment); if (equipment != null) { cbxEquipment.SelectedItem = equipment; } if (equipmentBid.Id_modification != null) { Modification modification = ModificationViewModel.instance().getById((int)equipmentBid.Id_modification); if (modification != null) { cbxModification.SelectedItem = modification; } } DataContext = new { ComplectationCollection = equipmentBid.ComplectationCollection }; this.equipmentBid = equipmentBid; cbxEquipment.IsEnabled = false; }
public ModificationPhaseFactory(IPofSerializer pofSerializer, IFileSystemProxy fileSystemProxy, TemporaryFileService temporaryFileService, ExeggutorService exeggutorService, ModificationPhaseManager phaseManager, ModificationLoader modificationLoader, ModificationViewModel viewModel, LeagueBuildUtilities leagueBuildUtilities, Modification modification) { this.pofSerializer = pofSerializer; this.fileSystemProxy = fileSystemProxy; this.temporaryFileService = temporaryFileService; this.exeggutorService = exeggutorService; this.phaseManager = phaseManager; this.modificationLoader = modificationLoader; this.viewModel = viewModel; this.leagueBuildUtilities = leagueBuildUtilities; this.modification = modification; }
public EquipmentWindow() { InitializeComponent(); viewSource.Source = EquipmentViewModel.instance().Collection; viewSource.Filter += delegate(object sender, FilterEventArgs e) { Equipment equipment = e.Item as Equipment; if (equipment == null) { return; } e.Accepted = equipment.IsVisible; }; modificationViewSource.Source = ModificationViewModel.instance().Collection; modificationViewSource.Filter += delegate(object sender, FilterEventArgs e) { Modification modification = e.Item as Modification; Equipment equipment = dgvEquipment.SelectedItem as Equipment; if (modification == null) { return; } if (equipment == null) { e.Accepted = false; return; } if (modification.Id_equipment == equipment.Id) { e.Accepted = true; } else { e.Accepted = false; } }; viewSource.SortDescriptions.Add(new SortDescription("Row_order", ListSortDirection.Descending)); modificationViewSource.SortDescriptions.Add(new SortDescription("Row_order", ListSortDirection.Descending)); DataContext = new { EquipmentCollection = viewSource.View, ModificationCollection = modificationViewSource.View }; }
//Установка коллекций void setViewSources() { defaultBrush = cbxEquipment.Background; equipmentViewSource.Source = EquipmentViewModel.instance().Collection; equipmentViewSource.SortDescriptions.Add(new SortDescription("Row_order", ListSortDirection.Descending)); cbxEquipment.ItemsSource = equipmentViewSource.View; modificationViewSource.Source = ModificationViewModel.instance().Collection; modificationViewSource.SortDescriptions.Add(new SortDescription("Row_order", ListSortDirection.Descending)); modificationViewSource.Filter += delegate(object sender, FilterEventArgs e) { Modification modification = e.Item as Modification; if (modification == null) { return; } if (cbxEquipment.SelectedIndex == -1) { e.Accepted = false; return; } Equipment equipment = cbxEquipment.SelectedItem as Equipment; if (equipment == null) { e.Accepted = false; return; } if (modification.Id_equipment == equipment.Id) { e.Accepted = true; } else { e.Accepted = false; } }; cbxModification.ItemsSource = modificationViewSource.View; cbxEquipment.SelectedIndex = -1; cbxModification.SelectedIndex = -1; }
//Восьмая строка (модификации) private bool createModificationRow() { string modificationName = ""; if (equipmentBid.Id_modification != null) { Modification modification = ModificationViewModel.instance().getById((int)equipmentBid.Id_modification); if (modification != null) { modificationName = modification.Name; } } ReportRow row = new ReportRow(); row.Cells.Add(new ReportCell("Модификация") { Height = 16.50, TextStyle = new List <TextStyle>() { TextStyle.Bold }, VerticalAlignment = VerticalAlignment.Bottom }); AddEmptyCell(row, 2); row.Cells.Add(new ReportCell(modificationName) { ColumnSpan = 12, BorderColor = System.Drawing.Color.Black }); AddEmptyCell(row, 11); row.Cells.Add(new ReportCell() { VerticalAlignment = VerticalAlignment.Bottom, }); Rows.Add(row); return(true); }
public IActionResult Post(int vehicleId, [FromBody] ModificationViewModel model) { try { if (ModelState.IsValid) { var newMod = _mapper.Map <ModificationViewModel, Modification>(model); var vehicle = _repository.GetVehicleById(vehicleId); _repository.AddModification(newMod); vehicle.Modifications.Add(newMod); _context.SaveChanges(); return(Ok(_mapper.Map <Modification, ModificationViewModel>(newMod))); } else { return(BadRequest(ModelState)); } } catch (Exception e) { return(BadRequest($"Unable to post a new modification {model} to vehicle: {vehicleId}.")); } }
public void ImportLegacyModification(string friendlyModificationName, string importedDirectoryPath, string[] importedFilePaths, LeagueModificationCategory category, ModificationImportWindow importWindow) { string repositoryName = Util.ExtractFileNameTokens(friendlyModificationName).Select(token => token.ToLower()).Join("-"); string finalRepositoryPath = Path.Combine(repositoriesDirectory, repositoryName); var temporaryDirectory = temporaryFileService.AllocateTemporaryDirectory(TimeSpan.FromHours(1)); var workingDirectory = Path.Combine(temporaryDirectory, "working"); var contentDirectory = Path.Combine(workingDirectory, "content"); var temporaryNestPath = Path.Combine(temporaryDirectory, "working_nest"); fileSystemProxy.PrepareDirectory(contentDirectory); fileSystemProxy.PrepareDirectory(temporaryNestPath); var temporaryNest = new LocalDargonNest(temporaryNestPath); var inMemoryEgg = new InMemoryEgg(repositoryName, "legacy", workingDirectory); temporaryNest.InstallEgg(inMemoryEgg); var temporaryEggPath = Path.Combine(temporaryNestPath, inMemoryEgg.Name); var temporaryModification = modificationLoader.FromPath(temporaryEggPath); var info = temporaryModification.GetComponent <InfoComponent>(); info.Id = Guid.NewGuid(); info.Name = friendlyModificationName; var leagueComponent = temporaryModification.GetComponent <LeagueMetadataComponent>(); leagueComponent.Category = category; var viewModel = new ModificationViewModel(); var controller = new ModificationController(null, viewModel); viewModel.SetController(controller); viewModel.SetModification(temporaryModification); Application.Current.Dispatcher.BeginInvoke( new Action(() => { modificationViewModels.Add(viewModel); importWindow.Close(); var modificationPhaseManager = new ModificationPhaseManager(); var modificationPhaseFactory = new ModificationPhaseFactory(pofSerializer, fileSystemProxy, temporaryFileService, exeggutorService, modificationPhaseManager, modificationLoader, viewModel, leagueBuildUtilities, temporaryModification); controller.SetModificationPhaseManager(modificationPhaseManager); modificationPhaseManager.Transition(modificationPhaseFactory.Importing(importedDirectoryPath, importedFilePaths, finalRepositoryPath)); controller.Initialize(); }), DispatcherPriority.Send ); // var modification = modificationLoader.FromPath(e.FullPath); // fileSystemProxy.MoveDirectory(temporaryEggPath, finalRepositoryPath); return; // foreach (var relativeFilePath in importedRelativeFilePaths) { // var importedFile = Path.Combine(modificationRoot, relativeFilePath); // var contentFile = Path.Combine(contentDirectory, relativeFilePath); // fileSystemProxy.PrepareParentDirectory(contentFile); // fileSystemProxy.CopyFile(importedFile, contentFile); // } // // var workingDirectoryInfo = fileSystemProxy.GetDirectoryInfo(workingDirectory); // // var destinationNestLockPath = Path.Combine(repositoriesDirectory, "LOCK"); // using (fileSystemProxy.OpenFile(destinationNestLockPath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) { // var temporaryNest = Path.Combine(temporaryDirectory, "working_nest"); // fileSystemProxy.PrepareDirectory(temporaryNest); // var inMemoryEgg = new InMemoryEgg(repositoryName, "legacy", workingDirectory); // var modificationsNest = new LocalDargonNest(temporaryNest); // modificationsNest.InstallEgg(inMemoryEgg); // // var temporaryEggPath = Path.Combine(temporaryNest, inMemoryEgg.Name); // fileSystemProxy.MoveDirectory(temporaryEggPath, finalRepositoryPath); // } // // fileSystemProxy.DeleteDirectory(temporaryDirectory, true); }
private void HandleRepositoriesDirectoryModified(object sender, FileSystemEventArgs e) { switch (e.ChangeType) { case WatcherChangeTypes.Changed: break; case WatcherChangeTypes.Created: var fileInfo = fileSystemProxy.GetFileInfo(e.FullPath); if (fileInfo.Attributes.HasFlag(FileAttributes.Directory)) { if (fileInfo.Name.StartsWith(".")) { logger.Info($"Ignoring modification candidate {fileInfo.Name} as name has leading period."); } else if (displayedModificationNames.Contains(fileInfo.Name)) { logger.Info($"Ignoring modification candidate {fileInfo.Name} as view model already exists."); } else { var modification = modificationLoader.FromPath(e.FullPath); var viewModel = new ModificationViewModel(); var controller = new ModificationController(modification, viewModel); viewModel.SetController(controller); viewModel.SetModification(modification); var modificationPhaseManager = new ModificationPhaseManager(); var modificationPhaseFactory = new ModificationPhaseFactory(pofSerializer, fileSystemProxy, temporaryFileService, exeggutorService, modificationPhaseManager, modificationLoader, viewModel, leagueBuildUtilities, modification); modificationPhaseManager.Transition(modificationPhaseFactory.Idle()); controller.SetModificationPhaseManager(modificationPhaseManager); controller.Initialize(); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() => { modificationViewModels.Add(viewModel); })); } } break; case WatcherChangeTypes.Deleted: var removedViewModel = modificationViewModels.FirstOrDefault(x => x.RepositoryName.Equals(e.Name, StringComparison.OrdinalIgnoreCase)); if (removedViewModel == null) { logger.Error("Failed to find viewmodel match for removed directory " + e.FullPath); } else { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() => { modificationViewModels.Remove(removedViewModel); })); } break; case WatcherChangeTypes.Renamed: var renamedArgs = (RenamedEventArgs)e; var parentDirectory = new FileInfo(renamedArgs.FullPath).Directory; HandleRepositoriesDirectoryModified(sender, new FileSystemEventArgs(WatcherChangeTypes.Deleted, parentDirectory.FullName, renamedArgs.OldName)); HandleRepositoriesDirectoryModified(sender, new FileSystemEventArgs(WatcherChangeTypes.Created, parentDirectory.FullName, renamedArgs.Name)); break; } }
private void HandleRepositoriesDirectoryModified(object sender, FileSystemEventArgs e) { switch (e.ChangeType) { case WatcherChangeTypes.Changed: break; case WatcherChangeTypes.Created: var fileInfo = fileSystemProxy.GetFileInfo(e.FullPath); if (fileInfo.Attributes.HasFlag(FileAttributes.Directory)) { if (fileInfo.Name.StartsWith(".")) { logger.Info($"Ignoring modification candidate {fileInfo.Name} as name has leading period."); } else if (displayedModificationNames.Contains(fileInfo.Name)) { logger.Info($"Ignoring modification candidate {fileInfo.Name} as view model already exists."); } else { var modification = modificationLoader.FromPath(e.FullPath); var viewModel = new ModificationViewModel(); var controller = new ModificationController(modification, viewModel); viewModel.SetController(controller); viewModel.SetModification(modification); var modificationPhaseManager = new ModificationPhaseManager(); var modificationPhaseFactory = new ModificationPhaseFactory(pofSerializer, fileSystemProxy, temporaryFileService, exeggutorService, modificationPhaseManager, modificationLoader, viewModel, leagueBuildUtilities, modification); modificationPhaseManager.Transition(modificationPhaseFactory.Idle()); controller.SetModificationPhaseManager(modificationPhaseManager); controller.Initialize(); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() => { modificationViewModels.Add(viewModel); })); } } break; case WatcherChangeTypes.Deleted: var removedViewModel = modificationViewModels.FirstOrDefault(x => x.RepositoryName.Equals(e.Name, StringComparison.OrdinalIgnoreCase)); if (removedViewModel == null) { logger.Error("Failed to find viewmodel match for removed directory " + e.FullPath); } else { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() => { modificationViewModels.Remove(removedViewModel); })); } break; case WatcherChangeTypes.Renamed: var renamedArgs = (RenamedEventArgs)e; var parentDirectory = new FileInfo(renamedArgs.FullPath).Directory; HandleRepositoriesDirectoryModified(sender, new FileSystemEventArgs(WatcherChangeTypes.Deleted, parentDirectory.FullName, renamedArgs.OldName)); HandleRepositoriesDirectoryModified(sender, new FileSystemEventArgs(WatcherChangeTypes.Created, parentDirectory.FullName, renamedArgs.Name)); break; } }
public override bool Save() { Bid bid = BidViewModel.instance().getById(equipmentBid.Id_bid); if (bid == null) { LastError = "Bid not found!"; return(false); } Buyer buyer = BuyerViewModel.instance().getById(bid.Id_buyer); if (buyer == null) { LastError = "Buyer not found!"; return(false); } Equipment equipment = EquipmentViewModel.instance().getById(equipmentBid.Id_equipment); if (equipment == null) { LastError = "Equipment not found!"; return(false); } Modification modification = null; if (equipmentBid.Id_modification != null) { modification = ModificationViewModel.instance().getById((int)equipmentBid.Id_modification); if (modification != null) { modificationString = modification.Name; } } ReportRow row = new ReportRow(); row.Cells.Add(new ReportCell(buyer.Name.ToUpper()) { ColumnSpan = 6, Height = 20.25, TextStyle = new List <TextStyle>() { TextStyle.Bold }, }); row.Cells.Add(new ReportCell()); row.Cells.Add(new ReportCell()); row.Cells.Add(new ReportCell()); row.Cells.Add(new ReportCell()); row.Cells.Add(new ReportCell()); row.Cells.Add(new ReportCell() { Width = 0.58, VerticalAlignment = VerticalAlignment.Bottom }); row.Cells.Add(new ReportCell(buyer.City.ToUpper()) { ColumnSpan = 2, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom, TextStyle = new List <TextStyle>() { TextStyle.Bold }, }); row.Cells.Add(new ReportCell() { Width = 7.29, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Right }); Rows.Add(row); ReportRow row_1 = new ReportRow(); row_1.Cells.Add(new ReportCell(buyer.Contact_person.ToUpper()) { ColumnSpan = 6, TextStyle = new List <TextStyle>() { TextStyle.Bold }, }); row_1.Cells.Add(new ReportCell()); row_1.Cells.Add(new ReportCell()); row_1.Cells.Add(new ReportCell()); row_1.Cells.Add(new ReportCell()); row_1.Cells.Add(new ReportCell()); row_1.Cells.Add(new ReportCell()); row_1.Cells.Add(new ReportCell(buyer.Phone.ToUpper()) { ColumnSpan = 2, TextStyle = new List <TextStyle>() { TextStyle.Bold }, HorizontalAlignment = HorizontalAlignment.Right }); Rows.Add(row_1); Rows.Add(new ReportRow()); ReportRow row_2 = new ReportRow(); row_2.Cells.Add(new ReportCell(equipment.Name.ToUpper()) { ColumnSpan = 6, TextStyle = new List <TextStyle>() { TextStyle.Bold } }); row_2.Cells.Add(new ReportCell()); row_2.Cells.Add(new ReportCell()); row_2.Cells.Add(new ReportCell()); row_2.Cells.Add(new ReportCell()); row_2.Cells.Add(new ReportCell()); row_2.Cells.Add(new ReportCell()); row_2.Cells.Add(new ReportCell(serialNumber.ToUpper()) { RowSpan = 1, ColumnSpan = 2, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom, TextStyle = new List <TextStyle>() { TextStyle.Bold } }); Rows.Add(row_2); ReportRow row_3 = new ReportRow(); row_3.Cells.Add(new ReportCell(modificationString.ToUpper()) { ColumnSpan = 6, TextStyle = new List <TextStyle>() { TextStyle.Bold } }); Rows.Add(row_3); AllDocumentFontSize = 14; return(Create()); }
public ModificationController(Modification modification, ModificationViewModel viewModel) { this.modification = modification; this.viewModel = viewModel; }