/// <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); List <Document> unityDocs = new List <Document>(); unityDocs.Add(_currentDocument); PrintQueue printQueue = app.Core.PrintManagement.PrintQueues.Find(printQ); PrintRequestProperties printReqProp = app.Core.PrintManagement.CreatePrintRequestProperties(unityDocs, printQueue); PrintJob printJob = app.Core.PrintManagement.EnqueuePrintRequest(printReqProp); app.Diagnostics.Write("Print Job Sent"); } 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) { _app = app; Document doc = args.Document; SetKeywordValues(doc); string sName = accountName.Replace("'", ""); string month = dateOfBirth.Substring(0, 2); string day = dateOfBirth.Substring(3, 2); string year = dateOfBirth.Substring(6, 4); string sBirthDate = year + "-" + month + "-" + day; if (sName != string.Empty && sBirthDate != "" && accountNumber == "") { string connectionString = "Server = WPEC5009onbsq01.cardinalhealth; Database = ONBASE; user=hsi; password=wstinol"; string queryString = "select ks101,ks102 from hsi.keysetdata112 (NOLOCK) where ks109 = '" + sBirthDate + "' and left(ks102,len(ks102)- len(substring(ks102,charindex(',',ks102),len(ks102)))) = '" + sName + "'"; DataTable dt = SelectDataRows(connectionString, queryString); foreach (DataRow dr in dt.Rows) { string sAccount = dr[0].ToString(); string sAccountName = dr[1].ToString(); if (sAccount != "" && sAccountName != "") { ModifyKeywordInCurrentDocument(doc, "AR - Account Number", sAccount); } } } }
/// <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 { // Script name for diagnostics logging app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("{0} - Start Script - [{1}]", DateTime.Now.ToString(DateTimeFormat), ScriptName)); // Get the active document Document objCurrentDocument = args.Document; app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Processing document: {0}", objCurrentDocument.ID.ToString())); // Get the default rendition and verify it is an e-form Rendition objFormRendition = objCurrentDocument.DefaultRenditionOfLatestRevision; if (objFormRendition.FileType.ID != EFORM_FILE_TYPE && objFormRendition.FileType.ID != VFORM_FILE_TYPE) { throw new InvalidProgramException(string.Format("File format ({0}) is invalid!", objFormRendition.FileType.Name)); } // Validate the document type DocumentType objCrdDocType = app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE); if (objCrdDocType == null) { throw new InvalidProgramException(string.Format("Document type \"{0}\" does not exist!", CRD_DOCUMENT_TYPE)); } ConversionUtilities unityConverter = new ConversionUtilities(app, TEMP_DIRECTORY, CONVERTER_DIRECTORY); List <FileDefinition> files = unityConverter.Convert(args.Document, UnityFileConversions.ImxFileType.Image, UnityFileConversions.ImportType.Document, app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE), true); unityConverter.CleanupFiles(); args.ScriptResult = true; } catch (InvalidProgramException ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Invalid Program Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } catch (UnityAPIException ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Unity API Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } catch (Exception ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("General Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } finally { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, ScriptName); } }
/// <summary> /// Get the signer information from the property bags. Also add anchors, if any from the SaveAnchorsToProp function /// </summary> /// <param name="app"></param> /// <param name="args"></param> /// <returns>A single signer object</returns> private Signer GetSigner(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args) { Signer signer = new Signer(); try { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "Adding a single signer to the envelope..."); string email = "", first = "", last = "", codeDesc = "", codeVal = ""; bool external = false; //Get all the signer info from prop bags if (!args.SessionPropertyBag.TryGetValue("TrueSignSignerEmail", out email)) { throw new Exception("An email must be provided for the signer."); } args.SessionPropertyBag.TryGetValue("TrueSignFirstName", out first); args.SessionPropertyBag.TryGetValue("TrueSignLastName", out last); args.SessionPropertyBag.TryGetValue("TrueSignExternal", out external); args.SessionPropertyBag.TryGetValue("TrueSignCodeDesc", out codeDesc); args.SessionPropertyBag.TryGetValue("TrueSignCodeVal", out codeVal); signer.Email = email; signer.First_Name = first == null ? "" : first; //not needed for internal signer signer.Last_Name = last == null ? "" : last; //not needed for internal signer signer.Type = external == true ? Signer_Type.External : Signer_Type.Internal; if (signer.Type == Signer_Type.External) { if (!string.IsNullOrEmpty(codeDesc) && !string.IsNullOrEmpty(codeVal)) { //If the signer is an external user, we are requiring them to enter a code they would know before being able to sign. //Only the code description will be known to the signer (they will see it in the email notification). //The value itself should be something that the signer already knows (like a date of birth, last 4 of SSN, or a case number) -- NOT REQUIRED Access_Code code = new Access_Code(); code.Description = codeDesc; code.Value = codeVal; signer.Code = code; } } string noteJson = ""; if (args.SessionPropertyBag.TryGetValue("TrueSignAnchors", out noteJson)) { List <Anchor> anchors = string.IsNullOrEmpty(noteJson) ? new List <Anchor>() : JsonConvert.DeserializeObject <List <Anchor> >(noteJson); signer.Anchors = anchors; } } catch { throw; } return(signer); }
private void AddDocsProperty(Application app, Hyland.Unity.WorkflowEventArgs args, TrueSignNextLibrary.Envelope envelope) { List <long> docHandles = new List <long>(); envelope.Content.Documents.ForEach(x => docHandles.Add(long.Parse(x.Client_Data))); args.SessionPropertyBag.Set("TrueSignEnvelopeDocs", docHandles.ToArray()); args.SessionPropertyBag.Set("TrueSignEnvelopeId", envelope.Id.ToString()); args.SessionPropertyBag.Set("TrueSignEnvelopeDocHandle", args.Document.ID.ToString()); }
private void SaveAnchorsToProp(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args, Guid docId) { try { string email = ""; string[] multipleEmails = new string[10]; long noteId = 0; bool singleSigner = false; if (args.SessionPropertyBag.TryGetValue("TrueSignSignerNoteId", out noteId)) { if (args.SessionPropertyBag.TryGetValue("TrueSignSignerEmail", out email)) { singleSigner = true; } else if (args.SessionPropertyBag.TryGetValue("TrueSignSignerEmail", out multipleEmails)) { singleSigner = SignerArrayOnlyOne(multipleEmails); } if (singleSigner) { if (args.Document.LatestRevision.Document.Notes.Count > 0 && noteId > 0) { string noteJson; args.SessionPropertyBag.TryGetValue("TrueSignAnchors", out noteJson); //Get all the document notes for the configured NoteTypeID. Make sure to only get notes of the latest revision //and the notes that have Repeat On All Revisions set to True. List <Anchor> anchors = string.IsNullOrEmpty(noteJson) ? new List <Anchor>() : JsonConvert.DeserializeObject <List <Anchor> >(noteJson); foreach (Note note in args.Document.Notes.FindAll(x => x.NoteType.ID == noteId && (x.DocumentRevision.ID == args.Document.LatestRevision.ID || x.NoteType.DisplaySettings == NoteTypeDisplaySettings.RepeatOnAllRevisions))) { var anchor = new Anchor(); anchor.Id = Guid.NewGuid(); anchor.Comment = note.Text; anchor.Page = (int)note.PageNumber; anchor.Required = true; anchor.Height = note.Size.Height * 72 / 96; anchor.Width = note.Size.Width * 72 / 96; anchor.X = note.Position.X * 72 / 96; anchor.Y = note.Position.Y * 72 / 96; anchor.Doc_Id = docId; anchor.Client_Data = note.ID.ToString(); anchor.Type = Anchor_Type.SignHere; anchors.Add(anchor); } args.SessionPropertyBag.Set("TrueSignAnchors", JsonConvert.SerializeObject(anchors)); } } } } catch { throw; } }
/// <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); // Create keyword modifier object to hold keyword changes KeywordModifier keyModifier = _currentDocument.CreateKeywordModifier(); Keyword kwdKeyName1 = null; if (!args.SessionPropertyBag.TryGetValue(gPropName1, out string[] lstProp1))
/// <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) { args.SessionPropertyBag.TryGetValue("propPriKey", out priKey); args.SessionPropertyBag.TryGetValue("propSecKey", out secKey); Document doc = args.Document; DocumentType docType = doc.DocumentType; SetKeywordValues(doc); DocumentQuery docQuery = app.Core.CreateDocumentQuery(); docQuery.AddDocumentType(docType); KeywordType keyType = app.Core.KeywordTypes.Find(priKey); Keyword priKeyword = keyType.CreateKeyword(priVal); docQuery.AddKeyword(priKeyword); DocumentList docList = docQuery.Execute(10000); Keyword secKeyword = keyType.CreateKeyword(secVal); foreach (Document newDoc in docList) { foreach (KeywordRecord keywordRecord in newDoc.KeywordRecords) { foreach (Keyword keyword in keywordRecord.Keywords) { if (keyword.KeywordType.Name == priKey) { string priGetValToCompare = keyword.IsBlank?string.Empty:keyword.Value.ToString(); if (priGetValToCompare.Trim() == priVal.Trim()) { using (DocumentLock documentLock = newDoc.LockDocument()) { if (documentLock.Status == DocumentLockStatus.LockObtained) { KeywordModifier keymod = newDoc.CreateKeywordModifier(); keymod.UpdateKeyword(priKeyword, secKeyword); keymod.ApplyChanges(); break; } } } } } } } }
private void AddRejectionProperty(Application app, Hyland.Unity.WorkflowEventArgs args, TrueSignNextLibrary.Envelope envelope) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Envelope with ID: {0} has been rejected.", envelope.Id)); //Find which signer rejected the envelope var rejected_signer = envelope.Content.Signers.FindLast(x => x.Rejected); //Add the rejected note to a property bag var note = string.Format("Envelope was rejected by signer {0} with the following reason: {1}", rejected_signer.First_Name + " " + rejected_signer.Last_Name, rejected_signer.Reject_Reason); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, note); args.SessionPropertyBag.Set("TrueSignEnvelopeRejected", true); args.SessionPropertyBag.Set("TrueSignEnvelopeRejectedReason", note); }
/// <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 { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("{0} - Start Script - [{1}]", DateTime.Now.ToString(DateTimeFormat), ScriptName)); ConversionUtilities unityConverter = new ConversionUtilities(app, TEMP_DIRECTORY, CONVERTER_DIRECTORY); List <FileDefinition> files = unityConverter.Convert(args.Document, UnityFileConversions.ImxFileType.Image, UnityFileConversions.ImportType.Document, app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE), true); unityConverter.CleanupFiles(); args.ScriptResult = true; } catch (InvalidProgramException ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Invalid Program Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } catch (UnityAPIException ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Unity API Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } catch (Exception ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("General Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } finally { 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 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"></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) 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 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"></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); //access Config Item for LicEase User string gUSER = ""; if (app.Configuration.TryGetValue("OnBaseUser", out gUSER)) { } //access Config Item for LicEase Password string gPASS = ""; if (app.Configuration.TryGetValue("OnBasePassword", out gPASS)) { } //access Config Item for LicEase PROD ODBC string gODBC = ""; if (app.Configuration.TryGetValue("OnBaseDEV", out gODBC)) { } string strBatch = ""; if (!args.SessionPropertyBag.TryGetValue(gProp, out strBatch)) { } 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 hsi.keyitem114.keyvaluecurr AS VAL from hsi.keyitem114 join hsi.keyitem143 on hsi.keyitem114.itemnum = hsi.keyitem143.itemnum "); strSql.Append(@" join hsi.itemdata on hsi.keyitem114.itemnum = hsi.itemdata.itemnum where hsi.itemdata.itemtypenum <> 146 and hsi.itemdata.status = 0 and hsi.keyitem143.keyvaluebig = "); strSql.Append(strBatch); 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) { while (reader.Read()) { lstProp.Add(reader["VAL"].ToString()); } double total = 0; foreach (string remit in lstProp) { total = total + double.Parse(remit); } Keyword kwdDesc = null; if (!String.IsNullOrEmpty(total.ToString())) { KeywordType kwtDesc = app.Core.KeywordTypes.Find("Remittance Total"); if (kwtDesc != null) { kwdDesc = CreateKeywordHelper(kwtDesc, total.ToString()); } } 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); } // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}', added to Document {2}.", "Remittance Total", total.ToString(), _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) 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 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 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"></param> /// <param name="args"></param> public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args) { bool result = true; try { Guid Envelope_Id = Guid.Empty; string propEnvId = "", title = "", notifySigner = "", overrideDeliveryMethod = "", singleEmail = ""; string[] multipleEmails = new string[10], designers = new string[10]; bool notify = true, design = false, uploadStaples = false; //Initiate a new TrueSign object. The clint API creds must have been set //on Session Property bags before the script was called. //TrueSignClientID - holds the Guid for the API client ID //TrueSignClientSecret - holds a string for the API client secret TrueSignNext TrueSign = new TrueSignNext(app, args); //Check if the envelope was already created (in a batch situation) if (!args.SessionPropertyBag.TryGetValue("TrueSignEnvelopeId", out propEnvId)) { //You are here because this is a new envelope. Get the title set in a prop bag args.SessionPropertyBag.TryGetValue("TrueSignEnvelopeTitle", out title); args.SessionPropertyBag.TryGetValue("TrueSignOverrideDeliveryMethod", out overrideDeliveryMethod); //If the title was empty, we will set a default one if (string.IsNullOrEmpty(title)) { title = "OnBase Envelope " + DateTime.Now.ToString("g"); } //Create a contact object that will be on external envelopes. //This info will appear on the email sent to the required signer. NOT REQUIRED var contact = new Contact(); contact.First_Name = ""; contact.Last_Name = ""; contact.Title = "ImageSoft County Court"; contact.Email = "*****@*****.**"; contact.Phone = "(313) 555 - 5555"; //Create the actual envelope var env = TrueSign.CreateEnvelope(title, null, null, contact, overrideDeliveryMethod); if (env == null) { throw new Exception("Failed to create a new envelope"); } //Set the envelope ID to a property bag. Envelope_Id = env.Id; args.SessionPropertyBag.Set("TrueSignEnvelopeId", Envelope_Id.ToString()); } else { //You are here because an envelope has already been created and this is the 1+ document in the batch. //You could also be here because you forgot to clear the properties. Envelope_Id = Guid.Parse(propEnvId); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "Envelope had already been created, adding files..."); } //Upload the current document to the envelope var doc = TrueSign.AddToEnvelope(Envelope_Id, args.Document); if (doc == null) { throw new Exception(string.Format("Failed to add document to envelope. Doc ID: {0}", args.Document.ID)); } args.SessionPropertyBag.TryGetValue("TrueSignUploadStaples", out uploadStaples); if (uploadStaples) { List <Hyland.Unity.Document> staples = new List <Hyland.Unity.Document>(); foreach (var note in args.Document.Notes.FindAll(x => x.NoteType.Flavor == NoteFlavor.Staple)) { staples.Add(note.StapledDocument); } if (staples.Count > 0) { TrueSign.AddToEnvelope(Envelope_Id, staples, true); } } //Call the function to save all notes in a prop bag. //This only works when the envelope has one signer and a TrueSignNoteId prop has been set. SaveAnchorsToProp(app, args, doc.Id); //If this is the last document in the batch if (args.BatchDocumentsRemaining == 0) { List <Signer> signers = new List <Signer>(); //Check if envelope has multiple or single signer //if (args.SessionPropertyBag.TryGetValue("TrueSignSignerEmail", out singleEmail)) // signers.Add(GetSigner(app, args)); if (args.SessionPropertyBag.TryGetValue("TrueSignSignerEmail", out multipleEmails)) { signers.AddRange(GetSigners(app, args)); } else { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "No property bag for signer email found..."); } foreach (Signer signer in signers) { //Check if this envelope is meant for an external signer if (signer.Type == Signer_Type.External) { //Add the signer to the envelope. TrueSign.AddExternalSigner(Envelope_Id, signer); } else { args.SessionPropertyBag.TryGetValue("TrueSignNotifySigner", out notifySigner); if (!string.IsNullOrEmpty(notifySigner)) { signer.Notify = bool.Parse(notifySigner); } //This is an internal signer so all we need is their email address TrueSign.AddInternalSigner(Envelope_Id, signer); } } args.SessionPropertyBag.TryGetValue("TrueSignDesign", out design); if (!design) { //Close the envelope and mark it ready for the signer to sign. TrueSign.SendEnvelope(Envelope_Id); } else { args.SessionPropertyBag.TryGetValue("TrueSignDesigners", out designers); var designerList = new List <string>(); for (int i = 0; i < designers.Length; i++) { if (!string.IsNullOrEmpty(designers[i])) { designerList.Add(designers[i]); } } TrueSign.SetDesigners(Envelope_Id, designerList); } } } catch (Exception ex) { app.Diagnostics.Write(ex); result = false; args.PropertyBag.Set("error", ex.Message); } args.ScriptResult = result; }
/// <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 { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("{0} - Start Script - [{1}]", DateTime.Now.ToString(DateTimeFormat), ScriptName)); // Initialize global settings IntializeScript(ref app, ref args); //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 gUATODBC = ""; if (app.Configuration.TryGetValue("OnBaseUAT", out gUATODBC)) { } //access Config Item for OnBase PROD ODBC string gPRODODBC = ""; if (app.Configuration.TryGetValue("OnBasePROD", out gPRODODBC)) { } LCID = args.Queue.LifeCycle.ID; app.Diagnostics.Write(LCID.ToString()); string connectionString = string.Format("DSN={0};Uid={1};Pwd={2};", gUATODBC, gUSER, gPASS); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionString)); StringBuilder strSql = new StringBuilder(); strSql.Append(@"SELECT hsi.useraccount.username AS USERNAME"); strSql.Append(@" FROM hsi.useraccount inner join hsi.itemlcxuser "); strSql.Append(@" ON hsi.useraccount.usernum = hsi.itemlcxuser.usernum "); strSql.Append(@" WHERE hsi.itemlcxuser.itemnum = '"); strSql.Append(_currentDocument.ID); strSql.Append(@"' AND hsi.itemlcxuser.lcnum = '"); strSql.Append(LCID); 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 strUN = ""; reader.Read(); strUN = reader["USERNAME"].ToString(); Keyword kwdUN = null; if (!String.IsNullOrEmpty(strUN)) { KeywordType kwtUN = app.Core.KeywordTypes.Find(gSaveToUserName); if (kwtUN != null) { kwdUN = CreateKeywordHelper(kwtUN, strUN); } } 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 (kwdUN != null) { keyModifier.AddKeyword(kwdUN); } // Apply keyword change to the document keyModifier.ApplyChanges(); string output = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.", gSaveToUserName, strUN, _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 for DH {0} and LCID ='{1}'", _currentDocument.ID, LCID)); } } } 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)); } } } catch (InvalidProgramException ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Invalid Program Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } catch (UnityAPIException ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Unity API Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } catch (Exception ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("General Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } finally { 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) { var result = true; try { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, "Starting Download Envelope Script"); //Check if this document is of type TrueSign Completed Envelope if (args.Document.DocumentType.Name.ToUpper() == "TRUESIGN COMPLETED ENVELOPE") { //Initiate a new TrueSign object TrueSignNext TrueSign = new TrueSignNext(app); //Read the JSON of this document as a TrueSign envelope var envelope = TrueSign.ReadEnvelope(args.Document); if (envelope == null) { throw new Exception("Unable to read OnBase doc as a TrueSign Envelope"); } //Add all doc ids to a property bag AddDocsProperty(app, args, envelope); //Check if the envelope was rejected if (envelope.Status == Envelope_Status.Rejected) { AddRejectionProperty(app, args, envelope); } else { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Downloading envelope with ID: {0}", envelope.Id)); //Download and create a new revision of the document var success = TrueSign.DownloadEnvelopeDocs(envelope); if (!success) { throw new Exception("Unable to download envelope docs from the TrueSign API"); } } } else { string Envelope_Id = ""; if (args.SessionPropertyBag.TryGetValue("TrueSignEnvelopeId", out Envelope_Id)) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Downloading envelope with ID: {0}", Envelope_Id)); //Initialize a new TrueSign object. We will retrieve the API creds from the prop bags //TrueSignClientId //TrueSignClientSecret TrueSignNext TrueSign = new TrueSignNext(app, args); //Get the envelope from the API var envelope = TrueSign.GetEnvelope(Guid.Parse(Envelope_Id)); if (envelope == null) { throw new Exception(string.Format("Unable to get envelope with ID {0} from TrueSign API", Envelope_Id)); } //Add all doc ids to a property bag AddDocsProperty(app, args, envelope); //Check if the envelope was rejected if (envelope.Status == Envelope_Status.Rejected) { AddRejectionProperty(app, args, envelope); } else { //Download and create a new revision of the document var success = TrueSign.DownloadEnvelopeDocs(envelope); if (!success) { throw new Exception("Unable to download envelope docs from the TrueSign API"); } } } else { throw new Exception("TrueSignEnvelopeId property bag not found."); } } } catch (Exception ex) { app.Diagnostics.Write(ex); result = false; args.PropertyBag.Set("error", ex.ToString()); } args.ScriptResult = result; }
/// <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) { app.Diagnostics.Level = Diagnostics.DiagnosticsLevel.Verbose; try { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "Begin Script - 274 - Convert Supporting Document to TIFF"); // Get the active document Document objCurrentDocument = args.Document; app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Processing document: {0}", objCurrentDocument.ID.ToString())); // Get the default rendition and verify it is an e-form Rendition objFormRendition = objCurrentDocument.DefaultRenditionOfLatestRevision; if (objFormRendition.FileType.ID != EFORM_FILE_TYPE && objFormRendition.FileType.ID != VFORM_FILE_TYPE) { throw new InvalidProgramException(string.Format("File format ({0}) is invalid!", objFormRendition.FileType.Name)); } // Obtain the Image page data ImageDataProvider objImageProvider = app.Core.Retrieval.Image; PageData objImageData = objImageProvider.GetDocument(objFormRendition); string fullPath = String.Format("{0}.{1}", @"c:\Temp", objImageData.Extension); Stream stream = objImageData.Stream; Utility.WriteStreamToFile(stream, fullPath); DocumentType objNewDocType = app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE); // Prepare to import the new document StoreNewDocumentProperties objDocProps = app.Core.Storage.CreateStoreNewDocumentProperties(objNewDocType, app.Core.FileTypes.Find(IMAGE_FILE_TYPE)); //Add all keywords foreach (KeywordRecord objKeyRecord in objCurrentDocument.KeywordRecords) { if (objKeyRecord.KeywordRecordType.RecordType == RecordType.StandAlone || objKeyRecord.KeywordRecordType.RecordType == RecordType.SingleInstance) { foreach (Keyword objKeyword in objKeyRecord.Keywords) { if (objNewDocType.KeywordRecordTypes.FindKeywordType(objKeyword.KeywordType.ID) != null) { objDocProps.AddKeyword(objKeyword); } } } else { EditableKeywordRecord objEditRecord = objKeyRecord.CreateEditableKeywordRecord(); objDocProps.AddKeywordRecord(objEditRecord); } } List <string> lstImportFiles = new List <string>(); lstImportFiles.Add(fullPath); // Store the new document Document objNewDoc = null; objNewDoc = app.Core.Storage.StoreNewDocument(lstImportFiles, objDocProps); if (objNewDoc == null) { throw new InvalidProgramException("Failed to store new document"); } app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Stored new document: {0}", objNewDoc.ID.ToString())); // Clean up objImageData.Dispose(); // If we got here, the script was successful args.ScriptResult = true; } catch (InvalidProgramException ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Invalid Program Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } catch (UnityAPIException ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Unity API Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } catch (Exception ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("General Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } finally { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "End Script - 274 - Convert HTML to TIFF"); } }
/// <summary> /// Get all signers for this envelope from the propery bags. No anchors are possible. /// </summary> /// <param name="app"></param> /// <param name="args"></param> /// <returns>A list of signer objects</returns> private List <Signer> GetSigners(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args) { List <Signer> signers = new List <Signer>(); try { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "Adding multiple signers to the envelope..."); string[] email = new string[10], first = new string[10], last = new string[10], codeDesc = new string[10], codeVal = new string[10]; bool[] external = new bool[10]; bool singleSigner = false; //Get all the signer info from prop bags if (!args.SessionPropertyBag.TryGetValue("TrueSignSignerEmail", out email)) { throw new Exception("An email must be provided for the signer."); } singleSigner = SignerArrayOnlyOne(email); args.SessionPropertyBag.TryGetValue("TrueSignFirstName", out first); args.SessionPropertyBag.TryGetValue("TrueSignLastName", out last); args.SessionPropertyBag.TryGetValue("TrueSignExternal", out external); args.SessionPropertyBag.TryGetValue("TrueSignCodeDesc", out codeDesc); args.SessionPropertyBag.TryGetValue("TrueSignCodeVal", out codeVal); if (singleSigner) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "This property bag has a single signer..."); //Create the signer data transfer object Signer signer = new Signer(); signer.Email = email[0]; signer.First_Name = first == null ? "" : first[0] ?? ""; //not needed for internal signer signer.Last_Name = last == null ? "" : last[0] ?? ""; //not needed for internal signer signer.Type = external == null ? Signer_Type.Internal : external[0] == true ? Signer_Type.External : Signer_Type.Internal; if (signer.Type == Signer_Type.External) { if (!string.IsNullOrEmpty(codeDesc[0]) && !string.IsNullOrEmpty(codeVal[0])) { //If the signer is an external user, we are requiring them to enter a code they would know before being able to sign. //Only the code description will be known to the signer (they will see it in the email notification). //The value itself should be something that the signer already knows (like a date of birth, last 4 of SSN, or a case number) -- NOT REQUIRED Access_Code code = new Access_Code(); code.Description = codeDesc[0]; code.Value = codeVal[0]; signer.Code = code; } } string noteJson = ""; if (args.SessionPropertyBag.TryGetValue("TrueSignAnchors", out noteJson)) { List <Anchor> anchors = string.IsNullOrEmpty(noteJson) ? new List <Anchor>() : JsonConvert.DeserializeObject <List <Anchor> >(noteJson); signer.Anchors = anchors; } signers.Add(signer); } else { for (int i = 0; i < email.Length; i++) { if (!string.IsNullOrEmpty(email[i])) { //Create the signer data transfer object Signer signer = new Signer(); signer.Email = email[i]; signer.First_Name = first == null ? "" : first[i] ?? ""; //not needed for internal signer signer.Last_Name = last == null ? "" : last[i] ?? ""; //not needed for internal signer signer.Type = external == null ? Signer_Type.Internal : external[i] == true ? Signer_Type.External : Signer_Type.Internal; if (signer.Type == Signer_Type.External) { if (!string.IsNullOrEmpty(codeDesc[i]) && !string.IsNullOrEmpty(codeVal[i])) { //If the signer is an external user, we are requiring them to enter a code they would know before being able to sign. //Only the code description will be known to the signer (they will see it in the email notification). //The value itself should be something that the signer already knows (like a date of birth, last 4 of SSN, or a case number) -- NOT REQUIRED Access_Code code = new Access_Code(); code.Description = codeDesc[i]; code.Value = codeVal[i]; signer.Code = code; } } signers.Add(signer); } } } } catch { throw; } return(signers); }
/// <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) { app.Diagnostics.Level = Diagnostics.DiagnosticsLevel.Verbose; try { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "Begin Script - Convert HTML to TIFF"); // Get the active document Document objCurrentDocument = args.Document; app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Processing document: {0}", objCurrentDocument.ID.ToString())); // Get the default rendition and verify it is an e-form Rendition objFormRendition = objCurrentDocument.DefaultRenditionOfLatestRevision; if (objFormRendition.FileType.ID != EFORM_FILE_TYPE && objFormRendition.FileType.ID != VFORM_FILE_TYPE) { throw new InvalidProgramException(string.Format("File format ({0}) is invalid!", objFormRendition.FileType.Name)); } // Validate the document type DocumentType objCrdDocType = app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE); if (objCrdDocType == null) { throw new InvalidProgramException(string.Format("Document type \"{0}\" does not exist!", CRD_DOCUMENT_TYPE)); } // Obtain the Image page data ImageDataProvider objImageProvider = app.Core.Retrieval.Image; PageData objImageData = objImageProvider.GetDocument(objFormRendition); // Convert to Multi-Page TIFF using (ImageModifier imageMod = new ImageModifier(TEMP_DIRECTORY, PAGE_RATIO)) { strFilePath = imageMod.MakeMultiPage(objImageData, app); if (strFilePath.StartsWith("ERROR:")) { throw new InvalidProgramException(string.Format("Error converting to multipage: ({0})", strFilePath.Replace("ERROR: ", ""))); } } // Prepare to import the new document StoreNewDocumentProperties objDocProps = app.Core.Storage.CreateStoreNewDocumentProperties(objCrdDocType, app.Core.FileTypes.Find(IMAGE_FILE_TYPE)); // Add all keywords foreach (KeywordRecord objKeyRecord in objCurrentDocument.KeywordRecords) { if (objKeyRecord.KeywordRecordType.RecordType == RecordType.StandAlone || objKeyRecord.KeywordRecordType.RecordType == RecordType.SingleInstance) { foreach (Keyword objKeyword in objKeyRecord.Keywords) { if (objCrdDocType.KeywordRecordTypes.FindKeywordType(objKeyword.KeywordType.ID) != null) { objDocProps.AddKeyword(objKeyword); } } } else { EditableKeywordRecord objEditRecord = objKeyRecord.CreateEditableKeywordRecord(); objDocProps.AddKeywordRecord(objEditRecord); } } List <string> lstImportFiles = new List <string>(); lstImportFiles.Add(strFilePath); // Store the new document Document objNewDoc = null; objNewDoc = app.Core.Storage.StoreNewDocument(lstImportFiles, objDocProps); if (objNewDoc == null) { throw new InvalidProgramException("Failed to store new document"); } app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Stored new document: {0}", objNewDoc.ID.ToString())); // Clean up objImageData.Dispose(); // If we got here, the script was successful args.ScriptResult = true; } catch (InvalidProgramException ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Invalid Program Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } catch (UnityAPIException ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Unity API Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } catch (Exception ex) { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("General Exception: {0}", ex.Message)); app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace)); args.ScriptResult = false; } finally { app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "End Script - Convert HTML to TIFF"); } }