/// <summary>
        /// Initialize global settings
        /// </summary>
        /// <param name="app">Unity Application object</param>
        /// <param name="args">Workflow event arguments</param>
        private void IntializeScript(ref Application app, ref WorkflowEventArgs args)
        {
            // Set the specified diagnostics level
            app.Diagnostics.Level = DiagLevel;

            // Log script execution start
            app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info,
                                    string.Format("{0} - Start Script - [{1}]", DateTime.Now.ToString(DateTimeFormat), ScriptName));

            // Capture active document as global
            _currentDocument = args.Document;
            //  _currentDocument = app.Core.GetDocumentByID(TestDocId);
            // If an error was stored in the property bag from a previous execution, clear it
            if (args.SessionPropertyBag.ContainsKey(ErrorMessageProperty))
            {
                args.SessionPropertyBag.Remove(ErrorMessageProperty);
            }

            // Set ScriptResult = true for workflow rules (will become false if an error is caught)
            args.ScriptResult = true;
        }
 ///--------------------------------------------------------------------------------
 /// <summary>This method applies workflow updates.</summary>
 ///--------------------------------------------------------------------------------
 public void ProcessEditWorkflowPerformed(WorkflowEventArgs data)
 {
     try
     {
         bool isItemMatch = false;
         if (data != null && data.Workflow != null)
         {
             foreach (WorkflowViewModel item in Workflows)
             {
                 if (item.Workflow.WorkflowID == data.Workflow.WorkflowID)
                 {
                     isItemMatch = true;
                     item.Workflow.TransformDataFromObject(data.Workflow, null, false);
                     item.OnUpdated(item, null);
                     item.ShowInTreeView();
                     break;
                 }
             }
             if (isItemMatch == false)
             {
                 // add new Workflow
                 data.Workflow.Solution = Solution;
                 WorkflowViewModel newItem = new WorkflowViewModel(data.Workflow, Solution);
                 newItem.Updated += new EventHandler(Children_Updated);
                 Workflows.Add(newItem);
                 Solution.WorkflowList.Add(newItem.Workflow);
                 Items.Add(newItem);
                 OnUpdated(this, null);
                 newItem.ShowInTreeView();
             }
         }
     }
     catch (Exception ex)
     {
         ShowIssue(ex.Message + ex.StackTrace);
     }
 }
Beispiel #3
0
        // This method will be called when a workflow instance is idled
        static void OnWorkflowIdled(object sender, WorkflowEventArgs e)
        {
            orderService.instanceId = e.WorkflowInstance;

            // Randomly approve, reject or timeout purchase orders
            Random randGen = new Random();

            int pick = randGen.Next(1, 100) % 3;

            switch (pick)
            {
            case 0:
                orderService.ApproveOrder();
                break;

            case 1:
                orderService.RejectOrder();
                break;

            case 2:
                // timeout
                break;
            }
        }
Beispiel #4
0
 // This method will be called when a workflow is aborted, such as by a failed database connection.
 static void OnWorkflowAborted(object sender, WorkflowEventArgs e)
 {
     Console.WriteLine("Workflow aborted: Please check database connectivity");
     waitHandle.Set();
 }
 public void OnNodeCompleted(object sender, WorkflowEventArgs e)
 {
     //nothing to do
 }
 public void OnProcessRejected(object sender, WorkflowEventArgs e)
 {
     //nothing to do
 }
 //Called when the workflow is unloaded from memory - in this sample the workflow instance is unloaded by the application
 // in the UnloadInstance method below.
 static void OnWorkflowUnloaded(object sender, WorkflowEventArgs e)
 {
     Console.WriteLine("Workflow was unloaded.");
 }
Beispiel #8
0
 static void OnWorkflowResume(object sender, WorkflowEventArgs instance)
 {
     Console.WriteLine("\nWorkflow Resumed event raised");
 }
Beispiel #9
0
 // Called when a workflow is started
 static void OnWorkflowStarted(object sender, WorkflowEventArgs e)
 {
     Console.WriteLine("Workflow started.\n");
 }
Beispiel #10
0
 static void OnWorkflowResume(object sender, WorkflowEventArgs instance)
 {
 }
 private void Publish_After(object sender, WorkflowEventArgs e)
 {
     SiteimproveUtility.RecheckNode(e.PublishedDocument);
 }
Beispiel #12
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));
            }
        }
Beispiel #13
0
 private static void workflowRuntime_WorkflowLoaded(object sender, WorkflowEventArgs e)
 {
     Debug.WriteLine("Loaded " + e.WorkflowInstance.InstanceId + " on " + DateTime.Now.ToUniversalTime());
 }
