Subversion Repository Public Repository

ChrisCompleteCodeTrunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AirgasExportLogParser
{
    public class Program
    {
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage : AirgasExportLogParser.exe -f <path to log file>");
            }
            else
            {
                string commandLineOption = args[0];
                if (!commandLineOption.StartsWith("-f"))
                {
                    Console.WriteLine("Usage : AirgasExportLogParser.exe -f <path to log file>");
                    Console.WriteLine("-------------------------------------------------------");
                    Console.WriteLine("-f is the only command switch you can use.");
                }
                else
                {
                    string fileName = args[1];
                    FileInfo fileInfo = new FileInfo(fileName);
                    if (!fileInfo.Exists)
                    {
                        Console.WriteLine("Usage : AirgasExportLogParser.exe -f <path to log file>");
                        Console.WriteLine("-------------------------------------------------------");
                        Console.WriteLine("The specified file did not exist.");
                    }
                    else
                    {
                        if (fileInfo.Length <= 0)
                        {
                            Console.WriteLine("Usage : AirgasExportLogParser.exe -f <path to log file>");
                            Console.WriteLine("-------------------------------------------------------");
                            Console.WriteLine("The log file is empty");
                        }
                        else
                        {
                            LogParser logParser = new LogParser(fileInfo);
                            logParser.Parse();

                            foreach (KeyValuePair<long, ExportFileInfo> item in logParser.LogItems)
                            {
                                long DWDocId = item.Key;
                                ExportFileInfo exportFileInfo = item.Value;

                                foreach (string metaFile in item.Value.MetaFiles)
                                {
                                    item.Value.Commands.Add(
                                        String.Format(
                                            "DEL \"{0}\"",
                                            new object[]
                                            {
                                                metaFile
                                            }
                                        )
                                    );
                                }

                                if(item.Value.ExportFiles.Count > 1)
                                {

                                   String exportPdfFilePath = Path.Combine(
                                        Path.GetDirectoryName(item.Value.ExportFiles[0]),
                                        String.Format(
                                            "MP_DWDOCID_{0}.pdf",
                                            new object[] {
                                                item.Key.ToString("0000000000")
                                            }
                                        )
                                    );

                                    string exportFiles = String.Empty;

                                    foreach(string exportFile in item.Value.ExportFiles)
                                    {
                                        exportFiles += "\"" + exportFile + "\" ";

                                    }

                                    string tiff2pdfcommand = String.Format(
                                        "gm convert {0} {1}",
                                        new object[]
                                        {
                                            exportFiles.Trim(),
                                            "\"" + exportPdfFilePath + "\""
                                            
                                        }
                                    );

                                    item.Value.Commands.Add(tiff2pdfcommand);
                                    foreach(var exportFile in item.Value.ExportFiles)
                                    {
                                        item.Value.Commands.Add(
                                            String.Format(
                                                "DEL \"{0}\"",
                                                new object[]
                                                {
                                                    exportFile
                                                }
                                            )
                                        );
                                    }
                                    item.Value.ExportFiles.Clear();
                                    item.Value.ExportFiles.Add(exportPdfFilePath);
                                        
                                }

                            }

                            List<String> commandList = new List<String>();
                            List<String> exportFileList = new List<String>();
                            exportFileList.Add("DWDOCID,EXPORT_FILE");


                            foreach (KeyValuePair<long,ExportFileInfo> logItem in logParser.LogItems)
                            {
                                foreach(String command in logItem.Value.Commands)
                                {
                                    commandList.Add(command);
                                }
                                foreach(String exportFile in logItem.Value.ExportFiles)
                                {
                                    exportFileList.Add( logItem.Key.ToString() + ",\"" + exportFile + "\"");
                                }
                            }

                            

                            File.WriteAllLines(Path.Combine(fileInfo.DirectoryName, "commands.bat"), commandList);
                            File.WriteAllLines(Path.Combine(fileInfo.DirectoryName, "exportfiles.csv"), exportFileList);


                        }
                    }
                }
            }
        }
    }
}

Commits for ChrisCompleteCodeTrunk/AirgasExportApplication/AirgasExportLogParser/Program.cs

Diff revisions: vs.
Revision Author Commited Message
1 BBDSCHRIS picture BBDSCHRIS Wed 22 Aug, 2018 20:08:03 +0000