Ejemplo n.º 1
0
        private void btnGonder_Click(object sender, EventArgs e)
        {
            try
            {
                string defterPath = Application.StartupPath + @"\doc\12345678011233132433.txt";

                string defter = (File.ReadAllText(defterPath)).Replace("#VKN#", txtTcVkn.Text.Trim());

                byte[] zipData = IncludeZip(defter, Guid.NewGuid().ToString());

                ELedgerCloudServiceClient wsClient = new ELedgerCloudServiceClient();

                using (new System.ServiceModel.OperationContextScope((System.ServiceModel.IClientChannel)wsClient.InnerChannel))
                {
                    System.ServiceModel.Web.WebOperationContext.Current.OutgoingRequest.Headers.Add(HttpRequestHeader.Authorization, GetAuthorization(txtKullanici.Text.Trim(), txtSifre.Text.Trim()));

                    var req = new SaveRequest()
                    {
                        company = new Company
                        {
                            identifier = txtTcVkn.Text.Trim(),
                        },

                        source = new LedgerStream
                        {
                            fileName   = "12345678011233132433.zip",
                            hash       = GetHashInfo(zipData),
                            binaryData = zipData
                        }
                    };

                    var result = wsClient.save(req);

                    txtDefterID.Text = result.ledgerId.ToString();

                    MessageBox.Show(result.message, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private void btnSorgula_Click(object sender, EventArgs e)
        {
            try
            {
                long defid;

                if (long.TryParse(txtDefterID.Text.Trim(), out defid))
                {
                    ELedgerCloudServiceClient wsClient = new ELedgerCloudServiceClient();

                    using (new System.ServiceModel.OperationContextScope((System.ServiceModel.IClientChannel)wsClient.InnerChannel))
                    {
                        System.ServiceModel.Web.WebOperationContext.Current.OutgoingRequest.Headers.Add(HttpRequestHeader.Authorization, GetAuthorization(txtKullanici.Text.Trim(), txtSifre.Text.Trim()));

                        var req = new StatusRequest()
                        {
                            company = new Company
                            {
                                identifier = txtTcVkn.Text.Trim()
                            },

                            ledgerId = defid
                        };

                        var result = wsClient.status(req);

                        MessageBox.Show(result.code + " - " + result.message, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Geçersiz e-Defter ID", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }