How to initialize BSO and PSO variables from the Spring environment?

Asked

Viewed 241 times

-1

I intend to initialize two context variables being ErpBS BSO and StdBSInterfPub PSO when I add an extension to Spring.

Why? I would like to use these variables with static classes and/or with Forms (which are not the ones from the Spring API). Could define the context or have a "general context"?

How can I detect when an extension is placed in spring?

Right now the only way I know how to do this is to use the function DepoisDeAbrirEmpresa or assign context through classes that themselves make use of their specific context (For example ClassName : FichaArtigos).

using Primavera.Extensibility.BusinessEntities.ExtensibilityService.EventArgs;
using Primavera.Extensibility.Base.Editors;

namespace Projeto
{
    class ClassName : FichaArtigos
    {        
         public override void AntesDeEditar(string Artigo, ref bool Cancel, ExtensibilityEventArgs e)
         {
              base.AntesDeEditar(Artigo, ref Cancel, e);
              AMinhaClassStatic.PSO = PSO;
              AMinhaClassStatic.BSO = BSO;
         }
    }
}

I would like to be able to initialize the variables assuming that the company is already open.

EDITED 19-12-2019

Example of AMinhaClassStatic, requested in comments. This example shows how it is not possible to use variables without first initializing.

using ErpBS100;
using StdPlatBS100;

namespace Projeto
{
    class AMinhaClassStatic
    {
        public static ErpBS BSO;
        public static StdBSInterfPub PSO;

        public static void teste()
        {
             PSO.Dialogos.MostraAviso("teste");
             BSO.Base.Clientes.AlteraCodigoCliente("TSTE", "TESTE");
        }
    }
}

public static ErpBS BSO = new ErpBS(); Doesn’t seem to help.

public static StdBSInterfPub PSO = new StdBSInterfPub(); Takes arguments I don’t know what they are.

tl;dr I intend to initialize BSO which is a spring context variable of the type ErpBS and initialize PSO which is a variable referring to the platform of type StdBSInterfPub, it would be possible to initialize one with context and another with the platform environment?

  • 2

    I have no idea how spring influences the problem, but I was surprised that AMinhaClassStatic, PSO or BSO are defined in your code. What are these objects?

  • @Woss The problem is wanting to use API variables but not being able to use them without first initializing them. I am aware that what I intend to do is not the right way to do this but having this knowledge would be helpful. Look at Edit.

1 answer

1


I understand the goal of creating the context class, and so be able to use throughout the project, but some important notes.

All extensibility classes that inherit from the PRIMAVERA base classes will have these two properties available to use properly initialize, so context is no longer necessary. If your project has multiple classes and forms that do not inherit, then I recommend implementing the pattern Singleton to have access to the only instance of these two properties, which would have to initialize in the event depoisabrirempresa().

  • The method of declaring the PSO and BSO in the Afterbenefits is a method I have been doing but this requires that every change in the extent at the time of its development makes me restart the Spring for it to give Rigger back to the function. Maybe I should rethink the code.

  • For someone with the same problem who might see this, please use #Preprocessing Directives, it might help your development and solve the problem. https://docs.microsoft.com/pt-br/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-if

Browser other questions tagged

You are not signed in. Login or sign up in order to post.