コード例 #1
0
ファイル: CreatureState.cs プロジェクト: MX-H/AIGame-Fork
 private void RpcAddKeywordModifier(KeywordModifier modifier)
 {
     if (!isServer)
     {
         creature.card.cardData.AddModifier(modifier);
     }
 }
コード例 #2
0
        /// <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))
コード例 #3
0
ファイル: qwerty.cs プロジェクト: itsamirzia/testing2
        /// <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;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        public Document UpdateDocumentKeywords(
            Document aDocument,
            IEnumerable <Keyword> aKeywords = null,
            bool aExpandKeyset = true, bool aUseDefaultForRequiredKeys = true)
        {
            using (DocumentLock lDocumentLock = aDocument.LockDocument())
            {
                if (lDocumentLock.Status == DocumentLockStatus.AlreadyLocked)
                {
                    throw new DocumentLockedException(aDocument, lDocumentLock);
                }

                KeywordModifier lKeywordModifier = aDocument.CreateKeywordModifier();
                EditKeywords(lKeywordModifier, aDocument, aDocument.DocumentType, aKeywords, aExpandKeyset, aUseDefaultForRequiredKeys);
                lKeywordModifier.ApplyChanges();
            }
            return(aDocument);
        }
コード例 #5
0
        private void ModifyKeywordInCurrentDocument(Document doc, string keywordType, string keywordValue)
        {
            using (DocumentLock documentLock = doc.LockDocument())
            {
                if (documentLock.Status == DocumentLockStatus.LockObtained)
                {
                    KeywordModifier keymod  = doc.CreateKeywordModifier();
                    KeywordType     keyType = _app.Core.KeywordTypes.Find(keywordType);
                    if (keyType == null)
                    {
                        keymod.AddKeyword(keywordType, keywordValue);
                    }
                    else
                    {
                        KeywordRecord     keyRec     = doc.KeywordRecords.Find(keyType);
                        KeywordRecordType keyRecType = keyRec.KeywordRecordType;

                        Keyword newKeyword = keyType.CreateKeyword(keywordValue);

                        if (keyRecType.RecordType == RecordType.MultiInstance)
                        {
                            EditableKeywordRecord editKeyRec = keyRec.CreateEditableKeywordRecord();
                            Keyword keyword = editKeyRec.Keywords.Find(keywordType);
                            editKeyRec.UpdateKeyword(keyword, newKeyword);
                            keymod.AddKeywordRecord(editKeyRec);
                        }
                        else
                        {
                            Keyword keyword = keyRec.Keywords.Find(keywordType);
                            keymod.UpdateKeyword(keyword, newKeyword);
                        }
                    }
                    keymod.ApplyChanges();
                }
            }
        }
コード例 #6
0
        /// <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));
            }
        }
コード例 #8
0
        public static void Reindex(Application app, string documentsDir)
        {
            logger.Info("Re-index document by updating a keyword...");
            try
            {
                string filePath = documentsDir + "\\reindex.json";
                if (File.Exists(filePath))
                {
                    logger.Info("Re-index config file found: " + filePath);
                    string inputJSON = File.ReadAllText(filePath);

                    IList <JToken> jTokens = JToken.Parse(inputJSON)["contents"].Children().ToList();
                    foreach (JToken jToken in jTokens)
                    {
                        Content content = jToken.ToObject <Content>();

                        logger.Info("Get Document ID: " + content.documentID);
                        long     documentId = long.Parse(content.documentID);
                        Document document   = app.Core.GetDocumentByID(documentId, DocumentRetrievalOptions.LoadKeywords);
                        if (document == null)
                        {
                            throw new Exception("Document was not found");
                        }

                        var keywords = document.KeywordRecords[0].Keywords.Where(x => content.keywords.Keys.Contains(x.KeywordType.Name));

                        using (DocumentLock documentLock = document.LockDocument())
                        {
                            if (documentLock.Status != DocumentLockStatus.LockObtained)
                            {
                                throw new Exception("Failed to lock document");
                            }

                            KeywordModifier keyModifier = document.CreateKeywordModifier();

                            foreach (var keyword in keywords)
                            {
                                logger.Info("Update Keyword: " + content.keywords[keyword.KeywordType.Name]);
                                Keyword keywordToModify = null;

                                switch (keyword.KeywordType.DataType)
                                {
                                case KeywordDataType.AlphaNumeric:
                                    keywordToModify = keyword.KeywordType.CreateKeyword(content.keywords[keyword.KeywordType.Name]);
                                    break;

                                case KeywordDataType.Currency:
                                case KeywordDataType.SpecificCurrency:
                                case KeywordDataType.Numeric20:
                                    keywordToModify = keyword.KeywordType.CreateKeyword(decimal.Parse(content.keywords[keyword.KeywordType.Name]));
                                    break;

                                case KeywordDataType.Date:
                                case KeywordDataType.DateTime:
                                    keywordToModify = keyword.KeywordType.CreateKeyword(DateTime.Parse(content.keywords[keyword.KeywordType.Name]));
                                    break;

                                case KeywordDataType.FloatingPoint:
                                    keywordToModify = keyword.KeywordType.CreateKeyword(double.Parse(content.keywords[keyword.KeywordType.Name]));
                                    break;

                                case KeywordDataType.Numeric9:
                                    keywordToModify = keyword.KeywordType.CreateKeyword(long.Parse(content.keywords[keyword.KeywordType.Name]));
                                    break;
                                }

                                keyModifier.UpdateKeyword(keyword, keywordToModify);
                            }

                            keyModifier.ApplyChanges();
                        }

                        logger.Info(string.Format("Keyword was successfully updated. Document Id: {0}", content.documentID));
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
            }

            logger.Info("");
        }
コード例 #9
0
        /// <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));
            }
        }
