Exemplo n.º 1
0
        private static void SendMessage()
        {
            var rnd     = new Random();
            var gender  = new string[] { "F", "M" }[rnd.Next(0, 2)];
            var address = AddressGenerator.Generate();

            var address1 = string.Format($"{address.Street} {address.HouseNo}");

            if (!" ".Contains(address.ApartmentNo))
            {
                address1 = string.Format($"{address1}, {address.ApartmentNo}");
            }

            var personCPR = new CPR()
            {
                CprNo         = CprGenerator.Generate(gender),
                FirstName     = NameGenerator.GenerateFirstName(gender),
                Surname       = NameGenerator.GenerateSurname(),
                Address1      = address1,
                Address2      = address.Address2,
                PostalCode    = address.PostalCode,
                City          = address.City,
                MaritalStatus = "Ugift",
                Spouse        = "",
                Children      = new List <string>(),
                Mother        = EuccidGenerator.Generate(new DateTime(1987, 11, 23)),
                Father        = EuccidGenerator.Generate(new DateTime(1984, 3, 18)),
                DoctorCVR     = "39227491",
                EuccidNo      = EuccidGenerator.Generate(),
                Gender        = gender,
            };

            Console.WriteLine("---------- CPR input: ----------");
            personCPR.PrintAll();

            // translate into CDM format
            var personCDM = CprTranslator.CprToCdm(personCPR);

            Console.WriteLine("\n---------- Translated into CDM: ----------");
            personCDM.PrintAll();

            // build message
            var message = new Message()
            {
                Body  = personCDM,
                Label = personCDM.ToString()
            };

            // build channel
            var path = @".\Private$\CPR_to_EUCCID";

            if (!MessageQueue.Exists(path))
            {
                MessageQueue.Create(path);
            }

            var cprToEuccidChannel = new MessageQueue(path)
            {
                Label = "CPR to EU-CCID"
            };

            // send
            cprToEuccidChannel.Send(message);

            Console.WriteLine("\n---------- Message sent. ----------\n\n");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("========== Test: Split address ==========\n");

            string[] addresses = new string[]
            {
                "Ove Sprogøes Gade 25, 1 th",
                "Raadhuspladsen 1, 4. sal, lejlighed 364",
                "Magnoliavænget 22 A"
            };

            foreach (string address in addresses)
            {
                Console.WriteLine("Input:\n" + address);

                CprTranslator.CprAddress splitAddress = CprTranslator.splitCprAddress(address);

                Console.WriteLine("\nOutput:");
                Console.WriteLine("Street = '" + splitAddress.street + "'");
                Console.WriteLine("House number = '" + splitAddress.houseNo + "'");
                Console.WriteLine("Apartment number = '" + splitAddress.apartmentNo + "'\n");

                Console.ReadKey();
            }

            Console.WriteLine("\n========== Test: Translate from CPR via CDM to EU-CCID and back ==========");

            var cprTest = new CPR()
            {
                CprNo         = "230287-8273",
                FirstName     = "Bettina",
                Surname       = "Møller-Hansen",
                Address1      = "Marselis Boulevard 25, 3 tv",
                Address2      = "c/o Hanne Weber",
                PostalCode    = "8000",
                City          = "Aarhus C",
                MaritalStatus = "Ugift",
                Spouse        = "",
                Children      = new List <string>()
                {
                    "11102010-325742", "24032015-349521"
                },
                Mother    = "06121955-342065",
                Father    = "15071952-316257",
                DoctorCVR = "39227491",
                EuccidNo  = "23021987-904534",
                Gender    = "F",
            };

            Console.WriteLine("Input: CPR");
            cprTest.PrintAll();

            var cdmFromCprTest = CprTranslator.CprToCdm(cprTest);

            Console.WriteLine("\nMediator: CDM");
            cdmFromCprTest.PrintAll();

            Console.ReadKey();

            var euccidFromCdmTest = EuccidTranslator.CdmToEuccid(cdmFromCprTest);

            Console.WriteLine("\nOutput: EU-CCID");
            euccidFromCdmTest.PrintAll();

            Console.ReadKey();

            var cdmFromEuccidTest = EuccidTranslator.EuccidToCdm(euccidFromCdmTest);

            Console.WriteLine("\nMediator: CDM");
            cdmFromEuccidTest.PrintAll();

            Console.ReadKey();

            var cprFromCdmTest = CprTranslator.CdmToCpr(cdmFromEuccidTest);

            Console.WriteLine("\nOutput: CPR");
            cprFromCdmTest.PrintAll();

            Console.ReadKey();

            Console.WriteLine("\n========== Test: Generate names ==========");

            var boyname = NameGenerator.GenerateFirstName("M");

            Console.WriteLine(boyname);

            var girlname = NameGenerator.GenerateFirstName("F");

            Console.WriteLine(girlname);

            var surname = NameGenerator.GenerateSurname();

            Console.WriteLine(surname);

            Console.ReadKey();


            Console.WriteLine("\n========== Test: Generate euccid ==========");

            var euccid1 = EuccidGenerator.Generate();

            Console.WriteLine("euccid1: " + euccid1);

            var euccid2 = EuccidGenerator.Generate();

            Console.WriteLine("euccid2: " + euccid2);

            var euccid3 = EuccidGenerator.Generate();

            Console.WriteLine("euccid3: " + euccid3);

            Console.ReadKey();
        }