Пример #1
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();
            }
        }
Пример #2
0
 private void SimulateExceptionIgnored()
 {
     try
     {
         File.ReadAllLines("notexistingfile");
     }
     catch (Exception ex)
     {
         StdLoggingHandler.FileTraceIgnoredException(ex);
     }
 }
Пример #3
0
 private void SimulateExceptionThrowed()
 {
     try
     {
         File.ReadAllLines("notexistingfile");
     }
     catch (Exception ex)
     {
         StdLoggingHandler.FileTraceWithThrow(ex);
     }
 }
        /// <summary>
        /// Shows the error message.
        /// </summary>
        /// <param name="ex">The ex.</param>
        /// <param name="title">The title.</param>
        /// <param name="frm">The FRM.</param>
        public static void ShowErrorMessage(Exception ex, string title, Form frm)
        {
            if (PriEngine.Platform == null)
            {
                MessageBox.Show(StdLoggingHandler.FullMessageFromException(ex), title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                PriEngine.Platform.AlertNotificationManager.ShowCustomAlert(title, ex.Message, Properties.Resources.error, frm);
            }

            StdLoggingHandler.FileTraceIgnoredException(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}");
        }
Пример #6
0
        private void ckbIsActive_CheckedChanged(object sender, EventArgs e)
        {
            linkActivate.Enabled   = !ckbIsActive.Checked;
            linkDeactivate.Enabled = ckbIsActive.Checked;

            if (ckbIsActive.Checked)
            {
                txtLogFile.Text = StdLoggingHandler.GetActiveLogFile();
            }
            else
            {
                txtLogFile.ResetText();
                txtPreview.ResetText();
            }
        }
Пример #7
0
        private void btSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtCode.Text) || string.IsNullOrEmpty(txtDescription.Text) || string.IsNullOrEmpty(txtFileLocation.Text))
                {
                    PriEngine.Platform.AlertNotificationManager.ShowCustomAlert(this.Text, "All text fields must be filled!", Properties.Resources.Icon_Message, this);
                    return;
                }

                switch (cbbCategory.SelectedIndex)
                {
                case 1:
                    tabela = EnumTabelaAnexos.anxClientes;
                    break;

                default:
                    tabela = EnumTabelaAnexos.anxOutrosTerceiros;
                    break;
                }

                StdBEAnexo anexo = new StdBEAnexo
                {
                    IdAnexo        = PriEngine.Platform.FuncoesGlobais.CriaGuid(true),
                    Chave          = txtCode.Text,
                    Tabela         = tabela,
                    Descricao      = Path.GetFileNameWithoutExtension(txtFileLocation.Text),
                    Encriptado     = ckbEncrypt.Checked,
                    FicheiroOrigem = txtFileLocation.Text,
                    EmModoEdicao   = false,
                    Utilizador     = PriEngine.Platform.Contexto.Utilizador.Utilizador,
                    Data           = DateTime.Now
                };

                PriEngine.Platform.Anexos.Actualiza(anexo);
                lstAttachs.Items.Add(txtFileLocation.Text);
                txtFileLocation.ResetText();

                PriEngine.Platform.AlertNotificationManager.ShowCustomAlert(this.Text, "Attachment added to entity with success.", Properties.Resources.Icon_Success, this);
            }
            catch (Exception ex)
            {
                StdLoggingHandler.FileTraceIgnoredException(ex);
                PriEngine.Platform.AlertNotificationManager.ShowCustomAlert(this.Text, "An error as occurred while adding the attachment to entity!", Properties.Resources.Icon_Alert, this);
            }
        }
Пример #8
0
        /// <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();
            }
        }
Пример #9
0
        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);
        }
Пример #10
0
 private void linkActivate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     StdLoggingHandler.ActivateLog();
     btReload_Click(sender, EventArgs.Empty);
 }
Пример #11
0
 private void linkDeactivate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     StdLoggingHandler.DeactivateLog();
 }
Пример #12
0
 private void linkClear_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     StdLoggingHandler.ClearLogFile();
     btReload_Click(sender, EventArgs.Empty);
 }
Пример #13
0
 private void btTraceVerbosed_Click(object sender, EventArgs e)
 {
     StdLoggingHandler.FileTrace("Following trace is verbosed!");
     StdLoggingHandler.FileTraceVerbose(txtMessage.Text);
     btReload_Click(sender, EventArgs.Empty);
 }
Пример #14
0
 private void btReload_Click(object sender, EventArgs e)
 {
     txtPreview.ResetText();
     txtPreview.AppendText(StdLoggingHandler.GetActiveLogTail(50));
 }