Beispiel #14
0
 //Called when the workflow is idle - in this sample this occurs when the workflow is waiting on the
 // delay1 activity to expire.
 static void OnWorkflowIdled(object sender, WorkflowEventArgs e)
 {
     Console.WriteLine("Workflow is idle.");
     e.WorkflowInstance.TryUnload();
 }
Beispiel #15
0
 private WorkflowResults(WorkflowEventArgs args)
 {
     Check.ArgumentIsNotNull(args, "args");
     InstanceId = args.WorkflowInstance.InstanceId;
 }
        /***********************************************
        * USER/SE: PLEASE DO NOT EDIT BELOW THIS LINE *
        ***********************************************/

        #region IWorkflowScript

        /// <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
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("{0} - Start Script - [{1}]", DateTime.Now.ToString(DateTimeFormat), ScriptName));

                // Get the active document
                Document objCurrentDocument = args.Document;
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Processing document: {0}", objCurrentDocument.ID.ToString()));

                // Get the default rendition
                Rendition objFormRendition = objCurrentDocument.DefaultRenditionOfLatestRevision;

                DocumentType objCrdDocType = app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE);

                // Validate the document type
                //DocumentType objCrdDocType = app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE);
                if (objCrdDocType == null)
                {
                    throw new InvalidProgramException(string.Format("Document type \"{0}\" does not exist!", CRD_DOCUMENT_TYPE));
                }

                //If the doc is already an image, pull it in its default format and save the new copy
                if (objFormRendition.FileType.ID == IMAGE_FILE_TYPE)
                {
                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "Document is an image, save copy to new Doc Type");

                    DefaultDataProvider objDefaultProvider  = app.Core.Retrieval.Default;
                    PageData            objDefaultImageData = objDefaultProvider.GetDocument(objFormRendition);

                    StoreNewDocumentProperties objDocProps = app.Core.Storage.CreateStoreNewDocumentProperties(objCrdDocType, app.Core.FileTypes.Find(IMAGE_FILE_TYPE));

                    foreach (KeywordRecord objKeyRecord in objCurrentDocument.KeywordRecords)
                    {
                        if (objKeyRecord.KeywordRecordType.RecordType == RecordType.StandAlone || objKeyRecord.KeywordRecordType.RecordType == RecordType.SingleInstance)
                        {
                            foreach (Keyword objKeyword in objKeyRecord.Keywords)
                            {
                                if (objCrdDocType.KeywordRecordTypes.FindKeywordType(objKeyword.KeywordType.ID) != null)
                                {
                                    objDocProps.AddKeyword(objKeyword);
                                }
                            }
                        }
                        else
                        {
                            EditableKeywordRecord objEditRecord = objKeyRecord.CreateEditableKeywordRecord();
                            objDocProps.AddKeywordRecord(objEditRecord);
                        }
                    }

                    // Store the new document
                    Document objNewDoc = null;
                    objNewDoc = app.Core.Storage.StoreNewDocument(objDefaultImageData, objDocProps);
                    if (objNewDoc == null)
                    {
                        throw new InvalidProgramException("Failed to store new document");
                    }
                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Stored new document: {0}", objNewDoc.ID.ToString()));

                    // Clean up
                    objDefaultImageData.Dispose();

                    // If we got here, the script was successful
                    args.ScriptResult = true;
                }
                //If the Doc is Word or Excel, convert it with the conversion utility and save it
                else if (objFormRendition.FileType.ID == WORD_FILE_TYPE || objFormRendition.FileType.ID == PDF_FILE_TYPE)
                {
                    ConversionUtilities unityConverter = new ConversionUtilities(app, TEMP_DIRECTORY, CONVERTER_DIRECTORY);
                    app.Diagnostics.Write("Word/PDF file conversion");

                    List <FileDefinition> files = unityConverter.Convert(args.Document, UnityFileConversions.ImxFileType.Image, UnityFileConversions.ImportType.Document, app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE));

                    unityConverter.CleanupFiles();

                    args.ScriptResult = true;
                }
                else
                {
                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "Document is not image/Word/PDF, convert to new Doc Type");

                    ImageDataProvider objImageProvider = app.Core.Retrieval.Image;
                    PageData          objImageData     = objImageProvider.GetDocument(objFormRendition);

                    StoreNewDocumentProperties objDocProps = app.Core.Storage.CreateStoreNewDocumentProperties(objCrdDocType, app.Core.FileTypes.Find(IMAGE_FILE_TYPE));

                    foreach (KeywordRecord objKeyRecord in objCurrentDocument.KeywordRecords)
                    {
                        if (objKeyRecord.KeywordRecordType.RecordType == RecordType.StandAlone || objKeyRecord.KeywordRecordType.RecordType == RecordType.SingleInstance)
                        {
                            foreach (Keyword objKeyword in objKeyRecord.Keywords)
                            {
                                if (objCrdDocType.KeywordRecordTypes.FindKeywordType(objKeyword.KeywordType.ID) != null)
                                {
                                    objDocProps.AddKeyword(objKeyword);
                                }
                            }
                        }
                        else
                        {
                            EditableKeywordRecord objEditRecord = objKeyRecord.CreateEditableKeywordRecord();
                            objDocProps.AddKeywordRecord(objEditRecord);
                        }
                    }

                    // Store the new document
                    Document objNewDoc = null;
                    objNewDoc = app.Core.Storage.StoreNewDocument(objImageData, objDocProps);
                    if (objNewDoc == null)
                    {
                        throw new InvalidProgramException("Failed to store new document");
                    }
                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Stored new document: {0}", objNewDoc.ID.ToString()));

                    // Clean up
                    objImageData.Dispose();

                    // If we got here, the script was successful
                    args.ScriptResult = true;
                }
            }
            catch (InvalidProgramException ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Invalid Program Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            catch (UnityAPIException ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Unity API Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            catch (Exception ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("General Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            finally
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("End Script - [{0}]", ScriptName));
            }
        }
Beispiel #17
0
 private static void workflowRuntime_WorkflowUnloaded(Object sender, WorkflowEventArgs e)
 {
     Trace.WriteLine(string.Format("Workflow {0}: Unloaded", e.WorkflowInstance.InstanceId));
 }
Beispiel #18
0
 void workflowRuntime_WorkflowIdled(object sender, WorkflowEventArgs e)
 {
     this.UpdateButtonStatus();
 }
Beispiel #19
0
 static void wr_WorkflowIdled(object sender, WorkflowEventArgs e)
 {
     Console.ForegroundColor = ConsoleColor.DarkYellow;
     Console.WriteLine("Idled:\t\t{0}", e.WorkflowInstance.InstanceId);
     Console.ResetColor();
 }
Beispiel #20
0
 static void OnWorkflowStarted(object sender, WorkflowEventArgs e)
 {
 }
        /// <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));
            }
        }