コード例 #10
0
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app">Unity Application object</param>
        /// <param name="args">Workflow event arguments</param>
        public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args)
        //public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args = null)
        {
            try
            {
                // Initialize global settings
                IntializeScript(ref app, ref args);

                KeywordType kwtLicenseType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamCase);
                string      strLicenseType = "";
                if (kwtLicenseType != null)
                {
                    KeywordRecord keyRecLicenseType = _currentDocument.KeywordRecords.Find(kwtLicenseType);
                    if (keyRecLicenseType != null)
                    {
                        Keyword kwdLicenseType = keyRecLicenseType.Keywords.Find(kwtLicenseType);
                        if (kwdLicenseType != null)
                        {
                            strLicenseType = CleanSeedKW(kwdLicenseType.ToString());
                        }
                    }
                }

                if (strLicenseType == "")
                {
                    throw new Exception(string.Format(" {0} is blank.", gParamCase));
                }

                //access Config Item for LicEase User
                string gUSER = "";
                if (app.Configuration.TryGetValue("LicEaseUser", out gUSER))
                {
                }

                //access Config Item for LicEase Password
                string gPASS = "";
                if (app.Configuration.TryGetValue("LicEasePassword", out gPASS))
                {
                }

                /* COMMENT THIS SECTION OUT WHEN MOVING TO PROD */
                //access Config Item for LicEase UAT ODBC
                string gODBC = "";
                if (app.Configuration.TryGetValue("LicEaseUAT", out gODBC))
                {
                }

                /* UNCOMMENT THIS SECTION WHEN MOVING TO PROD
                 *              //access Config Item for LicEase PROD ODBC
                 *              string gODBC = "";
                 *              if (app.Configuration.TryGetValue("LicEasePROD", out gODBC))
                 *              {
                 *              }
                 */

                string connectionString = string.Format("DSN={0};Uid={1};Pwd={2};", gODBC, gUSER, gPASS);
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionString));

                StringBuilder strSql = new StringBuilder();
                strSql.Append(@" select to_char(max(ca.actv_strt_dte), 'MM/DD/YYYY') as ACSERVED, to_char(max(ca.actv_strt_dte + 21), 'MM/DD/YYYY') as DAYS21  ");
                strSql.Append(@" from cmpln, cmpln_actv ca, cmpln_actv_typ cat where cmpln.cmpln_nbr = ' ");
                strSql.Append(strLicenseType);
                strSql.Append(@"' and cmpln.cmpln_id = ca.cmpln_id and ca.cmpln_actv_typ_id = cat.cmpln_actv_typ_id and cat.cmpln_actv_typ_cde = 'A180' and cmpln.clnt_cde like '20%' ");


                using (OdbcConnection con = new OdbcConnection(connectionString))
                {
                    try
                    {
                        con.Open();
                        using (OdbcCommand command = new OdbcCommand(strSql.ToString(), con))
                            using (OdbcDataReader reader = command.ExecuteReader())
                            {
                                if (reader.HasRows)
                                {
                                    string str21      = "";
                                    string strService = "";

                                    reader.Read();

                                    str21      = reader["DAYS21"].ToString();
                                    strService = reader["ACSERVED"].ToString();

                                    Keyword kwdFileNum = null;
                                    if (!String.IsNullOrEmpty(str21))
                                    {
                                        KeywordType kwtFileNum = app.Core.KeywordTypes.Find(gSaveToServiceDate);
                                        if (kwtFileNum != null)
                                        {
                                            kwdFileNum = CreateKeywordHelper(kwtFileNum, str21);
                                        }
                                    }
                                    Keyword kwdKeyName = null;
                                    if (!String.IsNullOrEmpty(strService))
                                    {
                                        KeywordType kwtKeyName = app.Core.KeywordTypes.Find(gSaveTo21);
                                        if (kwtKeyName != null)
                                        {
                                            kwdKeyName = CreateKeywordHelper(kwtKeyName, strService);
                                        }
                                    }

                                    using (DocumentLock documentLock = _currentDocument.LockDocument())
                                    {
                                        // Ensure lock was obtained
                                        if (documentLock.Status != DocumentLockStatus.LockObtained)
                                        {
                                            throw new Exception("Document lock not obtained");
                                        }
                                        // Create keyword modifier object to hold keyword changes
                                        KeywordModifier keyModifier = _currentDocument.CreateKeywordModifier();

                                        // Add update keyword call to keyword modifier object
                                        //Note Overloads available for use
                                        //(I.E.): keyModifier.AddKeyword(keywordTypeName,keywordValue)
                                        if (kwdFileNum != null)
                                        {
                                            keyModifier.AddKeyword(kwdFileNum);
                                        }
                                        if (kwdKeyName != null)
                                        {
                                            keyModifier.AddKeyword(kwdKeyName);
                                        }

                                        // Apply keyword change to the document
                                        keyModifier.ApplyChanges();

                                        string output = String.Format("Keyword: '{0}' Value: '{1}', {7}Keyword: '{2}' Value: '{3}', {5}added to Document {4}.",
                                                                      gSaveToServiceDate, str21, gSaveTo21, strService, _currentDocument.ID, Environment.NewLine);
                                        //Output the results to the OnBase Diagnostics Console
                                        app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output);
                                    }
                                }
                                else
                                {
                                    throw new Exception(string.Format("No records found in database for  {0}='{1}' ", gParamCase, strLicenseType));
                                }
                            }
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException("Error during database operations!", ex);
                    }
                    finally
                    {
                        if (con.State == ConnectionState.Open)
                        {
                            con.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Handle exceptions and log to Diagnostics Console and document history
                HandleException(ex, ref app, ref args);
            }
            finally
            {
                // Log script execution end
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info,
                                        string.Format("End Script - [{0}]", ScriptName));
            }
        }
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app"></param>
        /// <param name="args"></param>
        public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args)
        {
            try
            {
                // Initialize global settings
                IntializeScript(ref app, ref args);

                //get and clean LicenseType and Application # keywords for passing to LicEase database
                KeywordType kwtAppNum = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamAppNum);
                string      strAppNum = "";
                if (kwtAppNum != null)
                {
                    KeywordRecord keyRecFileNum = _currentDocument.KeywordRecords.Find(kwtAppNum);
                    if (keyRecFileNum != null)
                    {
                        Keyword kwdFileNum = keyRecFileNum.Keywords.Find(kwtAppNum);
                        if (kwdFileNum != null)
                        {
                            strAppNum = CleanSeedKW(kwdFileNum.ToString());
                        }
                    }
                }
                KeywordType kwtLicenseType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicType);
                string      strLicenseType = "";
                if (kwtLicenseType != null)
                {
                    KeywordRecord keyRecLicenseType = _currentDocument.KeywordRecords.Find(kwtLicenseType);
                    if (keyRecLicenseType != null)
                    {
                        Keyword kwdLicenseType = keyRecLicenseType.Keywords.Find(kwtLicenseType);
                        if (kwdLicenseType != null)
                        {
                            strLicenseType = CleanSeedKW(kwdLicenseType.ToString());
                        }
                    }
                }

                if ((strAppNum == "") || (strLicenseType == ""))
                {
                    throw new Exception(string.Format("Either {0} or {1} is blank.", gParamAppNum, gParamLicType));
                }

                //access Config Item for LicEase User
                string gUSER = "";
                if (app.Configuration.TryGetValue("LicEaseUser", out gUSER))
                {
                }

                //access Config Item for LicEase Password
                string gPASS = "";
                if (app.Configuration.TryGetValue("LicEasePassword", out gPASS))
                {
                }

                /* COMMENT THIS SECTION OUT WHEN MOVING TO PROD */
                //access Config Item for LicEase UAT ODBC
                string gODBC = "";
                if (app.Configuration.TryGetValue("LicEaseUAT", out gODBC))
                {
                }

                /* UNCOMMENT THIS SECTION WHEN MOVING TO PROD
                 *              //access Config Item for LicEase PROD ODBC
                 *              string gODBC = "";
                 *              if (app.Configuration.TryGetValue("LicEasePROD", out gODBC))
                 *              {
                 *              }
                 */

                string connectionString = string.Format("DSN={0};Uid={1};Pwd={2};", gODBC, gUSER, gPASS);
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionString));

                StringBuilder strSql = new StringBuilder();
                strSql.Append(@"SELECT f.mod_desc AS PLANMOD FROM appl a, appl_mdf m, mdf f");
                strSql.Append(@"  WHERE a.applc_id = m.applc_id AND m.mod_id = f.mod_id AND");
                strSql.Append(@"  f.mod_typ = 'K' AND a.clnt_cde = '");
                strSql.Append(strLicenseType);
                strSql.Append(@"' AND a.applc_nbr = '");
                strSql.Append(strAppNum);
                strSql.Append(@"'");

                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Sql Query: {0}", strSql.ToString()));

                using (OdbcConnection con = new OdbcConnection(connectionString))
                {
                    try
                    {
                        con.Open();
                        using (OdbcCommand command = new OdbcCommand(strSql.ToString(), con))
                            using (OdbcDataReader reader = command.ExecuteReader())
                            {
                                if (reader.HasRows)
                                {
                                    string strMOD = "";

                                    reader.Read();

                                    strMOD = reader["PLANMOD"].ToString();

                                    Keyword kwdMOD = null;
                                    if (!String.IsNullOrEmpty(strMOD))
                                    {
                                        KeywordType kwtMOD = app.Core.KeywordTypes.Find(gSaveToPlanMod);
                                        if (kwtMOD != null)
                                        {
                                            kwdMOD = CreateKeywordHelper(kwtMOD, strMOD);
                                        }
                                    }

                                    using (DocumentLock documentLock = _currentDocument.LockDocument())
                                    {
                                        // Ensure lock was obtained
                                        if (documentLock.Status != DocumentLockStatus.LockObtained)
                                        {
                                            throw new Exception("Document lock not obtained");
                                        }
                                        // Create keyword modifier object to hold keyword changes
                                        KeywordModifier keyModifier = _currentDocument.CreateKeywordModifier();

                                        // Add update keyword call to keyword modifier object
                                        //Note Overloads available for use
                                        //(I.E.): keyModifier.AddKeyword(keywordTypeName,keywordValue)
                                        if (kwdMOD != null)
                                        {
                                            keyModifier.AddKeyword(kwdMOD);
                                        }

                                        // Apply keyword change to the document
                                        keyModifier.ApplyChanges();

                                        string output = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.",
                                                                      gSaveToPlanMod, strMOD, _currentDocument.ID, Environment.NewLine);
                                        //Output the results to the OnBase Diagnostics Console
                                        app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output);
                                    }
                                }
                                else
                                {
                                    throw new Exception(string.Format("No records found in database for  {0}='{1}' and {4}{2}='{3}' ", gParamLicType, strLicenseType, gParamAppNum, strAppNum, Environment.NewLine));
                                }
                            }
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException("Error during database operations!", ex);
                    }
                    finally
                    {
                        if (con.State == ConnectionState.Open)
                        {
                            con.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Handle exceptions and log to Diagnostics Console and document history
                HandleException(ex, ref app, ref args);
            }
            finally
            {
                // Log script execution end
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info,
                                        string.Format("End Script - [{0}]", ScriptName));
            }
        }
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app"></param>
        /// <param name="args"></param>
        public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args)
        {
            try
            {
                // Initialize global settings
                IntializeScript(ref app, ref args);

                //get and clean LicenseType and 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));
            }
        }
