예제 #1
0
        //// Colocar SEMPRE ao nivel do módulo/class para não ser descarregado indevidamente
        //private static S50cAPICGCO18.SystemStarter systemStarter = null;

        /// <summary>basMain
        /// Inicializa a API da 50c
        /// Lança uma exceção se falhar
        /// </summary>
        /// <param name="companyId">Identificador da empresa a Abrir</param>
        public static void Initialize(string ProductCode, string CompanyId, bool DebugMode)
        {
            apiInitialized = false;

            //
            Terminate();
            //
            // NEW RECOMMENDED Startup - CGCO / CRTL
            var systemStarter = new S50cAPI18.SystemStarter();

            systemStarter.DebugMode = DebugMode;

            if (systemStarter.Initialize(ProductCode, CompanyId) != 0)
            {
                string initError = systemStarter.InitializationError;
                systemStarter = null;
                throw new Exception(initError);
            }
            // Eventos de erros e avisos vindos da API
            dataManagerEvents = (S50cData18.DataManagerEventsClass)s50cDataGlobals.DataManager.Events;
            dataManagerEvents.__DataManagerEvents_Event_WarningMessage += dataManagerEvents___DataManagerEvents_Event_WarningMessage;
            dataManagerEvents.__DataManagerEvents_Event_WarningError   += dataManagerEvents___DataManagerEvents_Event_WarningError;
            dataManagerEvents.__DataManagerEvents_Event_Message        += DataManagerEvents___DataManagerEvents_Event_Message;

            apiInitialized = true;
            //
            if (APIStarted != null)
            {
                APIStarted(null, null);
            }
        }
예제 #2
0
    /// <summary>basMain
    /// Inicializa a API do Retail
    /// Lança uma exceção se falhar
    /// </summary>
    /// <param name="companyId">Identificador da empresa a Abrir</param>
    public static void Initialize(ApplicationEnum apiKind, string companyId, bool debugMode)
    {
        apiInitialized = false;

        //
        Terminate();
        //
        // Init
        // 1. DataProvider (RTLData16)
        // 2. System (RTLSystem16)
        // 3. DataLayer (RTLData13)
        // 4. Core (RTLCore16)
        rtlDataGlobals   = new RTLData16.GlobalSettings();
        rtlSystemGlobals = new RTLSystem16.GlobalSettings();
        rtlDLGlobals     = new RTLDL16.GlobalSettings();
        rtlCoreGlobals   = new RTLCore16.GlobalSettings();
        rtlPrintGlobals  = new RTLPrint16.GlobalSettings();
        rtlBLGlobals     = new RTLBL16.GlobalSettings();
        //
        switch (apiKind)
        {
        case ApplicationEnum.SageRetail:
            systemStarter = new RTLAPIPRTL16.SystemStarter();
            break;

        case ApplicationEnum.SageGC:
            systemStarter = new SGCOAPIPRTL16.SystemStarter();
            break;
        }
        systemStarter.DebugMode = debugMode;
        if (systemStarter.Initialize(companyId) != 0)
        {
            string initError = systemStarter.InitializationError;
            systemStarter = null;
            throw new Exception(initError);
        }
        // Eventos de erros e avisos vindos da API
        dataManagerEvents = (RTLData16.DataManagerEventsClass)rtlDataGlobals.DataManager.Events;
        dataManagerEvents.__DataManagerEvents_Event_WarningMessage += dataManagerEvents___DataManagerEvents_Event_WarningMessage;
        dataManagerEvents.__DataManagerEvents_Event_WarningError   += dataManagerEvents___DataManagerEvents_Event_WarningError;
        dataManagerEvents.__DataManagerEvents_Event_Message        += DataManagerEvents___DataManagerEvents_Event_Message;

        //
        apiInitialized = true;
        //
        if (APIStarted != null)
        {
            APIStarted(null, null);
        }
    }