Beispiel #22
0
 static void OnWorkflowCreated(object sender, WorkflowEventArgs e)
 {
     ThreadMonitor.WriteToConsole(Thread.CurrentThread, "Host", "Host: Processed WorkflowCreated Event");
 }
Beispiel #23
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));
            }
        }
Beispiel #24
0
 static void wr_WorkflowCreated(object sender, WorkflowEventArgs e)
 {
     Console.ForegroundColor = ConsoleColor.DarkYellow;
     Console.WriteLine("Created:\t{0}, {1}", e.WorkflowInstance.InstanceId, e.WorkflowInstance.GetWorkflowDefinition().Name);
     Console.ResetColor();
 }
Beispiel #25
0
 void Runtime_WorkflowAborted(object sender, WorkflowEventArgs e)
 {
     //CurrentResultsInContext = WorkflowResults.CreateAbortedWorkflowResults(e);
 }
Beispiel #26
0
 void Runtime_WorkflowIdled(object sender, WorkflowEventArgs e)
 {
     CurrentResultsInContext = WorkflowResults.CreateRunningWorkflowResults(e);
 }
 public void OnProcessApprovalCompleted(object sender, WorkflowEventArgs e)
 {
     //nothing to do
 }
Beispiel #28
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));
            }
 public void OnNodeInitiated(object sender, WorkflowEventArgs e)
 {
     //nothing to do
 }
 //Called when the workflow is persisted - in this sample when it is unloaded and completed
 static void OnWorkflowPersisted(object sender, WorkflowEventArgs e)
 {
     Console.WriteLine("Workflow was persisted.");
 }
Beispiel #31
0
        protected void WorkflowDesigner1_SavingFile(object sender, WorkflowEventArgs e)
        {
            string pdl = e.Content;
            Regex r = new Regex("<owner>(.*?)</owner>");
            pdl = r.Replace(pdl, "<owner>OA</owner>");
            P_FileName = e.FileName;
            e.Content = pdl;

            //取第一个Name节点
            r = new Regex("<name>(.*?)</name>");
            MatchCollection mc = r.Matches(pdl);
            if (mc.Count > 0)
                P_DeployName = GetValue(mc[0].Value, "<name>", "</name>");
            SaveData();
        }