Esempio n. 1
0
        }       //	getName

        /// <summary>
        /// Rollback
        /// </summary>
        /// <returns>true, if success</returns>
        public bool Rollback()
        {
            try
            {
                if (_conn != null && _trx != null && _trx.Connection != null)
                {
                    _trx.Rollback();
                    log.Info("**R** " + _trxName);
                    _active = false;

                    if (_trxUniqueName != null)
                    {
                        ManageSkippedWF.Remove(_trxUniqueName);
                    }
                    return(true);
                }
            }
            catch (Exception e)
            {
                log.Log(Level.SEVERE, _trxName, e);
            }

            _active = false;
            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// Commit
        /// </summary>
        /// <returns>true, if success</returns>
        public bool Commit()
        {
            try
            {
                if (_conn != null && _trx != null && _trx.Connection != null)
                {
                    _trx.Commit();
                    log.Info("**C** " + _trxName);
                    _active = false;

                    if (_trxUniqueName != null)
                    {
                        ManageSkippedWF.Execute(_trxUniqueName);
                    }
                    return(true);
                }
            }
            catch (Exception sqlex)
            {
                log.Log(Level.SEVERE, _trxName, sqlex);
            }

            _active = false;
            return(false);
        }
        /// <summary>
        /// Process Document Value Workflow
        /// </summary>
        /// <param name="document">document</param>
        /// <param name="AD_Table_ID">table</param>
        /// <returns>true if WF started</returns>
        public bool Process(PO document, int AD_Table_ID)
        {
            _noCalled++;
            MWorkflow[] wfs = MWorkflow.GetDocValue(document.GetCtx(),
                                                    document.GetAD_Client_ID(), AD_Table_ID);
            if (wfs == null || wfs.Length == 0)
            {
                return(false);
            }

            bool started = false;

            for (int i = 0; i < wfs.Length; i++)
            {
                MWorkflow wf = wfs[i];
                //	We have a Document Workflow
                String logic = wf.GetDocValueLogic();
                if (logic == null || logic.Length == 0)
                {
                    log.Severe("Workflow has no Logic - " + wf.GetName());
                    continue;
                }

                //	Re-check: Document must be same Client as workflow
                if (wf.GetAD_Client_ID() != document.GetAD_Client_ID())
                {
                    continue;
                }

                //	Check Logic
                bool sql = logic.StartsWith("SQL=");
                if (sql && !TestStart(wf, document))
                {
                    log.Fine("SQL Logic evaluated to false (" + logic + ")");
                    continue;
                }
                if (!sql && !Evaluator.EvaluateLogic(document, logic))
                {
                    log.Fine("Logic evaluated to false (" + logic + ")");
                    continue;
                }

                if (document.Get_Trx() != null)
                {
                    ManageSkippedWF.Add(document.Get_Trx().SetUniqueTrxName(Trx.CreateTrxName("WFDV")), document);
                    log.Severe("Not started: " + wf);
                    continue;
                }
                //	Start Workflow
                log.Fine(logic);
                int         AD_Process_ID = 305;        //	HARDCODED
                ProcessInfo pi            = new ProcessInfo(wf.GetName(), AD_Process_ID, AD_Table_ID, document.Get_ID());
                pi.SetAD_User_ID(document.GetCtx().GetAD_User_ID());
                pi.SetAD_Client_ID(document.GetAD_Client_ID());

                // vinay bhatt for window id
                pi.SetAD_Window_ID(document.GetAD_Window_ID());
                //

                wf.GetCtx().SetContext("#AD_Client_ID", pi.GetAD_Client_ID().ToString());
                if (wf.Start(pi) != null)
                {
                    log.Config(wf.GetName());
                    _noStarted++;
                    started = true;
                }
            }
            return(started);
        }