using Hcs.Client;
using Hcs.Client.Logger;
using Hcs.Client.MessageCapturer;
using Hcs.TestApp.Scenario;
using System;

namespace Hcs.TestApp
{
    internal class Program
    {
        [STAThread]
        public static void Main(string[] _)
        {
            System.Threading.Thread.CurrentThread.CurrentUICulture =
               new System.Globalization.CultureInfo("en-US");

            var logger = new ConsoleLogger();
            var client = new UniClient
            {
                OrgPPAGUID = "ccd7fa02-a2bf-428a-984b-faef69ae0eb2",
                ExecutorGUID = "ccd7fa02-a2bf-428a-984b-faef69ae0eb2",
                UseTunnel = false,
                IsPPAK = false,
                Role = OrganizationRole.RSO,
                Logger = logger,
                MessageCapturer = new FileMessageCapturer(null, logger)
            };

            var cert = client.FindCertificate(x => x.SerialNumber == "0636D2330032B3C38A4A26D765C787C248");
            if (cert == null)
            {
                return;
            }

            Console.WriteLine("Certificate " + cert.Subject + " found");

            client.SetSigningCertificate(cert);

            var billsScenario = new BillsScenario(client);
            var deviceMeteringScenario = new DeviceMeteringScenario(client);
            var houseManagementScenario = new HouseManagementScenario(client);
            var nsiScenario = new NsiScenario(client);
            var nsiCommonScenario = new NsiCommonScenario(client);
            var orgRegistryCommonScenario = new OrgRegistryCommonScenario(client);
            var paymentsScenario = new PaymentsScenario(client);
            try
            {
                //billsScenario.ExportPaymentDocumentDataByPaymentDocumentID();
                //billsScenario.ExportPaymentDocumentDataByAccountNumber();
                //billsScenario.ExportPaymentDocumentDataByPaymentDocumentNumber();
                //billsScenario.ImportPaymentDocumentData();

                //deviceMeteringScenario.ExportMeteringDeviceHistory();
                //deviceMeteringScenario.ImportMeteringDeviceValues();

                //houseManagementScenario.ExportAccount();
                //houseManagementScenario.ExportHouse();
                //houseManagementScenario.ExportAllSupplyResourceContractData();
                //houseManagementScenario.ExportSupplyResourceContractDataByGuid();
                //houseManagementScenario.ExportSupplyResourceContractDataByNumber();
                //houseManagementScenario.ExportSupplyResourceContractObjectAddressData();

                //houseManagementScenario.ImportAccountData();
                //houseManagementScenario.ImportContractData();
                //houseManagementScenario.ImportLivingHouseUOData();
                //houseManagementScenario.ImportMeteringDeviceData();
                //houseManagementScenario.ImportNotificationData();
                //houseManagementScenario.ImportSupplyResourceContractData();
                //houseManagementScenario.ImportSupplyResourceContractProject();

                //nsiScenario.ExportDataProviderNsiItem1();
                //nsiScenario.ExportDataProviderNsiItem51();
                //nsiScenario.ExportDataProviderNsiItem59();
                //nsiScenario.ExportDataProviderNsiItem219();
                //nsiScenario.ExportDataProviderNsiItem272();
                //nsiScenario.ExportDataProviderNsiItem302();
                //nsiScenario.ExportDataProviderNsiItem337();

                //nsiCommonScenario.ExportNsiItem2();
                //nsiCommonScenario.ExportNsiItem16();
                //nsiCommonScenario.ExportNsiItem276();
                //nsiCommonScenario.ExportNsiList();

                //orgRegistryCommonScenario.ExportDataProvider();
                //orgRegistryCommonScenario.ExportOrgRegistry();

                //paymentsScenario.ImportNotificationsOfOrderExecution();
                //paymentsScenario.ImportSupplierNotificationsOfOrderExecution();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.ReadKey();
            }
        }
    }
}