コード例 #13
0
        public static void StoreInOnBase(string tempFile)
        {
            using (Application obApp = OnBaseConnect())
            {
                // Get OnBase Storage Object
                Storage storage = obApp.Core.Storage;

                String docTypeName = System.Configuration.ConfigurationManager.AppSettings["outputDocumentType"];

                var documentType = obApp.Core.DocumentTypes.Find(docTypeName);

                if (documentType == null)
                {
                    Log.Logger.Error("Failed to find DocumentType: {@documentType}", docTypeName);
                }
                else
                {
                    // Set file type
                    var      fileTypeName  = "MS Excel Spreadsheet";
                    var      fileExtension = @".xlsx";
                    FileType fileType      = obApp.Core.FileTypes.Find(fileTypeName);

                    if (fileType == null)
                    {
                        Log.Logger.Error("Failed to find FileType: {@fileTypeName}", fileTypeName);
                    }
                    else
                    {
                        MemoryStream OBDocumentStream = new MemoryStream(File.ReadAllBytes(tempFile + fileExtension));

                        // Create Hyland PageData object for storage
                        PageData OBDocumentPageData = obApp.Core.Storage.CreatePageData(OBDocumentStream, fileExtension);

                        StoreNewDocumentProperties storeDocumentProperties = storage.CreateStoreNewDocumentProperties(documentType, fileType);

                        // Store Document in OnBase
                        Document OBDocumentNew = obApp.Core.Storage.StoreNewDocument(OBDocumentPageData, storeDocumentProperties);

                        if (OBDocumentNew == null)
                        {
                            Log.Logger.Error("Failed to store Document in OnBase!");
                        }
                        else
                        {
                            //Set Keywords
                            KeywordType   ReportIdKWType   = obApp.Core.KeywordTypes.Find("Report ID");
                            Keyword       ReportIdKW       = ReportIdKWType.CreateKeyword("00");
                            KeywordRecord ReportIdKWRecord = OBDocumentNew.KeywordRecords.Find(ReportIdKWType);
                            if (ReportIdKWRecord == null)
                            {
                                KeywordModifier ReportIdKeywordModifier = OBDocumentNew.CreateKeywordModifier();
                                ReportIdKeywordModifier.AddKeyword(ReportIdKW);
                                ReportIdKeywordModifier.ApplyChanges();
                            }
                            else
                            {
                                Log.Logger.Error("Keyword not null!");
                            }

                            // Stored Document will have today's DateTime; Update with DateTime scraped from Evidence Summary
                            DocumentPropertiesModifier OBDocModifier = OBDocumentNew.CreateDocumentPropertiesModifier();
                            OBDocModifier.DocumentDate = docDate;
                            OBDocModifier.ApplyChanges();

                            Log.Logger.Information("Storage to OnBase succesful. Doc Handle: {OBDocHandle}", OBDocumentNew.ID);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app">Unity Application object</param>
        /// <param name="args">Workflow event arguments</param>
        public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args)
        // public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args=null)
        {
            try
            {
                // Initialize global settings
                IntializeScript(ref app, ref args);

                KeywordType ktwBatchType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamBatchType);
                string      strBatchType = "";
                if (ktwBatchType != null)
                {
                    KeywordRecord keyRecFileNum = _currentDocument.KeywordRecords.Find(ktwBatchType);
                    if (keyRecFileNum != null)
                    {
                        Keyword kwdBatchType = keyRecFileNum.Keywords.Find(ktwBatchType);
                        if (kwdBatchType != null)
                        {
                            strBatchType = kwdBatchType.ToString();
                        }
                    }
                }

                if (strBatchType == "")
                {
                    throw new Exception(string.Format("{0} is blank.", gParamBatchType));
                }

                //access Config Item for OnBase User
                string gUSER = "";
                if (app.Configuration.TryGetValue("OnBaseUser", out gUSER))
                {
                }

                //access Config Item for OnBase Password
                string gPASS = "";
                if (app.Configuration.TryGetValue("OnBasePassword", out gPASS))
                {
                }

                /* COMMENT THIS SECTION OUT WHEN MOVING TO PROD */
                //access Config Item for OnBase UAT ODBC
                string gODBC = "";
                if (app.Configuration.TryGetValue("OnBaseUAT", out gODBC))
                {
                }

                /* UNCOMMENT THIS SECTION WHEN MOVING TO PROD
                 *              //access Config Item for OnBase PROD ODBC
                 *              string gODBC = "";
                 *              if (app.Configuration.TryGetValue("OnBasePROD", out gODBC))
                 *              {
                 *              }
                 */

                string connectionString = string.Format("DSN={0};Uid={1};Pwd={2};", gODBC, gUSER, gPASS);
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionString));

                StringBuilder strSql = new StringBuilder();
                strSql.Append(@"SELECT TOP 1 ua.username AS PROFILER ");
                strSql.Append(@"  FROM hsi.userxusergroup ux ");
                strSql.Append(@"  INNER JOIN hsi.useraccount ua on ua.usernum = ux.usernum ");
                strSql.Append(@"  INNER JOIN hsi.usergroup ug on ug.usergroupnum = ux.usergroupnum ");
                strSql.Append(@"  where ug.usergroupname = '");
                strSql.Append(strBatchType);
                strSql.Append(@"' ORDER BY NEWID()'");

                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Sql Query: {0}", strSql.ToString()));

                using (OdbcConnection con = new OdbcConnection(connectionString))
                {
                    try
                    {
                        con.Open();
                        using (OdbcCommand command = new OdbcCommand(strSql.ToString(), con))
                            using (OdbcDataReader reader = command.ExecuteReader())
                            {
                                if (reader.HasRows)
                                {
                                    string strProf = "";

                                    reader.Read();

                                    strProf = reader["PROFILER"].ToString();

                                    Keyword kwdProf = null;
                                    if (!String.IsNullOrEmpty(strProf))
                                    {
                                        KeywordType kwtProf = app.Core.KeywordTypes.Find(gSaveToAssignedProf);
                                        if (kwtProf != null)
                                        {
                                            kwdProf = CreateKeywordHelper(kwtProf, strProf);
                                        }
                                    }

                                    using (DocumentLock documentLock = _currentDocument.LockDocument())
                                    {
                                        // Ensure lock was obtained
                                        if (documentLock.Status != DocumentLockStatus.LockObtained)
                                        {
                                            throw new Exception("Document lock not obtained");
                                        }
                                        // Create keyword modifier object to hold keyword changes
                                        KeywordModifier keyModifier = _currentDocument.CreateKeywordModifier();

                                        // Add update keyword call to keyword modifier object
                                        //Note Overloads available for use
                                        //(I.E.): keyModifier.AddKeyword(keywordTypeName,keywordValue)
                                        if (kwdProf != null)
                                        {
                                            keyModifier.AddKeyword(kwdProf);
                                        }

                                        // Apply keyword change to the document
                                        keyModifier.ApplyChanges();

                                        string output = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.",
                                                                      gSaveToAssignedProf, strProf, _currentDocument.ID, Environment.NewLine);
                                        //Output the results to the OnBase Diagnostics Console
                                        app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output);
                                    }
                                }
                                else
                                {
                                    throw new Exception(string.Format("No records found in database for  {0}='{1}'", gParamBatchType, strBatchType));
                                }
                            }
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException("Error during database operations!", ex);
                    }
                    finally
                    {
                        if (con.State == ConnectionState.Open)
                        {
                            con.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Handle exceptions and log to Diagnostics Console and document history
                HandleException(ex, ref app, ref args);
            }
            finally
            {
                // Log script execution end
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info,
                                        string.Format("End Script - [{0}]", ScriptName));
            }
        }
コード例 #15
0
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app">Unity Application object</param>
        /// <param name="args">Workflow event arguments</param>
        public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args)
        // public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args=null)
        {
            try
            {
                // Initialize global settings
                IntializeScript(ref app, ref args);

                //get BatchNum from Property
                args.SessionPropertyBag.TryGetValue(pbBatchNum, out strBatchNum)

                if (strBatchNum == "")
                {
                    throw new Exception("pbBatchNum is blank.  Cannot get District Value without a Batch");
                }

                //access Config Item for OnBase User
                string gUSER = "";
                if (app.Configuration.TryGetValue("OnBaseUser", out gUSER))
                {
                }

                //access Config Item for OnBase Password
                string gPASS = "";
                if (app.Configuration.TryGetValue("OnBasePassword", out gPASS))
                {
                }

                /* COMMENT THIS SECTION OUT WHEN MOVING TO PROD */
                //access Config Item for OnBase UAT ODBC
                string gODBC = "";
                if (app.Configuration.TryGetValue("OnBaseUAT", out gODBC))
                {
                }

                /* UNCOMMENT THIS SECTION WHEN MOVING TO PROD
                 *              //access Config Item for OnBase PROD ODBC
                 *              string gODBC = "";
                 *              if (app.Configuration.TryGetValue("OnBasePROD", out gODBC))
                 *              {
                 *              }
                 */

                string connectionString = string.Format("DSN={0};Uid={1};Pwd={2};", gODBC, gUSER, gPASS);
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionString));

                StringBuilder strSql = new StringBuilder();
                strSql.Append(@"SELECT hsi.archivedqueue.queuename AS QNAME ");
                strSql.Append(@"  FROM hsi.archivedqueue where batchnum = '");
                strSql.Append(strBatchNum);
                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 strQName     = "";
                                    string strQNameLeft = "";
                                    string strDisctrict = "";

                                    reader.Read();

                                    strQName = reader["QNAME"].ToString();

                                    strQNameLeft = strQName.Substring(0, 6);
                                    app.Diagnostics.Write(strQNameLeft);

                                    strDisctrict = strQNameLeft.Substring(5);
                                    app.Diagnostics.Write(strDisctrict);

                                    Keyword kwdDist = null;
                                    if (!String.IsNullOrEmpty(strQName))
                                    {
                                        KeywordType kwtDist = app.Core.KeywordTypes.Find(gSaveToKeywordName);
                                        if (kwtDist != null)
                                        {
                                            kwdDist = CreateKeywordHelper(kwtDist, strDisctrict);
                                        }
                                    }

                                    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 (kwdDist != null)
                                        {
                                            keyModifier.AddKeyword(kwdDist);
                                        }

                                        // Apply keyword change to the document
                                        keyModifier.ApplyChanges();

                                        string output = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.",
                                                                      gSaveToKeywordName, strDisctrict, _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  pbBatchNum ='{0}'", strBatchNum));
                                }
                            }
                    }
                    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));
            }
        }
