コード例 #1
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);
        }
    }
コード例 #2
0
        private void processFile_LowFreq(string label, string file)
        {
            ApplicationEnum application = getApplication(label);

            if ((int)application < 10)
            {
                REDDMeter.SetDescribtion(REDDMeter.GetDescription() + "-0" + (int)application);
            }
            else
            {
                REDDMeter.SetDescribtion(REDDMeter.GetDescription() + "-" + (int)application);
            }

            fillDBWithMeters();
            processFile(file);

            Console.WriteLine("Done");
        }
コード例 #3
0
 public Version(ApplicationEnum application, EditionEnum edition, CountryEnum country)
 {
     this.Applicagtion = application;
     this.Edition      = edition;
     this.Country      = country;
 }
コード例 #4
0
        protected override void fillDBWithMeters()
        {
            CustomerData tempCustomer = new CustomerData();
            int          customerId   = tempCustomer.FillEmptyCustomer();

            myDatabase.InsertCustomerData(tempCustomer);

            MeterManufactorData tempMeterManufactor = new MeterManufactorData();
            int meterManufactorId = tempMeterManufactor.FillEmptyMeterManufactor();

            myDatabase.InsertMeterManufactorData(tempMeterManufactor);

            MeterProtocolData tempMeterProtocol = new MeterProtocolData();
            int meterProtocolId = tempMeterProtocol.FillEmptyMeterProtocol();

            myDatabase.InsertMeterProtocolData(tempMeterProtocol);

            MeterTypeData tempMeterType = new MeterTypeData();
            int           meterTypeId   = tempMeterType.FillEmptyMeterType();

            myDatabase.InsertMeterTypeData(tempMeterType);

            ///Create whole houses meter
            for (int i = 0; i < 4; i++)
            {
                MeterManagementData UKDALEMeter = new MeterManagementData();
                UKDALEMeter.SetCustomerId(customerId);
                UKDALEMeter.SetManufactorId(meterManufactorId);
                UKDALEMeter.SetProtolId(meterProtocolId);
                UKDALEMeter.SetTypeId(meterTypeId);
                UKDALEMeter.SetDescribtion("UKDALE-" + i + "-ALL");
                UKDALEMeter.SetKey("not availiable");
                UKDALEMeter.SetPeriod(1);
                UKDALEMeter.SetPort("not availiable");
                UKDALEMeter.SetSerial("not availiable");
                UKDALEMeter.SetActive(true);
                myDatabase.InsertMeterManagementData(UKDALEMeter);

                int tempMeterId = UKDALEMeter.GetMeterId();

                Tuple <int, ApplicationEnum> temp;
                switch (i)
                {
                case 0:
                {
                    temp = new Tuple <int, ApplicationEnum>(tempMeterId, ApplicationEnum.UKDALEwholeHouse1);
                    break;
                }

                case 1:
                {
                    temp = new Tuple <int, ApplicationEnum>(tempMeterId, ApplicationEnum.UKDALEwholeHouse2);
                    break;
                }

                case 2:
                {
                    temp = new Tuple <int, ApplicationEnum>(tempMeterId, ApplicationEnum.UKDALEwholeHouse3);
                    break;
                }

                case 3:
                {
                    temp = new Tuple <int, ApplicationEnum>(tempMeterId, ApplicationEnum.UKDALEwholeHouse4);
                    break;
                }

                case 4:
                {
                    temp = new Tuple <int, ApplicationEnum>(tempMeterId, ApplicationEnum.UKDALEwholeHouse5);
                    break;
                }

                default:
                {
                    temp = new Tuple <int, ApplicationEnum>(tempMeterId, ApplicationEnum.None);
                    break;
                }
                }
                this.housesList.Add(temp);
            }

            String pathToUKDALEAplliances = "UKDaleAppliances\\";

            for (int i = 1; i <= 5; i++)
            {
                Console.WriteLine("working File: " + i);
                using (StreamReader file = new StreamReader(pathToUKDALEAplliances + "UKDALEdat_" + i + ".txt"))
                {
                    if (file != null)
                    {
                        String line = "";
                        while ((line = file.ReadLine()) != null)
                        {
                            MeterManagementData UKDALEMeter = new MeterManagementData();
                            UKDALEMeter.SetCustomerId(customerId);
                            UKDALEMeter.SetManufactorId(meterManufactorId);
                            UKDALEMeter.SetProtolId(meterProtocolId);
                            UKDALEMeter.SetTypeId(meterTypeId);

                            String[]        applicationParts     = line.Split(' ');
                            int             applicationNumber    = Int32.Parse(applicationParts[0]);
                            ApplicationEnum foundApplicationEnum = this.FindApplicationEnumByString(applicationParts[1]);

                            UKDALEMeter.SetDescribtion("UKDALE-" + (i - 1) + "-" + applicationNumber);
                            UKDALEMeter.SetKey("not availiable");
                            UKDALEMeter.SetPeriod(1);
                            UKDALEMeter.SetPort("not availiable");
                            UKDALEMeter.SetSerial("not availiable");
                            UKDALEMeter.SetActive(true);
                            myDatabase.InsertMeterManagementData(UKDALEMeter);

                            int tempMeterId = UKDALEMeter.GetMeterId();

                            int[] tempTupel = new int[2];
                            tempTupel[0] = tempMeterId;
                            tempTupel[1] = applicationNumber;

                            Tuple <int[], ApplicationEnum> temp = new Tuple <int[], ApplicationEnum>(tempTupel, foundApplicationEnum);

                            switch (i)
                            {
                            case 1:
                            {
                                this.house1ApplicationList.Add(temp);
                                break;
                            }

                            case 2:
                            {
                                this.house2ApplicationList.Add(temp);
                                break;
                            }

                            case 3:
                            {
                                this.house3ApplicationList.Add(temp);
                                break;
                            }

                            case 4:
                            {
                                this.house4ApplicationList.Add(temp);
                                break;
                            }

                            case 5:
                            {
                                this.house5ApplicationList.Add(temp);
                                break;
                            }
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        private bool compareApplicationEnumWithCurrentHouseholdApp(ApplicationEnum currentApp, int household, int device)
        {
            switch (household)
            {
            case 1:
            {
                foreach (Tuple <int[], ApplicationEnum> currentTupel in this.house1ApplicationList)
                {
                    if (currentTupel.Item2 == currentApp && currentTupel.Item1[1] == device)
                    {
                        return(true);
                    }
                }
                break;
            }

            case 2:
            {
                foreach (Tuple <int[], ApplicationEnum> currentTupel in this.house2ApplicationList)
                {
                    if (currentTupel.Item2 == currentApp && currentTupel.Item1[1] == device)
                    {
                        return(true);
                    }
                }
                break;
            }

            case 3:
            {
                foreach (Tuple <int[], ApplicationEnum> currentTupel in this.house3ApplicationList)
                {
                    if (currentTupel.Item2 == currentApp && currentTupel.Item1[1] == device)
                    {
                        return(true);
                    }
                }
                break;
            }

            case 4:
            {
                foreach (Tuple <int[], ApplicationEnum> currentTupel in this.house4ApplicationList)
                {
                    if (currentTupel.Item2 == currentApp && currentTupel.Item1[1] == device)
                    {
                        return(true);
                    }
                }
                break;
            }

            case 5:
            {
                foreach (Tuple <int[], ApplicationEnum> currentTupel in this.house5ApplicationList)
                {
                    if (currentTupel.Item2 == currentApp && currentTupel.Item1[1] == device)
                    {
                        return(true);
                    }
                }
                break;
            }
            }
            return(false);
        }
コード例 #6
0
 public string GetApplicationHost(ApplicationEnum client)
 {
     return  GetClients().Where(m => m.Id == (int)client).SingleOrDefault().Host;
 }