private IdArrContentArrModel createInvListWithNewId(string serialName)
        {
            //verılmek ıstenen ıd on ekıye aıt yenı ıd serıal arr olusturulur
            IdArrContentArrModel idArrContentArr = new IdArrContentArrModel();

            //id serisi olusturuldu
            idArrContentArr.newIdArr = InvoiceIdSetSerilaze.createNewInvId(serialName, tableGrid.SelectedRows.Count);

            idArrContentArr.newXmlContentArr = new string[idArrContentArr.newIdArr.Length];


            for (int cnt = 0; cnt < tableGrid.SelectedRows.Count; cnt++)
            {
                string uuidRow = tableGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.uuid)].Value.ToString();

                string xmlContent = Singl.despatchControllerGet.getDespatchContentXml(uuidRow, despactDirection);
                if (xmlContent == null) //content gerılemedıyse
                {
                    MessageBox.Show("content getırılemedı  " + tableGrid.SelectedRows[cnt].Cells[nameof(EI.Despatch.ID)].Value.ToString());
                    return(null);
                }

                idArrContentArr.newXmlContentArr[cnt] = XmlControl.xmlDespatchChangeIdValue(xmlContent, idArrContentArr.newIdArr[cnt]);

                Singl.despatchControllerGet.createDespatchListWithContent(idArrContentArr.newXmlContentArr[cnt]);
            }

            return(idArrContentArr);
        }
Ejemplo n.º 2
0
        private void btnSendDraftArchive_Click(object sender, EventArgs e)
        {
            try
            {
                //db den getırılen serı Namelerı comboboxda sectır
                FrmDialogSelectItem frmDialogSelectSeriName = new FrmDialogSelectItem(true, "");
                if (frmDialogSelectSeriName.ShowDialog() == DialogResult.OK)
                {
                    ArchiveContentPropertiesModel[] archiveModelArr = new ArchiveContentPropertiesModel[tableArchiveGrid.SelectedRows.Count];
                    string   seriName = frmDialogSelectSeriName.selectedValue;
                    string[] newIdArr = InvoiceIdSetSerilaze.createNewInvId(seriName, tableArchiveGrid.SelectedRows.Count);


                    for (int cnt = 0; cnt < tableArchiveGrid.SelectedRows.Count; cnt++)
                    {
                        ArchiveContentPropertiesModel archiveContentPropertiesModel = new ArchiveContentPropertiesModel();

                        archiveContentPropertiesModel.uuid = tableArchiveGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.uuid)].Value.ToString();

                        archiveContentPropertiesModel.archiveType = tableArchiveGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.eArchiveType)].Value.ToString();

                        //alınan contenttın ıdsını degıstırerek koy
                        string content = Singl.archiveControllerGet.getArchiveContentXml(archiveContentPropertiesModel.uuid);
                        archiveContentPropertiesModel.content = XmlControl.xmlInvoiceChangeIdValue(content, newIdArr[cnt]);

                        if (tableArchiveGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.receiverMail)].Value != null) //mail gonderılmek ısstenıyorsa
                        {
                            archiveContentPropertiesModel.mail = tableArchiveGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.receiverMail)].Value.ToString();
                        }

                        Singl.archiveControllerGet.addContentPropertiesToList(archiveContentPropertiesModel);

                        archiveModelArr[cnt] = archiveContentPropertiesModel;
                    }

                    string responseErrorMessage = Singl.archiveControllerGet.sendEarchive();
                    if (responseErrorMessage != null)
                    {
                        MessageBox.Show(responseErrorMessage, Lang.operationFailed, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        //db de fatura durumunu taslaktan cıkar
                        for (int cnt = 0; cnt < archiveModelArr.Length; cnt++)
                        {
                            string oldFolderPath = Singl.archiveInvoiceDalGet.findArchive(archiveModelArr[cnt].uuid).folderPath;

                            //path degıstır
                            string newFolderPath = FolderControl.inboxFolderArchive + newIdArr[cnt] + "." + nameof(EI.DocumentType.XML);

                            //guncelleme basarılıysa
                            if (Singl.archiveInvoiceDalGet.updateArchiveIdStateNoteDraftFlagFolderPath(archiveModelArr[cnt].uuid,
                                                                                                       newIdArr[cnt], EI.StateNote.SEND.ToString(), false, newFolderPath) == 1)
                            {
                                //diskten xmli sil
                                FolderControl.deleteFileFromPath(oldFolderPath);

                                //yenı kontentı dıske kaydet
                                FolderControl.writeFileOnDiskWithString(archiveModelArr[cnt].content, newFolderPath);
                            }
                            else
                            {
                                MessageBox.Show("Db ye kaydetme işlemi basarısız,İşlemi tekrar gerceklestırınız" + tableArchiveGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.ID)].Value.ToString());
                                return;
                            }
                        }

                        //db ye, en son olusturulan yenı ınv id serisinin son itemi ıle serı no ve yıl guncelle
                        Singl.invIdSerilazeDalGet.updateLastAddedInvIdSeri(newIdArr.Last());

                        MessageBox.Show(Lang.succesful);//"Başarılı"
                        gridArchiveUpdateList(Singl.archiveInvoiceDalGet.getArchiveList(true));
                    }
                }
            }
            catch (FaultException <REQUEST_ERRORType> ex)
            {
                if (ex.Detail.ERROR_CODE == 2005)
                {
                    Singl.authControllerGet.Login(FrmLogin.usurname, FrmLogin.password);
                }
                MessageBox.Show(ex.Detail.ERROR_SHORT_DES, "ProcessingFault", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
            {
                MessageBox.Show(Lang.dbFault + " " + ex.InnerException.Message.ToString(), "DataBaseFault", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (System.Data.DataException ex)
            {
                MessageBox.Show(ex.InnerException.Message.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }