Пример #1
0
        public IAck Send(object request)
        {
            using (var client = new LicensePortsTypeAsyncClient(_binding, _remoteAddress)) {
                client.Endpoint.EndpointBehaviors.Add(new MyEndpointBehavior());
                if (!_config.IsPPAK)
                {
                    client.ClientCredentials.UserName.UserName = Constants.UserAuth.Name;
                    client.ClientCredentials.UserName.Password = Constants.UserAuth.Passwd;
                }

                if (!_config.UseTunnel)
                {
                    client.ClientCredentials.ClientCertificate.SetCertificate(
                        StoreLocation.CurrentUser,
                        StoreName.My,
                        X509FindType.FindByThumbprint,
                        base._config.CertificateThumbprint);
                }

                switch (request.GetType().Name)
                {
                case nameof(exportDisqualifiedPersonRequest1):
                    return(client.exportDisqualifiedPerson(request as exportDisqualifiedPersonRequest1).AckRequest.Ack);

                case nameof(exportLicenseRequest1):
                    return(client.exportLicense(request as exportLicenseRequest1).AckRequest.Ack);

                default:
                    throw new ArgumentException($"{request.GetType().Name} - Не верный тип аргумента");
                }
            }
        }
Пример #2
0
        public bool TryGetResult(IAck ack, out IGetStateResult result)
        {
            using (var client = new LicensePortsTypeAsyncClient(_binding, _remoteAddress)) {
                client.Endpoint.EndpointBehaviors.Add(new MyEndpointBehavior());
                if (!_config.IsPPAK)
                {
                    client.ClientCredentials.UserName.UserName = Constants.UserAuth.Name;
                    client.ClientCredentials.UserName.Password = Constants.UserAuth.Passwd;
                }

                if (!_config.UseTunnel)
                {
                    client.ClientCredentials.ClientCertificate.SetCertificate(
                        StoreLocation.CurrentUser,
                        StoreName.My,
                        X509FindType.FindByThumbprint,
                        base._config.CertificateThumbprint);
                }

                var responce = client.getState(new getStateRequest1 {
                    RequestHeader   = RequestHelper.Create <RequestHeader>(_config.OrgPPAGUID, _config.Role),
                    getStateRequest = new getStateRequest {
                        MessageGUID = ack.MessageGUID
                    }
                });

                if (responce.getStateResult.RequestState == 3)
                {
                    result = responce.getStateResult;
                    return(true);
                }

                result = null;
                return(false);
            }
        }