-
Notifications
You must be signed in to change notification settings - Fork 0
/
420 - HR Lookup.cs
580 lines (515 loc) · 31 KB
/
420 - HR Lookup.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
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
// Skeleton generated by Hyland Unity Editor on 6/8/2017 12:03:07 PM
namespace HRElevatorInspectionLookuptoVR
{
using System;
using System.Text;
using System.Data;
using System.Data.Odbc;
using Hyland.Unity;
/// <summary>
/// 420 - HR - Elevelator Inspection Lookup
/// </summary>
public class HRElevatorInspectionLookuptoVR : Hyland.Unity.IWorkflowScript
{
#region User-Configurable Script Settings
// Script name for diagnostics logging
private const string ScriptName = "420 - HR - Elevator Inspection Lookup to VR";
// Diagnostics logging level - set to Verbose for testing, Error for production
private const Diagnostics.DiagnosticsLevel DiagLevel = Diagnostics.DiagnosticsLevel.Verbose;
// Workflow property where error message will be stored
private const string ErrorMessageProperty = "UnityError";
// If true, errors will be added to document history
private const bool WriteErrorsToHistory = true;
// Date/Time format for diagnostics logging
private const string DateTimeFormat = "MM-dd-yyyy HH:mm:ss.fff";
private const string gSaveToLicNum = "License #";
private const string gSaveToLicType = "License Type";
private const string gSaveToInspNum = "Inspection #";
private const string gSaveToFileNum = "File Number";
private const string gSaveToKeyName = "Key Name";
private const string gSaveToSubject = "Subject";
private const string gSaveToDBA = "DBA";
private const string gSaveToInspectVisitDate = "Inspection Visit Date";
private const string gSaveToIndOrgNum = "Indv/Org Number";
private const string gSaveToVisitNum = "Visit #";
private const string gSaveToDisposition = "Disposition";
private const string gSaveToCity = "City";
private const string gSaveToCounty = "County";
private const string gSaveToRegion = "Region";
private const string gSaveToInspectorName = "Inspector Name";
private const string gSaveToInspTypeDesc = "Inspection Type (HR-BES)";
private const string gSaveToInspectionID = "Inspection Visit ID";
#endregion
/***********************************************
* USER/SE: PLEASE DO NOT EDIT BELOW THIS LINE *
***********************************************/
#region Private Globals
// Active workflow document
private Document _currentDocument;
#endregion
#region IWorkflowScript
/// <summary>
/// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
/// <seealso cref="IWorkflowScript" />
/// </summary>
/// <param name="app"></param>
/// <param name="args"></param>
public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args)
{
try
{
// Initialize global settings
IntializeScript(ref app, ref args);
//get and clean LicenseType and Case # keywords for passing to LicEase database
KeywordType kwtLicNum = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gSaveToLicNum);
string strLicNum = "";
if (kwtLicNum != null)
{
KeywordRecord keyRecLicNum = _currentDocument.KeywordRecords.Find(kwtLicNum);
if (keyRecLicNum != null)
{
Keyword kwdLicNum = keyRecLicNum.Keywords.Find(kwtLicNum);
if (kwdLicNum != null)
strLicNum = CleanSeedKW(kwdLicNum.ToString());
}
}
KeywordType kwtLicenseType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gSaveToLicType);
string strLicenseType = "";
if (kwtLicenseType != null)
{
KeywordRecord keyRecLicenseType = _currentDocument.KeywordRecords.Find(kwtLicenseType);
if (keyRecLicenseType != null)
{
Keyword kwdLicenseType = keyRecLicenseType.Keywords.Find(kwtLicenseType);
if (kwdLicenseType != null)
strLicenseType = CleanSeedKW(kwdLicenseType.ToString());
}
}
KeywordType kwtInspectionDate = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gSaveToInspectVisitDate);
string strInspectionDate = "";
if (kwtInspectionDate != null)
{
KeywordRecord keyRecInspectionDate = _currentDocument.KeywordRecords.Find(kwtInspectionDate);
if (keyRecInspectionDate != null)
{
Keyword kwdInspectionDate = keyRecInspectionDate.Keywords.Find(kwtInspectionDate);
if (kwdInspectionDate != null)
strInspectionDate = CleanSeedKW(kwdInspectionDate.ToString());
}
}
if (strInspectionDate == "")
{
throw new Exception(string.Format("Search keyword {0} is blank.", gSaveToInspectVisitDate));
}
if (strLicNum == "")
{
throw new Exception(string.Format("Search keyword {0} is blank.", gSaveToLicNum));
}
if (strLicenseType == "")
{
throw new Exception(string.Format("Search keyword {0} is blank.", gSaveToLicType));
}
//access Config Item for LicEase User
string gUSER = "";
if (app.Configuration.TryGetValue("LicEaseUser", out gUSER))
{
}
//access Config Item for LicEase Password
string gPASS = "";
if (app.Configuration.TryGetValue("LicEasePassword", out gPASS))
{
}
/* COMMENT THIS SECTION OUT WHEN MOVING TO PROD */
//access Config Item for LicEase UAT ODBC
string gODBC = "";
if (app.Configuration.TryGetValue("LicEaseUAT", out gODBC))
{
}
/* UNCOMMENT THIS SECTION WHEN MOVING TO PROD
//access Config Item for LicEase PROD ODBC
string gODBC = "";
if (app.Configuration.TryGetValue("LicEasePROD", out gODBC))
{
}
*/
string connectionString = string.Format("DSN={0};Uid={1};Pwd={2};", gODBC, gUSER, gPASS);
app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionString));
StringBuilder strSql = new StringBuilder();
strSql.Append(@"SELECT a.insp_nbr, a.key_name, a.insp_vst_id AS insp_vst_id,a.lic_type AS lic_type, a.indorg_num, a.file_num, ");
strSql.Append(@" a.lic_num AS lic_num, a.visit_num, a.visit_date,a.insp_typ, a.disposition_kw, a.city_kw, a.county_kw, a.region_kw,a.inspector_name ");
strSql.Append(@" FROM (SELECT DISTINCT TO_CHAR (insp_hist.insp_nbr) AS insp_nbr,TO_CHAR(insp_vst.insp_vst_id) AS insp_vst_id,lic.clnt_cde AS lic_type,lic.lic_nbr AS lic_num, ");
strSql.Append(@" pri_name.key_nme AS key_name,TO_CHAR (lic.xent_id) AS indorg_num,TO_CHAR (lic.file_nbr) AS file_num,TO_CHAR (insp_vst.insp_vst_nbr) AS visit_num,TO_CHAR (insp_vst.insp_vst_strt_dte) AS visit_date, ");
strSql.Append(@" insp_typ_defn.insp_typ_desc AS insp_typ,addr.addr_cty AS city_kw,cnty.cnty_desc AS county_kw,insp_regn.insp_regn_cde AS region_kw, ");
strSql.Append(@" insp_disp_typ.insp_disp_typ_desc AS disposition_kw,stff.frst_nme || '.' || stff.surnme AS inspector_name ");
strSql.Append(@" FROM insp_vst,insp_hist,insp_typ_defn,insp_disp_typ,inspr,stff,lic,clnt,NAME pri_name,insp_regn,inspr_insp_regn,LINK,addr,cnty ");
strSql.Append(@" WHERE lic.lic_nbr = '");
strSql.Append(strLicNum);
strSql.Append(@"' AND lic.clnt_cde = '");
strSql.Append(strLicenseType);
strSql.Append(@"' AND insp_hist.lic_id = lic.lic_id and insp_hist.link_id = link.link_id AND LINK.nme_id = pri_name.nme_id AND addr.addr_id = LINK.addr_id ");
strSql.Append(@" AND LINK.insp_regn_id = inspr_insp_regn.insp_regn_id AND insp_regn.insp_regn_id = inspr_insp_regn.insp_regn_id AND addr.cnty = cnty.cnty ");
strSql.Append(@" AND lic.clnt_cde = clnt.clnt_cde AND clnt.clnt_cde_prnt = '210' and insp_hist.insp_hist_id = insp_vst.insp_hist_id ");
strSql.Append(@" AND insp_vst.insp_vst_end_dte = TO_DATE ('");
strSql.Append(strLicenseType);
strSql.Append(@"', 'MM/DD/YYYY') AND insp_typ_defn.insp_typ_defn_id = insp_hist.insp_typ_defn_id AND insp_vst.inspr_id = inspr.inspr_id AND stff.stff_oper_id = inspr.stff_oper_id AND insp_disp_typ.insp_disp_typ_id = insp_hist.insp_disp_typ_id) a ");
app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Sql Query: {0}", strSql.ToString()));
using (OdbcConnection con = new OdbcConnection(connectionString))
{
try
{
con.Open();
using (OdbcCommand command = new OdbcCommand(strSql.ToString(), con))
using (OdbcDataReader reader = command.ExecuteReader())
{
if (reader.HasRows)
{
string strLicType = "";
string strInspID = "";
string strLicenseNum = "";
string strFileNum = "";
string strKeyName = "";
string strDBAName = "";
string strInDorgNum = "";
string strVisitNum = "";
string strDisposition = "";
//string strInspDate = "";
string strCity = "";
string strCounty = "";
string strRegion = "";
string strInspector = "";
//string strInspNum = "";
string strSubject = "";
string strInspType = "";
reader.Read();
strLicType = reader["lic_Type"].ToString();
strInspID = reader["insp_vst_id"].ToString();
strLicenseNum = reader["lic_Num"].ToString();
strFileNum = reader["file_Num"].ToString();
strKeyName = reader["key_Name"].ToString();
strDBAName = reader["dba_kw"].ToString();
strInDorgNum = reader["indorg_num"].ToString();
strVisitNum = reader["visit_Num"].ToString();
//strInspDate = reader["visit_date"].ToString();
strDisposition = reader["disposition_kw"].ToString();
strCity = reader["city_kw"].ToString();
strInspector = reader["inspector_name"].ToString();
//strInspNum = reader["insp_nbr"].ToString();
strSubject = reader["key_Name"].ToString();
strInspType = reader["insp_typ"].ToString();
if (reader["county_kw"] != DBNull.Value)
{
strCounty = reader["county_kw"].ToString();
}
else
{
strCounty = "Not Available";
}
if (reader["region_kw"] != DBNull.Value)
{
strRegion = reader["region_kw"].ToString();
}
else
{
strRegion = "Not Available";
}
Keyword kwdLicType = null;
if (!String.IsNullOrEmpty(strLicType))
{
KeywordType kwtLicType = app.Core.KeywordTypes.Find(gSaveToLicType);
if (kwtLicType != null)
kwdLicType = CreateKeywordHelper(kwtLicType, strLicType);
}
Keyword kwdLicenseNum = null;
if (!String.IsNullOrEmpty(strLicenseNum))
{
KeywordType kwtLicenseNum = app.Core.KeywordTypes.Find(gSaveToLicNum);
if (kwtLicenseNum != null)
kwdLicenseNum = CreateKeywordHelper(kwtLicenseNum, strLicenseNum);
}
Keyword kwdFileNum = null;
if (!String.IsNullOrEmpty(strFileNum))
{
KeywordType kwtFileNum = app.Core.KeywordTypes.Find(gSaveToFileNum);
if (kwtFileNum != null)
kwdFileNum = CreateKeywordHelper(kwtFileNum, strFileNum);
}
Keyword kwdKeyName = null;
if (!String.IsNullOrEmpty(strKeyName))
{
KeywordType kwtKeyName = app.Core.KeywordTypes.Find(gSaveToKeyName);
if (kwtKeyName != null)
kwdKeyName = CreateKeywordHelper(kwtKeyName, strKeyName);
}
Keyword kwdSubject = null;
if (!String.IsNullOrEmpty(strSubject))
{
KeywordType kwtSubject = app.Core.KeywordTypes.Find(gSaveToSubject);
if (kwtSubject != null)
kwdSubject = CreateKeywordHelper(kwtSubject, strSubject);
}
Keyword kwdDBAName = null;
if (!String.IsNullOrEmpty(strDBAName))
{
KeywordType kwtDBAName = app.Core.KeywordTypes.Find(gSaveToDBA);
if (kwtDBAName != null)
kwdDBAName = CreateKeywordHelper(kwtDBAName, strDBAName);
}
Keyword kwdInDorgNum = null;
if (!String.IsNullOrEmpty(strInDorgNum))
{
KeywordType kwtInDorgNum = app.Core.KeywordTypes.Find(gSaveToIndOrgNum);
if (kwtInDorgNum != null)
kwdInDorgNum = CreateKeywordHelper(kwtInDorgNum, strInDorgNum);
}
Keyword kwdVisitNum = null;
if (!String.IsNullOrEmpty(strVisitNum))
{
KeywordType kwtVisitNum = app.Core.KeywordTypes.Find(gSaveToVisitNum);
if (kwtVisitNum != null)
kwdVisitNum = CreateKeywordHelper(kwtVisitNum, strVisitNum);
}
Keyword kwdDisposition = null;
if (!String.IsNullOrEmpty(strDisposition))
{
KeywordType kwtDisposition = app.Core.KeywordTypes.Find(gSaveToLicType);
if (kwtDisposition != null)
kwdDisposition = CreateKeywordHelper(kwtDisposition, strDisposition);
}
Keyword kwdCity = null;
if (!String.IsNullOrEmpty(strCity))
{
KeywordType kwtCity = app.Core.KeywordTypes.Find(gSaveToCity);
if (kwtCity != null)
kwdCity = CreateKeywordHelper(kwtCity, strCity);
}
Keyword kwdCounty = null;
if (!String.IsNullOrEmpty(strCounty))
{
KeywordType kwtCounty = app.Core.KeywordTypes.Find(gSaveToCounty);
if (kwtCounty != null)
kwdCounty = CreateKeywordHelper(kwtCounty, strCounty);
}
Keyword kwdRegion = null;
if (!String.IsNullOrEmpty(strRegion))
{
KeywordType kwtRegion = app.Core.KeywordTypes.Find(gSaveToRegion);
if (kwtRegion != null)
kwdRegion = CreateKeywordHelper(kwtRegion, strRegion);
}
Keyword kwdInspector = null;
if (!String.IsNullOrEmpty(strInspector))
{
KeywordType kwtInspector = app.Core.KeywordTypes.Find(gSaveToInspectorName);
if (kwtInspector != null)
kwdInspector = CreateKeywordHelper(kwtInspector, strInspector);
}
Keyword kwdInspectorID = null;
if (!String.IsNullOrEmpty(strInspID))
{
KeywordType kwtInspNum = app.Core.KeywordTypes.Find(gSaveToInspectionID);
if (kwtInspNum != null)
kwdInspectorID = CreateKeywordHelper(kwtInspNum, strInspID);
}
Keyword kwdInspTypeDesc = null;
if (!String.IsNullOrEmpty(strInspType))
{
KeywordType kwtInspTypeDesc = app.Core.KeywordTypes.Find(gSaveToInspTypeDesc);
if (kwtInspTypeDesc != null)
kwdInspTypeDesc = CreateKeywordHelper(kwtInspTypeDesc, strInspType);
}
using (DocumentLock documentLock = _currentDocument.LockDocument())
{
// Ensure lock was obtained
if (documentLock.Status != DocumentLockStatus.LockObtained)
{
throw new Exception("Document lock not obtained");
}
// Create keyword modifier object to hold keyword changes
KeywordModifier keyModifier = _currentDocument.CreateKeywordModifier();
// Add update keyword call to keyword modifier object
//Note Overloads available for use
//(I.E.): keyModifier.AddKeyword(keywordTypeName,keywordValue)
if (kwdLicType != null) keyModifier.AddKeyword(kwdLicType);
if (kwdLicenseNum != null) keyModifier.AddKeyword(kwdLicenseNum);
if (kwdInspectorID != null) keyModifier.AddKeyword(kwdInspectorID);
if (kwdFileNum != null) keyModifier.AddKeyword(kwdFileNum);
if (kwdKeyName != null) keyModifier.AddKeyword(kwdKeyName);
if (kwdDBAName != null) keyModifier.AddKeyword(kwdDBAName);
if (kwdInDorgNum != null) keyModifier.AddKeyword(kwdInDorgNum);
if (kwdVisitNum != null) keyModifier.AddKeyword(kwdVisitNum);
if (kwdDisposition != null) keyModifier.AddKeyword(kwdDisposition);
if (kwdCity != null) keyModifier.AddKeyword(kwdCity);
if (kwdCounty != null) keyModifier.AddKeyword(kwdCounty);
if (kwdRegion != null) keyModifier.AddKeyword(kwdRegion);
if (kwdInspector != null) keyModifier.AddKeyword(kwdInspector);
if (kwdInspTypeDesc != null) keyModifier.AddKeyword(kwdInspTypeDesc);
if (kwdSubject != null) keyModifier.AddKeyword(kwdSubject);
// Apply keyword change to the document
keyModifier.ApplyChanges();
string output = String.Format("Keyword: '{0}' Value: '{1}', {33}Keyword: '{2}' Value: '{3}', {33}Keyword: '{4}' Value: '{5}', {33}Keyword: '{6}' Value: '{7}'," +
"{33}Keyword: '{8}' Value: '{9}', {33}Keyword: '{10}' Value: '{11}', {33}Keyword: '{12}' Value: '{13}', {33}Keyword: '{14}' Value: '{15}', {33}Keyword: '{16}' Value: '{17}'," +
"{33}Keyword: '{18}' Value: '{19}', {33}Keyword: '{20}' Value: '{21}', {33}Keyword: '{22}' Value: '{23}', {33}Keyword: '{24}' Value: '{25}', {33}Keyword: '{26}' Value: '{27}'," +
"{33}Keyword: '{28}' Value: '{29}', {33}Keyword: '{30}' Value: '{31}', {33}added to Document {32}.",
gSaveToLicNum, strLicNum, gSaveToLicType, strLicType, gSaveToInspectionID, strInspID, gSaveToFileNum, strFileNum, gSaveToKeyName, strKeyName, gSaveToSubject, strSubject,
gSaveToDBA, strDBAName, gSaveToIndOrgNum, strInDorgNum, gSaveToVisitNum, strVisitNum, gSaveToDisposition, strDisposition, gSaveToCity, strCity, gSaveToCounty, strCounty,
gSaveToRegion, strRegion, gSaveToInspectorName, strInspector, gSaveToInspTypeDesc, strInspType, gSaveToInspNum, "Not being returned", _currentDocument.ID, Environment.NewLine);
//Output the results to the OnBase Diagnostics Console
app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output);
documentLock.Release();
}
}
else
{
throw new Exception(string.Format("No records found in database"));
}
}
}
catch (Exception ex)
{
throw new ApplicationException("Error during database operations!", ex);
}
finally
{
if (con.State == ConnectionState.Open) con.Close();
}
}
}
catch (Exception ex)
{
// Handle exceptions and log to Diagnostics Console and document history
HandleException(ex, ref app, ref args);
}
finally
{
// Log script execution end
app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info,
string.Format("End Script - [{0}]", ScriptName));
}
}
#endregion
#region Helper Functions
/// <summary>
/// Initialize global settings
/// </summary>
/// <param name="app">Unity Application object</param>
/// <param name="args">Workflow event arguments</param>
private void IntializeScript(ref Application app, ref WorkflowEventArgs args)
{
// Set the specified diagnostics level
app.Diagnostics.Level = DiagLevel;
// Log script execution start
app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info,
string.Format("{0} - Start Script - [{1}]", DateTime.Now.ToString(DateTimeFormat), ScriptName));
// Capture active document as global
_currentDocument = args.Document;
// _currentDocument = app.Core.GetDocumentByID(TestDocId);
// If an error was stored in the property bag from a previous execution, clear it
if (args.SessionPropertyBag.ContainsKey(ErrorMessageProperty)) args.SessionPropertyBag.Remove(ErrorMessageProperty);
// Set ScriptResult = true for workflow rules (will become false if an error is caught)
args.ScriptResult = true;
}
/// <summary>
/// Handle exceptions and log to Diagnostics Console and document history
/// </summary>
/// <param name="ex">Exception</param>
/// <param name="app">Unity Application object</param>
/// <param name="args">Workflow event arguments</param>
/// <param name="otherDocument">Document on which to update history if not active workflow document</param>
private void HandleException(Exception ex, ref Application app, ref WorkflowEventArgs args, Document otherDocument = null)
{
var history = app.Core.LogManagement;
bool isInner = false;
// Cycle through all inner exceptions
while (ex != null)
{
// Construct error text to store to workflow property
string propertyError = string.Format("{0}{1}: {2}",
isInner ? "Inner " : "",
ex.GetType().Name,
ex.Message);
// Construct error text to store to document history
string historyError = propertyError.Replace(ex.GetType().Name, "Unity Script Error");
// Construct error text to log to diagnostics console
string diagnosticsError = string.Format("{0} - ***ERROR***{1}{2}{1}{1}Stack Trace:{1}{3}",
DateTime.Now.ToString(DateTimeFormat),
Environment.NewLine,
propertyError,
ex.StackTrace);
// Add error message to document history (on current or specified document)
var document = otherDocument ?? _currentDocument;
if (document != null && WriteErrorsToHistory) history.CreateDocumentHistoryItem(document, historyError);
// Write error message to Diagnostcs Consonle
app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, diagnosticsError);
// Store the original (inner) exception message to error workflow property
if (ex.InnerException == null) args.SessionPropertyBag.Set(ErrorMessageProperty, ex.Message);
// Move on to next inner exception
ex = ex.InnerException;
isInner = true;
}
// Set ScriptResult = false for workflow rules
args.ScriptResult = false;
}
/// <summary>
/// Clean Seed Keyword
/// </summary>
/// <param name="pValue">Keyword Value</param>
private string CleanSeedKW(string pValue)
{
string temp = pValue;
StringBuilder newString = new StringBuilder();
int firstSpace = pValue.IndexOf(" ");
if (firstSpace > 0)
{
temp = pValue.Substring(0, firstSpace);
foreach (char c in temp)
{
if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')))
{
newString.Append(c);
}
else
{
newString.Append(" ");
}
}
newString = newString.Replace(" ", "");
newString = newString.Replace("'", "''");
return newString.ToString();
}
else
{
return pValue.ToString();
}
}
private Keyword CreateKeywordHelper(KeywordType Keytype, string Value)
{
Keyword key = null;
switch (Keytype.DataType)
{
case KeywordDataType.Currency:
case KeywordDataType.Numeric20:
decimal decVal = decimal.Parse(Value);
key = Keytype.CreateKeyword(decVal);
break;
case KeywordDataType.Date:
case KeywordDataType.DateTime:
DateTime dateVal = DateTime.Parse(Value);
key = Keytype.CreateKeyword(dateVal);
break;
case KeywordDataType.FloatingPoint:
double dblVal = double.Parse(Value);
key = Keytype.CreateKeyword(dblVal);
break;
case KeywordDataType.Numeric9:
long lngVal = long.Parse(Value);
key = Keytype.CreateKeyword(lngVal);
break;
default:
key = Keytype.CreateKeyword(Value);
break;
}
return key;
}
#endregion
}
}