コード例 #16
0
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app">Unity Application object</param>
        /// <param name="args">Workflow event arguments</param>
        public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args)
        // public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args=null)
        {
            try
            {
                // Initialize global settings
                IntializeScript(ref app, ref args);

                KeywordType ktwBatchType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamBatchType);
                string      strBatchType = "";
                if (ktwBatchType != null)
                {
                    KeywordRecord keyRecBatchType = _currentDocument.KeywordRecords.Find(ktwBatchType);
                    if (keyRecBatchType != null)
                    {
                        Keyword kwdBatchType = keyRecBatchType.Keywords.Find(ktwBatchType);
                        if (kwdBatchType != null)
                        {
                            strBatchType = kwdBatchType.ToString();
                        }
                    }
                }

                if (strBatchType == "")
                {
                    throw new Exception(string.Format("{0} is blank.", gParamBatchType));
                }

                KeywordType ktwTranCode = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamTranCode);
                string      strTranCode = "";
                if (ktwTranCode != null)
                {
                    KeywordRecord keyRecTranCode = _currentDocument.KeywordRecords.Find(ktwTranCode);
                    if (keyRecTranCode != null)
                    {
                        Keyword kwdTranCode = keyRecTranCode.Keywords.Find(ktwTranCode);
                        if (kwdTranCode != null)
                        {
                            strTranCode = kwdTranCode.ToString();
                        }
                    }
                }

                KeywordType ktwLicType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicType);
                string      strLicType = "";
                if (ktwLicType != null)
                {
                    KeywordRecord keyRecLicType = _currentDocument.KeywordRecords.Find(ktwLicType);
                    if (keyRecLicType != null)
                    {
                        Keyword kwdLicType = keyRecLicType.Keywords.Find(ktwLicType);
                        if (kwdLicType != null)
                        {
                            strLicType = kwdLicType.ToString();
                        }
                    }
                }

                if (strLicType == "")
                {
                    throw new Exception(string.Format("{0} is blank.", gParamLicType));
                }

                //access Config Item for OnBase User
                string gUSER = "";
                if (app.Configuration.TryGetValue("OnBaseUser", out gUSER))
                {
                }

                //access Config Item for OnBase Password
                string gPASS = "";
                if (app.Configuration.TryGetValue("OnBasePassword", out gPASS))
                {
                }

                /* COMMENT THIS SECTION OUT WHEN MOVING TO PROD */
                //access Config Item for OnBase UAT ODBC
                string gODBCBET = "";
                if (app.Configuration.TryGetValue("BETOnBaseMISC", out gODBCBET))
                {
                }

                string gODBCOnBase = "";
                if (app.Configuration.TryGetValue("OnBaseUAT", out gODBCOnBase))
                {
                }

                /* UNCOMMENT THIS SECTION WHEN MOVING TO PROD
                 *              //access Config Item for OnBase PROD ODBC
                 *              string gODBCOnBase = "";
                 *              if (app.Configuration.TryGetValue("OnBasePROD", out gODBCOnBase))
                 *              {
                 *              }
                 */

                string obDocTypeFull = _currentDocument.DocumentType.Name.ToString();
                string obDocType     = obDocTypeFull.Substring(7);

                if (strTranCode != "" && strLicType != "")
                {
                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Trans Code and License Type Present"));

                    //StringBuilder strSql = new StringBuilder();
                    strSql.Append(@"SELECT users AS USER, proc_unit AS UNIT, last_user AS LASTUSER ");
                    strSql.Append(@"  FROM dbo.tbl_ccb ");
                    strSql.Append(@"  WHERE license_type = '");
                    strSql.Append(strLicType);
                    strSql.Append(@"' AND tran_code = '");
                    strSql.Append(strTranCode);
                    strSql.Append(@"'");
                }
                else if (strLicType != "" && strTranCode == "" && (strBatchType == "BET - CAND. (FEE)" || strBatchType == "BET - CAND. (NON FEE)"))
                {
                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("BET - CAND FEE or NON FEE"));

                    string strMidLicType = strLicType.Substring(1, 2);

                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("LicType {0}, Doc Type - Description {1}", strMidLicType, obDocType));

                    //StringBuilder strSql = new StringBuilder();
                    strSql.Append(@"SELECT users AS USER, proc_unit AS UNIT, last_user AS LASTUSER ");
                    strSql.Append(@"  FROM dbo.tbl_ccb ");
                    strSql.Append(@"  WHERE license_type = '");
                    strSql.Append(strMidLicType);
                    strSql.Append(@"' AND description = '");
                    strSql.Append(obDocType);
                    strSql.Append(@"'");
                }
                else if (strLicType != "" && strTranCode == "")
                {
                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("License Type but NO Trans Code"));

                    strSql.Append(@"SELECT users AS USER, proc_unit AS UNIT, last_user AS LASTUSER ");
                    strSql.Append(@"  FROM dbo.tbl_ccb ");
                    strSql.Append(@"  WHERE license_type = '");
                    strSql.Append(strLicType);
                    strSql.Append(@"' AND description = '");
                    strSql.Append(obDocType);
                    strSql.Append(@"'");
                }

                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Sql Query: {0}", strSql.ToString()));

                string connectionString = string.Format("DSN={0};Uid={1};Pwd={2};", gODBCBET, gUSER, gPASS);
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionString));

                using (OdbcConnection con = new OdbcConnection(connectionString))
                {
                    try
                    {
                        con.Open();
                        using (OdbcCommand command = new OdbcCommand(strSql.ToString(), con))
                            using (OdbcDataReader reader = command.ExecuteReader())
                            {
                                if (reader.HasRows)
                                {
                                    //string strUser = "";
                                    string        strUnit = "";
                                    List <string> lstUser = new List <string>();
                                    //string strLastUser = "";

                                    reader.Read();

                                    lstUser.Add(reader["USER"].ToString());
                                    //strUser = reader["USER"].ToString();
                                    //strLastUser = reader["LASTUSER"].ToString();
                                    strUnit = reader["UNIT"].ToString();

                                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Checking Users"));

                                    string strSQLUsers = "";

                                    foreach (string result in lstUser)
                                    {
                                        if (result != "" && strSQLUsers == "")
                                        {
                                            strSQLUsers = "'" + strSQLUsers + result + "'";
                                        }
                                        else if (result != "" && strSQLUsers != "")
                                        {
                                            strSQLUsers = strSQLUsers + ",'" + result + "'";
                                        }
                                    }

                                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("users to pass to OnBase " + strSQLUsers));

                                    //StringBuilder strSql = new StringBuilder();
                                    strSql.Append(@"SELECT TOP 1 ua.username AS WFUSER ");
                                    strSql.Append(@"  FROM hsi.useraccount ua ");
                                    strSql.Append(@"  LEFT OUTER JOIN (SELECT usernum FROM hsi.itemlcxuser ");
                                    strSql.Append(@"  WHERE hsi.itemlcxuser.lcnum = ");
                                    strSql.Append(gLCNUM);
                                    strSql.Append(@" ) ilcu ON us.usernum = ilcu.usernum ");
                                    strSql.Append(@"  WHERE ua.username IN(");
                                    strSql.Append(strSQLUsers);
                                    strSql.Append(@"'");

                                    string connectionStringOnBase = string.Format("DSN={0};Uid={1};Pwd={2};", gODBCOnBase, gUSER, gPASS);
                                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionStringOnBase));

                                    using (OdbcConnection conOnBase = new OdbcConnection(connectionStringOnBase))
                                    {
                                        try
                                        {
                                            conOnBase.Open();
                                            using (OdbcCommand commandOnBase = new OdbcCommand(strSql.ToString(), conOnBase))
                                                using (OdbcDataReader readerOnBase = commandOnBase.ExecuteReader())
                                                {
                                                    if (readerOnBase.HasRows)
                                                    {
                                                        strWFUser = readerOnBase["WFUSER"].ToString();

                                                        app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("WFUser set to " + strWFUser));
                                                    }
                                                }
                                        }
                                        catch (Exception ex)
                                        {
                                            throw new ApplicationException("Error during database operations!", ex);
                                        }
                                        finally
                                        {
                                            if (conOnBase.State == ConnectionState.Open)
                                            {
                                                conOnBase.Close();
                                            }
                                        }
                                    }

                                    Keyword kwdUnit = null;
                                    if (!String.IsNullOrEmpty(strUnit))
                                    {
                                        KeywordType kwtUnit = app.Core.KeywordTypes.Find(gSaveToAssignedProcUnit);
                                        if (kwtUnit != null)
                                        {
                                            kwdUnit = CreateKeywordHelper(kwtUnit, strUnit);
                                        }
                                    }

                                    Keyword kwdUser = null;
                                    if (!String.IsNullOrEmpty(strWFUser))
                                    {
                                        KeywordType kwtUser = app.Core.KeywordTypes.Find(gSaveToAssignedProc);
                                        if (kwtUser != null)
                                        {
                                            kwdUser = CreateKeywordHelper(kwtUser, strWFUser);
                                        }
                                    }

                                    using (DocumentLock documentLock = _currentDocument.LockDocument())
                                    {
                                        // Ensure lock was obtained
                                        if (documentLock.Status != DocumentLockStatus.LockObtained)
                                        {
                                            throw new Exception("Document lock not obtained");
                                        }
                                        // Create keyword modifier object to hold keyword changes
                                        KeywordModifier keyModifier = _currentDocument.CreateKeywordModifier();

                                        // Add update keyword call to keyword modifier object
                                        //Note Overloads available for use
                                        //(I.E.): keyModifier.AddKeyword(keywordTypeName,keywordValue)
                                        if (kwdUnit != null)
                                        {
                                            keyModifier.AddKeyword(kwdUnit);
                                        }
                                        if (kwdUser != null)
                                        {
                                            keyModifier.AddKeyword(kwdUser);
                                        }

                                        // Apply keyword change to the document
                                        keyModifier.ApplyChanges();

                                        string output = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.",
                                                                      gSaveToAssignedProcUnit, strUnit, _currentDocument.ID, Environment.NewLine);

                                        //Output the results to the OnBase Diagnostics Console
                                        app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output);

                                        string output2 = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.",
                                                                       gSaveToAssignedProc, strWFUser, _currentDocument.ID, Environment.NewLine);

                                        app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output2);
                                    }
                                }
                                else
                                {
                                    throw new Exception(string.Format("No records found in database for  {0}='{1}'", gParamBatchType, strBatchType));
                                }
                            }
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException("Error during database operations!", ex);
                    }
                    finally
                    {
                        if (con.State == ConnectionState.Open)
                        {
                            con.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Handle exceptions and log to Diagnostics Console and document history
                HandleException(ex, ref app, ref args);
            }
            finally
            {
                // Log script execution end
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info,
                                        string.Format("End Script - [{0}]", ScriptName));
            }
        }
