コード例 #1
0
ファイル: MProcess.cs プロジェクト: vuongthai91/ERP-CMR-DMS
        /// <summary>
        /// Starts the class
        /// </summary>
        /// <param name="Classname">class name</param>
        /// <param name="pi">process info</param>
        /// <param name="trx">trx</param>
        /// <returns>status in bool</returns>
        private bool StartClass(String className, ProcessInfo pi, Trx trx)
        {
            bool retValue = false;

            ProcessEngine.ProcessCall myObject = null;

            //System.Reflection.Assembly asm = null;
            Type type = null;

            className = className.Replace("org.compiere.process", "VAdvantage.Process");
            try
            {
                /*********** Module ********************/



                // string cName = className.Substring(className.LastIndexOf('.') + 1);
                //Name Of process
                string cName = pi.GetTitle();


                type = Utility.ModuleTypeConatiner.GetClassType(className, cName);


                //Classname = Classname.Replace("org.compiere", "VAdvantage");
                myObject = (ProcessEngine.ProcessCall)Activator.CreateInstance(type);

                if (myObject == null)
                {
                    retValue = false;
                }
                else
                {
                    retValue = myObject.StartProcess(GetCtx(), pi, trx);
                }
            }
            catch (Exception e)
            {
                pi.SetSummary("Error Start Class " + className, true);
                log.Log(VAdvantage.Logging.Level.SEVERE, className, e);
                //throw new Exception(e.ToString());
            }
            return(retValue);
        }
コード例 #2
0
ファイル: ProcessCtl.cs プロジェクト: vuongthai91/ERP-CMR-DMS
        /// <summary>
        /// Starts the process by calling the required class at run time.
        /// </summary>
        /// <returns>Returs ture or false on the successfull calling of the proecss</returns>
        private bool StartProcess()
        {
            //_trx = Trx.Get("ServerProcess", true);
            //log.Fine(_pi.ToString());
            try
            {
                string className = _pi.GetClassName().Replace("org.compiere.process", "VAdvantage.Process");
                className = className.Replace("org.compiere.wf", "VAdvantage.WF");
                className = className.Replace("org.compiere.report", "VAdvantage.Report");
                className = className.Replace("org.compiere.install", "VAdvantage.Install");
                className = className.Replace("org.compiere.print", "VAdvantage.Print");
                className = className.Replace("org.compiere.cmrp.process", "ViennaAdvantage.CMRP.Process");
                className = className.Replace("org.compiere.cmfg.process", "ViennaAdvantage.CMFG.Process");
                className = className.Replace("org.compiere.cwms.process", "ViennaAdvantage.CWMS.Process");
                className = className.Replace("org.compiere.cm", "VAdvantage.CM");

                /*Customization Process */

                Type   type  = null;
                string cName = _pi.GetTitle();

                type = Utility.ModuleTypeConatiner.GetClassType(className, cName);

                if (type == null)
                {
                    //MessageBox.Show("no Type");
                }

                if (type.IsClass)
                {
                    ProcessEngine.ProcessCall oClass = (ProcessEngine.ProcessCall)Activator.CreateInstance(type);
                    if (oClass == null)
                    {
                        return(false);
                    }
                    else
                    {
                        //oClass.StartProcess(_ctx, _pi, _trx);
                        oClass.StartProcess(_ctx, _pi, _trx);
                    }

                    if (_trx != null)
                    {
                        _trx.Commit();
                        //log.Fine("Commit " + _trx.ToString());
                        _trx.Close();
                    }
                }
            }
            catch
            {
                if (_trx != null)
                {
                    _trx.Rollback();
                    //log.Fine("Rollback " + _trx.ToString());
                    _trx.Close();
                }
                _pi.SetSummary("Error starting Class " + _pi.GetClassName().Replace("org.compiere.process", "VAdvantage.Process"), true);

                //log.Log(Level.SEVERE, _pi.GetClassName(), ex);
            }
            return(!_pi.IsError());
        }