-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathSelectedTemplate.cs
127 lines (106 loc) · 3.82 KB
/
SelectedTemplate.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DigitalPlatform.CirculationClient
{
public class SelectedTemplate
{
public string DbName = "";
public bool NotAskDbName = false;
public string TemplateName = "";
public bool NotAskTemplateName = false;
}
public class SelectedTemplateCollection : List<SelectedTemplate>
{
public SelectedTemplate Find(string strDbName)
{
for (int i = 0; i < this.Count; i++)
{
SelectedTemplate temp = this[i];
if (temp.DbName == strDbName)
return temp;
}
return null;
}
// 根据数据库名获得模板名
public string Get(string strDbName)
{
SelectedTemplate temp = this.Find(strDbName);
if (temp == null)
{
return null;
}
return temp.TemplateName;
}
public void Set(string strDbName,
bool bNotAskDbName,
string strSelectedTemplateName,
bool bNotAskTemplateName)
{
SelectedTemplate temp = this.Find(strDbName);
if (temp == null)
{
temp = new SelectedTemplate();
temp.DbName = strDbName;
temp.NotAskDbName = bNotAskDbName;
temp.TemplateName = strSelectedTemplateName;
temp.NotAskTemplateName = bNotAskTemplateName;
this.Add(temp);
}
else
{
temp.NotAskDbName = bNotAskDbName;
temp.TemplateName = strSelectedTemplateName;
temp.NotAskTemplateName = bNotAskTemplateName;
}
}
// 从字符串创建整个内存对象
public void Build(string strContent)
{
this.Clear();
string[] sections = strContent.Split(new char[] { ';' });
for (int i = 0; i < sections.Length; i++)
{
string strSection = sections[i].Trim();
if (String.IsNullOrEmpty(strSection) == true)
continue;
string strDbName = "";
string strNotAskDbName = "";
string strTemplateName = "";
string strNotAskTemplateName = "";
string[] parts = strSection.Split(new char[] { ',' });
if (parts.Length > 0)
strDbName = parts[0].Trim();
if (parts.Length > 1)
strNotAskDbName = parts[1].Trim();
if (parts.Length > 2)
strTemplateName = parts[2].Trim();
if (parts.Length > 3)
strNotAskTemplateName = parts[3].Trim();
SelectedTemplate temp = new SelectedTemplate();
temp.DbName = strDbName;
temp.NotAskDbName = (strNotAskDbName == "true" ? true : false);
temp.TemplateName = strTemplateName;
temp.NotAskTemplateName = (strNotAskTemplateName == "true" ? true : false);
this.Add(temp);
}
}
// 把内存对象输出到字符串
public string Export()
{
string strContent = "";
for (int i = 0; i < this.Count; i++)
{
SelectedTemplate temp = this[i];
if (i != 0)
strContent += ";";
strContent += temp.DbName + ",";
strContent += (temp.NotAskDbName == true ? "true" : "false") + ",";
strContent += temp.TemplateName + ",";
strContent += (temp.NotAskTemplateName == true ? "true" : "false");
}
return strContent;
}
}
}