/// <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(); } }
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); } }
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); } }
public static PriEngine CreatContext(string Company, string User, string Password) { StdBSConfApl objAplConf = new StdBSConfApl(); StdPlatBS Plataforma = new StdPlatBS(); ErpBS MotorLE = new ErpBS(); EnumTipoPlataforma objTipoPlataforma; objTipoPlataforma = EnumTipoPlataforma.tpEmpresarial; objAplConf.Instancia = "Default"; objAplConf.AbvtApl = "ERP"; objAplConf.PwdUtilizador = Password; objAplConf.Utilizador = User; objAplConf.LicVersaoMinima = "10.00"; StdBETransaccao objStdTransac = new StdBETransaccao(); try { Plataforma.AbrePlataformaEmpresa(Company, objStdTransac, objAplConf, objTipoPlataforma); } catch (Exception ex) { throw (ex); } if (Plataforma.Inicializada) { // Use this service to trigger the API events. ExtensibilityService service = new ExtensibilityService(); // Suppress all message box events from the API. // Plataforma.ExtensibilityLogger.AllowInteractivity = false; service.Initialize(MotorLE); // Check if service is operational if (service.IsOperational) { // Inshore that all extensions are loaded. service.LoadExtensions(); } MotorLE.AbreEmpresaTrabalho(objTipoPlataforma, Company, User, Password, objStdTransac, "Default"); Platform = Plataforma; Engine = MotorLE; EngineStatus = true; } return(engineInstance); }
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; } }
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); } }
/// <summary> /// This method is called when the application is loaded. /// </summary> /// <param name="enuTipoPlataforma"></param> /// <param name="strEmpresa"></param> /// <param name="strInstalacao"></param> /// <param name="objLic"></param> public void Inicializa(StdBETipos.EnumTipoPlataforma enuTipoPlataforma, string strEmpresa, string strInstalacao, clsLicenca objLic) { StdPlatBS plataforma = new StdPlatBS(); StdBSConfApl objAplConf = new StdBSConfApl(); objAplConf.Instancia = "Default"; objAplConf.AbvtApl = "ERP"; objAplConf.PwdUtilizador = this.PassWord; objAplConf.Utilizador = this.UserName; objAplConf.LicVersaoMinima = "10.00"; plataforma.AbrePlataformaEx(enuTipoPlataforma, strInstalacao, objAplConf); this.Plataforma = plataforma; }
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); }
/// <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); } }
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; } }
public static bool InitializeCompany() { if (Platform != null && Platform.Inicializada) { return(true); } bool blnModoPrimario = true; var objAplConf = new StdBSConfApl(); objAplConf.Instancia = "Default"; objAplConf.AbvtApl = "GCP"; objAplConf.PwdUtilizador = Properties.Settings.Default.Password.Trim(); objAplConf.Utilizador = Properties.Settings.Default.User.Trim(); objAplConf.LicVersaoMinima = "9.00"; var MotorLE = new ErpBS(); var Plataforma = new StdPlatBS(); var objStdTransac = new StdBETransaccao(); var tipoPlataforma = EnumTipoPlataforma.tpProfissional; try { Plataforma.AbrePlataformaEmpresa(Properties.Settings.Default.Company.Trim(), ref objStdTransac, ref objAplConf, ref tipoPlataforma, ""); } catch { return(false); } PrimaveraEngine.InitializeSQLite(); if (Plataforma.Inicializada) { Platform = Plataforma; MotorLE.AbreEmpresaTrabalho(EnumTipoPlataforma.tpProfissional, Properties.Settings.Default.Company.Trim(), Properties.Settings.Default.User.Trim(), Properties.Settings.Default.Password.Trim(), ref objStdTransac, "Default", ref blnModoPrimario); MotorLE.set_CacheActiva(true); Engine = MotorLE; } return(Plataforma.Inicializada); }
public void AbrePlataforma(ErpBS motor) { StdBSConfApl objAplConf = new StdBSConfApl(); plat = new StdPlatBS(); try { objAplConf.Instancia = motor.Contexto.Instancia; objAplConf.AbvtApl = "ERP"; objAplConf.PwdUtilizador = motor.Contexto.PasswordUtilizadorActual; objAplConf.Utilizador = motor.Contexto.UtilizadorActual; objAplConf.LicVersaoMinima = "10.00"; plat.AbrePlataformaEmpresa(motor.Contexto.CodEmp, null, objAplConf, motor.Contexto.TipoPlataforma); } catch (Exception ex) { throw ex; } }
public static PriEngine CreatContext(string Company, string User, string Password) { StdBSConfApl objAplConf = new StdBSConfApl(); StdPlatBS Plataforma = new StdPlatBS(); ErpBS MotorLE = new ErpBS(); EnumTipoPlataforma objTipoPlataforma; objTipoPlataforma = EnumTipoPlataforma.tpEmpresarial; objAplConf.Instancia = "Default"; objAplConf.AbvtApl = "ERP"; objAplConf.PwdUtilizador = Password; objAplConf.Utilizador = User; objAplConf.LicVersaoMinima = "10.00"; StdBETransaccao objStdTransac = new StdBETransaccao(); try { Plataforma.AbrePlataformaEmpresa(Company, objStdTransac, objAplConf, objTipoPlataforma); } catch (Exception ex) { throw (ex); } if (Plataforma.Inicializada) { MotorLE.AbreEmpresaTrabalho(objTipoPlataforma, Company, User, Password, objStdTransac, "Default"); Platform = Plataforma; Engine = MotorLE; EngineStatus = true; } return(engineInstance); }
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; } }
public string DocFacturaToPDF(string cliente,string serie, string tipodoc,int numdoc) { try { var objConfPlat = new StdBSConfApl(); objConfPlat.AbvtApl = "GCP"; objConfPlat.Instancia = "DEFAULT"; objConfPlat.Utilizador = _erpBs.Contexto.UtilizadorActual; objConfPlat.PwdUtilizador = _erpBs.Contexto.PasswordUtilizadorActual; objConfPlat.LicVersaoMinima = "9.00"; StdBETransaccao objTrans = new StdBETransaccao(); StdPlatBS _plataforma = new StdPlatBS(); _plataforma.AbrePlataformaEmpresa(_erpBs.Contexto.CodEmp, null, objConfPlat, _erpBs.Contexto.TipoPlataforma, ""); string _CurrentDocId; string folder; _CurrentDocId = String.Format("{0}_{1}_{2}", "Pendentes", cliente, DateTime.Now.ToString("dd_MM_yyyy_hh_mm_ss")); folder = String.Format(@"{0}{1}\", @"c:\Emails\", _erpBs.Contexto.CodEmp); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } string sFileName = String.Format("{0}{1}.pdf", folder, _CurrentDocId); if (!File.Exists(sFileName)) { _plataforma.Mapas.Inicializar("GCP"); _plataforma.Contexto.Erp.set_Inicializado(true); // Inicialização dos parametros do report string inicializaParametros = "NumberVar TipoDesc;NumberVar RegimeIva;NumberVar DecQde;NumberVar DecPrecUnit;StringVar MotivoIsencao;StringVar PRI_TextoCertificacao;"; inicializaParametros += "TipoDesc:=" + 1 + ";RegimeIva:=3;DecQde:=1;DecPrecUnit:=" + 2 + ";MotivoIsencao:=' ';"; inicializaParametros += String.Format("PRI_TextoCertificacao:='{0}'", _erpBs.Comercial.Vendas.DevolveTextoAssinaturaDoc(tipodoc, serie, numdoc,"000")); // Dados da empresa para colocar no mapa string dadosEmpresa = "StringVar Nome; StringVar Morada;StringVar Localidade; StringVar CodPostal; StringVar Telefone; StringVar Fax; StringVar Contribuinte; StringVar CapitalSocial; StringVar Conservatoria; StringVar Matricula;StringVar MoedaCapitalSocial;"; dadosEmpresa += String.Format("Nome:='{0}';", _erpBs.Contexto.IDNome); dadosEmpresa += String.Format("Localidade:='{0}';", _erpBs.Contexto.IDLocalidade); dadosEmpresa += String.Format("CodPostal:='{0}';", _erpBs.Contexto.IDCodPostal); dadosEmpresa += String.Format("Telefone:='{0}';", _erpBs.Contexto.IDTelefone); dadosEmpresa += String.Format("Fax:='{0}';", _erpBs.Contexto.IDFax); dadosEmpresa += String.Format("Contribuinte:='{0}';", _erpBs.Contexto.IFNIF); dadosEmpresa += String.Format("CapitalSocial:='{0}';", _erpBs.Contexto.ICCapitalSocial); dadosEmpresa += String.Format("Conservatoria:='{0}';", _erpBs.Contexto.ICConservatoria); dadosEmpresa += String.Format("Matricula:='{0}';", _erpBs.Contexto.ICMatricula); dadosEmpresa += String.Format("MoedaCapitalSocial:='{0}';", _erpBs.Contexto.ICMoedaCapSocial); // filtro para o documento a imprimir string sFiltro = String.Format("{{Cabecdoc.Serie}}='{0}' and {{cabecdoc.tipodoc}}='{1}' and {{cabecdoc.numdoc}}={2}", serie, tipodoc, numdoc); // Modelo definido para a serie string sMapa = _erpBs.Comercial.Series.DaConfig("V", tipodoc, serie); bool bMapaSistema; try { bMapaSistema = (int)_plataforma.Administrador.Consulta(String.Format("select custom from mapas where mapa='{0}'", sMapa)).Valor(0) == 0; } catch { bMapaSistema = false; } // formulas para o mapa _plataforma.Mapas.AddFormula("InicializaParamentros", inicializaParametros, true); _plataforma.Mapas.AddFormula("DadosEmpresa", dadosEmpresa, true); // Propriedades para o output dos mapas _plataforma.Mapas.set_Destino(CRPEExportDestino.edFicheiro); _plataforma.Mapas.SetFileProp(CRPEExportFormat.efPdf, sFileName); // Imprime a listagem (Gera o PDF) //short a = _plataforma.Mapas.ImprimeListagem(sMapa, "Extrato Pendentes", "P", 1, "N", sFiltro, CRPESentidoOrdenacao.soNenhuma, false, bMapaSistema, "", false, 0, false); short a = _plataforma.Mapas.ImprimeListagem(sMapa, "FACTURA", "P", 1, "S", sFiltro, CRPESentidoOrdenacao.soNenhuma, false, bMapaSistema, "", false, 0, false); if (File.Exists(sFileName)) { return (sFileName); } else { return ""; } } else return (sFileName); } catch (Exception ex) { System.Diagnostics.Debug.Print(ex.ToString()); return ex.Message; } }