/// <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(); } }
private void SimulateException() { try { File.ReadAllLines("notexistingfile"); } catch (Exception ex) { StdLoggingHandler.FileTrace(ex); } }
/// <summary> /// Shows the error message. /// </summary> /// <param name="message">The message.</param> /// <param name="title">The title.</param> /// <param name="frm">The FRM.</param> public static void ShowErrorMessage(string message, string title, Form frm) { if (PriEngine.Platform == null) { MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { PriEngine.Platform.AlertNotificationManager.ShowCustomAlert(title, message, Properties.Resources.error, frm); } StdLoggingHandler.FileTrace($"ERROR: {title} | {message}"); }
/// <summary> /// Handles the Click event of the CmdLogin control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void CmdLogin_Click(object sender, EventArgs e) { try { StdLoggingHandler.FileTraceEnterMethod(); StdLoggingHandler.FileTrace("Building priengine context"); PriEngine.CreatContext(txtempresa.Text, txtuser.Text, txtpass.Text, txtInstance.Text); StdLoggingHandler.FileTrace("Check priengine Status"); if (PriEngine.EngineStatus) { StringBuilder status = new StringBuilder(); status.Append("Company: ").Append(PriEngine.Platform.Contexto.Empresa.CodEmp).Append(" | "); status.Append("Company Name: ").Append(PriEngine.Platform.Contexto.Empresa.IDNome).Append(" | "); status.Append("Currency: ").Append(PriEngine.Platform.Contexto.Empresa.MoedaBase); StdLoggingHandler.FileTrace(status); pnlActions.Visible = true; lblStatus.Text = status.ToString(); } else { StdLoggingHandler.FileTrace("ERROR: Cannot access primavera!"); lblStatus.Text = "Cannot acess to primavera. Check your configuration."; } } catch (Exception ex) { ExceptionHelper.ShowErrorMessage(ex, "Login", this); } finally { StdLoggingHandler.FileTraceExitMethod(); } }
private void btLog_Click(object sender, EventArgs e) { switch (cbbLogType.SelectedIndex) { case 0: StdLoggingHandler.FileTrace(GetMessage()); break; case 1: StdLoggingHandler.Indent(); StdLoggingHandler.FileTrace(GetMessage()); StdLoggingHandler.Outdent(); break; case 2: StdLoggingHandler.FileTrace("Enter method can be called with or withou message"); StdLoggingHandler.FileTraceEnterMethod(); StdLoggingHandler.FileTraceEnterMethod(GetMessage()); break; case 3: StdLoggingHandler.FileTrace("Exit method can be called with or withou message"); StdLoggingHandler.FileTraceExitMethod(GetMessage()); StdLoggingHandler.FileTraceExitMethod(); break; case 4: SimulateException(); break; default: break; } btReload_Click(sender, EventArgs.Empty); }
private void btTraceVerbosed_Click(object sender, EventArgs e) { StdLoggingHandler.FileTrace("Following trace is verbosed!"); StdLoggingHandler.FileTraceVerbose(txtMessage.Text); btReload_Click(sender, EventArgs.Empty); }