public IEnumerable <SubmitHandInFileModel> GetHandInFiles() { List <SubmitHandInFileModel> list = this.HandInFileSelectorViewModel.GetHandInFiles().ToList <SubmitHandInFileModel>(); HandInFileModel fileMetadata = this._handInFieldValueStorageService.GetFileMetadata(this._boardingPassStorageService.GetExisting(), this.CreateHandInFieldId()); list.Add(new SubmitHandInFileModel(fileMetadata.Name, fileMetadata.Path, SubmitHandInFileType.HandInFields)); return((IEnumerable <SubmitHandInFileModel>)list); }
public IEnumerable <SubmitHandInFileModel> GetHandInFiles() { List <HandInFileModel> list = this._handInFileMetadataStorageService.GetAttachmentFilePaths().Where <HandInFileModel>((Func <HandInFileModel, bool>)(a => this._fileService.Exists(a.Path))).ToList <HandInFileModel>(); HandInFileModel documentFilePath = this._handInFileMetadataStorageService.GetMainDocumentFilePath(); int num = string.IsNullOrEmpty(documentFilePath?.Path) ? 0 : (this._fileService.Exists(documentFilePath.Path) ? 1 : 0); List <SubmitHandInFileModel> submitHandInFileModelList = new List <SubmitHandInFileModel>(list.Select <HandInFileModel, SubmitHandInFileModel>((Func <HandInFileModel, SubmitHandInFileModel>)(a => new SubmitHandInFileModel(a.Name, a.Path, SubmitHandInFileType.Attachment)))); if (num != 0) { submitHandInFileModelList.Add(new SubmitHandInFileModel(documentFilePath.Name, documentFilePath.Path, SubmitHandInFileType.MainDocument)); } return((IEnumerable <SubmitHandInFileModel>)submitHandInFileModelList); }
private bool AnyExistingHandInFilesForName(HandInFileModel handInFileModel, IEnumerable <HandInFileModel> newAttachments) { if ((string.IsNullOrEmpty(this.SelectedMainDocument?.HandInFileModel?.Name) || !(this.SelectedMainDocument.HandInFileModel.Name == handInFileModel.Name)) && !this.SelectedAttachments.Any <HandInFileViewModel>((Func <HandInFileViewModel, bool>)(e => e.HandInFileModel?.Name == handInFileModel.Name))) { return(newAttachments.Any <HandInFileModel>((Func <HandInFileModel, bool>)(a => { if (a.Path != handInFileModel.Path) { return a.Name == handInFileModel.Name; } return false; }))); } return(true); }
private HandInFileModel GetNewHandInFileModel(HandInFileModel newHandInFileModel, List <HandInFileModel> alreadyAddedHandInFileModels) { int num = 1; string newName; while (true) { newName = this._pathService.GetFileNameWithoutExtension(newHandInFileModel.Name) + string.Format(" ({0})", (object)num); if (!alreadyAddedHandInFileModels.All <HandInFileModel>((Func <HandInFileModel, bool>)(a => this._pathService.GetFileNameWithoutExtension(a.Name) != newName))) { ++num; } else { break; } } return(new HandInFileModel(newName + "." + this._pathService.GetExtension(newHandInFileModel.Name), newHandInFileModel.Path)); }
public HandInResult TagHandIn(string id, HandInFileModel mainDocument, IEnumerable <HandInFileModel> attachments, HandInFileModel handInFieldsFile) { List <SubmitHandInFileModel> submitHandInFileModelList = new List <SubmitHandInFileModel>(attachments.Select <HandInFileModel, SubmitHandInFileModel>((Func <HandInFileModel, SubmitHandInFileModel>)(a => new SubmitHandInFileModel(a.Name, a.Path, SubmitHandInFileType.Attachment)))) { new SubmitHandInFileModel(mainDocument.Name, mainDocument.Path, SubmitHandInFileType.MainDocument) }; List <SubmitHandInFileModel> storage = this.CopyToStorage(id, (IEnumerable <SubmitHandInFileModel>)submitHandInFileModelList); storage.Add(new SubmitHandInFileModel(handInFieldsFile.Name, handInFieldsFile.Path, SubmitHandInFileType.HandInFields)); IEnumerable <PendingFileUpload> source = storage.Where <SubmitHandInFileModel>((Func <SubmitHandInFileModel, bool>)(h => h != null)).Select <SubmitHandInFileModel, PendingFileUpload>((Func <SubmitHandInFileModel, PendingFileUpload>)(h => new PendingFileUpload() { Filename = h.Name, Hash = this._hashProvider.ComputeHashAsBase64(this._fileService.ReadAllBytesFromFile(h.Path)) })); return(new HandInResult(this._flexClient.TagHandin(new TagPendingHandinRequest() { PendingFileUploads = source.ToList <PendingFileUpload>() }).HandinStatus.ToHandInStatus(), (IEnumerable <SubmitHandInFileModel>)storage)); }
private void ChooseMainDocumentClick() { DispatcherHelper.CheckBeginInvokeOnUI((Action)(() => { FilesResult selectedFile = this._selectFilesService.GetSelectedFile(this.HandInDirectory, this._languageService.GetString("HandInFileSelectorValidExtensionsText"), (IEnumerable <string>) this.AllowedFileExtensions); if (!selectedFile.HasSelected || !selectedFile.HandInFileModels.Any <HandInFileModel>()) { return; } HandInFileModel selectedMainDocument = selectedFile.HandInFileModels.First <HandInFileModel>(); try { if (this._fileService.GetSizeInBytes(selectedMainDocument.Path) > this.MaxHandInFileSizeInBytes) { this._messenger.Send <OnOkPopupOpened>(new OnOkPopupOpened(new OkPopupViewModel(string.Format(this._languageService.GetString("HandInFileSelectorMainDocumentExceedsFileLimitMessageText"), (object)(this.MaxHandInFileSizeInBytes / 1048576L)), this._languageService.GetString("HandInFileSelectorFilesExceedsFileLimitOkButtonText"), this._messenger))); return; } } catch (Exception ex) { return; } if (this.SelectedAttachments.Any <HandInFileViewModel>((Func <HandInFileViewModel, bool>)(e => e.HandInFileModel?.Name == selectedMainDocument.Name))) { this._messenger.Send <OnOkCancelPopupOpened>(new OnOkCancelPopupOpened(new OkCancelPopupViewModel(this._languageService.GetString("HandInFileSelectorAddDuplicatesMessageText"), this._languageService.GetString("HandInFileSelectorDuplicatesAddButtonText"), this._languageService.GetString("HandInFileSelectorDuplicatesCancelButtonText"), this._messenger), (Action <bool>)(isOkSelected => { if (!isOkSelected) { return; } List <HandInFileViewModel> list = this.SelectedAttachments.ToList <HandInFileViewModel>(); HandInFileModel newMainDocument = this.GetNewHandInFileModel(selectedMainDocument, list.Select <HandInFileViewModel, HandInFileModel>((Func <HandInFileViewModel, HandInFileModel>)(e => e.HandInFileModel)).ToList <HandInFileModel>()); DispatcherHelper.CheckBeginInvokeOnUI((Action)(() => this.SetMainDocument(newMainDocument))); }))); } else { this.SetMainDocument(selectedMainDocument); } })); }
private void SetMainDocument(HandInFileModel selectedMainDocument) { Task.Factory.StartNew((Action)(() => this._handInFileMetadataStorageService.StoreMainDocumentFilePath(selectedMainDocument))); this.SelectedMainDocument = new HandInFileViewModel(selectedMainDocument); }
public HandInFileViewModel(HandInFileModel handInFileModel) { this.HandInFileModel = handInFileModel; this.ClickablePathViewModel = new ClickablePathViewModel(handInFileModel.Path, handInFileModel.Name); }
public void StoreMainDocumentFilePath(HandInFileModel handInFileModel) { this._registryService.SetValue("MainDocumentFilePath", handInFileModel.Name + "?" + handInFileModel.Path); }