コード例 #17
0
        /// <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));
            }
        }
コード例 #18
0
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app">Unity Application object</param>
        /// <param name="args">Workflow event arguments</param>
        public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args)
        //public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args = null)
        {
            try
            {
                // Initialize global settings
                IntializeScript(ref app, ref args);

                args.PropertyBag.TryGetValue("pbLicType", out propLicType);
                propLicType = propLicType.Substring(0, 2);
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("LicType trimmed: {0}", propLicType));

                string strBoard = "";

                switch (propLicType)
                {
                case "01":
                    strBoard = "CPA";
                    break;

                case "02":
                    strBoard = "Architecture";
                    break;

                case "03":
                    strBoard = "Barbers";
                    break;

                case "04":
                    strBoard = "Home Inspectors";
                    break;

                case "05":
                    strBoard = "Cosmetology";
                    break;

                case "06":
                    strBoard = "CILB";
                    break;

                case "07":
                    strBoard = "Mold";
                    break;

                case "08":
                    strBoard = "Electrical";
                    break;

                case "09":
                    strBoard = "CPE";
                    break;

                case "10":
                    strBoard = "PMW";
                    break;

                case "11":
                    strBoard = "Funeral Directors and Embalmers";
                    break;

                case "12":
                    strBoard = "Surveyors & Mappers";
                    break;

                case "13":
                    strBoard = "Landscape Architecture";
                    break;

                case "20":
                    strBoard = "Hotels and Restaurants";
                    break;

                case "21":
                    strBoard = "Elevator Safety";
                    break;

                case "23":
                    strBoard = "Harbor Pilot";
                    break;

                case "25":
                    strBoard = "FREC";
                    break;

                case "26":
                    strBoard = "Veterinary Medicine";
                    break;

                case "33":
                    strBoard = "DDC";
                    break;

                case "38":
                    strBoard = "CAM";
                    break;

                case "40":
                    strBoard = "ABT";
                    break;

                case "48":
                    strBoard = "Auctioneers";
                    break;

                case "49":
                    strBoard = "Talent Agents";
                    break;

                case "50":
                    strBoard = "Building Code Administrators";
                    break;

                case "53":
                    strBoard = "Geologists";
                    break;

                case "59":
                    strBoard = "Asbestos";
                    break;

                case "60":
                    strBoard = "Athletic Agents";
                    break;

                case "63":
                    strBoard = "Employee Leasing";
                    break;

                case "64":
                    strBoard = "FREAB";
                    break;

                case "74":
                    strBoard = "Labor Organization";
                    break;

                case "75":
                    strBoard = "Farm Labor";
                    break;

                case "76":
                    strBoard = "Child Labor";
                    break;

                case "80":
                    strBoard = "Condos, Coops, Timeshares";
                    break;

                case "81":
                    strBoard = "Mobile Homes";
                    break;

                case "82":
                    strBoard = "Land Sales";
                    break;

                case "83":
                    strBoard = "Other Entities";
                    break;

                case "85":
                    strBoard = "Yacht and Ship Brokers";
                    break;

                case "90":
                    strBoard = "Office of the Secretary";
                    break;

                case "98":
                    strBoard = "OGC Miscellaneous";
                    break;

                case "99":
                    strBoard = "Regulation";
                    break;
                }

                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Board KW to = {0}", strBoard));

                Keyword kwdBoard = null;
                if (!String.IsNullOrEmpty(strBoard))
                {
                    KeywordType kwtBoard = app.Core.KeywordTypes.Find(gSaveToBoard);
                    if (kwtBoard != null)
                    {
                        kwdBoard = CreateKeywordHelper(kwtBoard, strBoard);
                    }
                }

                args.PropertyBag.TryGetValue("pbRegion", out propRegion);
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Region = {0}", propRegion));

                string strRegionFullName = "";

                switch (propRegion)
                {
                case "01":
                    strRegionFullName = "Fort Walton";
                    break;

                case "02":
                    strRegionFullName = "Tallahassee";
                    break;

                case "03":
                    strRegionFullName = "Jacksonville";
                    break;

                case "04":
                    strRegionFullName = "Gainesville";
                    break;

                case "05":
                    strRegionFullName = "Orlando";
                    break;

                case "06":
                    strRegionFullName = "Tampa";
                    break;

                case "07":
                    strRegionFullName = "Fort Myers";
                    break;

                case "08":
                    strRegionFullName = "West Palm Beach";
                    break;

                case "09":
                    strRegionFullName = "Margate";
                    break;

                case "10":
                    strRegionFullName = "Miami";
                    break;

                default:
                    strRegionFullName = "";
                    break;
                }

                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Region Value = {0}", strRegionFullName));

                string strFullComplainant = "DBPR - " + strRegionFullName;

                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Complainant KW to = {0}", strFullComplainant));


                Keyword kwdRegion = null;
                if (!String.IsNullOrEmpty(strRegionFullName))
                {
                    KeywordType kwtRegion = app.Core.KeywordTypes.Find(gSaveToComplainant);
                    if (kwtRegion != null)
                    {
                        kwdRegion = CreateKeywordHelper(kwtRegion, strRegionFullName);
                    }
                }

                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 (kwdRegion != null)
                    {
                        keyModifier.AddKeyword(kwdRegion);
                    }

                    // Apply keyword change to the document
                    keyModifier.ApplyChanges();

                    string output = String.Format("Keyword: '{0}' Value: '{1}', {5}Keyword: '{2}' Value: '{3}', {5}added to Document {4}.",
                                                  gSaveToBoard, strBoard, gSaveToComplainant, strFullComplainant, _currentDocument.ID, Environment.NewLine);
                    //Output the results to the OnBase Diagnostics Console
                    app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output);
                }
            }
            catch (Exception ex)
            {
                // Handle exceptions and log to Diagnostics Console and document history
                HandleException(ex, ref app, ref args);
            }
            finally
            {
                // Log script execution end
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info,
                                        string.Format("End Script - [{0}]", ScriptName));
            }
        }
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app">Unity Application object</param>
        /// <param name="args">Workflow event arguments</param>
        public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args)
        //public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args = null)
        {
            try
            {
                // Initialize global settings
                IntializeScript(ref app, ref args);

                KeywordType kwtLicenseType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicType);
                string strLicenseType = "";
                if (kwtLicenseType != null)
                {
                    KeywordRecord keyRecLicenseType = _currentDocument.KeywordRecords.Find(kwtLicenseType);
                    if (keyRecLicenseType != null)
                    {
                        Keyword kwdLicenseType = keyRecLicenseType.Keywords.Find(kwtLicenseType);
                        if (kwdLicenseType != null)
                            strLicenseType = CleanSeedKW(kwdLicenseType.ToString());
                    }
                }

                KeywordType kwtLicenseNum = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicNum);
                string strLicenseNum = "";
                if (kwtLicenseNum != null)
                {
                    KeywordRecord keyRecLicenseNum = _currentDocument.KeywordRecords.Find(kwtLicenseNum);
                    if (keyRecLicenseNum != null)
                    {
                        Keyword kwdLicenseNum = keyRecLicenseNum.Keywords.Find(kwtLicenseNum);
                        if (kwdLicenseNum != null)
                            strLicenseNum = CleanSeedKW(kwdLicenseNum.ToString());
                    }
                }

                if ((strLicenseNum == "") || (strLicenseType == ""))
                {
                    throw new Exception(string.Format("Either {0} or {1} is blank.", gParamLicNum, gParamLicType));
                }

                //access Config Item for LicEase User
                string gUSER = "";
                if (app.Configuration.TryGetValue("LicEaseUser", out gUSER))
                {
                }

                //access Config Item for LicEase Password
                string gPASS = "";
                if (app.Configuration.TryGetValue("LicEasePassword", out gPASS))
                {
                }

                /* COMMENT THIS SECTION OUT WHEN MOVING TO PROD */
                //access Config Item for LicEase UAT ODBC
                string gODBC = "";
                if (app.Configuration.TryGetValue("LicEaseUAT", out gODBC))
                {
                }

                /* UNCOMMENT THIS SECTION WHEN MOVING TO PROD
				//access Config Item for LicEase PROD ODBC
				string gODBC = "";
				if (app.Configuration.TryGetValue("LicEasePROD", out gODBC))
				{
				}
				*/

                string connectionString = string.Format("DSN={0};Uid={1};Pwd={2};", gODBC, gUSER, gPASS);
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionString));

                StringBuilder strSql = new StringBuilder();
                strSql.Append(@"SELECT l.file_nbr AS FILENUM, n.key_nme AS KEYNAME, l.xent_id AS INDNUM ");
                strSql.Append(@"  FROM Lic l ");
                strSql.Append(@"  left join name n on l.xent_id = n.xent_id  ");
                strSql.Append(@"  WHERE l.clnt_cde = '");
                strSql.Append(strLicenseType);
                strSql.Append(@"' CAST(l.lic_nbr AS number) = '");
                strSql.Append(strLicenseNum);
                strSql.Append(@"' AND n.ent_nme_typ = 'D' AND n.cur_nme_ind = 'Y' AND rownum = '1'");

                using (OdbcConnection con = new OdbcConnection(connectionString))
                {
                    try
                    {
                        con.Open();
                        using (OdbcCommand command = new OdbcCommand(strSql.ToString(), con))
                        using (OdbcDataReader reader = command.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                string strFileNum = "";
                                string strKeyName = "";
                                string strIndNum = "";

                                reader.Read();

                                strFileNum = reader["FILENUM"].ToString();
                                strKeyName = reader["KEYNAME"].ToString();
                                strIndNum = reader["INDNUM"].ToString();

                                Keyword kwdFileNum = null;
                                if (!String.IsNullOrEmpty(strFileNum))
                                {
                                    KeywordType kwtFileNum = app.Core.KeywordTypes.Find(gSaveToFileNum);
                                    if (kwtFileNum != null)
                                        kwdFileNum = CreateKeywordHelper(kwtFileNum, strFileNum);
                                }
                                Keyword kwdKeyName = null;
                                if (!String.IsNullOrEmpty(strKeyName))
                                {
                                    KeywordType kwtKeyName = app.Core.KeywordTypes.Find(gSaveToKeyName);
                                    if (kwtKeyName != null)
                                        kwdKeyName = CreateKeywordHelper(kwtKeyName, strKeyName);
                                }
                                Keyword kwdIndNum = null;
                                if (!String.IsNullOrEmpty(strIndNum))
                                {
                                    KeywordType kwtIndNum = app.Core.KeywordTypes.Find(gSaveToIndNum);
                                    if (kwtIndNum != null)
                                        kwdIndNum = CreateKeywordHelper(kwtIndNum, strIndNum);
                                }
                                using (DocumentLock documentLock = _currentDocument.LockDocument())
                                {
                                    // Ensure lock was obtained
                                    if (documentLock.Status != DocumentLockStatus.LockObtained)
                                    {
                                        throw new Exception("Document lock not obtained");
                                    }
                                    // Create keyword modifier object to hold keyword changes
                                    KeywordModifier keyModifier = _currentDocument.CreateKeywordModifier();

                                    // Add update keyword call to keyword modifier object
                                    //Note Overloads available for use
                                    //(I.E.): keyModifier.AddKeyword(keywordTypeName,keywordValue)
                                    if (kwdFileNum != null) keyModifier.AddKeyword(kwdFileNum);
                                    if (kwdKeyName != null) keyModifier.AddKeyword(kwdKeyName);
                                    if (kwdIndNum != null) keyModifier.AddKeyword(kwdIndNum);

                                    // Apply keyword change to the document
                                    keyModifier.ApplyChanges();

                                    string output = String.Format("Keyword: '{0}' Value: '{1}', {7}Keyword: '{2}' Value: '{3}', {7}Keyword: '{4}' Value: '{5}', {7}added to Document {6}.",
                                        gSaveToFileNum, strFileNum, gSaveToKeyName, strKeyName, gSaveToIndNum, strIndNum, _currentDocument.ID, Environment.NewLine);
                                    //Output the results to the OnBase Diagnostics Console
                                    app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output);
                                }
                            }
                            else
                            {
                                throw new Exception(string.Format("No records found in database for  {0}='{1}' and {4}{2}='{3}' ", gParamLicType, strLicenseType, gParamLicNum, strLicenseNum, Environment.NewLine));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException("Error during database operations!", ex);
                    }
                    finally
                    {
                        if (con.State == ConnectionState.Open) con.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                // Handle exceptions and log to Diagnostics Console and document history
                HandleException(ex, ref app, ref args);
            }
            finally
            {
                // Log script execution end
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info,
                    string.Format("End Script - [{0}]", ScriptName));
            }
        }
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app"></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));
            }
        }
