Beispiel #1
0
        /// <summary>
        /// Prüft, ob in DirPath für alle *.xlsx-Dateien eine gleichnamige .pdf vorhanden ist und erstellt ggf. fehlende PDFs außer vom aktuellen Tag.
        /// </summary>
        /// <param name="DirPath">Ordner in dem *xlsx-Dateien ohne dazugehörige PDFs liegen können.</param>
        /// <param name="skipToday">true: Überspringt den aktuellen Tag</param>
        internal static void CreatePdf4AllXlsxInDir(string DirPath, bool skipToday = true) //Fehlernummern siehe Log.cs 0803ZZ
        {
            Log.Write(Log.Cat.MethodCall, Log.Prio.Info, 080301, string.Format("CreatePdf4AllXlsxInDir({0})", DirPath));
            Console.WriteLine("Prüfe Ordner " + DirPath);

            if (!Directory.Exists(DirPath))
            {
                Log.Write(Log.Cat.PdfWrite, Log.Prio.Error, 080304, "PDF erstellen: Der übergebene Ordner ist ungültig:" + DirPath);
                return;
            }

            foreach (string filePath in Directory.GetFiles(DirPath, "*.xlsx"))
            {
                //Erzeuge kein PDF vom aktuellen Tag
                if (skipToday && filePath == Excel.CeateXlFilePath())
                {
                    continue;
                }

                string pdfPath = Path.ChangeExtension(filePath, ".pdf");
                if (!Path.GetFileName(filePath).StartsWith("~") && (!File.Exists(pdfPath) || filePath == Excel.CeateXlFilePath()))
                {
                    Log.Write(Log.Cat.PdfWrite, Log.Prio.Info, 080302, "Erzeuge Datei " + pdfPath);
                    CreatePdf(filePath);
                }
            }
        }