-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClockAddInProvider.cs
More file actions
247 lines (220 loc) · 6.81 KB
/
Copy pathClockAddInProvider.cs
File metadata and controls
247 lines (220 loc) · 6.81 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BeeSys.Wasp3D.Hosting;
using System.Reflection;
using System.IO;
using System.Diagnostics;
using Beesys.Wasp.Workflow;
namespace Beesys.Wasp.AddIn
{
public class ClockAddInProvider : WProvider
{
#region Class Members
private List<AddinInfo> m_lstAddinInfo = null;
private List<IWContainer> m_lstContainer = null;
private static string m_sAssemblyPath = string.Empty;
private string addinName = "Clock";
#endregion
#region constructor
static ClockAddInProvider()
{
string sLocation = string.Empty;
string sDirectoryName = string.Empty;
try
{
sLocation = Assembly.GetExecutingAssembly().Location;
if (!string.IsNullOrEmpty(sLocation))
{
sDirectoryName = Path.GetDirectoryName(sLocation);
if (!string.IsNullOrEmpty(sDirectoryName))
m_sAssemblyPath = sDirectoryName;
}
}
catch(Exception ex)
{
Beesys.Wasp.Workflow.LogWriter.WriteLog(ex);
}
finally
{
sLocation = null;
sDirectoryName = null;
}
}
public ClockAddInProvider()
{
try
{
AssemblyPath = m_sAssemblyPath;
}
catch (Exception ex)
{
Workflow.LogWriter.WriteLog(ex);
}
}
#endregion
#region Properties
public string DefaultCulture
{
get;
set;
}
public string AssemblyPath
{
get;
set;
}
public Beesys.Wasp.Workflow.WaspCulture CultureReader
{
get;
private set;
}
/// <summary>
/// Override to return type of addin contains by provider
/// </summary>
public override AddinInfo[] AddinsType
{
get
{
return m_lstAddinInfo.ToArray();
}
}
/// <summary>
/// Override the type of addin to be created .
/// Set as DataTable, as single table created having time information.
/// </summary>
public override WProviderType Type
{
get
{
return WProviderType.DataTable;
}
}
/// <summary>
/// override Singleton to determine whether single addin to be created or not.
/// return false as multiple addin in local scene can be created.
/// </summary>
public override bool Singleton
{
get
{
return false;
}
}
#endregion
#region Overrided Methods
/// <summary>
/// Override Delete container to call containers shut down and remove container
/// from list
/// </summary>
/// <param name="container"></param>
public override void DeleteContainer(IWContainer container)
{
if (container != null)
{
if (m_lstContainer != null)
{
if (m_lstContainer.Contains(container))
{
container.ShutDown();
m_lstContainer.Remove(container);
}
}
}
container = null;
}
/// <summary>
/// Return Conatiner Object, for new scene
/// </summary>
/// <returns></returns>
public override IWContainer GetContainer()
{
ClockAddInContainer objClockAddInContainer = null;
try
{
objClockAddInContainer = new ClockAddInContainer();
objClockAddInContainer.Provider = this;
objClockAddInContainer.Engine = Engine;
if (m_lstContainer != null)
{
m_lstContainer.Add(objClockAddInContainer);
}
return objClockAddInContainer;
}
finally
{
objClockAddInContainer = null;
}
}
/// <summary>
/// On Addin Shutdown, release the resources by calling containers shut down
/// </summary>
public override void ShutDown()
{
try
{
if (m_lstContainer != null)
{
foreach (ClockAddInContainer objContainer in m_lstContainer)
{
objContainer.ShutDown();
}
m_lstContainer.Clear();
m_lstContainer = null;
}
Engine = null;
}
catch (Exception ex)
{
Beesys.Wasp.Workflow.LogWriter.WriteLog(ClockAddinConstants.MODULENAME, ex);
}
}
/// <summary>
/// On Addin start up
/// Set the culture file for addin
/// Set the addin type info
/// </summary>
public override void StartUp()
{
try
{
InitCultureReader();
WaspCulture m_WaspCulture = null;
if (m_WaspCulture == null)
{
m_WaspCulture = this.CultureReader;
}
if (!string.IsNullOrEmpty(m_WaspCulture.GetResourceValue("clock")))
addinName = m_WaspCulture.GetResourceValue("clock");
m_lstContainer = new List<IWContainer>();
m_lstAddinInfo = new List<AddinInfo>();
m_lstAddinInfo.Add(new AddinInfo() { AddinType = "Clock", Button = true, ButtonCaption = addinName });
} //End(try)
catch (Exception ex)
{
Beesys.Wasp.Workflow.LogWriter.WriteLog(ClockAddinConstants.MODULENAME, ex);
}
}//End(StartUp())
#endregion
public virtual void InitCultureReader()
{
try
{
if (CultureReader == null)
{
if (!string.IsNullOrEmpty(this.CurrentCulture))
DefaultCulture = this.CurrentCulture;
if (!string.IsNullOrEmpty(AssemblyPath))
{
CultureReader = new Beesys.Wasp.Workflow.WaspCulture();
CultureReader.Initialize(AssemblyPath, DefaultCulture);
}
}
}
catch (Exception ex)
{
}
}
}
}