Пример #1
0
        public async Task Execute()
        {
            if (Invoice == null)
            {
                throw new ArgumentNullException("Invoice boş olamaz!");
            }


            _serviceProxy = IsNetHelper.CreateServiceProxy(
                ServiceInfo.ServiceUrl,
                ServiceInfo.UserName,
                ServiceInfo.Password);

            var request = new SendInvoiceXmlRequest()
            {
                Invoices = new[]
                {
                    new InvoiceXml()
                    {
                        InvoiceContent = Serialization.SerializeToBytes(this.Invoice),
                        ReceiverTag    = this.ServiceInfo.ReceiverPostboxName
                    }
                }
            };

            await _serviceProxy.SendInvoiceXmlAsync(request)
            .ContinueWith(d => {
                var result = new ServiceResponse()
                {
                    Hatali = false,
                };

                if (d.IsCanceled || d.IsFaulted)
                {
                    result.Hatali = true;
                    foreach (System.Exception innerException in d.Exception.Flatten().InnerExceptions)
                    {
                        result.Istisna += innerException.ToString();
                    }
                }
                else
                {
                    result.Sonuc = d.IsCompletedSuccessfully ? "İşlem başarıyla tamamlandı" : "İşlem tamamlandı!";
                    result.Data  = new { d.Result };
                }

                this.Result = Task.FromResult(result);
            });
        }