Exemplo n.º 1
0
        public List <Child> GetChildren(Employment employment)
        {
            var children = new List <Child>();

#if !DEBUG
            using (var webService = new GetChildren.GetChildren_OS_SIClient("HTTPS_Port2"))
            {
                var certName = ConfigurationManager.AppSettings["PROTECTED_CERTIFICATE_NAME"];
                webService.ClientCredentials.ClientCertificate.SetCertificate(System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine, System.Security.Cryptography.X509Certificates.StoreName.My, System.Security.Cryptography.X509Certificates.X509FindType.FindBySubjectName, certName);

                var request = new GetChildren.GetChildrenRequest();
                request.PersonnelNumber = employment.EmploymentId.ToString();

                var response = webService.GetChildren_OS_SI(request);

                foreach (var child in response.Child)
                {
                    children.Add(new Child
                    {
                        Id        = int.Parse(child.ChildNumber),
                        FirstName = child.FirstName,
                        LastName  = child.LastName
                    });
                }
            }
#endif
            return(children);
        }
Exemplo n.º 2
0
        public List <Child> GetChildren(Employment employment)
        {
            var children = new List <Child>();

            if (!Boolean.Parse(config["KMDVacationService:GetChildrenEnabled"]))
            {
                logger.LogWarning("KMDVacationService GetChildren is disabled. Returning empty list of children");
                return(children);
            }

            var webService  = new GetChildren.GetChildren_OS_SIClient();
            var certificate = new X509Certificate2(config["KMDVacationService:CertificateFilename"], config["KMDVacationService:CertificatePassword"]);

            webService.ClientCredentials.ClientCertificate.Certificate = certificate;
            ((BasicHttpBinding)webService.Endpoint.Binding).Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
            webService.Endpoint.Address = new EndpointAddress(config["KMDVacationService:GetChildrenEndpoint"]);
            webService.Endpoint.EndpointBehaviors.Add(new LoggingBehavior(logger));

            var request = new GetChildren.GetChildrenRequest();

            request.PersonnelNumber = employment.EmploymentId.ToString();

            var response = webService.GetChildren_OS_SI(request);

            foreach (var kmdChild in response.Child)
            {
                var child = new Child();
                child.Id        = int.Parse(kmdChild.ChildNumber);
                child.FirstName = String.IsNullOrWhiteSpace(kmdChild.FirstName) ? "Ukendt navn" : kmdChild.FirstName;
                child.LastName  = kmdChild.LastName ?? "";
                children.Add(child);
            }
            return(children);
        }