public static ErpBS AbreEmpresa(string strEmpresa, string strUtilizador, string strPassword, string strInstancia)
        {
            //------------------------------------------------------------------------
            //Open plt
            //------------------------------------------------------------------------

            StdBSConfApl objAplConf = new StdBSConfApl();
            ErpBS objMotor = new ErpBS();

            //[ Open Plt 1ª time ]
            EnumTipoPlataforma objTipoPlataforma = new EnumTipoPlataforma();
            objTipoPlataforma = EnumTipoPlataforma.tpProfissional;

            objAplConf.Instancia = strInstancia;
            objAplConf.AbvtApl = "GCP";
            objAplConf.PwdUtilizador = "";
            objAplConf.Utilizador = "";

            StdBETransaccao objStdTransac = new StdBETransaccao();

            Plataforma.AbrePlataformaEmpresaIntegrador(ref strEmpresa, ref objStdTransac, ref objAplConf, ref objTipoPlataforma);

            bool blnModoPrimario = true;
            objMotor.AbreEmpresaTrabalho(ref objTipoPlataforma, ref strEmpresa, ref strUtilizador, ref strPassword, ref objStdTransac, ref strInstancia, ref blnModoPrimario);

            MotorLE = objMotor;

            return MotorLE;
        }
        public static ErpBS AbreEmpresa(string strEmpresa, string strUtilizador, string strPassword, string strInstancia)
        {
            //------------------------------------------------------------------------
            //Open plt
            //------------------------------------------------------------------------

            StdBSConfApl objAplConf = new StdBSConfApl();
            ErpBS        objMotor   = new ErpBS();

            //[ Open Plt 1ª time ]
            EnumTipoPlataforma objTipoPlataforma = new EnumTipoPlataforma();

            objTipoPlataforma = EnumTipoPlataforma.tpProfissional;

            objAplConf.Instancia     = strInstancia;
            objAplConf.AbvtApl       = "GCP";
            objAplConf.PwdUtilizador = "";
            objAplConf.Utilizador    = "";

            StdBETransaccao objStdTransac = new StdBETransaccao();

            Plataforma.AbrePlataformaEmpresaIntegrador(ref strEmpresa, ref objStdTransac, ref objAplConf, ref objTipoPlataforma);


            bool blnModoPrimario = true;

            objMotor.AbreEmpresaTrabalho(ref objTipoPlataforma, ref strEmpresa, ref strUtilizador, ref strPassword, ref objStdTransac, ref strInstancia, ref blnModoPrimario);

            MotorLE = objMotor;

            return(MotorLE);
        }
        private void cmdCriaFatura_Click(object sender, EventArgs e)
        {
            if (!this.bw.IsBusy)
            {
                MotorLE           = new ErpBS();
                objTipoPlataforma = new EnumTipoPlataforma();
                objStdTransac     = new StdBETransaccao();

                bool blnModoPrimario = true;
                objTipoPlataforma = EnumTipoPlataforma.tpEmpresarial;

                try
                {
                    this.MotorLE.AbreEmpresaTrabalho(EnumTipoPlataforma.tpEmpresarial, txtEmpresa.Text
                                                     , txtUtilizador.Text, txtPassword.Text
                                                     , ref objStdTransac
                                                     , "Default"
                                                     , ref blnModoPrimario);

                    this.bw.RunWorkerAsync();
                    this.cmdCriaFatura.Enabled = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro ao abrir o motor. \n" + ex.Message.ToString());
                }
            }
        }
