-
Notifications
You must be signed in to change notification settings - Fork 1
/
OutputFile.cs
113 lines (103 loc) · 2.93 KB
/
OutputFile.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Data;
namespace Script_Builder
{
class OutputFile
{
public string FileName;
public string FilePath;
public bool SerialFile { get; private set; }
public DataTable SerialInputTable;
public string SerialFieldLinkA;
public string SerialFieldLinkB;
private int fileType;
public int FileType
{
get
{
return fileType;
}
set
{
if (value < 0 || value > 3)
fileType = 3;
else
fileType = value;
}
}
public bool Overwrite;
public OutputFile(string FileName, string FilePath, int FileType)
{
this.FileName = FileName;
this.FilePath = FilePath;
this.fileType = FileType;
this.SerialFile = false;
this.Overwrite = false;
}
public OutputFile(string FileName, string FilePath, int FileType, bool SerialFile)
{
this.FileName = FileName;
this.FilePath = FilePath;
this.fileType = FileType;
this.SerialFile = SerialFile;
this.Overwrite = false;
if (SerialFile)
{
this.SerialInputTable = new DataTable();
this.SerialFieldLinkA = "";
this.SerialFieldLinkB = "";
}
}
public bool Exists
{
get
{
return File.Exists(FullFileName);
}
}
public string FullFileName
{
get
{
return Path.Combine(FilePath,FileName);
}
}
public Encoding Encoding
{
get
{
switch (fileType)
{
case 0:
return Encoding.UTF8;
case 1:
return Encoding.Unicode;
case 2:
return Encoding.ASCII;
default:
return Encoding.Default;
}
}
}
public int SerialFieldLinkID()
{
return serialFieldLinkID(SerialInputTable, SerialFieldLinkA);
}
public int SerialFieldLinkID(DataTable inputTable)
{
return serialFieldLinkID(inputTable, SerialFieldLinkB);
}
private int serialFieldLinkID(DataTable inputTable,string matchColumnName)
{
if (inputTable != null)
for (int output = 0; output < inputTable.Columns.Count; output++)
if (inputTable.Columns[output].ColumnName == matchColumnName)
return output;
return -1;
}
}
}