Ejemplo n.º 1
0
        /// <summary>
        ///  Zarf durumunu sorgular
        /// </summary>
        /// <returns> Zarf Durum Sorgulama</returns>
        private void btnZarfDurumSorgula_Click(object sender, EventArgs e)
        {
            DespatchUUID = null;

            List <string> allUUID = new List <string>();
            List <GetDesEnvelopeStatusResponseType> resultList = new List <GetDesEnvelopeStatusResponseType>();
            var despatch = new DespatchWebService();

            try
            {
                if (!CheckConnParam())
                {
                    throw new CheckConnParamException("TCKN/VKN, Gönderici Birim Etiketi, Posta Kutusu Etiketi, WS Kullanıcı Adı ve WS Şifre alanları boş bırakılamaz!");
                }

                foreach (DataGridViewRow item in grdListIrsaliye.Rows)
                {
                    allUUID.Add(item.Cells[0].Value.ToString());
                }

                if (allUUID.Count != 0)
                {
                    var splitUUIDArray = allUUID.Split(20);

                    foreach (var UUIDList in splitUUIDArray)
                    {
                        GetDesEnvelopeStatusResponseType[] result = despatch.ZarfDurumSorgula(SetTextModel(), UUIDList.ToArray(), CheckedSSL());

                        foreach (var item in result)
                        {
                            resultList.Add(item);
                        }
                    }

                    grdListIrsaliye.DataSource = null;
                    ButtonAktifPasif(false, false);

                    var dt = new DataTable();
                    dt.Columns.Add("ZarfUUID");
                    dt.Columns.Add("IssueDate");
                    dt.Columns.Add("DocumentTypeCode");
                    dt.Columns.Add("DocumentType");
                    dt.Columns.Add("ResponseCode");
                    dt.Columns.Add("Description");

                    foreach (var item in resultList)
                    {
                        DataRow dRow = dt.NewRow();
                        dRow["ZarfUUID"]         = item.UUID;
                        dRow["IssueDate"]        = item.IssueDate;
                        dRow["DocumentTypeCode"] = item.DocumentTypeCode;
                        dRow["DocumentType"]     = item.DocumentType;
                        dRow["ResponseCode"]     = item.ResponseCode;
                        dRow["Description"]      = item.Description;

                        dt.Rows.Add(dRow);
                    }

                    grdListIrsaliye.DataSource = dt;
                    lblBaslik.Text             = "Zarf Durumu Sorgulandı.";
                }
                else
                {
                    MessageBox.Show("Sorgulanacak Zarf Bulunamadı.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (CheckConnParamException ex)
            {
                MessageBox.Show(ex.Message, "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (UUIDNullException ex)
            {
                MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (FaultException <ProcessingFault> ex)
            {
                MessageBox.Show(ex.Detail.Message, "ProcessingFault", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FaultException ex)
            {
                MessageBox.Show(ex.Message, "FaultException", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Grid üzerindeki irsaliyelerin XML(UBL) formatında masaüstünde oluşturulan bir klasöre kaydını yapar
        /// </summary>
        /// <returns>e-İrsaliye UBL Kaydetme</returns>
        private void btnIrsaliyeUblIndir_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckConnParam())
                {
                    throw new CheckConnParamException("TCKN/VKN, Gönderici Birim Etiketi, Posta Kutusu Etiketi, WS Kullanıcı Adı ve WS Şifre alanları boş bırakılamaz!");
                }


                List <string> allUUID  = new List <string>();
                var           despatch = new DespatchWebService();

                foreach (DataGridViewRow item in grdListIrsaliye.Rows)
                {
                    allUUID.Add(item.Cells[0].Value.ToString());
                }

                if (allUUID.Count != 0)
                {
                    string recordPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + String.Format("\\{0}-UBL", RequestModel.DocType);
                    if (File.Exists(recordPath) == false)
                    {
                        Directory.CreateDirectory(recordPath);
                    }


                    var splitUUIDArray = allUUID.Split(20);

                    foreach (var UUIDList in splitUUIDArray)
                    {
                        var result = despatch.IrsaliyeUBLIndir(SetTextModel(), UUIDList.ToArray(), CheckedSSL(), RequestModel).Response;

                        for (int i = 0; i < result.Count(); i++)
                        {
                            File.WriteAllBytes(Path.Combine(recordPath, UUIDList[i] + ".xml"), ZipUtility.UncompressFile(result[i].DocData));
                        }
                    }

                    MessageBox.Show("UBL İndirme Başarılı", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("İndirilecek Bir UBL Bulunmamaktadır.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            catch (UUIDNullException ex)
            {
                MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            catch (CheckConnParamException ex)
            {
                MessageBox.Show(ex.Message, "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            catch (FaultException <ProcessingFault> ex)
            {
                MessageBox.Show(ex.Detail.Message, "ProcessingFault", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FaultException ex)
            {
                MessageBox.Show(ex.Message, "FaultException", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        /// <summary>
        /// Grid üzerindeki tüm faturaların id bilgisini aldıktan sonra xml formatında masaüstünde oluşacak dosyaya kayıt eder.
        /// </summary>
        /// <returns>e-Fatura XML Kaydetme</returns>
        private void btnFaturaUblIndir_Click(object sender, EventArgs e)
        {
            {
                try
                {
                    if (!CheckConnParam())
                        throw new CheckConnParamException("TCKN/VKN, Gönderici Birim Etiketi, Posta Kutusu Etiketi, WS Kullanıcı Adı ve WS Şifre alanları boş bırakılamaz!");

                    List<string> allUUID = new List<string>();
                    var fatura = new InvoiceWebService();

                    foreach (DataGridViewRow item in grdListFatura.Rows)
                    {
                        allUUID.Add(item.Cells[0].Value.ToString());
                    }

                    if (allUUID.Count != 0)
                    {

                        string recordPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\INVOICE-UBL";

                        if (File.Exists(recordPath) == false)
                            Directory.CreateDirectory(recordPath);

                        var splitUUIDArray = allUUID.Split(20);

                        foreach (var UUIDList in splitUUIDArray)
                        {
                            var result = fatura.FaturaUBLIndir(SetValue(), UUIDList.ToArray(), CheckedSSL());

                            for (int i = 0; i < result.Count(); i++)
                            {
                                File.WriteAllBytes(Path.Combine(recordPath, UUIDList[i] + ".xml"), result[i]);
                            }
                        }

                        MessageBox.Show("Fatura UBL İndirme Başarılı", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }else
                    {
                        MessageBox.Show("İndirilecek Fatura UBL'i Bulunamadı.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                catch (UUIDNullException ex)
                {
                    MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                catch (CheckConnParamException ex)
                {
                    MessageBox.Show(ex.Message, "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                catch (FaultException<ProcessingFault> ex)
                {
                    MessageBox.Show(ex.Detail.Message, "ProcessingFault", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (FaultException ex)
                {
                    MessageBox.Show(ex.Message, "FaultException", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    lblBaslik.Text = "";
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }