Exemplo n.º 1
0
 public void OnPreviewDocument()
 {
     PDFMerge.MergePDFs(new List <Document>()
     {
         SelectedDocument
     });
 }
Exemplo n.º 2
0
        public bool AccessGold()
        {
            try
            {
                // Filepaths
                string tFile     = Globals.PathConfig + Globals.SettingsFile;
                string tFileLock = Globals.PathConfig + Globals.LockFile;
                string user      = "";

                // Check for a lock file
                if (File.Exists(tFileLock))
                {
                    user = File.GetAccessControl(tFileLock).GetOwner(typeof(System.Security.Principal.NTAccount)).ToString();
                    Globals.ShowMsg($"Someone else appears to be editing the configuration. There can only be one user editing at a time. Please try again later.\n\n" +
                                    $"User:\n{user}\n\n" +
                                    $"Lock file:\n{tFileLock}\n\nIf you are 100% certain no one is editing the file, delete the lock file and try again.\n\n" +
                                    $"WARNING: this will cause changes to be overridden if two people are working at the same time!",
                                    "File Locked", MessageBoxButton.OK, MessageBoxImage.Information);
                    return(false);
                }

                if (File.Exists(tFile))
                {
                    if (PDFMerge.IsFileinUse(new FileInfo(tFile)))
                    {
                        Globals.ShowMsg("Oops! You do not have Read/Write access to the setup file (gold.json).\n\n" +
                                        $"This may be because someone already has the file open. Try again in 30 seconds.\n\nFile location:\n{tFile}",
                                        "Oops!", MessageBoxButton.OK, MessageBoxImage.Information);
                        return(false);
                    }
                    File.Create(tFileLock);
                    Globals.Locked = true;
                }
                else
                {
                    if (!Directory.Exists(Globals.PathConfig))
                    {
                        Directory.CreateDirectory(Globals.PathConfig);
                    }

                    Globals.ShowMsg($"The configuration file (gold.json) was not found, so a new file will be created.\n\nPath:\n{tFile}",
                                    "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                    File.Create(tFile);
                }
                return(true);
            }
            catch (Exception e)
            {
                Globals.ShowMsg($"Something unexpected happened.\n\nMessage Details:\n{e.Message}", "Error",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
        }
Exemplo n.º 3
0
 public void OnGenerateDocument()
 {
     PDFMerge.MergePDFs(FilteredDocuments.Where(f => f.Selected == true));
 }