Example #4
0
        /// <summary>
        /// Creats the context.
        /// </summary>
        /// <param name="Company">The company.</param>
        /// <param name="User">The user.</param>
        /// <param name="Password">The password.</param>
        /// <param name="Instance">ERP instance.</param>
        /// <returns></returns>
        public static PriEngine CreatContext(string Company, string User, string Password, string Instance)
        {
            try
            {
                StdLoggingHandler.FileTraceEnterMethod();
                StdLoggingHandler.FileTrace("Creating objects");

                StdBSConfApl objAplConf = new StdBSConfApl();
                StdPlatBS    Plataforma = new StdPlatBS();
                ErpBS        MotorLE    = new ErpBS();

                StdLoggingHandler.FileTrace("Setting configuration");
                EnumTipoPlataforma objTipoPlataforma = EnumTipoPlataforma.tpEmpresarial;

                objAplConf.Instancia       = Instance;
                objAplConf.AbvtApl         = "ERP";
                objAplConf.PwdUtilizador   = Password;
                objAplConf.Utilizador      = User;
                objAplConf.LicVersaoMinima = "10.00";

                StdLoggingHandler.FileTrace("Setting transaccao");
                StdBETransaccao objStdTransac = new StdBETransaccao();

                try
                {
                    StdLoggingHandler.FileTrace("Calling AbrePlataformaEmpresa");
                    Plataforma.AbrePlataformaEmpresa(Company, objStdTransac, objAplConf, objTipoPlataforma);
                    StdLoggingHandler.FileTrace("Exit from AbrePlataformaEmpresa");
                }
                catch (Exception ex)
                {
                    StdLoggingHandler.FileTraceWithThrow(ex);
                    throw;
                }

                if (Plataforma.Inicializada)
                {
                    StdLoggingHandler.FileTrace("Calling AbreEmpresaTrabalho");
                    MotorLE.AbreEmpresaTrabalho(objTipoPlataforma, Company, User, Password, objStdTransac, Instance);
                    StdLoggingHandler.FileTrace("Exit from AbreEmpresaTrabalho");

                    Platform = Plataforma;
                    Engine   = MotorLE;

                    EngineStatus = true;
                }

                return(engineInstance);
            }
            catch (Exception ex)
            {
                StdLoggingHandler.FileTraceWithThrow(ex);
                throw;
            }
            finally
            {
                StdLoggingHandler.FileTraceExitMethod();
            }
        }
