/// <summary> /// Performs all the necessary operations on the EditableKeywordModifier /// Removes will not affect updates or adds. /// Meaning a request to update the old value of a keyword will not be affected by a request to remove the old value /// Similarly a request to update a keyword that is in the add request collection, will not succeed. /// the method also handles expansion of autofill keysets if requested, and using defaults to satisfy /// retuired keywords if requested. /// </summary> /// <param name="aModifier">EditableKeywordModifier on which to operate</param> /// <param name="aDocument">Document on which modifications will take place</param> /// <param name="aUpdateRequest">Collection of keyword update requests</param> /// <param name="aAddRequest">Collection of keyword addition requests</param> /// <param name="aRemoveRequest">Collection of keyword removal requests</param> /// <param name="aExpandKeyset">If true, autofill keysets will be expanded</param> /// <param name="aUseDefaultForRequiredKeys">If true, default keyword values will be used to satisfy any missing required keywords</param> private void EditKeywords(EditableKeywordModifier aModifier, Document aDocument, IEnumerable <KeywordUpdate> aUpdateRequest, IEnumerable <Keyword> aAddRequest, IEnumerable <Keyword> aRemoveRequest, bool aExpandKeyset, bool aUseDefaultForRequiredKeys) { if (aUpdateRequest == null) { aUpdateRequest = new List <KeywordUpdate>(); } if (aAddRequest == null) { aAddRequest = new List <Keyword>(); } if (aRemoveRequest == null) { aRemoveRequest = new List <Keyword>(); } DocumentType lDocumentType = aDocument.DocumentType; KeywordRecordType lStandaloneKeywordRecordType = lDocumentType.KeywordRecordTypes.Find(STANDALONE_KEYWORD_RECORD_TYPE); KeywordRecord lStandaloneKeywordRecord = aDocument.KeywordRecords.Find(lStandaloneKeywordRecordType); List <Keyword> lExpectedUnmodified = new List <Keyword>(); List <Keyword> lExpectedRemoved = new List <Keyword>(); List <Keyword> lExpectedAddedByUpdate = new List <Keyword>(); ILookup <Keyword, Keyword> lLookupUpdate = aUpdateRequest.ToLookup(x => x.OldValue, y => y.NewValue); foreach (Keyword lExistingKeyword in lStandaloneKeywordRecord.Keywords) { IEnumerable <Keyword> lNewValues = lLookupUpdate[lExistingKeyword]; if (lNewValues.Any()) { lExpectedAddedByUpdate.AddRange(lNewValues); } else if (aRemoveRequest.Contains(lExistingKeyword)) { lExpectedRemoved.Add(lExistingKeyword); } else { lExpectedUnmodified.Add(lExistingKeyword); } } IEnumerable <Keyword> lUpdateAndAdd = lExpectedAddedByUpdate.Concat(aAddRequest); IEnumerable <Keyword> lExpanded = (aExpandKeyset) ? ExpandAutoFillKeyset(lUpdateAndAdd, lDocumentType, aUseDefaultForRequiredKeys) : new List <Keyword>(); IEnumerable <Keyword> lExpectedResult = lExpectedUnmodified.Concat(lUpdateAndAdd).Concat(lExpanded); IEnumerable <Keyword> lRequiredDefault = VerifyRequiredKeyword(lExpectedResult, lDocumentType.KeywordTypesRequiredForArchival, aUseDefaultForRequiredKeys); foreach (Keyword lKeyword in lExpectedRemoved) { aModifier.RemoveKeyword(lKeyword); } foreach (KeywordUpdate lUpdate in aUpdateRequest) { aModifier.UpdateKeyword(lUpdate.OldValue, lUpdate.NewValue); } AddKeywords(aModifier, aAddRequest); AddKeywords(aModifier, lExpanded); AddKeywords(aModifier, lRequiredDefault); }
public static IEnumerable <Keyword> GetStandaloneKeywords(this Document aDocument) { KeywordRecord aRecord = aDocument.KeywordRecords.Find(x => x.KeywordRecordType.RecordType == RecordType.StandAlone); if (aRecord != null) { return(aRecord.Keywords); } else { return(new List <Keyword>()); } }
private void ModifyKeywordInCurrentDocument(Document doc, string keywordType, string keywordValue) { using (DocumentLock documentLock = doc.LockDocument()) { if (documentLock.Status == DocumentLockStatus.LockObtained) { KeywordModifier keymod = doc.CreateKeywordModifier(); KeywordType keyType = _app.Core.KeywordTypes.Find(keywordType); if (keyType == null) { keymod.AddKeyword(keywordType, keywordValue); } else { KeywordRecord keyRec = doc.KeywordRecords.Find(keyType); KeywordRecordType keyRecType = keyRec.KeywordRecordType; Keyword newKeyword = keyType.CreateKeyword(keywordValue); if (keyRecType.RecordType == RecordType.MultiInstance) { EditableKeywordRecord editKeyRec = keyRec.CreateEditableKeywordRecord(); Keyword keyword = editKeyRec.Keywords.Find(keywordType); editKeyRec.UpdateKeyword(keyword, newKeyword); keymod.AddKeywordRecord(editKeyRec); } else { Keyword keyword = keyRec.Keywords.Find(keywordType); keymod.UpdateKeyword(keyword, newKeyword); } } keymod.ApplyChanges(); } } }
public static void StoreInOnBase(string tempFile) { using (Application obApp = OnBaseConnect()) { // Get OnBase Storage Object Storage storage = obApp.Core.Storage; String docTypeName = System.Configuration.ConfigurationManager.AppSettings["outputDocumentType"]; var documentType = obApp.Core.DocumentTypes.Find(docTypeName); if (documentType == null) { Log.Logger.Error("Failed to find DocumentType: {@documentType}", docTypeName); } else { // Set file type var fileTypeName = "MS Excel Spreadsheet"; var fileExtension = @".xlsx"; FileType fileType = obApp.Core.FileTypes.Find(fileTypeName); if (fileType == null) { Log.Logger.Error("Failed to find FileType: {@fileTypeName}", fileTypeName); } else { MemoryStream OBDocumentStream = new MemoryStream(File.ReadAllBytes(tempFile + fileExtension)); // Create Hyland PageData object for storage PageData OBDocumentPageData = obApp.Core.Storage.CreatePageData(OBDocumentStream, fileExtension); StoreNewDocumentProperties storeDocumentProperties = storage.CreateStoreNewDocumentProperties(documentType, fileType); // Store Document in OnBase Document OBDocumentNew = obApp.Core.Storage.StoreNewDocument(OBDocumentPageData, storeDocumentProperties); if (OBDocumentNew == null) { Log.Logger.Error("Failed to store Document in OnBase!"); } else { //Set Keywords KeywordType ReportIdKWType = obApp.Core.KeywordTypes.Find("Report ID"); Keyword ReportIdKW = ReportIdKWType.CreateKeyword("00"); KeywordRecord ReportIdKWRecord = OBDocumentNew.KeywordRecords.Find(ReportIdKWType); if (ReportIdKWRecord == null) { KeywordModifier ReportIdKeywordModifier = OBDocumentNew.CreateKeywordModifier(); ReportIdKeywordModifier.AddKeyword(ReportIdKW); ReportIdKeywordModifier.ApplyChanges(); } else { Log.Logger.Error("Keyword not null!"); } // Stored Document will have today's DateTime; Update with DateTime scraped from Evidence Summary DocumentPropertiesModifier OBDocModifier = OBDocumentNew.CreateDocumentPropertiesModifier(); OBDocModifier.DocumentDate = docDate; OBDocModifier.ApplyChanges(); Log.Logger.Information("Storage to OnBase succesful. Doc Handle: {OBDocHandle}", OBDocumentNew.ID); } } } } }
/// <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 Application # keywords for passing to LicEase database KeywordType kwtInspectorName = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamInspectorName); string strInspectorName = ""; if (kwtInspectorName != null) { KeywordRecord keyRecFileNum = _currentDocument.KeywordRecords.Find(kwtInspectorName); if (keyRecFileNum != null) { Keyword kwdFileNum = keyRecFileNum.Keywords.Find(kwtInspectorName); if (kwdFileNum != null) { strInspectorName = CleanSeedKW(kwdFileNum.ToString()); } } } KeywordType kwtInspVisitID = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamInspVisitID); string strInspVisitID = ""; if (kwtInspVisitID != null) { KeywordRecord keyRecLicenseType = _currentDocument.KeywordRecords.Find(kwtInspVisitID); if (keyRecLicenseType != null) { Keyword kwdLicenseType = keyRecLicenseType.Keywords.Find(kwtInspVisitID); if (kwdLicenseType != null) { strInspVisitID = CleanSeedKW(kwdLicenseType.ToString()); } } } if ((strInspectorName == "") || (strInspVisitID == "")) { throw new Exception(string.Format("Either {0} or {1} is blank.", gParamInspectorName, gParamInspVisitID)); } //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)) { } //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, key_name, dba_name as dba_kw, a.insp_vst_id, a.lic_type AS lic_type, a.indorg_num, a.file_num, a.lic_num AS lic_num, a.visit_num, a.visit_date, "); strSql.Append(@" a.insp_typ_desc, a.disposition_kw, city_kw, county_kw, region_kw, a.inspector_name FROM (SELECT DISTINCT TO_CHAR (insp_hist.insp_nbr) AS insp_nbr, "); strSql.Append(@" TO_CHAR (insp_vst.insp_vst_id) AS insp_vst_id, lic.clnt_cde AS lic_type, lic.xent_id AS indorg_num, lic.lic_nbr AS lic_num, lic.file_nbr as file_num,"); strSql.Append(@" TO_CHAR (insp_vst.insp_vst_nbr) AS visit_num, TO_CHAR (insp_vst.insp_vst_strt_dte) AS visit_date, insp_typ_defn.insp_typ_desc, insp_disp_typ.insp_disp_typ_desc AS disposition_kw, "); strSql.Append(@" stff.frst_nme || '.' || stff.surnme AS inspector_name ,insp_hist.lic_id as insp_lic_id ,(select max(key_nme) from name n, link k where k.link_id = insp_hist.link_id and "); strSql.Append(@" k.nme_id = n.nme_id) as key_name,(SELECT MAX (key_nme) FROM NAME n, LINK k WHERE k.prnt_id = insp_hist.lic_id and k.link_prnt_cde = 'L' and k.curr_ind = 'Y' "); strSql.Append(@" and k.clnt_link_typ_id in (select clnt_link_typ_id from clnt_link_typ c, link_typ t where t.link_typ_id = c.link_typ_id and t.link_typ_cde = 'DBA') "); strSql.Append(@" AND k.nme_id = n.nme_id) AS dba_name,(select addr_cty from addr n, link k where k.link_id = insp_hist.link_id and k.addr_id = n.addr_id) as city_kw, "); strSql.Append(@" (select cnty_desc from cnty c, addr n, link k where k.link_id = insp_hist.link_id and k.addr_id = n.addr_id and c.cnty = n.cnty) as county_kw , "); strSql.Append(@" (select insp_regn_cde from insp_regn r, link k where k.link_id = insp_hist.link_id and k.insp_regn_id = r.insp_regn_id) as region_kw FROM insp_vst, insp_hist,"); strSql.Append(@" insp_typ_defn, insp_disp_typ, inspr, stff, lic WHERE insp_hist.insp_hist_id = insp_vst.insp_hist_id AND insp_vst.insp_vst_id = (SELECT NVL(max(s.alt_insp_vst_id), "); strSql.Append(@" max(s.insp_vst_id)) FROM insp_vst_synch s WHERE s.insp_vst_id = '"); strSql.Append(strInspVisitID); strSql.Append(@"') 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"); strSql.Append(@" lic.lic_id = insp_hist.lic_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 strMOD = ""; reader.Read(); strMOD = reader["inspector_name"].ToString(); Keyword kwdMOD = null; if (!String.IsNullOrEmpty(strMOD)) { KeywordType kwtMOD = app.Core.KeywordTypes.Find(gSaveToEnfInspector); if (kwtMOD != null) { kwdMOD = CreateKeywordHelper(kwtMOD, strMOD); } } 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 (kwdMOD != null) { keyModifier.AddKeyword(kwdMOD); } // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.", gSaveToEnfInspector, strMOD, _currentDocument.ID, Environment.NewLine); //Output the results to the OnBase Diagnostics Console app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output); } } else { throw new Exception(string.Format("No records found in database for {0}='{1}' and {4}{2}='{3}' ", gParamInspVisitID, strInspVisitID, gParamInspectorName, strInspectorName, Environment.NewLine)); } } } 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)); } }
/// <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(gParamFileNum); string strFileNum = ""; if (kwtLicNum != null) { KeywordRecord keyRecLicNum = _currentDocument.KeywordRecords.Find(kwtLicNum); if (keyRecLicNum != null) { Keyword kwdLicNum = keyRecLicNum.Keywords.Find(kwtLicNum); if (kwdLicNum != null) { strFileNum = CleanSeedKW(kwdLicNum.ToString()); } } } KeywordType kwtLicenseType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicType); 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()); } } } if (strFileNum == "") { throw new Exception(string.Format("Search keyword {0} is blank.", gSaveToDBA)); } if (strLicenseType == "") { throw new Exception(string.Format("Search keyword {0} is blank.", gParamLicType)); } //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)) { } //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 (select n.key_nme from link l, clnt_link_typ clt, link_typ lt, name n where c.lic_id = l.prnt_id and l.link_prnt_cde = 'L' and l.curr_ind = 'Y' "); strSql.Append(@" and l.clnt_link_typ_id = clt.clnt_link_typ_id and clt.link_typ_id = lt.link_typ_id and lt.link_typ_cde = 'DBA' and l.nme_id = n.nme_id and n.ent_nme_typ = 'D' "); strSql.Append(@" and n.cur_nme_ind = 'Y') as DBA, (select trim(a.str_addr_nbr||' '||a.addr_line1||' '||a.addr_line2||' '||a.addr_line3||' '||a.addr_cty||', '||a.st_cde||' '||a.addr_zip) "); strSql.Append(@" from link l, clnt_link_typ clt, link_typ lt, addr a where c.lic_id = l.prnt_id and l.link_prnt_cde = 'L' and l.curr_ind = 'Y' and l.clnt_link_typ_id = clt.clnt_link_typ_id "); strSql.Append(@" and clt.link_typ_id = lt.link_typ_id and lt.link_typ_cde = 'LL' and l.addr_id = a.addr_id) as LocationAddress, (select y.cnty_desc from link l, clnt_link_typ clt, link_typ lt, addr a, cnty y "); strSql.Append(@" where c.lic_id = l.prnt_id and l.link_prnt_cde = 'L' and l.curr_ind = 'Y' and l.clnt_link_typ_id = clt.clnt_link_typ_id "); strSql.Append(@" and clt.link_typ_id = lt.link_typ_id and lt.link_typ_cde = 'LL' and l.addr_id = a.addr_id and a.cnty = y.cnty) as LocationCounty from lic c"); strSql.Append(@" where c.clnt_cde = '"); strSql.Append(strLicenseType); strSql.Append(@"' and c.file_nbr = '"); strSql.Append(strFileNum); strSql.Append(@"'"); 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 strDBA = ""; string strCounty = ""; string strDesc = ""; reader.Read(); strDesc = reader["LocationAddress"].ToString(); strDBA = reader["DBA"].ToString(); strCounty = reader["LocationCounty"].ToString(); Keyword kwdDesc = null; if (!String.IsNullOrEmpty(strDesc)) { KeywordType kwtDesc = app.Core.KeywordTypes.Find(gSaveToLocationAddress); if (kwtDesc != null) { kwdDesc = CreateKeywordHelper(kwtDesc, strDesc); } } Keyword kwdDBA = null; if (!String.IsNullOrEmpty(strDBA)) { KeywordType kwtDBA = app.Core.KeywordTypes.Find(gSaveToDBA); if (kwtDBA != null) { kwdDBA = CreateKeywordHelper(kwtDBA, strDBA); } } Keyword kwdCounty = null; if (!String.IsNullOrEmpty(strCounty)) { KeywordType kwtCounty = app.Core.KeywordTypes.Find(gSaveToCounty); if (kwtCounty != null) { kwdCounty = CreateKeywordHelper(kwtCounty, strCounty); } } 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 (kwdDesc != null) { keyModifier.AddKeyword(kwdDesc); } if (kwdDBA != null) { keyModifier.AddKeyword(kwdDBA); } if (kwdCounty != null) { keyModifier.AddKeyword(kwdCounty); } // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}', {7}Keyword: '{2}' Value: '{3}', {7}Keyword: '{4}' Value: '{5}', {7}added to Document {6}.", gSaveToDBA, strDBA, gSaveToLocationAddress, strDesc, gSaveToCounty, strCounty, _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)); } }
/// <summary> /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />. /// <seealso cref="IWorkflowScript" /> /// </summary> /// <param name="app">Unity Application object</param> /// <param name="args">Workflow event arguments</param> // public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args) //public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args = null) public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args) { try { // Initialize global settings IntializeScript(ref app, ref args); KeywordType kwtLicenseType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicType); 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 kwtLicenseNum = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamFileNumber); string strFileNum = ""; if (kwtLicenseNum != null) { KeywordRecord keyRecLicenseNum = _currentDocument.KeywordRecords.Find(kwtLicenseNum); if (keyRecLicenseNum != null) { Keyword kwdLicenseNum = keyRecLicenseNum.Keywords.Find(kwtLicenseNum); if (kwdLicenseNum != null) { strFileNum = CleanSeedKW(kwdLicenseNum.ToString()); } } } if ((strFileNum == "") || (strLicenseType == "")) { throw new Exception(string.Format("Either {0} or {1} is blank.", gParamFileNumber, gParamLicType)); } //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 * from (select distinct(c.cmpln_nbr) as CASENUMBER, becec.enf_cde as ACTYPE, c.rcv_dte as ISSUEDATE, to_char(cacat.actv_strt_dte, 'MM/DD/YYYY') as CLERKEDDATE, ccscs.cmpln_sta_cde as COMPSTATUS, c.clnt_cde as LICTYPE "); strSql.Append(@", c1_mc.chrg_amt as FINEAMT from cmpln c inner join (select ec.enf_cde, bec.clnt_enf_cde_id from brd_enf_cde bec inner join enf_cde ec on bec.enf_cde_id = ec.enf_cde_id where (ec.enf_cde like 'CLOS' or ec.clnt_cde like 'AD%' or ec.enf_cde like 'AC%') ) becec on c.clnt_cmpln_cls_id = becec.clnt_enf_cde_id inner join "); strSql.Append(@"(select cs.cmpln_sta_cde, ccs.clnt_cmpln_sta_id from clnt_cmpln_sta ccs inner join cmpln_sta cs on ccs.cmpln_sta_id = cs.cmpln_sta_id ) ccscs on c.clnt_cmpln_sta_id = ccscs.clnt_cmpln_sta_id inner join (select l.file_nbr, l.clnt_cde, l.lic_id, r.cmpln_id from rspn r inner join lic l on r.lic_id = l.lic_id ) rl "); strSql.Append(@" on c.cmpln_id = rl.cmpln_id left outer join (select ca.actv_strt_dte, ca.cmpln_id from cmpln_actv ca inner join cmpln_actv_typ cat on ca.cmpln_actv_typ_id = cat.cmpln_actv_typ_id where cat.cmpln_actv_typ_cde = 'A400' ) cacat on c.cmpln_id = cacat.cmpln_id left outer join (select mc.chrg_amt, c1.cmpln_id from cmply_ordr c1 inner join misc_chrg mc on c1.misc_chrg_id = mc.misc_chrg_id ) c1_mc on c.cmpln_id = c1_mc.cmpln_id where rl.file_nbr = '"); strSql.Append(strFileNum); strSql.Append(@"' and rl.clnt_cde = '"); strSql.Append(strLicenseType); strSql.Append(@"' and c.rcv_dte > (SYSDATE - 1826) and c.clnt_cde like '20%' and c.cmpln_nbr > '2010%') order by 1 desc "); 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) { while (reader.Read()) { lstProp1.Add(reader["CASENUMBER"].ToString()); lstProp2.Add(reader["ACTYPE"].ToString()); lstProp3.Add(reader["ISSUEDATE"].ToString()); lstProp4.Add(reader["CLERKEDDATE"].ToString()); lstProp5.Add(reader["COMPSTATUS"].ToString()); lstProp6.Add(reader["LICTYPE"].ToString()); lstProp7.Add(reader["FINEAMT"].ToString()); } // Create keyword modifier object to hold keyword changes EForm currentForm = _currentDocument.EForm; FieldModifier fieldModifier = currentForm.CreateFieldModifier(); foreach (string props in lstProp1) { if (props != null) { fieldModifier.UpdateField("CASENUMBER", props); } } foreach (string props in lstProp2) { if (props != null) { fieldModifier.UpdateField("ACTYPE", props); } } foreach (string props in lstProp3) { if (props != null) { fieldModifier.UpdateField("ISSUEDATE", props); } } foreach (string props in lstProp4) { if (props != null) { fieldModifier.UpdateField("CLERKEDDATE", props); } } foreach (string props in lstProp5) { if (props != null) { fieldModifier.UpdateField("COMPSTATUS", props); } } foreach (string props in lstProp6) { if (props != null) { fieldModifier.UpdateField("LICTYPE", props); } } foreach (string props in lstProp7) { if (props != null) { fieldModifier.UpdateField("FINEAMT", props); } } using (DocumentLock documentLock = _currentDocument.LockDocument()) { // Ensure lock was obtained if (documentLock.Status != DocumentLockStatus.LockObtained) { throw new Exception("Document lock not obtained"); } // Apply keyword change to the document fieldModifier.ApplyChanges(); documentLock.Release(); } } else { throw new Exception(string.Format("No records found in database for {0}='{1}' and {4}{2}='{3}' ", gParamLicType, strLicenseType, gParamFileNumber, strFileNum, Environment.NewLine)); } } } 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)); } }
/// <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 Application # keywords for passing to LicEase database KeywordType kwtAppNum = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamAppNum); string strAppNum = ""; if (kwtAppNum != null) { KeywordRecord keyRecFileNum = _currentDocument.KeywordRecords.Find(kwtAppNum); if (keyRecFileNum != null) { Keyword kwdFileNum = keyRecFileNum.Keywords.Find(kwtAppNum); if (kwdFileNum != null) { strAppNum = CleanSeedKW(kwdFileNum.ToString()); } } } KeywordType kwtLicenseType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicType); 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()); } } } if ((strAppNum == "") || (strLicenseType == "")) { throw new Exception(string.Format("Either {0} or {1} is blank.", gParamAppNum, gParamLicType)); } //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 f.mod_desc AS PLANMOD FROM appl a, appl_mdf m, mdf f"); strSql.Append(@" WHERE a.applc_id = m.applc_id AND m.mod_id = f.mod_id AND"); strSql.Append(@" f.mod_typ = 'K' AND a.clnt_cde = '"); strSql.Append(strLicenseType); strSql.Append(@"' AND a.applc_nbr = '"); strSql.Append(strAppNum); strSql.Append(@"'"); 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 strMOD = ""; reader.Read(); strMOD = reader["PLANMOD"].ToString(); Keyword kwdMOD = null; if (!String.IsNullOrEmpty(strMOD)) { KeywordType kwtMOD = app.Core.KeywordTypes.Find(gSaveToPlanMod); if (kwtMOD != null) { kwdMOD = CreateKeywordHelper(kwtMOD, strMOD); } } 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 (kwdMOD != null) { keyModifier.AddKeyword(kwdMOD); } // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.", gSaveToPlanMod, strMOD, _currentDocument.ID, Environment.NewLine); //Output the results to the OnBase Diagnostics Console app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output); } } else { throw new Exception(string.Format("No records found in database for {0}='{1}' and {4}{2}='{3}' ", gParamLicType, strLicenseType, gParamAppNum, strAppNum, Environment.NewLine)); } } } 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)); } }
/// <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 Application # keywords for passing to LicEase database KeywordType kwtAppNum = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamAppNum); string strAppNum = ""; if (kwtAppNum != null) { KeywordRecord keyRecFileNum = _currentDocument.KeywordRecords.Find(kwtAppNum); if (keyRecFileNum != null) { Keyword kwdFileNum = keyRecFileNum.Keywords.Find(kwtAppNum); if (kwdFileNum != null) { strAppNum = CleanSeedKW(kwdFileNum.ToString()); } } } if (strAppNum == "") { throw new Exception(string.Format("App Num is blank!")); } //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 c.lic_nbr as Brand_Lic_Number, (select n.org_nme from link l, clnt_link_typ clt, link_typ lt, name n "); strSql.Append(@" where c.xent_id = l.xent_id and l.link_prnt_cde is Null and l.curr_ind = 'Y' and l.clnt_link_typ_id = clt.clnt_link_typ_id"); strSql.Append(@" and clt.link_typ_id = lt.link_typ_id and lt.link_typ_cde = 'MA' and l.nme_id = n.nme_id and n.ent_nme_typ = 'P' and n.cur_nme_ind = 'Y') as Key_Name, "); strSql.Append(@" (select cr.vald_nbr from csh_pmt cp, csh_rcpt cr where cp.chrg_id = a.applc_id and cp.csh_rcpt_id = cr.csh_rcpt_id and cp.chrg_typ = 'A' "); strSql.Append(@" and cr.csh_rcpt_id = (select max (cp2.csh_rcpt_id) from csh_pmt cp2 where cp2.chrg_id = cp.chrg_id and cp2.chrg_typ = 'A')) as Validation_Number, "); strSql.Append(@" x.xact_cde as Tran_Code from lic c, appl a, xact_defn x where a.applc_nbr = ' "); strSql.Append(strAppNum); strSql.Append(@"' and c.clnt_cde = '4008' and c.lic_id = a.lic_id and a.xact_defn_id = x.xact_defn_id "); 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 strTranCode = ""; string strKeyName = ""; string strValNum = ""; string strBrandNum = ""; reader.Read(); strTranCode = reader["Tran_Code"].ToString(); strKeyName = reader["Key_Name"].ToString(); strValNum = reader["Validation_Number"].ToString(); strBrandNum = reader["Brand_Lic_Number"].ToString(); Keyword kwdTranCode = null; if (!String.IsNullOrEmpty(strTranCode)) { KeywordType kwtTranCode = app.Core.KeywordTypes.Find(gSaveToTranNum); if (kwtTranCode != null) { kwdTranCode = CreateKeywordHelper(kwtTranCode, strTranCode); } } Keyword kwdKeyName = null; if (!String.IsNullOrEmpty(strKeyName)) { KeywordType kwtKeyName = app.Core.KeywordTypes.Find(gSaveToKeyName); if (kwtKeyName != null) { kwdKeyName = CreateKeywordHelper(kwtKeyName, strKeyName); } } Keyword kwdValNum = null; if (!String.IsNullOrEmpty(strValNum)) { KeywordType kwtValNum = app.Core.KeywordTypes.Find(gSaveToValNum); if (kwtValNum != null) { kwdValNum = CreateKeywordHelper(kwtValNum, strValNum); } } Keyword kwdBrandNum = null; if (!String.IsNullOrEmpty(strBrandNum)) { KeywordType kwtBrandNum = app.Core.KeywordTypes.Find(gSaveToLicNum); if (kwtBrandNum != null) { kwdBrandNum = CreateKeywordHelper(kwtBrandNum, strBrandNum); } } 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 (kwdTranCode != null) { keyModifier.AddKeyword(kwdTranCode); } if (kwdKeyName != null) { keyModifier.AddKeyword(kwdKeyName); } if (kwdValNum != null) { keyModifier.AddKeyword(kwdValNum); } if (kwdBrandNum != null) { keyModifier.AddKeyword(kwdBrandNum); } // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}', {9}Keyword: '{2}' Value: '{3}', {9}Keyword: '{4}' Value: '{5}', {9}Keyword: '{6}' Value: '{7}', {9}added to Document {8}.", gSaveToTranNum, strTranCode, gSaveToKeyName, strKeyName, gSaveToLicNum, strBrandNum, gSaveToValNum, strValNum, _currentDocument.ID, Environment.NewLine); //Output the results to the OnBase Diagnostics Console app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output); } } else { throw new Exception(string.Format("No records found in database for {0}='{1}' ", gParamAppNum, strAppNum)); } } } 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)); } }
/// <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 kwtCaseNum = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamCaseNum); string strCaseNum = ""; if (kwtCaseNum != null) { KeywordRecord keyRecFileNum = _currentDocument.KeywordRecords.Find(kwtCaseNum); if (keyRecFileNum != null) { Keyword kwdFileNum = keyRecFileNum.Keywords.Find(kwtCaseNum); if (kwdFileNum != null) { strCaseNum = CleanSeedKW(kwdFileNum.ToString()); } } } KeywordType kwtLicenseType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicType); 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()); } } } if ((strCaseNum == "") || (strLicenseType == "")) { throw new Exception(string.Format("Either {0} or {1} is blank.", gParamCaseNum, gParamLicType)); } //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 "); strSql.Append(@" (SELECT clnt.clnt_lng_nme "); strSql.Append(@" FROM clnt clnt "); strSql.Append(@" WHERE a.clnt_cde = clnt.clnt_cde) AS Profession, "); strSql.Append(@" (SELECT clnt3.clnt_lng_nme "); strSql.Append(@" FROM clnt clnt2, clnt clnt3 "); strSql.Append(@" WHERE a.clnt_cde = clnt2.clnt_cde "); strSql.Append(@" AND clnt2.clnt_cde_prnt = clnt3.clnt_cde) AS BOARD, "); strSql.Append(@" (SELECT x.key_nme "); strSql.Append(@" FROM invl_party y, link u, clnt_link_typ v, link_typ w, name x "); strSql.Append(@" WHERE a.cmpln_id = y.cmpln_id "); strSql.Append(@" AND y.xent_id = u.xent_id "); strSql.Append(@" AND y.invl_party_id = u.prnt_id "); strSql.Append(@" AND u.link_prnt_cde = 'I' "); strSql.Append(@" AND u.curr_ind = 'Y' "); strSql.Append(@" AND u.clnt_link_typ_id = v.clnt_link_typ_id "); strSql.Append(@" AND v.link_typ_id = w.link_typ_id "); strSql.Append(@" AND w.link_typ_cde = 'CM' "); strSql.Append(@" AND u.nme_id = x.nme_id "); strSql.Append(@" AND x.ent_nme_typ = 'R' "); strSql.Append(@" AND x.cur_nme_ind = 'Y') as COMPLAINANT, "); strSql.Append(@" (SELECT n.key_nme "); strSql.Append(@" FROM rspn r, link l, clnt_link_typ clt, link_typ lt, name n "); strSql.Append(@" WHERE a.cmpln_id = r.cmpln_id "); strSql.Append(@" AND r.rspn_id = l.prnt_id "); strSql.Append(@" AND l.link_prnt_cde = 'R' "); strSql.Append(@" AND l.curr_ind = 'Y' "); strSql.Append(@" AND l.clnt_link_typ_id = clt.clnt_link_typ_id "); strSql.Append(@" AND clt.link_typ_id = lt.link_typ_id "); strSql.Append(@" AND lt.link_typ_cde = 'RS' "); strSql.Append(@" AND l.nme_id = n.nme_id "); strSql.Append(@" AND n.ent_nme_typ = 'R' "); strSql.Append(@" AND n.cur_nme_ind = 'Y') as SUBJECT "); strSql.Append(@" FROM cmpln a "); strSql.Append(@" WHERE a.clnt_cde = '"); strSql.Append(strLicenseType); strSql.Append(@"' AND a.cmpln_nbr = '"); strSql.Append(strCaseNum); strSql.Append(@"'"); 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 strBoard = ""; string strSubject = ""; string strComplainant = ""; reader.Read(); strBoard = reader["BOARD"].ToString(); strSubject = reader["SUBJECT"].ToString(); strComplainant = reader["COMPLAINANT"].ToString(); Keyword kwdBoard = null; if (!String.IsNullOrEmpty(strBoard)) { KeywordType kwtBoard = app.Core.KeywordTypes.Find(gSaveToBoard); if (kwtBoard != null) { kwdBoard = CreateKeywordHelper(kwtBoard, strBoard); } } Keyword kwdSubject = null; if (!String.IsNullOrEmpty(strSubject)) { KeywordType kwtSubject = app.Core.KeywordTypes.Find(gSaveToSubject); if (kwtSubject != null) { kwdSubject = CreateKeywordHelper(kwtSubject, strSubject); } } Keyword kwdComplainant = null; if (!String.IsNullOrEmpty(strComplainant)) { KeywordType kwtComplainant = app.Core.KeywordTypes.Find(gSaveToComplainant); if (kwtComplainant != null) { kwdComplainant = CreateKeywordHelper(kwtComplainant, strComplainant); } } 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 (kwdBoard != null) { keyModifier.AddKeyword(kwdBoard); } if (kwdSubject != null) { keyModifier.AddKeyword(kwdSubject); } if (kwdComplainant != null) { keyModifier.AddKeyword(kwdComplainant); } // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}', {7}Keyword: '{2}' Value: '{3}', {7}Keyword: '{4}' Value: '{5}', {7}added to Document {6}.", gSaveToBoard, strBoard, gSaveToSubject, strSubject, gSaveToComplainant, strComplainant, _currentDocument.ID, Environment.NewLine); //Output the results to the OnBase Diagnostics Console app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output); } } else { throw new Exception(string.Format("No records found in database for {0}='{1}' and {4}{2}='{3}' ", gParamLicType, strLicenseType, gParamCaseNum, strCaseNum, Environment.NewLine)); } } } 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)); } }
/// <summary> /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />. /// <seealso cref="IWorkflowScript" /> /// </summary> /// <param name="app">Unity Application object</param> /// <param name="args">Workflow event arguments</param> public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args) // public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args=null) { try { // Initialize global settings IntializeScript(ref app, ref args); KeywordType ktwBatchType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamBatchType); string strBatchType = ""; if (ktwBatchType != null) { KeywordRecord keyRecBatchType = _currentDocument.KeywordRecords.Find(ktwBatchType); if (keyRecBatchType != null) { Keyword kwdBatchType = keyRecBatchType.Keywords.Find(ktwBatchType); if (kwdBatchType != null) { strBatchType = kwdBatchType.ToString(); } } } if (strBatchType == "") { throw new Exception(string.Format("{0} is blank.", gParamBatchType)); } KeywordType ktwTranCode = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamTranCode); string strTranCode = ""; if (ktwTranCode != null) { KeywordRecord keyRecTranCode = _currentDocument.KeywordRecords.Find(ktwTranCode); if (keyRecTranCode != null) { Keyword kwdTranCode = keyRecTranCode.Keywords.Find(ktwTranCode); if (kwdTranCode != null) { strTranCode = kwdTranCode.ToString(); } } } KeywordType ktwLicType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicType); string strLicType = ""; if (ktwLicType != null) { KeywordRecord keyRecLicType = _currentDocument.KeywordRecords.Find(ktwLicType); if (keyRecLicType != null) { Keyword kwdLicType = keyRecLicType.Keywords.Find(ktwLicType); if (kwdLicType != null) { strLicType = kwdLicType.ToString(); } } } if (strLicType == "") { throw new Exception(string.Format("{0} is blank.", gParamLicType)); } //access Config Item for OnBase User string gUSER = ""; if (app.Configuration.TryGetValue("OnBaseUser", out gUSER)) { } //access Config Item for OnBase Password string gPASS = ""; if (app.Configuration.TryGetValue("OnBasePassword", out gPASS)) { } /* COMMENT THIS SECTION OUT WHEN MOVING TO PROD */ //access Config Item for OnBase UAT ODBC string gODBCBET = ""; if (app.Configuration.TryGetValue("BETOnBaseMISC", out gODBCBET)) { } string gODBCOnBase = ""; if (app.Configuration.TryGetValue("OnBaseUAT", out gODBCOnBase)) { } /* UNCOMMENT THIS SECTION WHEN MOVING TO PROD * //access Config Item for OnBase PROD ODBC * string gODBCOnBase = ""; * if (app.Configuration.TryGetValue("OnBasePROD", out gODBCOnBase)) * { * } */ string obDocTypeFull = _currentDocument.DocumentType.Name.ToString(); string obDocType = obDocTypeFull.Substring(7); if (strTranCode != "" && strLicType != "") { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Trans Code and License Type Present")); //StringBuilder strSql = new StringBuilder(); strSql.Append(@"SELECT users AS USER, proc_unit AS UNIT, last_user AS LASTUSER "); strSql.Append(@" FROM dbo.tbl_ccb "); strSql.Append(@" WHERE license_type = '"); strSql.Append(strLicType); strSql.Append(@"' AND tran_code = '"); strSql.Append(strTranCode); strSql.Append(@"'"); } else if (strLicType != "" && strTranCode == "" && (strBatchType == "BET - CAND. (FEE)" || strBatchType == "BET - CAND. (NON FEE)")) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("BET - CAND FEE or NON FEE")); string strMidLicType = strLicType.Substring(1, 2); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("LicType {0}, Doc Type - Description {1}", strMidLicType, obDocType)); //StringBuilder strSql = new StringBuilder(); strSql.Append(@"SELECT users AS USER, proc_unit AS UNIT, last_user AS LASTUSER "); strSql.Append(@" FROM dbo.tbl_ccb "); strSql.Append(@" WHERE license_type = '"); strSql.Append(strMidLicType); strSql.Append(@"' AND description = '"); strSql.Append(obDocType); strSql.Append(@"'"); } else if (strLicType != "" && strTranCode == "") { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("License Type but NO Trans Code")); strSql.Append(@"SELECT users AS USER, proc_unit AS UNIT, last_user AS LASTUSER "); strSql.Append(@" FROM dbo.tbl_ccb "); strSql.Append(@" WHERE license_type = '"); strSql.Append(strLicType); strSql.Append(@"' AND description = '"); strSql.Append(obDocType); strSql.Append(@"'"); } app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Sql Query: {0}", strSql.ToString())); string connectionString = string.Format("DSN={0};Uid={1};Pwd={2};", gODBCBET, gUSER, gPASS); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionString)); 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 strUser = ""; string strUnit = ""; List <string> lstUser = new List <string>(); //string strLastUser = ""; reader.Read(); lstUser.Add(reader["USER"].ToString()); //strUser = reader["USER"].ToString(); //strLastUser = reader["LASTUSER"].ToString(); strUnit = reader["UNIT"].ToString(); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Checking Users")); string strSQLUsers = ""; foreach (string result in lstUser) { if (result != "" && strSQLUsers == "") { strSQLUsers = "'" + strSQLUsers + result + "'"; } else if (result != "" && strSQLUsers != "") { strSQLUsers = strSQLUsers + ",'" + result + "'"; } } app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("users to pass to OnBase " + strSQLUsers)); //StringBuilder strSql = new StringBuilder(); strSql.Append(@"SELECT TOP 1 ua.username AS WFUSER "); strSql.Append(@" FROM hsi.useraccount ua "); strSql.Append(@" LEFT OUTER JOIN (SELECT usernum FROM hsi.itemlcxuser "); strSql.Append(@" WHERE hsi.itemlcxuser.lcnum = "); strSql.Append(gLCNUM); strSql.Append(@" ) ilcu ON us.usernum = ilcu.usernum "); strSql.Append(@" WHERE ua.username IN("); strSql.Append(strSQLUsers); strSql.Append(@"'"); string connectionStringOnBase = string.Format("DSN={0};Uid={1};Pwd={2};", gODBCOnBase, gUSER, gPASS); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionStringOnBase)); using (OdbcConnection conOnBase = new OdbcConnection(connectionStringOnBase)) { try { conOnBase.Open(); using (OdbcCommand commandOnBase = new OdbcCommand(strSql.ToString(), conOnBase)) using (OdbcDataReader readerOnBase = commandOnBase.ExecuteReader()) { if (readerOnBase.HasRows) { strWFUser = readerOnBase["WFUSER"].ToString(); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("WFUser set to " + strWFUser)); } } } catch (Exception ex) { throw new ApplicationException("Error during database operations!", ex); } finally { if (conOnBase.State == ConnectionState.Open) { conOnBase.Close(); } } } Keyword kwdUnit = null; if (!String.IsNullOrEmpty(strUnit)) { KeywordType kwtUnit = app.Core.KeywordTypes.Find(gSaveToAssignedProcUnit); if (kwtUnit != null) { kwdUnit = CreateKeywordHelper(kwtUnit, strUnit); } } Keyword kwdUser = null; if (!String.IsNullOrEmpty(strWFUser)) { KeywordType kwtUser = app.Core.KeywordTypes.Find(gSaveToAssignedProc); if (kwtUser != null) { kwdUser = CreateKeywordHelper(kwtUser, strWFUser); } } 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 (kwdUnit != null) { keyModifier.AddKeyword(kwdUnit); } if (kwdUser != null) { keyModifier.AddKeyword(kwdUser); } // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.", gSaveToAssignedProcUnit, strUnit, _currentDocument.ID, Environment.NewLine); //Output the results to the OnBase Diagnostics Console app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output); string output2 = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.", gSaveToAssignedProc, strWFUser, _currentDocument.ID, Environment.NewLine); app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output2); } } else { throw new Exception(string.Format("No records found in database for {0}='{1}'", gParamBatchType, strBatchType)); } } } 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)); } }
/// <summary> /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />. /// <seealso cref="IWorkflowScript" /> /// </summary> /// <param name="app">Unity Application object</param> /// <param name="args">Workflow event arguments</param> public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args) //public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args = null) { try { // Initialize global settings IntializeScript(ref app, ref args); KeywordType kwtLicenseType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicType); 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 kwtLicenseNum = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicNum); string strLicenseNum = ""; if (kwtLicenseNum != null) { KeywordRecord keyRecLicenseNum = _currentDocument.KeywordRecords.Find(kwtLicenseNum); if (keyRecLicenseNum != null) { Keyword kwdLicenseNum = keyRecLicenseNum.Keywords.Find(kwtLicenseNum); if (kwdLicenseNum != null) strLicenseNum = CleanSeedKW(kwdLicenseNum.ToString()); } } if ((strLicenseNum == "") || (strLicenseType == "")) { throw new Exception(string.Format("Either {0} or {1} is blank.", gParamLicNum, gParamLicType)); } //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 l.file_nbr AS FILENUM, n.key_nme AS KEYNAME, l.xent_id AS INDNUM "); strSql.Append(@" FROM Lic l "); strSql.Append(@" left join name n on l.xent_id = n.xent_id "); strSql.Append(@" WHERE l.clnt_cde = '"); strSql.Append(strLicenseType); strSql.Append(@"' CAST(l.lic_nbr AS number) = '"); strSql.Append(strLicenseNum); strSql.Append(@"' AND n.ent_nme_typ = 'D' AND n.cur_nme_ind = 'Y' AND rownum = '1'"); 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 strFileNum = ""; string strKeyName = ""; string strIndNum = ""; reader.Read(); strFileNum = reader["FILENUM"].ToString(); strKeyName = reader["KEYNAME"].ToString(); strIndNum = reader["INDNUM"].ToString(); 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 kwdIndNum = null; if (!String.IsNullOrEmpty(strIndNum)) { KeywordType kwtIndNum = app.Core.KeywordTypes.Find(gSaveToIndNum); if (kwtIndNum != null) kwdIndNum = CreateKeywordHelper(kwtIndNum, strIndNum); } 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 (kwdFileNum != null) keyModifier.AddKeyword(kwdFileNum); if (kwdKeyName != null) keyModifier.AddKeyword(kwdKeyName); if (kwdIndNum != null) keyModifier.AddKeyword(kwdIndNum); // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}', {7}Keyword: '{2}' Value: '{3}', {7}Keyword: '{4}' Value: '{5}', {7}added to Document {6}.", gSaveToFileNum, strFileNum, gSaveToKeyName, strKeyName, gSaveToIndNum, strIndNum, _currentDocument.ID, Environment.NewLine); //Output the results to the OnBase Diagnostics Console app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output); } } else { throw new Exception(string.Format("No records found in database for {0}='{1}' and {4}{2}='{3}' ", gParamLicType, strLicenseType, gParamLicNum, strLicenseNum, Environment.NewLine)); } } } 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)); } }
/// <summary> /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />. /// <seealso cref="IWorkflowScript" /> /// </summary> /// <param name="app">Unity Application object</param> /// <param name="args">Workflow event arguments</param> public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args) // public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args=null) { try { // Initialize global settings IntializeScript(ref app, ref args); KeywordType ktwBatchType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamBatchType); string strBatchType = ""; if (ktwBatchType != null) { KeywordRecord keyRecFileNum = _currentDocument.KeywordRecords.Find(ktwBatchType); if (keyRecFileNum != null) { Keyword kwdBatchType = keyRecFileNum.Keywords.Find(ktwBatchType); if (kwdBatchType != null) { strBatchType = kwdBatchType.ToString(); } } } if (strBatchType == "") { throw new Exception(string.Format("{0} is blank.", gParamBatchType)); } //access Config Item for OnBase User string gUSER = ""; if (app.Configuration.TryGetValue("OnBaseUser", out gUSER)) { } //access Config Item for OnBase Password string gPASS = ""; if (app.Configuration.TryGetValue("OnBasePassword", out gPASS)) { } /* COMMENT THIS SECTION OUT WHEN MOVING TO PROD */ //access Config Item for OnBase UAT ODBC string gODBC = ""; if (app.Configuration.TryGetValue("OnBaseUAT", out gODBC)) { } /* UNCOMMENT THIS SECTION WHEN MOVING TO PROD * //access Config Item for OnBase PROD ODBC * string gODBC = ""; * if (app.Configuration.TryGetValue("OnBasePROD", 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 TOP 1 ua.username AS PROFILER "); strSql.Append(@" FROM hsi.userxusergroup ux "); strSql.Append(@" INNER JOIN hsi.useraccount ua on ua.usernum = ux.usernum "); strSql.Append(@" INNER JOIN hsi.usergroup ug on ug.usergroupnum = ux.usergroupnum "); strSql.Append(@" where ug.usergroupname = '"); strSql.Append(strBatchType); strSql.Append(@"' ORDER BY NEWID()'"); 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 strProf = ""; reader.Read(); strProf = reader["PROFILER"].ToString(); Keyword kwdProf = null; if (!String.IsNullOrEmpty(strProf)) { KeywordType kwtProf = app.Core.KeywordTypes.Find(gSaveToAssignedProf); if (kwtProf != null) { kwdProf = CreateKeywordHelper(kwtProf, strProf); } } 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 (kwdProf != null) { keyModifier.AddKeyword(kwdProf); } // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.", gSaveToAssignedProf, strProf, _currentDocument.ID, Environment.NewLine); //Output the results to the OnBase Diagnostics Console app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output); } } else { throw new Exception(string.Format("No records found in database for {0}='{1}'", gParamBatchType, strBatchType)); } } } 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)); } }
/// <summary> /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />. /// <seealso cref="IWorkflowScript" /> /// </summary> /// <param name="app">Unity Application object</param> /// <param name="args">Workflow event arguments</param> public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args) //public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args = null) { try { // Initialize global settings IntializeScript(ref app, ref args); KeywordType kwtLicenseType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamCase); 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()); } } } if (strLicenseType == "") { throw new Exception(string.Format(" {0} is blank.", gParamCase)); } //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 to_char(max(ca.actv_strt_dte), 'MM/DD/YYYY') as ACSERVED, to_char(max(ca.actv_strt_dte + 21), 'MM/DD/YYYY') as DAYS21 "); strSql.Append(@" from cmpln, cmpln_actv ca, cmpln_actv_typ cat where cmpln.cmpln_nbr = ' "); strSql.Append(strLicenseType); strSql.Append(@"' and cmpln.cmpln_id = ca.cmpln_id and ca.cmpln_actv_typ_id = cat.cmpln_actv_typ_id and cat.cmpln_actv_typ_cde = 'A180' and cmpln.clnt_cde like '20%' "); 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 str21 = ""; string strService = ""; reader.Read(); str21 = reader["DAYS21"].ToString(); strService = reader["ACSERVED"].ToString(); Keyword kwdFileNum = null; if (!String.IsNullOrEmpty(str21)) { KeywordType kwtFileNum = app.Core.KeywordTypes.Find(gSaveToServiceDate); if (kwtFileNum != null) { kwdFileNum = CreateKeywordHelper(kwtFileNum, str21); } } Keyword kwdKeyName = null; if (!String.IsNullOrEmpty(strService)) { KeywordType kwtKeyName = app.Core.KeywordTypes.Find(gSaveTo21); if (kwtKeyName != null) { kwdKeyName = CreateKeywordHelper(kwtKeyName, strService); } } 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 (kwdFileNum != null) { keyModifier.AddKeyword(kwdFileNum); } if (kwdKeyName != null) { keyModifier.AddKeyword(kwdKeyName); } // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}', {7}Keyword: '{2}' Value: '{3}', {5}added to Document {4}.", gSaveToServiceDate, str21, gSaveTo21, strService, _currentDocument.ID, Environment.NewLine); //Output the results to the OnBase Diagnostics Console app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output); } } else { throw new Exception(string.Format("No records found in database for {0}='{1}' ", gParamCase, strLicenseType)); } } } 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)); } }
/// <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 Inspection Visit ID keyword for passing to LicEase database - says license type, but is passing ID KeywordType kwtLicenseType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gSaveToInspectionVisitID); 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()); } } } if (strLicenseType == "") { throw new Exception(string.Format("Inspection Visit ID is blank!")); } //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.cmpln_nbr As COMPLAINTNUM from insp_vst iv, insp_hist ih, cmpln a "); strSql.Append(@" where iv.insp_vst_id = '"); strSql.Append(strLicenseType); strSql.Append(@"' and iv.insp_hist_id = ih.insp_hist_id and ih.cmpln_id = a.cmpln_id"); 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 strCaseNum = ""; reader.Read(); strCaseNum = reader["COMPLAINTNUM"].ToString(); Keyword kwdLicNum = null; if (!String.IsNullOrEmpty(strCaseNum)) { KeywordType kwtLicNum = app.Core.KeywordTypes.Find(gSaveToCaseNum); if (kwtLicNum != null) { kwdLicNum = CreateKeywordHelper(kwtLicNum, strCaseNum); } } 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 (kwdLicNum != null) { keyModifier.AddKeyword(kwdLicNum); } // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}' added to Document {2}.", gSaveToCaseNum, strCaseNum, _currentDocument.ID); //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 for {0}='{1}' and {4}{2}='{3}' ", gSaveToInspectionVisitID, strLicenseType, gParamAppNum, strCaseNum, Environment.NewLine)); } } } 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)); } }
/// <summary> /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />. /// <seealso cref="IWorkflowScript" /> /// </summary> /// <param name="app">Unity Application object</param> /// <param name="args">Workflow event arguments</param> // public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args) //public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args = null) public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args) { try { // Initialize global settings IntializeScript(ref app, ref args); KeywordType kwtISN = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamISN); string strISN = ""; if (kwtISN != null) { KeywordRecord keyISN = _currentDocument.KeywordRecords.Find(kwtISN); if (keyISN != null) { Keyword kwdISN = keyISN.Keywords.Find(kwtISN); if (kwdISN != null) { strISN = kwdISN.ToString(); } } } if (strISN == "") { throw new Exception(string.Format("Search keyword {0} is blank.", gSaveToISN)); } string strCountry = ""; string strTheater = ""; string strPower = ""; string strSequence = ""; string strDetainee = ""; strCountry = strISN.Substring(0, 2); strTheater = strISN.Substring(2, 1); strPower = strISN.Substring(3, 2); strSequence = strISN.Substring(5, 6); strDetainee = strISN.Substring(11, 2); string strTheaterResult = ""; switch (strTheater) { case "A": strTheaterResult = "TRANSCOM"; break; case "1": strTheaterResult = "FORSCOM"; break; case "2": strTheaterResult = "AFRICOM"; break; case "3": strTheaterResult = "PACOM"; break; case "4": strTheaterResult = "EUCOM"; break; case "5": strTheaterResult = "PACOM"; break; case "6": strTheaterResult = "SOUTHCOM"; break; case "7": strTheaterResult = "SPACECOM"; break; case "8": strTheaterResult = "STRATCOM"; break; case "9": strTheaterResult = "CENTCOM"; break; default: strTheaterResult = "UNDETERMINED"; break; } Keyword kwdCountry = null; if (!String.IsNullOrEmpty(strCountry)) { KeywordType kwtCountry = app.Core.KeywordTypes.Find(gSaveToCountry); if (kwtCountry != null) { kwdCountry = CreateKeywordHelper(kwtCountry, strCountry); } } Keyword kwdTheater = null; if (!String.IsNullOrEmpty(strTheaterResult)) { KeywordType kwtTheater = app.Core.KeywordTypes.Find(gSaveToTheater); if (kwtTheater != null) { kwdTheater = CreateKeywordHelper(kwtTheater, strTheaterResult); } } Keyword kwdPower = null; if (!String.IsNullOrEmpty(strPower)) { KeywordType kwtPower = app.Core.KeywordTypes.Find(gSaveToPower); if (kwtPower != null) { kwdPower = CreateKeywordHelper(kwtPower, strPower); } } Keyword kwdSequence = null; if (!String.IsNullOrEmpty(strSequence)) { KeywordType kwtSequence = app.Core.KeywordTypes.Find(gSaveToSequence); if (kwtSequence != null) { kwdSequence = CreateKeywordHelper(kwtSequence, strSequence); } } Keyword kwdDetainee = null; if (!String.IsNullOrEmpty(strDetainee)) { KeywordType kwtDetainee = app.Core.KeywordTypes.Find(gSaveToDetainee); if (kwtDetainee != null) { kwdDetainee = CreateKeywordHelper(kwtDetainee, strDetainee); } } 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(); keyModifier.AddKeyword(kwdCountry); keyModifier.AddKeyword(kwdTheater); keyModifier.AddKeyword(kwdPower); keyModifier.AddKeyword(kwdSequence); keyModifier.AddKeyword(kwdDetainee); // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}', {11}Keyword: '{2}' Value: '{3}', {11}Keyword: '{4}' Value: '{5}', {11}Keyword: '{6}' Value: '{7}'," + "{11}Keyword: '{8}' Value: '{9}', {11}added to Document {10}.", gSaveToCountry, strCountry, gSaveToTheater, strTheater, gSaveToPower, strPower, gSaveToSequence, strSequence, gSaveToDetainee, strDetainee, _currentDocument.ID, Environment.NewLine); //Output the results to the OnBase Diagnostics Console app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output); documentLock.Release(); } } 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)); } }
/// <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)); } }
/// <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 kwtAppNum = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamAppNum); string strAppNum = ""; if (kwtAppNum != null) { KeywordRecord keyRecLicNum = _currentDocument.KeywordRecords.Find(kwtAppNum); if (keyRecLicNum != null) { Keyword kwdLicNum = keyRecLicNum.Keywords.Find(kwtAppNum); if (kwdLicNum != null) { strAppNum = CleanSeedKW(kwdLicNum.ToString()); } } } KeywordType kwtLicenseType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicType); 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()); } } } if (strAppNum == "") { throw new Exception(string.Format("Search keyword {0} is blank.", gParamAppNum)); } if (strLicenseType == "") { throw new Exception(string.Format("Search keyword {0} is blank.", gParamLicType)); } //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)) { } //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 lic.clnt_cde, lic.lic_nbr as License_Number from appl, lic where appl.lic_id = lic.lic_id"); strSql.Append(@" and appl.applc_nbr = '"); strSql.Append(strAppNum); strSql.Append(@"' and appl.clnt_cde = '"); strSql.Append(strLicenseType); strSql.Append(@"')"); 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 strLicNum = ""; reader.Read(); strLicNum = reader["License_Number"].ToString(); Keyword kwdLicenseNum = null; if (!String.IsNullOrEmpty(strLicNum)) { KeywordType kwtLicenseNum = app.Core.KeywordTypes.Find(gSaveToLicNum); if (kwtLicenseNum != null) { kwdLicenseNum = CreateKeywordHelper(kwtLicenseNum, strLicNum); } } 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 (kwdLicenseNum != null) { keyModifier.AddKeyword(kwdLicenseNum); } // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}', added to Document {2}.", gSaveToLicNum, strLicNum, _currentDocument.ID); //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)); } }
/// <summary> /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />. /// <seealso cref="IWorkflowScript" /> /// </summary> /// <param name="app">Unity Application object</param> /// <param name="args">Workflow event arguments</param> public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args) // public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args=null) { try { // Initialize global settings IntializeScript(ref app, ref args); KeywordType ktwTranCode = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamTranCode); string strTranCode = ""; if (ktwTranCode != null) { KeywordRecord keyRecTranCode = _currentDocument.KeywordRecords.Find(ktwTranCode); if (keyRecTranCode != null) { Keyword kwdTranCode = keyRecTranCode.Keywords.Find(ktwTranCode); if (kwdTranCode != null) strTranCode = kwdTranCode.ToString(); } } KeywordType ktwLicType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicType); string strLicType = ""; if (ktwLicType != null) { KeywordRecord keyRecLicType = _currentDocument.KeywordRecords.Find(ktwLicType); if (keyRecLicType != null) { Keyword kwdLicType = keyRecLicType.Keywords.Find(ktwLicType); if (kwdLicType != null) strLicType = kwdLicType.ToString(); } } if (strLicType == "" || strTranCode == "") { throw new Exception(string.Format("{0} or {1} is blank.", gParamLicType, gParamTranCode)); } //access Config Item for OnBase User string gUSER = ""; if (app.Configuration.TryGetValue("OnBaseUser", out gUSER)) { } //access Config Item for OnBase Password string gPASS = ""; if (app.Configuration.TryGetValue("OnBasePassword", out gPASS)) { } /* COMMENT THIS SECTION OUT WHEN MOVING TO PROD */ //access Config Item for OnBase UAT ODBC string gODBCMISC = ""; if (app.Configuration.TryGetValue("OnbaseMISC", out gODBCMISC)) { } string gODBCOnBase = ""; if (app.Configuration.TryGetValue("OnBaseUAT", out gODBCOnBase)) { } /* UNCOMMENT THIS SECTION WHEN MOVING TO PROD //access Config Item for OnBase PROD ODBC string gODBCOnBase = ""; if (app.Configuration.TryGetValue("OnBasePROD", out gODBCOnBase)) { } */ // ************** // Get Routing Values - This query gets the Proc Unit, Users and LastUser from SQL strSql.Append(@"SELECT users AS USERS, proc_unit AS UNIT "); strSql.Append(@" FROM dbo.pmwccb "); strSql.Append(@" WHERE license_type = '"); strSql.Append(strLicType); strSql.Append(@"' AND tran_code = '"); strSql.Append(strTranCode); strSql.Append(@"'"); string connectionString = string.Format("DSN={0};Uid={1};Pwd={2};", gODBCMISC, gUSER, gPASS); 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, con)) using (OdbcDataReader reader = command.ExecuteReader()) { if (reader.HasRows) { reader.Read(); string strUnit = ""; string lstUser = ""; lstUser = reader["USERS"].ToString(); strUnit = reader["UNIT"].ToString(); string[] result = lstUser.Split(','); string strSQLUsers = ""; foreach (string item in result) { if (item != "" && strSQLUsers == "") { strSQLUsers = "'" + item + "'"; } else if (item != "" && strSQLUsers != "") { strSQLUsers = strSQLUsers + ",'" + item + "'"; } } app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Users from CIU Database = {0}", strSQLUsers)); strSql.Append(@"select CT1.username, sum(CT1.DocCount) as DocCount from ((select ua.username, count(ilcu.usernum) as DocCount "); strSql.Append(@" from hsi.useraccount ua left outer join (select usernum,itemnum from hsi.itemlcxuser where hsi.itemlcxuser.lcnum = "); strSql.Append(gLCNUM); strSql.Append(@") ilcu on ua.usernum = ilcu.usernum inner join hsi.itemlc il on il.itemnum = ilcu.itemnum inner join hsi.itemdata id on ilcu.itemnum = id.itemnum "); strSql.Append(@" inner join hsi.lcstate lcs on il.statenum = lcs.statenum where ua.username in ("); strSql.Append(strSQLUsers); strSql.Append(@") and id.status=0 and lcs.statename like 'PMWAP - Initial Review%' and lcs.statename not like 'PMWAP - Research' "); strSql.Append(@" and lcs.statename not like 'PMWAP - Pending Review' and lcs.statename not like 'PMWAP - Application Processing Routing Exceptions' group by ua.username) "); strSql.Append(@" UNION (select ua.username, 0 as DocCount from hsi.useraccount ua where ua.username in ( "); strSql.Append(strSQLUsers); strSql.Append(@") ) ) CT1 group by CT1.username order by DocCount asc "); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("2nd Sql Query: {0}", strSql.ToString())); string connectionStringOnBase = string.Format("DSN={0};Uid={1};Pwd={2};", gODBCOnBase, gUSER, gPASS); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionStringOnBase)); string strNextUser = ""; using (OdbcConnection conOnBase = new OdbcConnection(connectionStringOnBase)) { try { conOnBase.Open(); using (OdbcCommand command = new OdbcCommand(strSql, conOnBase)) using (OdbcDataReader readerOnBase = command.ExecuteReader()) { if (readerOnBase.HasRows) { while (readerOnBase.Read()) { strNextUser = readerOnBase[0].ToString(); } } } } catch (Exception ex) { throw new ApplicationException("Error during database operations!", ex); } finally { if (conOnBase.State == ConnectionState.Open) conOnBase.Close(); } } Keyword kwdUser = null; if (!String.IsNullOrEmpty(strNextUser)) { KeywordType kwtUser = app.Core.KeywordTypes.Find(gSaveToAssignedProc); if (kwtUser != null) kwdUser = CreateKeywordHelper(kwtUser, strNextUser); } Keyword kwdUnit = null; if (!String.IsNullOrEmpty(strUnit)) { KeywordType kwtUnit = app.Core.KeywordTypes.Find(gSaveToAssignedProcUnit); if (kwtUnit != null) kwdUnit = CreateKeywordHelper(kwtUnit, strUnit); } 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 (kwdUnit != null) keyModifier.AddKeyword(kwdUnit); if (kwdUser != null) keyModifier.AddKeyword(kwdUser); // Apply keyword change to the document keyModifier.ApplyChanges(); documentLock.Release(); string output = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.", gSaveToAssignedProcUnit, strUnit, _currentDocument.ID, Environment.NewLine); //Output the results to the OnBase Diagnostics Console app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output); string output2 = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.", gSaveToAssignedProc, strWFUser, _currentDocument.ID, Environment.NewLine); app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output2); } } 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)); }
/// <summary> /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />. /// <seealso cref="IWorkflowScript" /> /// </summary> /// <param name="app">Unity Application object</param> /// <param name="args">Workflow event arguments</param> public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args) //public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args = null) { try { // Initialize global settings IntializeScript(ref app, ref args); //int intNumDocsProcessed = 0; string strProcessingErrors = ""; //int gDocCount = 0; KeywordType kwtAppNum = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(KNAPPNUM); if (kwtAppNum == null) { throw new Exception( string.Format( "The Keyword Type '{0}' could not be found or is not on the document type with name of: {1} ", KNAPPNUM, _currentDocument.Name)); } Keyword kwdAppNum = null; string strApplicationNumber = ""; KeywordRecord keyRecAppNum = _currentDocument.KeywordRecords.Find(kwtAppNum); if (keyRecAppNum != null) { kwdAppNum = keyRecAppNum.Keywords.Find(kwtAppNum); if (kwdAppNum != null) { strApplicationNumber = kwdAppNum.ToString(); } } KeywordType kwtLicenseType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(KNLICTYPE); if (kwtLicenseType == null) { throw new Exception( string.Format( "The Keyword Type '{0}' could not be found or is not on the document type with name of: {1} ", KNLICTYPE, _currentDocument.Name)); } Keyword kwdLicenseType = null; string strLicenseType = ""; KeywordRecord keyRecLicenseType = _currentDocument.KeywordRecords.Find(kwtLicenseType); if (keyRecLicenseType != null) { kwdLicenseType = keyRecLicenseType.Keywords.Find(kwtLicenseType); if (kwdLicenseType != null) { strLicenseType = kwdLicenseType.ToString().Trim(); } } KeywordType kwtBusinessUnit = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(KNBUSUNIT); if (kwtBusinessUnit == null) { throw new Exception( string.Format( "The Keyword Type '{0}' could not be found or is not on the document type with name of: {1} ", KNBUSUNIT, _currentDocument.Name)); } Keyword kwdBusinessUnit = null; string strBusinessUnit = ""; KeywordRecord keyRecBusinessUnit = _currentDocument.KeywordRecords.Find(kwtBusinessUnit); if (keyRecBusinessUnit != null) { kwdBusinessUnit = keyRecBusinessUnit.Keywords.Find(kwtBusinessUnit); if (kwdBusinessUnit != null) { strBusinessUnit = kwdBusinessUnit.ToString().Trim(); } } if (strBusinessUnit == "") { strBusinessUnit = "TEST"; } KeywordType kwtAgendaMtgMonth = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(KNAGDMON); if (kwtAgendaMtgMonth == null) { throw new Exception( string.Format( "The Keyword Type '{0}' could not be found or is not on the document type with name of: {1} ", KNAGDMON, _currentDocument.Name)); } Keyword kwdAgendaMtgMonth = null; string strAGMeetingMonth = ""; KeywordRecord keyRecAgendaMtgMonth = _currentDocument.KeywordRecords.Find(kwtAgendaMtgMonth); if (keyRecAgendaMtgMonth != null) { kwdAgendaMtgMonth = keyRecAgendaMtgMonth.Keywords.Find(kwtAgendaMtgMonth); if (kwdAgendaMtgMonth != null) { strAGMeetingMonth = kwdAgendaMtgMonth.ToString().Trim(); } } KeywordType kwtAgendaMtgYear = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(KNAGDYR); if (kwtAgendaMtgYear == null) { throw new Exception( string.Format( "The Keyword Type '{0}' could not be found or is not on the document type with name of: {1} ", KNAGDYR, _currentDocument.Name)); } Keyword kwdAgendaMtgYear = null; string strAGMeetingYear = ""; KeywordRecord keyRecAgendaMtgYear = _currentDocument.KeywordRecords.Find(kwtAgendaMtgYear); if (keyRecAgendaMtgYear != null) { kwdAgendaMtgYear = keyRecAgendaMtgYear.Keywords.Find(kwtAgendaMtgYear); if (kwdAgendaMtgYear != null) { strAGMeetingYear = kwdAgendaMtgYear.ToString().Trim(); } } KeywordType kwtAgendaAddendum = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(KNAGDADD); if (kwtAgendaAddendum == null) { throw new Exception( string.Format( "The Keyword Type '{0}' could not be found or is not on the document type with name of: {1} ", KNAGDADD, _currentDocument.Name)); } Keyword kwdAgendaAddendum = null; string strAGAddendum = ""; KeywordRecord keyRecAgendaAddendum = _currentDocument.KeywordRecords.Find(kwtAgendaAddendum); if (keyRecAgendaAddendum != null) { kwdAgendaAddendum = keyRecAgendaAddendum.Keywords.Find(kwtAgendaAddendum); if (kwdAgendaAddendum != null) { strAGAddendum = kwdAgendaAddendum.ToString().Trim(); } } string strOkayToProcessWithoutError = ""; // Get property values long lngDocHandle = _currentDocument.ID; KeywordType kwtMasterDocHandle = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(KNDOCNUMBERCONSTKWID); if (kwtMasterDocHandle == null) { throw new Exception( string.Format( "The Keyword Type '{0}' could not be found or is not on the document type with name of: {1} ", KNAPPNUM, _currentDocument.Name)); } Keyword kwdMasterDocHandle = null; string lngMstrDocHandle = ""; KeywordRecord keyRecMasterDocHandle = _currentDocument.KeywordRecords.Find(kwtMasterDocHandle); if (keyRecMasterDocHandle != null) { kwdMasterDocHandle = keyRecMasterDocHandle.Keywords.Find(kwtMasterDocHandle); if (kwdMasterDocHandle != null) { lngMstrDocHandle = kwdMasterDocHandle.ToString(); } } app.Diagnostics.Write("Prop Master Doc Handle = " + lngMstrDocHandle); bool bOkayToProcessWithoutError = false; args.PropertyBag.TryGetValue(PALL_MISSING_DOCS_TO_PROCESS_WITHOUT_REPORTING_ERROR, out strOkayToProcessWithoutError); if (!string.IsNullOrEmpty(strOkayToProcessWithoutError)) { if (strOkayToProcessWithoutError.Trim() == "MISSING DOCS") { bOkayToProcessWithoutError = true; } } // Beginning of log file WriteLog(app, @"@@@@@@@@@@@@@@@@@@@@@@@@@@ SCRIPT START @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); WriteLog(app, @"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); string strDocType = "CAMERA READY DOCUMENT"; string strCameraReady = "YES"; WriteLog(app, "Starting to Consolidating CIU - CR - Camera Ready Document"); bool bReturn = RunCQ(app, args, strBusinessUnit, strAGMeetingMonth, strAGMeetingYear, strAGAddendum, strDocType, strLicenseType, strApplicationNumber, lngDocHandle, strCameraReady, lngMstrDocHandle, bOkayToProcessWithoutError); if (!bReturn) { args.ScriptResult = false; } WriteLog(app, string.Format("Completed Consolidating CIU - CR - Camera Ready Document. Number of docs consolidated: {0}", intNumDocsProcessed.ToString().Trim())); if (strProcessingErrors.Trim().Length > 0) { args.PropertyBag.Set(PALL_PROCESSING_ERRORS, strProcessingErrors); } // End Log File WriteLog(app, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); WriteLog(app, "@@@@@@@@@@@@@@@@@@@@@@@@@@ SCRIPT COMPLETE @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); } 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)); } }