コード例 #21
0
        /// <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"></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));
            }
        }
コード例 #23
0
        /// <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));
            }
        }
コード例 #24
0
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app">Unity Application object</param>
        /// <param name="args">Workflow event arguments</param>
        public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args)
        // public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args=null)
        {
            try
            {
                // Initialize global settings
                IntializeScript(ref app, ref args);

                string strRelatedCase = "";
                args.SessionPropertyBag.TryGetValue(gPropCase, out strRelatedCase);

                app.Diagnostics.Write(string.Format("property for related case # = {0}", strRelatedCase));

                if (string.IsNullOrEmpty(strRelatedCase))
                {
                    throw new Exception(String.Format("Property '{0}' not found", strRelatedCase));
                }

                //access Config Item for OnBase User
                string gUSER = "";
                if (app.Configuration.TryGetValue("OnBaseUser", out gUSER))
                {
                }

                //access Config Item for OnBase Password
                string gPASS = "";
                if (app.Configuration.TryGetValue("OnBasePassword", out gPASS))
                {
                }

                /* COMMENT THIS SECTION OUT WHEN MOVING TO PROD */
                //access Config Item for OnBase UAT ODBC
                string gODBC = "";
                if (app.Configuration.TryGetValue("OBUAT", out gODBC))
                {
                }

                /* UNCOMMENT THIS SECTION WHEN MOVING TO PROD
                 *              //access Config Item for OnBase PROD ODBC
                 *              string gODBC = "";
                 *              if (app.Configuration.TryGetValue("OnBasePROD", out gODBC))
                 *              {
                 *              }
                 */

                string connectionString = string.Format("DSN={0};Uid={1};Pwd={2};", gODBC, gUSER, gPASS);
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionString));

                StringBuilder strSql = new StringBuilder();
                strSql.Append("select distinct ua.username AS USER FROM hsi.itemlc ilc ");
                strSql.Append("join hsi.itemlcxuser ilcxu on ilc.itemnum = ilcxu.itemnum ");
                strSql.Append("join hsi.useraccount ua on ilcxu.usernum = ua.usernum ");
                strSql.Append("join hsi.keyxitem138 ki138 on ilc.itemnum = ki138.itemnum ");
                strSql.Append("join hsi.keytable138 kt138 on ki138.keywordnum = kt138.keywordnum ");
                strSql.Append("where ilc.lcnum = 177 and ilc.statenum = 568 and kt138.keyvaluechar = '");
                strSql.Append(strRelatedCase);
                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 strProf = "";

                                    reader.Read();

                                    strProf = reader["USER"].ToString();

                                    Keyword kwdProf = null;
                                    if (!String.IsNullOrEmpty(strProf))
                                    {
                                        KeywordType kwtProf = app.Core.KeywordTypes.Find(gSaveToReassignedAnalyst);
                                        if (kwtProf != null)
                                        {
                                            kwdProf = CreateKeywordHelper(kwtProf, strProf);
                                        }
                                    }

                                    using (DocumentLock documentLock = _currentDocument.LockDocument())
                                    {
                                        // Ensure lock was obtained
                                        if (documentLock.Status != DocumentLockStatus.LockObtained)
                                        {
                                            throw new Exception("Document lock not obtained");
                                        }
                                        // Create keyword modifier object to hold keyword changes
                                        KeywordModifier keyModifier = _currentDocument.CreateKeywordModifier();

                                        // Add update keyword call to keyword modifier object
                                        //Note Overloads available for use
                                        //(I.E.): keyModifier.AddKeyword(keywordTypeName,keywordValue)
                                        if (kwdProf != null)
                                        {
                                            keyModifier.AddKeyword(kwdProf);
                                        }

                                        // Apply keyword change to the document
                                        keyModifier.ApplyChanges();

                                        string output = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.",
                                                                      gSaveToReassignedAnalyst, strProf, _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  {0}='{1}'", gPropCase, strRelatedCase));
                                }
                            }
                    }
                    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));
            }
        }
コード例 #25
0
        /// <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));
            }
        }
