Ejemplo n.º 1
0
        /// <summary>
        /// UserServiceClient ve ConnectorServiceClient sınıflarından nesneler oluşturulur.
        /// Önce wsLogin ile kullanıcı girişi yapılır ve dönen cookie bilgisi connectorService nesnesine her talebi için atanır.
        /// </summary>
        /// <returns>ServiceResponse Türünde yanıt döner</returns>
        public async Task Execute()
        {
            var result = new ServiceResponse()
            {
                Hatali = false,
            };

            if (Invoice == null)
            {
                throw new ArgumentNullException("Invoice boş olamaz!");
            }

            try {
                this._connectorWsClient = EFinansHelper.CreateConnectorServiceClient(
                    ServiceInfo.ServiceUrl,
                    ServiceInfo.UserName,
                    ServiceInfo.Password);

                this._userWsClient = EFinansHelper.CreateUserServiceClient(
                    ServiceInfo.UserServiceUrl,
                    ServiceInfo.UserName,
                    ServiceInfo.Password);

                var    cookie = EFinansHelper.GetValidCookie(_userWsClient, ServiceInfo.UserName, ServiceInfo.Password);
                string belgeOid;

                using (new OperationContextScope(_connectorWsClient.InnerChannel)) {
                    var requestProp = new HttpRequestMessageProperty();
                    requestProp.Headers["Set-Cookie"] = cookie;
                    OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestProp;

                    var request = PrepareGidenBelgeParametreleri();
                    belgeOid = _connectorWsClient.belgeGonderExt(request);
                }

                result.Sonuc = string.IsNullOrEmpty(belgeOid)
                    ? "İşlem tamamlandı!"
                    : "İşlem başarıyla tamamlandı";
                result.Data = new { belgeOid };
            } catch (Exception ex) {
                result.Hatali   = true;
                result.Istisna += ex.ToString();
            }

            this.Result = Task.FromResult(result);
        }
        public async Task Execute()
        {
            var serviceResponse = new ServiceResponse()
            {
                Hatali = false,
            };

            _serviceProxy = EFinansHelper.CreateConnectorServiceClient(
                ServiceInfo.ServiceUrl,
                ServiceInfo.UserName,
                ServiceInfo.Password);

            string vergiTcKimlikNo = ServiceInfo.SupplierVkn;

            string[] ettnler      = this.UUIDs; //new string[] { "291DB9EC-4FC4-4F7E-BDD2-C5C54F62A635", "3e60aad6-48cc-4f76-a20c-5fc892d1a837" };
            string   belgeTuru    = "FATURA";   // "FATURA" ve "UYGULAMA_YANITI"
            string   belgeFormati = "UBL";      // "HTML", "PDF", "UBL"

            byte[] ublZip = _serviceProxy.gelenBelgeleriIndir(vergiTcKimlikNo, ettnler, belgeTuru, belgeFormati);

            serviceResponse.Sonuc = "UBL Başarıyla alındı";
            serviceResponse.Data  = ublZip;
            this.Result           = Task.FromResult(serviceResponse);
        }