Example #5
0
        public static bool InitializeCompany(string Company, string User, string Password)
        {
            if (!initialized)
            {
                StdBSConfApl objAplConf = new StdBSConfApl();
                objAplConf.Instancia       = "Default";
                objAplConf.AbvtApl         = "GCP";
                objAplConf.PwdUtilizador   = Password;
                objAplConf.Utilizador      = User;
                objAplConf.LicVersaoMinima = "9.00";
                StdBETransaccao objStdTransac = new StdBETransaccao();

                StdPlatBS Plataforma = new StdPlatBS();
                ErpBS     MotorLE    = new ErpBS();

                EnumTipoPlataforma objTipoPlataforma = new EnumTipoPlataforma();
                objTipoPlataforma = EnumTipoPlataforma.tpProfissional;

                objAplConf.Instancia       = "Default";
                objAplConf.AbvtApl         = "GCP";
                objAplConf.PwdUtilizador   = Password;
                objAplConf.Utilizador      = User;
                objAplConf.LicVersaoMinima = "9.00";

                // Retuns the ptl.
                Platform = Plataforma;
                // Returns the engine.
                Engine = MotorLE;

                try
                {
                    Platform.AbrePlataformaEmpresa(ref Company, ref objStdTransac, ref objAplConf, ref objTipoPlataforma, "");
                }
                catch (Exception ex)
                {
                    throw new Exception("Error on open Primavera Platform.");
                }

                // Is plt initialized?
                if (Platform.Inicializada)
                {
                    bool blnModoPrimario = true;
                    // Open Engine
                    Engine.AbreEmpresaTrabalho(EnumTipoPlataforma.tpProfissional, ref Company, ref User, ref Password, ref objStdTransac, "Default", ref blnModoPrimario);
                    Engine.set_CacheActiva(false);
                    initialized = true;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
Example #6
0
        public static bool InitializeCompany(string Company, string User, string Password)
        {
            var postCompany  = HttpContext.Current.Request.Form["company"];
            var postUsername = HttpContext.Current.Request.Form["username"];
            var postPassword = HttpContext.Current.Request.Form["password"];

            StdBSConfApl objAplConf = new StdBSConfApl();
            StdPlatBS    Plataforma = new StdPlatBS();
            ErpBS        MotorLE    = new ErpBS();

            EnumTipoPlataforma objTipoPlataforma = new EnumTipoPlataforma();

            objTipoPlataforma = EnumTipoPlataforma.tpProfissional;

            objAplConf.Instancia       = "Default";
            objAplConf.AbvtApl         = "GCP";
            objAplConf.PwdUtilizador   = postPassword;
            objAplConf.Utilizador      = postUsername;
            objAplConf.LicVersaoMinima = "9.00";

            StdBETransaccao objStdTransac = new StdBETransaccao();

            // Opem platform.
            try
            {
                Plataforma.AbrePlataformaEmpresa(ref postCompany, ref objStdTransac, ref objAplConf, ref objTipoPlataforma, "");
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.StatusCode      = (int)HttpStatusCode.Forbidden;
                HttpContext.Current.Response.SuppressContent = true;
                HttpContext.Current.ApplicationInstance.CompleteRequest();
                return(false);
            }

            // Is plt initialized?
            if (Plataforma.Inicializada)
            {
                // Retuns the ptl.
                Platform = Plataforma;

                bool blnModoPrimario = true;

                // Open Engine
                MotorLE.AbreEmpresaTrabalho(EnumTipoPlataforma.tpProfissional, ref postCompany, ref postUsername, ref postPassword, ref objStdTransac, "Default", ref blnModoPrimario);
                MotorLE.set_CacheActiva(false);

                // Returns the engine.
                Engine = MotorLE;

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #7
0
        public Boolean AbrirMotorPrimavera(string userPrimavera, string passUserPrimavera, string empresa, int tipoEmpPRI)
        {
            try
            {
                StdBSConfApl objAplConf = new StdBSConfApl();
                StdPlatBS    Plataforma = new StdPlatBS();
                ErpBS        MotorLE    = new ErpBS();

                EnumTipoPlataforma objTipoPlataforma = new EnumTipoPlataforma();
                objTipoPlataforma = EnumTipoPlataforma.tpEmpresarial;

                objAplConf.Instancia       = "Default";
                objAplConf.AbvtApl         = "ERP";
                objAplConf.PwdUtilizador   = passUserPrimavera;
                objAplConf.Utilizador      = userPrimavera;
                objAplConf.LicVersaoMinima = "9.00";

                StdBETransaccao objStdTransac = new StdBETransaccao();

                try
                {
                    Plataforma.AbrePlataformaEmpresa(ref empresa, ref objStdTransac, ref objAplConf, ref objTipoPlataforma, "");
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                if (Plataforma.Inicializada)
                {
                    plat = Plataforma.InterfacePublico;

                    bool blnModoPrimario = true;

                    MotorLE.AbreEmpresaTrabalho(tipoEmpPRI == 0 ? EnumTipoPlataforma.tpEmpresarial : EnumTipoPlataforma.tpProfissional,
                                                ref empresa, ref userPrimavera, ref passUserPrimavera, ref objStdTransac, "Default", ref blnModoPrimario);
                    MotorLE.set_CacheActiva(true);

                    bso = MotorLE;

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #8
0
        public static bool InitializeCompany(string Company, string User, string Password)
        {
            StdBSConfApl objAplConf = new StdBSConfApl();
            StdPlatBS    Plataforma = new StdPlatBS();
            ErpBS        MotorLE    = new ErpBS();

            EnumTipoPlataforma objTipoPlataforma = new EnumTipoPlataforma();

            objTipoPlataforma = EnumTipoPlataforma.tpProfissional;

            objAplConf.Instancia       = "Default";
            objAplConf.AbvtApl         = "GCP";
            objAplConf.PwdUtilizador   = Password;
            objAplConf.Utilizador      = User;
            objAplConf.LicVersaoMinima = "9.00";

            StdBETransaccao objStdTransac = new StdBETransaccao();

            // Opem platform (verifica se o utilizador tem permissões de acesso)
            try {
                Plataforma.AbrePlataformaEmpresa(ref Company, ref objStdTransac, ref objAplConf, ref objTipoPlataforma, "");
            } catch (Exception ex) {
                throw new Exception("Error on open Primavera Platform: " + ex.Message);
            }

            // Is plt initialized?
            if (Plataforma.Inicializada)
            {
                // Retuns the ptl.
                platform = Plataforma;

                bool blnModoPrimario = true;

                // Open Engine
                MotorLE.AbreEmpresaTrabalho(EnumTipoPlataforma.tpProfissional, ref Company, ref User, ref Password, ref objStdTransac, "Default", ref blnModoPrimario);
                MotorLE.set_CacheActiva(false);

                // Returns the engine.
                engine = MotorLE;

                string databaseInstance = "Default";
                string dbNomeEmpresa    = platform.BaseDados.DaNomeBDdaEmpresa(engine.Contexto.CodEmp);
                databaseConnectionString = platform.BaseDados.DaConnectionStringNET(dbNomeEmpresa, databaseInstance);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #9
0
        public static void OpenPlataform(string Instance, string Company, string User, string Password, bool Executive)
        {
            var objAplConf = new StdBSConfApl();
            EnumTipoPlataforma objTipoPlataforma = Executive ? EnumTipoPlataforma.tpEmpresarial : EnumTipoPlataforma.tpProfissional;

            objAplConf.Instancia       = Instance;
            objAplConf.AbvtApl         = "ERP";
            objAplConf.PwdUtilizador   = Password;
            objAplConf.Utilizador      = User;
            objAplConf.LicVersaoMinima = "10.00";

            StdBETransaccao objStdTransac = new StdBETransaccao();

            Platform = new StdPlatBS();
            Platform.AbrePlataformaEmpresa(Company, objStdTransac, objAplConf, objTipoPlataforma);
        }
Example #10
0
        public void init()
        {
            if (_admBs == null)
            {
                _admBs = new AdmBS();
                StdBETransaccao objtrans = new StdBETransaccao();

                EnumTipoPlataforma tp = EnumTipoPlataforma.tpProfissional;
                if (Type.Equals("Executive"))
                {
                    tp = EnumTipoPlataforma.tpEmpresarial;
                }

                _admBs.AbrePRIEMPRE(ref tp, User, Password, ref objtrans, Instance);
            }
        }
Example #11
0
        /// <summary>
        /// Only intialized in the frist time.
        /// </summary>
        /// <param name="Company"></param>
        /// <param name="User"></param>
        /// <param name="Password"></param>
        public static bool InitializeCompany(string Company, string User, string Password)
        {
            StdBSConfApl objAplConf = new StdBSConfApl();
            StdPlatBS    Plataforma = new StdPlatBS();
            ErpBS        MotorLE    = new ErpBS();

            EnumTipoPlataforma objTipoPlataforma = new EnumTipoPlataforma();

            objTipoPlataforma = EnumTipoPlataforma.tpEmpresarial;

            objAplConf.Instancia       = "Default";
            objAplConf.AbvtApl         = "ERP";
            objAplConf.PwdUtilizador   = Password;
            objAplConf.Utilizador      = User;
            objAplConf.LicVersaoMinima = "9.00";

            StdBETransaccao objStdTransac = new StdBETransaccao();

            try
            {
                Plataforma.AbrePlataformaEmpresa(ref Company, ref objStdTransac, ref objAplConf, ref objTipoPlataforma, "");
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            if (Plataforma.Inicializada)
            {
                Platform = Plataforma;

                bool blnModoPrimario = true;

                MotorLE.AbreEmpresaTrabalho(EnumTipoPlataforma.tpEmpresarial, ref Company, ref User, ref Password, ref objStdTransac, "Default", ref blnModoPrimario);
                MotorLE.set_CacheActiva(true);

                Engine = MotorLE;

                return(true);
            }
            else
            {
                return(false);
            }
        }
        public static bool InitializeCompany(string Company, string User, string Password)
        {
            StdBSConfApl objAplConf = new StdBSConfApl();
            StdPlatBS    Plataforma = new StdPlatBS();
            ErpBS        MotorLE    = new ErpBS();

            EnumTipoPlataforma objTipoPlataforma = new EnumTipoPlataforma();

            objTipoPlataforma = EnumTipoPlataforma.tpProfissional;

            objAplConf.Instancia     = "Default";
            objAplConf.AbvtApl       = "GCP";
            objAplConf.Utilizador    = User;
            objAplConf.PwdUtilizador = Password;


            StdBETransaccao objStdTransac = new StdBETransaccao();

            // Opem platform.
            Plataforma.AbrePlataformaEmpresaIntegrador(ref Company, ref objStdTransac, ref objAplConf, ref objTipoPlataforma);

            // Is plt initialized?
            if (Plataforma.Inicializada)
            {
                // Retuns the ptl.
                Platform = Plataforma;

                bool blnModoPrimario = true;

                // Open Engine
                MotorLE.AbreEmpresaTrabalho(EnumTipoPlataforma.tpProfissional, ref Company, ref User, ref Password, ref objStdTransac, "Default", ref blnModoPrimario);

                // Returns the engine.
                Engine = MotorLE;

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #13
0
        public static bool InitializeCompany(string Company, string User, string Password)
        {
            StdBSConfApl objAplConf = new StdBSConfApl();
            StdPlatBS Plataforma = new StdPlatBS();
            ErpBS MotorLE = new ErpBS();

            EnumTipoPlataforma objTipoPlataforma = new EnumTipoPlataforma();
            objTipoPlataforma = EnumTipoPlataforma.tpProfissional;

            objAplConf.Instancia = "Default";
            objAplConf.AbvtApl = "GCP";
            objAplConf.PwdUtilizador = Password;
            objAplConf.Utilizador = User;

            StdBETransaccao objStdTransac = new StdBETransaccao();

            // Opem platform.
            Plataforma.AbrePlataformaEmpresaIntegrador(ref Company, ref objStdTransac, ref objAplConf, ref objTipoPlataforma);

            // Is plt initialized?
            if (Plataforma.Inicializada)
            {

                // Retuns the ptl.
                Platform = Plataforma;

                bool blnModoPrimario = true;

                // Open Engine
                MotorLE.AbreEmpresaTrabalho(EnumTipoPlataforma.tpProfissional, ref Company, ref User, ref Password, ref objStdTransac, "Default", ref blnModoPrimario);
                _connection = Plataforma.BaseDados.AbreBaseDadosADO("Default", "PRI" + Company);

                // Returns the engine.
                Engine = MotorLE;

                return true;
            }
            else
            {
                return false;
            }
        }
Example #14
0
        public static bool InitializeCompany(string Company, string User, string Password)
        {
            EnumTipoPlataforma objTipoPlataforma = new EnumTipoPlataforma();
            objTipoPlataforma = EnumTipoPlataforma.tpProfissional;
            objAplConf.Instancia = "Default";
            objAplConf.AbvtApl = "GCP";
            objAplConf.PwdUtilizador = Password;
            objAplConf.Utilizador = User;
            StdBETransaccao objStdTransac = new StdBETransaccao();
            // Opem platform.
            try
            {
                Plataforma.AbrePlataformaEmpresaIntegrador(ref Company, ref objStdTransac, ref objAplConf, ref objTipoPlataforma);
                // Is plt initialized?
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                return false;
            }
            if (Plataforma.Inicializada)
            {
                // Retuns the ptl.
                Platform = Plataforma;
                bool blnModoPrimario = true;
                // Open Engine
                MotorLE.AbreEmpresaTrabalho(EnumTipoPlataforma.tpProfissional, ref Company, ref User, ref Password, ref objStdTransac, "Default", ref blnModoPrimario);

                // Returns the engine.
                Engine = MotorLE;
                return true;
            }
            else
            {
                return false;
            }
        }