コード例 #26
0
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app">Unity Application object</param>
        /// <param name="args">Workflow event arguments</param>
        public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args)
        //    public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args=null)
        {
            try
            {
                // Initialize global settings
                IntializeScript(ref app, ref args);

                KeywordType ktwTranCode = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamTranCode);
                string strTranCode = "";
                if (ktwTranCode != null)
                {
                    KeywordRecord keyRecTranCode = _currentDocument.KeywordRecords.Find(ktwTranCode);
                    if (keyRecTranCode != null)
                    {
                        Keyword kwdTranCode = keyRecTranCode.Keywords.Find(ktwTranCode);
                        if (kwdTranCode != null)
                            strTranCode = kwdTranCode.ToString();
                    }
                }

                KeywordType ktwLicType = _currentDocument.DocumentType.KeywordRecordTypes.FindKeywordType(gParamLicType);
                string strLicType = "";
                if (ktwLicType != null)
                {
                    KeywordRecord keyRecLicType = _currentDocument.KeywordRecords.Find(ktwLicType);
                    if (keyRecLicType != null)
                    {
                        Keyword kwdLicType = keyRecLicType.Keywords.Find(ktwLicType);
                        if (kwdLicType != null)
                            strLicType = kwdLicType.ToString();
                    }
                }

                if (strLicType == "" || strTranCode == "")
                {
                    throw new Exception(string.Format("{0} or {1} is blank.", gParamLicType, gParamTranCode));
                }

                //access Config Item for OnBase User
                string gUSER = "";
                if (app.Configuration.TryGetValue("OnBaseUser", out gUSER))
                {
                }

                //access Config Item for OnBase Password
                string gPASS = "";
                if (app.Configuration.TryGetValue("OnBasePassword", out gPASS))
                {
                }

                /* COMMENT THIS SECTION OUT WHEN MOVING TO PROD */
                //access Config Item for OnBase UAT ODBC
                string gODBCMISC = "";
                if (app.Configuration.TryGetValue("OnbaseMISC", out gODBCMISC))
                {
                }

                string gODBCOnBase = "";
                if (app.Configuration.TryGetValue("OnBaseUAT", out gODBCOnBase))
                {
                }

                /* UNCOMMENT THIS SECTION WHEN MOVING TO PROD
				//access Config Item for OnBase PROD ODBC
				string gODBCOnBase = "";
				if (app.Configuration.TryGetValue("OnBasePROD", out gODBCOnBase))
				{
				}
				*/

                // **************
                // Get Routing Values - This query gets the Proc Unit, Users and LastUser from SQL

                strSql.Append(@"SELECT users AS USERS, proc_unit AS UNIT ");
                strSql.Append(@"  FROM dbo.pmwccb ");
                strSql.Append(@"  WHERE license_type = '");
                strSql.Append(strLicType);
                strSql.Append(@"' AND tran_code = '");
                strSql.Append(strTranCode);
                strSql.Append(@"'");

                string connectionString = string.Format("DSN={0};Uid={1};Pwd={2};", gODBCMISC, gUSER, gPASS);
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Sql Query: {0}", strSql.ToString()));


                using (OdbcConnection con = new OdbcConnection(connectionString))
                {
                    try
                    {
                        con.Open();
                        using (OdbcCommand command = new OdbcCommand(strSql, con))
                        using (OdbcDataReader reader = command.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                reader.Read();

                                string strUnit = "";
                                string lstUser = "";

                                lstUser = reader["USERS"].ToString();
                                strUnit = reader["UNIT"].ToString();

                                string[] result = lstUser.Split(',');

                                string strSQLUsers = "";

                                foreach (string item in result)
                                {
                                    if (item != "" && strSQLUsers == "")
                                    {
                                        strSQLUsers = "'" + item + "'";
                                    }
                                    else if (item != "" && strSQLUsers != "")
                                    {
                                        strSQLUsers = strSQLUsers + ",'" + item + "'";
                                    }
                                }

                                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Users from CIU Database = {0}", strSQLUsers));

                                strSql.Append(@"select CT1.username, sum(CT1.DocCount) as DocCount from ((select ua.username, count(ilcu.usernum) as DocCount ");
                                strSql.Append(@" from hsi.useraccount ua left outer join (select usernum,itemnum from hsi.itemlcxuser where hsi.itemlcxuser.lcnum = ");
                                strSql.Append(gLCNUM);
                                strSql.Append(@") ilcu on ua.usernum = ilcu.usernum inner join hsi.itemlc il on il.itemnum = ilcu.itemnum inner join hsi.itemdata id on ilcu.itemnum = id.itemnum ");
                                strSql.Append(@" inner join hsi.lcstate lcs on il.statenum = lcs.statenum where ua.username in (");
                                strSql.Append(strSQLUsers);
                                strSql.Append(@") and id.status=0 and lcs.statename like 'PMWAP - Initial Review%' and lcs.statename not like 'PMWAP - Research' ");
                                strSql.Append(@" and lcs.statename not like 'PMWAP - Pending Review' and lcs.statename not like 'PMWAP - Application Processing Routing Exceptions' group by ua.username) ");
                                strSql.Append(@" UNION (select ua.username, 0 as DocCount from hsi.useraccount ua where ua.username in ( ");
                                strSql.Append(strSQLUsers);
                                strSql.Append(@") ) ) CT1 group by CT1.username order by DocCount asc ");

                                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("2nd Sql Query: {0}", strSql.ToString()));

                                string connectionStringOnBase = string.Format("DSN={0};Uid={1};Pwd={2};", gODBCOnBase, gUSER, gPASS);
                                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Verbose, string.Format("Connection string: {0}", connectionStringOnBase));

                                string strNextUser = "";
                                using (OdbcConnection conOnBase = new OdbcConnection(connectionStringOnBase))
                                {
                                    try
                                    {
                                        conOnBase.Open();
                                        using (OdbcCommand command = new OdbcCommand(strSql, conOnBase))
                                        using (OdbcDataReader readerOnBase = command.ExecuteReader())
                                        {
                                            if (readerOnBase.HasRows)
                                            {
                                                while (readerOnBase.Read())
                                                {
                                                    strNextUser = readerOnBase[0].ToString();
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new ApplicationException("Error during database operations!", ex);
                                    }
                                    finally
                                    {
                                        if (conOnBase.State == ConnectionState.Open) conOnBase.Close();
                                    }
                                }

                                Keyword kwdUser = null;
                                if (!String.IsNullOrEmpty(strNextUser))
                                {
                                    KeywordType kwtUser = app.Core.KeywordTypes.Find(gSaveToAssignedProc);
                                    if (kwtUser != null)
                                        kwdUser = CreateKeywordHelper(kwtUser, strNextUser);
                                }


                                Keyword kwdUnit = null;
                                if (!String.IsNullOrEmpty(strUnit))
                                {
                                    KeywordType kwtUnit = app.Core.KeywordTypes.Find(gSaveToAssignedProcUnit);
                                    if (kwtUnit != null)
                                        kwdUnit = CreateKeywordHelper(kwtUnit, strUnit);
                                }

                                using (DocumentLock documentLock = _currentDocument.LockDocument())
                                {
                                    // Ensure lock was obtained
                                    if (documentLock.Status != DocumentLockStatus.LockObtained)
                                    {
                                        throw new Exception("Document lock not obtained");
                                    }
                                    // Create keyword modifier object to hold keyword changes
                                    KeywordModifier keyModifier = _currentDocument.CreateKeywordModifier();

                                    // Add update keyword call to keyword modifier object
                                    //Note Overloads available for use
                                    //(I.E.): keyModifier.AddKeyword(keywordTypeName,keywordValue)
                                    if (kwdUnit != null) keyModifier.AddKeyword(kwdUnit);
                                    if (kwdUser != null) keyModifier.AddKeyword(kwdUser);

                                    // Apply keyword change to the document
                                    keyModifier.ApplyChanges();

                                    documentLock.Release();

                                    string output = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.",
                                        gSaveToAssignedProcUnit, strUnit, _currentDocument.ID, Environment.NewLine);

                                    //Output the results to the OnBase Diagnostics Console
                                    app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output);

                                    string output2 = String.Format("Keyword: '{0}' Value: '{1}', {3}added to Document {2}.",
                                        gSaveToAssignedProc, strWFUser, _currentDocument.ID, Environment.NewLine);

                                    app.Diagnostics.WriteIf(Hyland.Unity.Diagnostics.DiagnosticsLevel.Verbose, output2);
                                }
                            }
                            else
                            {
                                throw new Exception(string.Format("No records found in database"));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException("Error during database operations!", ex);
                    }
                    finally
                    {
                        if (con.State == ConnectionState.Open) con.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                // Handle exceptions and log to Diagnostics Console and document history
                HandleException(ex, ref app, ref args);
            }
            finally
            {
                // Log script execution end
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info,
                    string.Format("End Script - [{0}]", ScriptName));
            }
コード例 #27
0
        private bool RunCQ(Application app, WorkflowEventArgs args, string strBusinessUnit, string strAGMeetingMonth, string strAGMeetingYear, string strAGAddendum, string strDocType, string strLicenseType, string strApplicationNumber, long lngDocHandle, string strCameraReady, string lngMstrDocHandle, bool bOkayToProcessWithoutError)

        {
            const long CIU_APPLICATION_MSTR_DTID              = 773;
            const long CIU_CRIMINAL_RESULTS_MSTR_DTID         = 771;
            const long CIU_SUPPORTING_DOCS_MSTR_DTID          = 770;
            const long CIU_CORRESPONDENCE_MSTR_DTID           = 772;
            const long CIU_CR_CAMERA_READY_DOCUMENT_MSTR_DTID = 2343;

            //String to hold output information
            string output = string.Empty;

            WriteLog(app, string.Format("[{0}][{1}][{2}][{3}][{4}][{5}][{6}][{7}]", strBusinessUnit, strAGMeetingYear, strAGMeetingMonth, strAGAddendum, strDocType, strLicenseType, strApplicationNumber, lngDocHandle.ToString(), strCameraReady));

            long gDocTypeID;
            long lngCurrentMSTRDTID;

            switch (strDocType)
            {
            case "CAMERA READY DOCUMENT":
            {
                gDocTypeID         = PCIU_CR_CAMERA_READY_DOCUMENT_DTID;
                lngCurrentMSTRDTID = CIU_CR_CAMERA_READY_DOCUMENT_MSTR_DTID;
                break;
            }

            case "APPLICATION":
            {
                gDocTypeID         = PCIU_APPLICATIONS_CR_DTID;
                lngCurrentMSTRDTID = CIU_APPLICATION_MSTR_DTID;
                break;
            }

            case "CRIMINAL RESULTS":
            {
                gDocTypeID         = PCIU_CRIMINAL_RESULTS_CR_DTID;
                lngCurrentMSTRDTID = CIU_CRIMINAL_RESULTS_MSTR_DTID;
                break;
            }

            case "SUPPORTING DOCS":
            {
                gDocTypeID         = PCIU_SUPPORTING_DOCS_CR_DTID;
                lngCurrentMSTRDTID = CIU_SUPPORTING_DOCS_MSTR_DTID;
                break;
            }

            case "CORRESPONDENCE":
            {
                gDocTypeID         = PCIU_CORRESPONDENCE_CR_DTID;
                lngCurrentMSTRDTID = CIU_CORRESPONDENCE_MSTR_DTID;
                break;
            }

            default:
            {
                gDocTypeID         = 0;
                lngCurrentMSTRDTID = 0;
                break;
            }
            }


            // Create document query
            WriteLog(app, string.Format("Setting up Document Query [{0} - {1}]", strDocType, gDocTypeID.ToString()));
            DocumentQuery documentQuery = app.Core.CreateDocumentQuery();

            // Ensure custom query was found
            if (documentQuery == null)
            {
                throw new Exception("Unable to create document query");
            }

            // Add custom query to document query
            DocumentType docType = app.Core.DocumentTypes.Find(gDocTypeID);

            if (docType == null)
            {
                throw new Exception(string.Format("Could not find document type with ID: {0}", gDocTypeID.ToString()));
            }
            documentQuery.AddDocumentType(docType);

            KeywordType kwdType = app.Core.KeywordTypes.Find(PAPPNUMBERKWID);

            if (kwdType == null)
            {
                throw new Exception(string.Format("Could not find keyword type with ID: {0}", PAPPNUMBERKWID.ToString()));
            }
            documentQuery.AddKeyword(kwdType.Name, Convert.ToInt64(strApplicationNumber));

            kwdType = app.Core.KeywordTypes.Find(PLICTYPEKWID);
            if (kwdType == null)
            {
                throw new Exception(string.Format("Could not find keyword type with ID: {0}", PLICTYPEKWID.ToString()));
            }
            documentQuery.AddKeyword(kwdType.Name, strLicenseType);

            kwdType = app.Core.KeywordTypes.Find(PDOCNUMBERCONSTKWID);
            if (kwdType == null)
            {
                throw new Exception(string.Format("Could not find keyword type with ID: {0}", PDOCNUMBERCONSTKWID.ToString()));
            }
            documentQuery.AddKeyword(kwdType.Name, Convert.ToInt64(lngMstrDocHandle));

            documentQuery.AddSort(DocumentQuery.SortAttribute.DocumentID, true);

            WriteLog(app, string.Format("Running Document Query - Search KW [{0} = {1}]", PAPPNUMBERKWID.ToString(), strApplicationNumber));
            WriteLog(app, string.Format("Running Document Query - Search KW [{0} = {1}]", KNLICTYPE, strLicenseType));
            WriteLog(app, string.Format("Running Document Query - Search KW [{0} = {1}]", KNDOCNUMBERCONSTKWID, lngMstrDocHandle.ToString()));

            // Execute query
            const int    MAX_DOCUMENTS = 1000;
            DocumentList documentList  = documentQuery.Execute(MAX_DOCUMENTS);

            if (documentList.Count == 0)
            {
                if (!bOkayToProcessWithoutError)
                {
                    WriteLog(app, "  ");
                    WriteLog(app, "*************** ERROR: NO DOCUMENTS FOUND IN SEARCH **************");
                    WriteLog(app, "  ");
                    strProcessingErrors = string.Format("{0}{1}  Failed to locate any documents of type - {2}.  AN: {3} - LT: {4}", strProcessingErrors, DateTime.Now, strDocType, strApplicationNumber, strLicenseType);

                    return(false);
                }
                else
                {
                    WriteLog(app, "  ");
                    WriteLog(app, "*************** ERROR BYPASSED: USER STATED TO PROCESS WITH MISSING DOCUMENTS **************");
                    WriteLog(app, "  ");
                    WriteLog(app, "TEST CAMERA READY");
                    WriteLog(app, "  ");
                    return(true);
                }
            }
            // Line 298 from VB script.
            // Iterate through documents returned from query
            bool   bIsFirstDocument = true;
            string ProcessedDocIDs  = "";
            //string ProcessedDoc = "";
            //string strDocID = "";
            string laststrPrimaryDocID = "0";

            //int intNumDocsProcessed = 0;
            //int gDocCount = 0;

            foreach (Document document in documentList)
            {
                if (bIsFirstDocument)
                {
                    DocumentType objDocType = document.DocumentType;
                    WriteLog(app, "  ");
                    WriteLog(app, "*************** SETTING DOCUMENT TYPE TO IT MASTER EQUIVALENT **************");
                    WriteLog(app, "  ");
                    WriteLog(app, String.Format("*************** CURRENT DOCUMENT TYPE : {0} **************", objDocType.Name.ToString().Trim()));
                    WriteLog(app, String.Format("*************** CURRENT DOCUMENT TYPE : {0} **************", objDocType.ID.ToString().Trim()));

                    DocumentType newdoctype = app.Core.DocumentTypes.Find(lngCurrentMSTRDTID);

                    if (newdoctype == null)
                    {
                        throw new ApplicationException(string.Format("Document Type {0} does not exist", lngCurrentMSTRDTID));
                    }
                    Storage           storage           = app.Core.Storage;
                    ReindexProperties reindexProperties = storage.CreateReindexProperties(document, newdoctype);
                    Document          newDocument       = storage.ReindexDocument(reindexProperties);

                    WriteLog(app, String.Format("*************** UPDATED DOCUMENT TYPE : {0} **************", newdoctype.Name));
                    WriteLog(app, String.Format("*************** UPDATED DOCUMENT TYPE ID (Should be: {0} : {1} **************", lngCurrentMSTRDTID.ToString(), document.ID.ToString()));

                    // Update the document AutoName
                    //WriteLog(app,"*************** UPDATED DOCUMENT AUTO NAME: " & Trim(CStr(objDoc.Name)) & " **************")
                    //objDoc.AutoName
                }
                app.Diagnostics.Write(string.Format("Document ID: {0} Document Name: {1}{2}", document.ID, document.Name, Environment.NewLine));
                //Line 349
                //int x = 1;
                // If there are multiple instances of a KW value on a document, we do not want to output the same doc again
                // as the result set will contain an document entry for each unique KW value of the same type.
                if (ProcessedDocIDs.Contains(document.ID.ToString().Trim()) || (document.ID.ToString() == laststrPrimaryDocID.Trim()))
                {
                    app.Diagnostics.Write("Made it into odd logic fork");
                }
                else
                {
                    //intNumDocsProcessed++;
                    ProcessedDocIDs = string.Format("{0}{1}", ProcessedDocIDs, document.ID.ToString().Trim());
                    //gDocCount++;
                    string fileTypeExt = "";

                    long      fileTypeID       = 2;
                    Rendition objFormRendition = document.DefaultRenditionOfLatestRevision;
                    fileTypeID = objFormRendition.FileType.ID;

                    switch (fileTypeID)
                    {
                    case 1:
                        fileTypeExt = "txt";
                        break;

                    case 2:
                        fileTypeExt = "tif";
                        break;

                    case 16:
                        fileTypeExt = "pdf";
                        break;

                    case 17:
                        fileTypeExt = "htm";
                        break;

                    case 13:
                        fileTypeExt = "xls";
                        break;

                    case 12:
                        fileTypeExt = "doc";
                        break;

                    case 14:
                        fileTypeExt = "ppt";
                        break;

                    case 15:
                        fileTypeExt = "rtf";
                        break;

                    case 24:
                        fileTypeExt = "htm";
                        break;

                    case 32:
                        fileTypeExt = "xml";
                        break;

                    default:
                        fileTypeExt = "unknown";
                        break;
                    }

                    KeywordType kwtDocConversionStatus = null;
                    Keyword     kwdDocConversionStatus = null;
                    if (fileTypeExt == "tif")
                    {
                        kwtDocConversionStatus = app.Core.KeywordTypes.Find(DOCUMENTCONVERSIONSTATUS);
                        if (kwtDocConversionStatus == null)
                        {
                            throw new Exception(String.Format("Keyword Type '{0}' not found", DOCUMENTCONVERSIONSTATUS));
                        }
                        kwdDocConversionStatus = CreateKeywordHelper(kwtDocConversionStatus, "CONV OK");
                        WriteLog(app, "Document file format is TIFF");
                    }
                    else
                    {
                        kwtDocConversionStatus = app.Core.KeywordTypes.Find(DOCUMENTCONVERSIONSTATUS);
                        if (kwtDocConversionStatus == null)
                        {
                            throw new Exception(String.Format("Keyword Type '{0}' not found", DOCUMENTCONVERSIONSTATUS));
                        }
                        kwdDocConversionStatus = CreateKeywordHelper(kwtDocConversionStatus, "NOT IMAGE FORMAT");
                        WriteLog(app, "Document file format is NOT TIFF - need to add logic to convert to TIFF");
                        strProcessingErrors = string.Format("{0}{1}{2}   " +
                                                            "Document is not Image File Format - {3}.  AN: {4} - LT: {5}", strProcessingErrors, Environment.NewLine, DateTime.Now.ToString(DateTimeFormat), strDocType, strApplicationNumber, strLicenseType);
                    }

                    using (DocumentLock documentLock = document.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 = document.CreateKeywordModifier();

                        //Add update keyword call to keyword modifier object
                        //Note Overloads available for use
                        //(I.E.): keyModifier.AddKeyword(keywordTypeName,keywordValue)
                        keyModifier.AddKeyword(kwdDocConversionStatus);

                        // Apply keyword change to the document
                        keyModifier.ApplyChanges();

                        WriteLog(app, string.Format("Keyword: '{0}' added to Document .", DOCUMENTCONVERSIONSTATUS));
                    }
                    if (fileTypeExt != "tif")
                    {
                        return(false);
                    }

                    WriteLog(app, string.Format("  Processing DocID [{0}]", document.ID.ToString()));
                    // Set property bag for use by OnBase DocDataProvider object
                    args.PropertyBag.Set("docID", document.ID.ToString());

                    sourceDocHandle = document.ID;

                    // If the source file format is not image, we need to save it out and append to the current document.
                    // Otherwise, we need to append the current image file in the diskgroup
                    // If currentDocumentFileFormatIsImage Then
                    if (bIsFirstDocument)
                    {
                        app.Diagnostics.Write("in first doc logic");
                        destinationDocHandle = sourceDocHandle;
                        bIsFirstDocument     = false;
                    }
                    else
                    {
                        app.Diagnostics.Write("Made it in");
                        AppendToDocument(app, args, sourceDocHandle, destinationDocHandle);
                    }
                }
                laststrPrimaryDocID = document.ID.ToString();
            }
            return(true);
        }