private void btnShowDocument_Click(object sender, RoutedEventArgs e) { try { var azureClient = new AzureDataClient(); var file = azureClient.GetFile(CurrentToDo.Path); if (file.Exists()) { string copiedFile = azureClient.DownloadFileToOpen(file, (progress, total) => { }); if (String.IsNullOrEmpty(copiedFile)) { return; } System.Diagnostics.Process process = new System.Diagnostics.Process(); Uri pdf = new Uri(copiedFile, UriKind.RelativeOrAbsolute); process.StartInfo.FileName = pdf.LocalPath; process.Start(); } else { throw new FileNotFoundException(); } } catch (Exception error) { MessageBox.Show("Could not open the file.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void btnZipAndMailTo_Click(object sender, RoutedEventArgs e) { var paths = DocumentsForMail.Where(x => !String.IsNullOrEmpty(x.Path)).Select(x => x.Path).Distinct().ToList(); if (paths.Count() < 1) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("OdaberiBarJedanDokumentUzvicnik")); return; } try { List <string> completedPaths = new List <string>(); var azureClient = new AzureDataClient(); foreach (var item in paths) { var file = azureClient.GetFile(item); var localPath = azureClient.DownloadFileToOpen(file, (progress, total) => { }); completedPaths.Add(localPath); } System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog(); var result = folderBrowser.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { var path = ZipFileHelper.MakeArchiveFromFiles(completedPaths, folderBrowser.SelectedPath); if (!String.IsNullOrEmpty(path)) { try { string outlookPath = AppConfigurationHelper.Configuration?.OutlookDefinedPath ?? ""; Process.Start($"{outlookPath}", $"/a \"{path}\" /c ipm.note "); } catch (Exception error) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("OutlookNijeInstaliranIliNijePovezanUzvicnik")); } } } } catch (Exception ex) { } }
private void btnShowPhysicalPersonDocument_Click(object sender, RoutedEventArgs e) { try { var azureClient = new AzureDataClient(); var file = azureClient.GetFile(CurrentPhysicalPersonDocument.Path); string localFile = azureClient.DownloadFileToOpen(file, (progress, total) => { }); if (!String.IsNullOrEmpty(localFile)) { System.Diagnostics.Process process = new System.Diagnostics.Process(); //string path = "C:\\Users\\Zdravko83\\Desktop\\1 ZBORNIK.pdf"; Uri pdf = new Uri(localFile, UriKind.RelativeOrAbsolute); process.StartInfo.FileName = pdf.LocalPath; process.Start(); } } catch (Exception error) { MessageBox.Show("Could not open the file.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void btnSavePdf_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(DocumentName)) { MainWindow.ErrorMessage = (string)Application.Current.FindResource("MorasUnetiNazivDokumentaUzicnik"); return; } if (Images == null || Images.Where(x => x.IsSelected).Count() < 1) { MainWindow.ErrorMessage = (string)Application.Current.FindResource("MorasSkeniratiNestoIOznacitiStavkeUzvicnik"); return; } if (String.IsNullOrEmpty(SelectedPath)) { MainWindow.ErrorMessage = (string)Application.Current.FindResource("MorasOdabratiFolderUzvicnik"); return; } CanInteractWithForm = false; Thread td = new Thread(() => { try { var tempPath = System.IO.Path.GetTempPath(); var generator = new PDFGenerator(Images .Where(x => x.IsSelected) .OrderBy(x => x.CreatedAt) .Select(x => x.ImagePath) .ToList(), tempPath, DocumentName, MainWindow.CurrentUser.FirstName + " " + MainWindow.CurrentUser.LastName); CurrentDocumentFullPath = generator.Generate(); if (DocumentSavePathOption.Value == true) { File.Copy(CurrentDocumentFullPath, $"{SelectedPath}\\{DocumentName}.pdf"); Dispatcher.BeginInvoke((Action)(() => { DocumentSaved?.Invoke(CurrentDocumentFullPath); })); } else { var documentFolderResp = new DocumentFolderSQLiteRepository().GetDirectoryByPath(MainWindow.CurrentCompanyId, SelectedPath); var documentFolder = documentFolderResp?.DocumentFolder ?? null; var azureClient = new AzureDataClient(); var file = azureClient.GetFile($"{SelectedPath}/{DocumentName}.pdf"); file.UploadFromFile(CurrentDocumentFullPath); file.FetchAttributes(); var documentFile = new DocumentFileViewModel() { Identifier = Guid.NewGuid(), Name = $"{DocumentName}.pdf", DocumentFolder = documentFolder, Path = file.Uri.LocalPath, Size = file.Properties.Length / 1024, CreatedAt = file.Properties.LastModified.Value.DateTime, Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }, CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId } }; var documentFileService = DependencyResolver.Kernel.Get <IDocumentFileService>(); var response = documentFileService.Create(documentFile); if (response.Success) { Dispatcher.BeginInvoke((Action)(() => { DocumentSaved?.Invoke(file.Uri.LocalPath); })); } else { MainWindow.WarningMessage = "Dokument je sačuvan na serveru ali nije indeksiran, molimo kontaktirajte administraciju!"; Dispatcher.BeginInvoke((Action)(() => { DocumentSaved?.Invoke(file.Uri.LocalPath); })); } } MainWindow.SuccessMessage = (string)Application.Current.FindResource("DokumentJeUspesnoSacuvanUzvicnik"); } catch (Exception ex) { MainWindow.ErrorMessage = ex.Message; } finally { CanInteractWithForm = true; } }); td.IsBackground = true; td.Start(); }