Esempio n. 1
0
        public int addDespatchFromServiceAndSaveContentOnDisk(DESPATCHADVICE[] despatchArr, string direction)
        {
            DespatchAdvices despatchAdvice;

            using (DatabaseContext databaseContext = new DatabaseContext())
            {
                foreach (var despatch in despatchArr)
                {
                    despatchAdvice = new DespatchAdvices();

                    despatchAdvice.ID                   = despatch.ID;
                    despatchAdvice.uuid                 = despatch.UUID;
                    despatchAdvice.direction            = direction;
                    despatchAdvice.issueDate            = Convert.ToDateTime(despatch.DESPATCHADVICEHEADER.ISSUE_DATE);
                    despatchAdvice.profileId            = despatch.DESPATCHADVICEHEADER.PROFILEID;
                    despatchAdvice.senderVkn            = despatch.DESPATCHADVICEHEADER.SENDER.VKN;
                    despatchAdvice.cDate                = despatch.DESPATCHADVICEHEADER.CDATE;
                    despatchAdvice.envelopeIdentifier   = despatch.DESPATCHADVICEHEADER.ENVELOPE_IDENTIFIER;
                    despatchAdvice.status               = despatch.DESPATCHADVICEHEADER.STATUS;
                    despatchAdvice.gibStatusCode        = despatch.DESPATCHADVICEHEADER.GIB_STATUS_CODE;
                    despatchAdvice.gibStatusDescription = despatch.DESPATCHADVICEHEADER.GIB_STATUS_DESCRIPTION;
                    despatchAdvice.folderPath           = FolderControl.createDespatchDocPath(despatch.ID, direction, nameof(EI.DocumentType.XML));
                    despatchAdvice.issueTime            = despatch.DESPATCHADVICEHEADER.ISSUE_TIME;
                    despatchAdvice.shipmentDate         = despatch.DESPATCHADVICEHEADER.ACTUAL_SHIPMENT_DATE;
                    despatchAdvice.shipmentTime         = despatch.DESPATCHADVICEHEADER.ACTUAL_SHIPMENT_TIME;
                    despatchAdvice.typeCode             = despatch.DESPATCHADVICEHEADER.TYPE_CODE;
                    despatchAdvice.statusCode           = despatch.DESPATCHADVICEHEADER.STATUS_CODE;

                    FolderControl.writeFileOnDiskWithString(Encoding.UTF8.GetString(Compress.UncompressFile(despatch.CONTENT.Value)), despatchAdvice.folderPath);

                    databaseContext.despatchAdvices.Add(despatchAdvice);
                }
                return(databaseContext.SaveChanges());
            }
        }
Esempio n. 2
0
        public int addCreditNoteToDbAndSaveContentOnDisk(CREDITNOTE[] creditNoteArr, string isDraft)
        {
            CreditNotes CreditNote;

            using (DatabaseContext databaseContext = new DatabaseContext())
            {
                foreach (var creditNotes in creditNoteArr)
                {
                    CreditNote = new CreditNotes();
                    CreditNote.CreditNoteID       = creditNotes.ID;
                    CreditNote.uuid               = creditNotes.UUID;
                    CreditNote.customerTitle      = creditNotes.HEADER.CUSTOMER.NAME;
                    CreditNote.customerIdentifier = creditNotes.HEADER.CUSTOMER.IDENTIFIER;
                    CreditNote.profileID          = creditNotes.HEADER.PROFILE_ID.ToString();
                    CreditNote.status             = creditNotes.HEADER.STATUS;
                    CreditNote.statusCode         = creditNotes.HEADER.STATUS_CODE;
                    CreditNote.statusDesc         = creditNotes.HEADER.STATUS_DESCRIPTION;
                    CreditNote.cDate              = creditNotes.HEADER.CDATE;
                    CreditNote.issueDate          = creditNotes.HEADER.ISSUE_DATE;
                    CreditNote.email              = creditNotes.HEADER.EMAIL != null?creditNotes.HEADER.EMAIL.First() : null;

                    CreditNote.emailStatusCode = creditNotes.HEADER.EMAIL_STATUS_CODE;
                    CreditNote.isDraft         = isDraft;
                    CreditNote.folderPath      = FolderControl.CreditNoteFolderPath + CreditNote.CreditNoteID + "." + nameof(EI.DocumentType.XML);

                    FolderControl.writeFileOnDiskWithString(Encoding.UTF8.GetString(Compress.UncompressFile(creditNotes.CONTENT.Value)), CreditNote.folderPath);

                    databaseContext.creditNotes.Add(CreditNote);
                }

                return(databaseContext.SaveChanges());
            }
        }
Esempio n. 3
0
        public int addSmmToDbAndSaveContentOnDisk(SMM[] smmArr)
        {
            SelfEmploymentReceipts selfEmployment;

            using (DatabaseContext databaseContext = new DatabaseContext())
            {
                foreach (var smm in smmArr)
                {
                    selfEmployment = new SelfEmploymentReceipts();

                    selfEmployment.smmID         = smm.ID;
                    selfEmployment.uuid          = smm.UUID;
                    selfEmployment.customerTitle = smm.HEADER.CUSTOMER.NAME;
                    selfEmployment.customerID    = smm.HEADER.CUSTOMER.IDENTIFIER;
                    selfEmployment.profileID     = smm.HEADER.PROFILE_ID.ToString();
                    selfEmployment.status        = smm.HEADER.STATUS;
                    selfEmployment.statusCode    = smm.HEADER.STATUS_CODE;
                    selfEmployment.statusDesc    = smm.HEADER.STATUS_DESCRIPTION;
                    selfEmployment.cDate         = smm.HEADER.CDATE;
                    selfEmployment.issueDate     = smm.HEADER.ISSUE_DATE;
                    selfEmployment.email         = smm.HEADER.EMAIL != null?smm.HEADER.EMAIL.First() : null;

                    selfEmployment.emailStatusCode = smm.HEADER.EMAIL_STATUS_CODE;
                    selfEmployment.folderPath      = FolderControl.smmFolderPath + smm.ID + "." + nameof(EI.DocumentType.XML);

                    FolderControl.writeFileOnDiskWithString(Encoding.UTF8.GetString(Compress.UncompressFile(smm.CONTENT.Value)), selfEmployment.folderPath);

                    databaseContext.selfEmployments.Add(selfEmployment);
                }
                return(databaseContext.SaveChanges());
            }
        }
Esempio n. 4
0
        public bool DeleteDevice(GCDevice device)
        {
            GCError.ClearLastError();

            //validate device
            if (device == null || device.DeviceID < 0)
            {
                GCError.SetLastError("Invalid device.");
                return(false);
            }

            //delete record from database
            if (!DeviceTable.DeleteDevice(device.DeviceID))
            {
                GCError.SetLastError("Delete device from database failed.");
                return(false);
            }

            //delete device folder
            if (!FolderControl.DeleteDevice(device.FolderPath))
            {
                GCError.SetLastError("Delete device folder " + device.FolderPath + " failed.");
                return(false);
            }

            return(true);
        }
Esempio n. 5
0
        public void BrowseFolder()
        {
            GCDevice device = GetSelectedDevice();

            if (device != null)
            {
                FolderControl.BrowseFolder(device.FolderPath);
            }
        }
        public mainWindow()
        {
            InitializeComponent();

            ImageList nodeTreeImageList = new ImageList();

            nodeTreeImageList.Images.Add(Properties.Resources.FolderNodeOpenIcon);
            nodeTreeImageList.Images.Add(Properties.Resources.RootNodeIcon);
            nodeTreeImageList.Images.Add(Properties.Resources.FolderNodeIcon);
            nodeTreeImageList.Images.Add(Properties.Resources.DeviceNodeIcon);
            nodeTreeImageList.Images.Add(Properties.Resources.DatapointNodeIcon);

            NodeTreeView.ImageList = nodeTreeImageList;

            String DatabaseType     = ConfigurationManager.AppSettings["DatabaseConnector"];
            String DatabaseName     = ConfigurationManager.AppSettings["DatabaseName"];
            String DatabaseServer   = ConfigurationManager.AppSettings["DatabaseServer"];
            String DatabaseUsername = ConfigurationManager.AppSettings["DatabaseUsername"];
            String DatabasePassword = ConfigurationManager.AppSettings["DatabasePassword"];

            // Create a DatabaseFacade instance
            this.database = new DatabaseFacade();
            if (DatabaseType.Equals("MYSQL"))
            {
                // Tell the DatabseFacade to use the MySQLConnector
                this.database.SetDatabaseConnector(
                    new MySQLConnector(String.Format("SERVER={0};DATABASE={1};UID={2};PASSWORD={3};", DatabaseServer, DatabaseName, DatabaseUsername, DatabasePassword))
                    );
            }

            // Open a connection to the datbase
            this.database.OpenConnection();

            parentIdDictionary = database.GetObjectTreeSortedByParentID();
            PopulateTreeView();
            NodeTreeView.Nodes[0].Expand();

            this.database.CloseConnection();

            this.FolderControl      = new FolderControl();
            this.FolderControl.Dock = DockStyle.Fill;
            ContentPanel.Controls.Add(this.FolderControl);

            this.DeviceControl      = new DeviceControl();
            this.DeviceControl.Dock = DockStyle.Fill;
            ContentPanel.Controls.Add(this.DeviceControl);

            this.DatapointControl      = new DatapointControl();
            this.DatapointControl.Dock = DockStyle.Fill;
            ContentPanel.Controls.Add(this.DatapointControl);

            ContentPanel.Controls[0].Visible = true;
            ContentPanel.Controls[1].Visible = false;
            ContentPanel.Controls[2].Visible = false;
        }
Esempio n. 7
0
        private void profileListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            customFieldsGroupBox.Controls.Clear();

            if (!(profileListBox.SelectedItem is SitecoreProfile profile))
            {
                return;
            }

            //Load all the files for the profile
            var configuration = Utility.GetInstanceConfiguration(profile.Topology, profile.Version);

            var fields = new List <Field>();

            foreach (var field in configuration.FieldSet.Fields)
            {
                if (field != null)
                {
                    fields.Add(field);
                }
            }

            var position = 20;

            foreach (var field in fields)
            {
                switch (field.Type.ToLower())
                {
                case "text":
                    var stringControl = new StringControl(field.Label, field.Map, field.Description)
                    {
                        Top = position, Left = 20
                    };
                    stringControl.Value        = field.DefaultValue.Replace("[[PREFIX]]", prefixTextBox.Text);
                    stringControl.DefaultValue = field.DefaultValue;
                    prefixTextBox.TextChanged += stringControl.Prefix_Changed;
                    customFieldsGroupBox.Controls.Add(stringControl);
                    break;

                case "folder":
                    var folderControl = new FolderControl(field.Label, field.Map, field.Description)
                    {
                        Top = position, Left = 20
                    };
                    customFieldsGroupBox.Controls.Add(folderControl);
                    break;
                }

                position += 25;
            }
        }
Esempio n. 8
0
        private void btnGetSignedXmlArchive_Click(object sender, EventArgs e)
        {
            try
            {
                //gridde secılı arsıvlerın ımzalı xmlını dıske yazar
                List <string> listUnvalidArchive = new List <string>();

                foreach (DataGridViewRow row in tableArchiveGrid.SelectedRows)
                {
                    byte[] content = Singl.archiveControllerGet.getReadFromEArchive(row.Cells[nameof(EI.Invoice.uuid)].Value.ToString(), nameof(EI.DocumentType.XML));
                    if (content != null)
                    {
                        string path = FolderControl.inboxFolderArchive + row.Cells[nameof(EI.Invoice.ID)].Value.ToString() + "." + nameof(EI.DocumentType.XML);
                        FolderControl.writeFileOnDiskWithByte(content, path);
                    }
                    else
                    {
                        listUnvalidArchive.Add(row.Cells[nameof(EI.Invoice.ID)].Value.ToString());
                    }
                }

                if (listUnvalidArchive.Count > 0)
                {
                    MessageBox.Show(string.Join(Environment.NewLine, listUnvalidArchive) + Environment.NewLine + Lang.noGetInvoice);//Seçili arsivler getirilemedi
                }
                else
                {
                    MessageBox.Show(Lang.succesful);//"Başarılı"
                }
            }
            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());
            }
        }
Esempio n. 9
0
        private void btnGetSingedXml_Click(object sender, EventArgs e)
        {
            try
            {
                List <string> listReportNoSucc = new List <string>();

                foreach (DataGridViewRow row in tableArchiveGrid.SelectedRows)
                {
                    string reportNo = row.Cells[nameof(EI.ArchiveReports.reportNo)].Value.ToString();

                    string signedXmlContent = Singl.archiveControllerGet.getArchiveReportXml(reportNo);
                    if (signedXmlContent != null)
                    {
                        //contentı dıske yazdır
                        FolderControl.writeFileOnDiskWithString(signedXmlContent, FolderControl.inboxFolderArchiveReport + reportNo + "." + nameof(EI.DocumentType.XML));
                        listReportNoSucc.Add(row.Cells[nameof(EI.ArchiveReports.reportNo)].Value.ToString());
                    }
                }

                if (listReportNoSucc.Count > 0)
                {
                    MessageBox.Show(string.Join(Environment.NewLine, listReportNoSucc) + Environment.NewLine + Lang.hasIdArchiveReportSave);//"secılı arsıv raporları basarıyla kaydedıldı"
                }
                else
                {
                    MessageBox.Show(Lang.operationFailed);//"islem basarısız"
                }
            }
            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());
            }
        }
Esempio n. 10
0
        public string getSmmContentXml(string uuid)
        {
            //db den pathı getırdı
            string xmlPath = Singl.smmDalGet.findSmmWithUuid(uuid).folderPath;

            if (FolderControl.xmlFileIsInFolder(xmlPath)) // xml dosyası verılen pathde bulunuyorsa
            {
                return(File.ReadAllText(xmlPath));
            }
            else
            {
                //servisten, gonderilen uuıd ye aıt faturanın contentını getır
                return(getSmmWithUuidOnService(uuid));
            }
        }
Esempio n. 11
0
        /// <summary>
        /// diskten xmlı alır
        /// </summary>
        /// <returns></returns>
        public string getArchiveReportXml(string reportNo)
        {
            //db den pathı getırdı
            string xmlPath = FolderControl.archiveFolderReportPath + reportNo + "." + nameof(EI.DocumentType.XML);

            if (!FolderControl.xmlFileIsInFolder(xmlPath)) // xml dosyası verılen pathde bulunmuyorsa
            {
                // repor no ya ait servisten raporun ımzalı xmlını  getır
                return(getReportSignedXml(reportNo));
            }
            else
            {
                return(File.ReadAllText(xmlPath));
            }
        }
Esempio n. 12
0
        public string getDespatchContentXml(string uuid, string direction)
        {
            //db den pathı getırdı
            string xmlPath = Singl.DespatchAdviceDalGet.getDespatch(uuid, direction).folderPath;

            if (!FolderControl.xmlFileIsInFolder(xmlPath)) // xml dosyası verılen pathde bulunmuyorsa
            {
                //servisten, gonderilen uuıd ye aıt faturanın contentını getır
                return(getDespatchXmlContentFromService(uuid, direction));
            }
            else
            {
                return(File.ReadAllText(xmlPath));
            }
        }
        private void getXmlDespatch()
        {
            try
            {
                List <string> idList = new List <string>();

                foreach (DataGridViewRow row in tableGrid.SelectedRows)
                {
                    string content = Singl.despatchControllerGet.getDespatchXmlContentFromService(row.Cells[nameof(EI.Despatch.uuid)].Value.ToString(), despactDirection);
                    if (content != null)
                    {
                        FolderControl.writeFileOnDiskWithString(content, row.Cells[nameof(EI.Despatch.folderPath)].Value.ToString());
                        idList.Add(row.Cells[nameof(EI.Despatch.ID)].Value.ToString());
                    }
                }

                if (idList.Count > 0)
                {
                    MessageBox.Show(string.Join(Environment.NewLine, idList) + Environment.NewLine + "Kaydedildi");//Seçili arsivler getirilemedi
                }
                else
                {
                    MessageBox.Show("işlem Basarısız", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            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());
            }
        }
Esempio n. 14
0
        public bool AddInterfaceToDatabase(GCInterface gcInterface)
        {
            //return TempFunctionHandler("Runing AddInterfaceToDatabase script...");

            GCError.ClearLastError();

            // validate interface
            if (gcInterface == null)
            {
                GCError.SetLastError("Invalid interface.");
                return(false);
            }

            // insert interface record into database
            gcInterface.Directory = null;
            if (!InterfaceTable.InsertInterface(gcInterface))
            {
                GCError.SetLastError("Insert database failed.");
                return(false);
            }

            // get interface id
            gcInterface.InterfaceID = InterfaceTable.GetMaxID();
            if (gcInterface.InterfaceID < 1)
            {
                GCError.SetLastError("Invalid interface ID.");
                return(false);
            }

            // update DeviceDir: update interface id, which will be used by interface NT service to identify itself when notifying its status to IM via windows message.
            GCDevice device = FolderControl.LoadDevice(gcInterface.FolderPath);

            device.Directory.Header.ID = gcInterface.InterfaceID.ToString();
            if (!FolderControl.SaveDevice(device))
            {
                GCError.SetLastError("Update device index file failed.");
                return(false);
            }

            return(true);
        }
Esempio n. 15
0
        private void CreateUninstallScript()
        {
            string scriptFile    = Application.StartupPath + "\\UninstallServices.bat";
            string interfacePath = Application.StartupPath + "\\" + Program.ConfigMgt.Config.InterfaceFolder;

            string[]      folderList = Directory.GetDirectories(interfacePath);
            StringBuilder sb         = new StringBuilder();

            foreach (string folder in folderList)
            {
                GCDevice device = FolderControl.LoadDevice(folder);
                if (device != null && device.Directory != null)
                {
                    Command[] clist = device.Directory.Commands.FindCommands(CommandType.Stop);
                    if (clist != null)
                    {
                        foreach (Command cmd in clist)
                        {
                            sb.Append("\"" + folder + "\\" + cmd.Path + "\"").Append(" ").AppendLine(cmd.Argument);
                        }
                    }
                    clist = device.Directory.Commands.FindCommands(CommandType.Uninstall);
                    if (clist != null)
                    {
                        foreach (Command cmd in clist)
                        {
                            sb.Append("\"" + folder + "\\" + cmd.Path + "\"").Append(" ").AppendLine(cmd.Argument);
                        }
                    }
                }

                string f = Path.GetFileName(folder);
                sb.Append("net stop ").AppendLine(f);
                sb.Append("sc delete ").AppendLine(f);
            }
            using (StreamWriter sw = File.CreateText(scriptFile))
            {
                sw.Write(sb.ToString());
            }
            Program.Log.Write("{Interface} Update uninstall script in " + scriptFile);
        }
Esempio n. 16
0
        public int addInvoiceToDbAndSaveContentOnDisk(INVOICE[] invoiceArray, string direction)
        {
            using (DatabaseContext dbContext = new DatabaseContext())
            {
                Invoices invoice;
                foreach (var inv in invoiceArray)
                {
                    invoice = new Invoices();

                    invoice.ID                   = inv.ID;
                    invoice.uuid                 = inv.UUID;
                    invoice.direction            = direction;
                    invoice.issueDate            = inv.HEADER.ISSUE_DATE;
                    invoice.profileId            = inv.HEADER.PROFILEID;
                    invoice.invoiceType          = inv.HEADER.INVOICE_TYPE_CODE;
                    invoice.suplier              = inv.HEADER.SUPPLIER;
                    invoice.senderVkn            = inv.HEADER.SENDER;
                    invoice.receiverVkn          = inv.HEADER.RECEIVER;
                    invoice.cDate                = inv.HEADER.CDATE;
                    invoice.envelopeIdentifier   = inv.HEADER.ENVELOPE_IDENTIFIER;
                    invoice.status               = inv.HEADER.STATUS;
                    invoice.gibStatusCode        = inv.HEADER.GIB_STATUS_CODE;
                    invoice.gibStatusDescription = inv.HEADER.GIB_STATUS_DESCRIPTION;
                    invoice.senderAlias          = inv.HEADER.FROM;
                    invoice.receiverAlias        = inv.HEADER.TO;
                    invoice.folderPath           = FolderControl.createInvoiceDocPath(inv.ID, direction, nameof(EI.DocumentType.XML));

                    byte[] unCompressedContent = Compress.UncompressFile(inv.CONTENT.Value);
                    FolderControl.writeFileOnDiskWithString(Encoding.UTF8.GetString(unCompressedContent), invoice.folderPath);

                    if (direction == nameof(EI.Direction.DRAFT))
                    {
                        invoice.draftFlag = EI.ActiveOrPasive.Y.ToString();  //servisten cektıklerımız flag Y  ☺
                    }

                    dbContext.invoices.Add(invoice);
                }
                var i = dbContext.SaveChanges();
                return(i);
            }
        }
Esempio n. 17
0
        public int addArchiveToDbAndSaveContentOnDisk(EARCHIVEINV[] archiveArr)
        {
            ArchiveInvoices archive;

            using (DatabaseContext databaseContext = new DatabaseContext())
            {
                foreach (var arc in archiveArr)
                {
                    archive = new ArchiveInvoices();

                    //bu row uuid degerı dbye daha once eklenmemısse
                    if (databaseContext.archiveInvoices.Find(archive.uuid) == null)
                    {
                        archive.ID           = arc.HEADER.INVOICE_ID;
                        archive.uuid         = arc.HEADER.UUID;
                        archive.totalAmount  = Convert.ToDecimal(arc.HEADER.PAYABLE_AMOUNT);
                        archive.issueDate    = Convert.ToDateTime(arc.HEADER.ISSUE_DATE);
                        archive.profileId    = arc.HEADER.PROFILE_ID;
                        archive.invoiceType  = arc.HEADER.INVOICE_TYPE;
                        archive.sendingType  = arc.HEADER.SENDING_TYPE;
                        archive.eArchiveType = arc.HEADER.EARCHIVE_TYPE;
                        archive.senderName   = arc.HEADER.SENDER_NAME;
                        archive.senderVkn    = arc.HEADER.SENDER_IDENTIFIER;
                        archive.receiverVkn  = arc.HEADER.CUSTOMER_IDENTIFIER;
                        archive.status       = arc.HEADER.STATUS;
                        archive.statusCode   = arc.HEADER.STATUS_CODE;
                        archive.currencyCode = arc.HEADER.CURRENCY_CODE;
                        archive.folderPath   = FolderControl.inboxFolderArchive + archive.ID + "." + nameof(EI.DocumentType.XML);

                        FolderControl.writeFileOnDiskWithString(Encoding.UTF8.GetString(Compress.UncompressFile(arc.CONTENT.Value)), archive.folderPath);



                        databaseContext.archiveInvoices.Add(archive);
                    }
                }
                return(databaseContext.SaveChanges());
            }
        }
Esempio n. 18
0
        public bool DeleteInterfaceFromFolder(GCInterface gcInterface)
        {
            GCError.ClearLastError();

            // validation
            if (gcInterface == null)
            {
                GCError.SetLastError("Invalid gcInterface object.");
                return(false);
            }

            // delete folder
            string folderPath = gcInterface.FolderPath;
            bool   result     = FolderControl.DeleteDevice(folderPath);

            if (!result)
            {
                GCError.SetLastError("Delete folder " + folderPath + "  failed.");
            }

            return(result);
        }
Esempio n. 19
0
        /// <summary>
        /// IMZALI XML DISKE KAYDET
        /// </summary>

        public bool isGetInvoiceSingnedXml(string direction)
        {
            using (new OperationContextScope(eInvoiceOIBPortClient.InnerChannel))
            {
                GetInvoiceRequest req = new GetInvoiceRequest();
                req.REQUEST_HEADER                            = RequestHeader.getRequestHeaderOib;
                req.REQUEST_HEADER.COMPRESSED                 = nameof(EI.ActiveOrPasive.Y);
                req.INVOICE_SEARCH_KEY                        = InvoiceSearchKey.invoiceSearchKeyGetInvoice;
                req.INVOICE_SEARCH_KEY.READ_INCLUDED          = true; //okunmusları da al
                req.INVOICE_SEARCH_KEY.READ_INCLUDEDSpecified = true;
                req.HEADER_ONLY = EI.ActiveOrPasive.N.ToString();
                req.INVOICE_SEARCH_KEY.DIRECTION = direction;
                if (direction == nameof(EI.Direction.DRAFT))
                {
                    req.INVOICE_SEARCH_KEY.DIRECTION  = nameof(EI.Direction.OUT);
                    req.INVOICE_SEARCH_KEY.DRAFT_FLAG = nameof(EI.ActiveOrPasive.Y);
                }

                INVOICE[] invoiceArr = eInvoiceOIBPortClient.GetInvoice(req);
                if (invoiceArr == null || invoiceArr.Length != 0)
                {
                    foreach (var invoice in invoiceArr)
                    {
                        FolderControl.saveInvDocContentWithByte(Compress.UncompressFile(invoice.CONTENT.Value), direction, invoice.ID, nameof(EI.DocumentType.XML));
                    }
                    //db ye kaydetmedıgım ıcın aldıgım faturaları mark ınv yapmadım

                    if (invoiceArr.Length == 100) //butun okunmamısları almak ıcın ... limit 100 vermıstık
                    {
                        isGetInvoiceSingnedXml(direction);
                    }
                    return(true);
                }
                return(false);
            }
        }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                //bos eleamn olmaması
                if (validEmptyComponent())
                {
                    //iade secılı ıse temel fatura olarak gonderılmesı
                    if (isValidInvoice())
                    {
                        //tutar hesapla
                        calculateTotalMoney();

                        //kullanıcı bılgılerı getır
                        getUserInformationOnDb();

                        ////////UBL OLUSTURMA ISLEMI////////
                        BaseInvoiceUBL invoice;

                        //eger INVOİCE ıse
                        if (invoiceType == nameof(EI.Invoice.Invoices))
                        {
                            invoice = new InvoiceUBL(cmbScenario.Text, cmbInvType.Text);
                        }
                        else //ARCHİVE İSE
                        {
                            invoice = new ArchiveUBL(cmbArchiveSendingType.Text, cmbScenario.Text, cmbInvType.Text);

                            if (cmbArchiveType.Text == nameof(EI.ArchiveType.INTERNET))
                            {
                                //eger gonderım tıpı ınternet ıse ekstra adınatıonal ref ekle
                                invoice.addAdditionalDocumentReference(nameof(EI.Profileid.EARSIVFATURA), cmbArchiveType.Text);

                                //DELİVERY BOLUMU EKLE
                                //carrıer ekle
                                PartyType carrierParty = invoice.createParty(txtCarrierTitle.Text, "", "", "");
                                invoice.addPartyIdentification(carrierParty, 1, nameof(EI.VknTckn.VKN), msdDeliveryVkn.Text, "", "", "", "");
                                invoice.createDelivery(carrierParty, Convert.ToDateTime(datepicDespatchDate.Text));

                                //payment means ekle
                                invoice.createPaymentMeans(getPaymentCode(cmbPaymentType.Text), Convert.ToDateTime(datepicPaymentDate.Text), txtMediator.Text);
                            }
                        }

                        PartyType supParty;
                        PartyType cusParty;
                        string    partyIdentificationSchemaType;

                        //SUPPLİER  PARTY OLUSTURULMASI
                        supParty = invoice.createParty(partyName, cityName, telephone, mail);
                        if (senderVknTc.Length == 10) //sup vkn
                        {
                            partyIdentificationSchemaType = nameof(EI.VknTckn.VKN);
                            invoice.addPartyTaxSchemeOnParty(supParty);
                        }
                        else  //sup tckn .. add person metodu eklenır
                        {
                            partyIdentificationSchemaType = nameof(EI.VknTckn.TCKN);
                            invoice.addPersonOnParty(supParty, firstName, familyName);
                        }
                        invoice.addPartyIdentification(supParty, 2, partyIdentificationSchemaType, senderVknTc, nameof(EI.Mersis.MERSISNO), sicilNo, "", "");
                        invoice.SetSupplierParty(supParty);

                        //CUST PARTY OLUSTURULMASI
                        cusParty = invoice.createParty(txtPartyName.Text, txtCity.Text, msdPhone.Text, txtMail.Text);
                        if (msdVknTc.Text.Length == 10) //customer vkn
                        {
                            partyIdentificationSchemaType = nameof(EI.VknTckn.VKN);
                            invoice.addPartyTaxSchemeOnParty(cusParty);
                        }
                        else  //customer tckn
                        {
                            partyIdentificationSchemaType = nameof(EI.VknTckn.TCKN);
                            invoice.addPersonOnParty(cusParty, txtCustName.Text, txtCustSurname.Text);
                        }
                        invoice.addPartyIdentification(cusParty, 1, partyIdentificationSchemaType, msdVknTc.Text, "", "", "", "");
                        invoice.SetCustomerParty(cusParty);


                        //INV LINE OLUSTURULMASI
                        foreach (DataGridViewRow row in gridPrice.Rows)
                        {
                            //Inv Lıne Olusturulması
                            //unıt code get fonk cagırılarak secılen bırımın unıt codu getırılırilerek aktarılır
                            invoice.addInvoiceLine(row.Index.ToString(), cmbMoneyType.Text, getUnitCode(row.Cells[nameof(EI.InvLineGridRowClm.unit)].Value.ToString())
                                                   , Convert.ToDecimal(row.Cells[nameof(EI.InvLineGridRowClm.quantity)].Value), Convert.ToDecimal(row.Cells[nameof(EI.InvLineGridRowClm.total)].Value)
                                                   , Convert.ToDecimal(row.Cells[nameof(EI.InvLineGridRowClm.taxAmount)].Value), Convert.ToDecimal(row.Cells[nameof(EI.InvLineGridRowClm.total)].Value)
                                                   , Convert.ToDecimal(row.Cells[nameof(EI.InvLineGridRowClm.taxPercent)].Value), row.Cells[nameof(EI.InvLineGridRowClm.productName)].Value.ToString()
                                                   , Convert.ToDecimal(row.Cells[nameof(EI.InvLineGridRowClm.unitPrice)].Value));
                        }

                        invoice.setInvLines();
                        invoice.setTaxTotal(invoice.invoiceTaxTotal());
                        invoice.SetLegalMonetaryTotal(invoice.CalculateLegalMonetaryTotal());
                        invoice.SetAllowanceCharge(invoice.CalculateAllowanceCharges());

                        //olusturdugumuz nesne ubl turune cevrılır
                        var invoiceUbl = invoice.baseInvoiceUBL;
                        //xml olustur
                        string xmlPath = FolderControl.writeDiscInvoiceConvertUblToXml(invoiceUbl, invoiceType).ToString();

                        if (xmlPath != null)
                        {
                            //db ye kaydet
                            if (invoiceType == nameof(EI.Invoice.Invoices))
                            {
                                Singl.invoiceDalGet.insertDraftInvoice(invoiceUbl, xmlPath);
                            }
                            else if (invoiceType == nameof(EI.Invoice.ArchiveInvoices)) //arsıv ıse
                            {
                                Singl.archiveInvoiceDalGet.insertArchiveOnDbFromUbl(invoiceUbl, xmlPath, chkSendMail.Checked);
                            }

                            MessageBox.Show(xmlPath + "  faturalar kaydedıldı");
                        }
                        else
                        {
                            MessageBox.Show("işlem basarısız");
                        }
                    }
                    else
                    {
                        MessageBox.Show("iade faturası secılıyse temel olarak gonderılmelıdır");
                    }
                }
                else  //bos eleman varsa
                {
                    MessageBox.Show("yıldızlı alanları bos bırakmayınız");
                }
            }
            catch (FaultException <REQUEST_ERRORType> ex) //oib req error
            {
                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)
            {
                MessageBox.Show(Lang.dbFault, "DataBaseFault", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 21
0
        public GCInterface AddInterfaceToFolder(GCDevice gcDevice, string interfaceName, string interfacDesc)
        {
            GCError.ClearLastError();

            // validation
            if (gcDevice == null || gcDevice.Directory == null)
            {
                GCError.SetLastError("Invalid device object.");
                return(null);
            }

            int progCount = 0;
            int fileCount = gcDevice.Directory.Files.Count;

            NotifyStart(fileCount + 2, 0, progCount++, "Create interface folder...");

            // create interface folder
            string targetFolder = InterfacesFolder + "\\" + interfaceName;

            try
            {
                if (Directory.Exists(targetFolder))
                {
                    GCError.SetLastError("Folder " + targetFolder + " have already exist, please try another name.");
                    NotifyComplete(false, "");
                    return(null);
                }

                if (Directory.CreateDirectory(targetFolder) == null)
                {
                    GCError.SetLastError("Cannot create folder " + targetFolder + ", please try another name.");
                    NotifyComplete(false, "");
                    return(null);
                }
            }
            catch (Exception e)
            {
                GCError.SetLastError("Cannot create folder " + targetFolder);
                GCError.SetLastError(e);
                NotifyComplete(false, "");
                return(null);
            }

            // copy device files
            DeviceDir dir          = gcDevice.Directory;
            string    sourceFolder = gcDevice.FolderPath;
            string    sourceFile   = sourceFolder + "\\" + DeviceDirManager.IndexFileName;
            string    targetFile   = targetFolder + "\\" + DeviceDirManager.IndexFileName;

            try
            {
                NotifyGoing(progCount++, "Copying files... ");
                File.Copy(sourceFile, targetFile);
                foreach (DeviceFile f in dir.Files)
                {
                    NotifyGoing(progCount++, "Copying files...");
                    sourceFile = sourceFolder + "\\" + f.Location;
                    targetFile = targetFolder + "\\" + f.Location;

                    // support sub folder in device dir
                    string path = Path.GetDirectoryName(targetFile);
                    if (!Directory.Exists(path))
                    {
                        if (Directory.CreateDirectory(path) == null)
                        {
                            GCError.SetLastError("Cannot create folder " + path);
                            NotifyComplete(false, "");
                            return(null);
                        }
                    }

                    File.Copy(sourceFile, targetFile);
                }
            }
            catch (Exception e)
            {
                GCError.SetLastError("Cannot copy file from " + sourceFile + " to " + targetFile);
                GCError.SetLastError(e);
                NotifyComplete(false, "");

                // roll back...
                FolderControl.DeleteDevice(targetFolder);
                return(null);
            }

            NotifyGoing(progCount++, "Updating files...");

            // update DeviceDir: save interface name, which will be used by interface installation program
            GCDevice device = FolderControl.LoadDevice(targetFolder);

            device.Directory.Header.RefDeviceName = gcDevice.DeviceName;
            device.Directory.Header.RefDeviceID   = gcDevice.DeviceID.ToString();
            device.Directory.Header.Description   = interfacDesc;
            device.Directory.Header.Name          = interfaceName;
            if (!FolderControl.SaveDevice(device))
            {
                GCError.SetLastError("Update device index file failed.");
                NotifyComplete(false, "");

                // roll back...
                FolderControl.DeleteDevice(targetFolder);
                return(null);
            }

            // create interface object
            GCInterface i = new GCInterface();

            i.Directory     = device.Directory;
            i.InterfaceName = interfaceName;
            i.FolderPath    = targetFolder;
            i.Device        = gcDevice;

            NotifyComplete(true, "");

            return(i);
        }
        private void btnSendDespatch_Click(object sender, EventArgs e)
        {
            try
            {
                bool valid = true;


                //aynı kısıye gıdecek faturalar secılı mı kontrolu
                string receiverVkn = tableGrid.SelectedRows[0].Cells[nameof(EI.Despatch.receiverVkn)].Value.ToString();
                foreach (DataGridViewRow row in tableGrid.SelectedRows)
                {
                    if (row.Cells[nameof(EI.Despatch.receiverVkn)].Value != null && row.Cells[nameof(EI.Despatch.receiverVkn)].Value.ToString() != receiverVkn) //vkn farklı ıse
                    {
                        MessageBox.Show(Lang.selectOnePerson);                                                                                                  //sadece aynı kısıye olan faturaları bırlıkte gonderebılırsınız
                        valid = false; break;
                    }
                }

                if (valid) //uymayan irsaliye durumu yoksa
                {
                    //db den getırılen serı Namelerı comboboxda sectır
                    FrmDialogSelectItem frmDialogSelectSeriName = new FrmDialogSelectItem(true, "");
                    if (frmDialogSelectSeriName.ShowDialog() == DialogResult.OK)
                    {
                        FrmDialogSelectItem frmDialogIdSelectAlias = new FrmDialogSelectItem(false, receiverVkn);
                        ////gb  sectır
                        if (frmDialogIdSelectAlias.ShowDialog() == DialogResult.OK)
                        {
                            IdArrContentArrModel ıdContentModel = createInvListWithNewId(frmDialogSelectSeriName.selectedValue);

                            //send despatch
                            string errorMessage = Singl.despatchControllerGet.sendDespatch(frmDialogIdSelectAlias.selectedValue, receiverVkn);
                            if (errorMessage != null)
                            {
                                MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                for (int cnt = 0; cnt < tableGrid.SelectedRows.Count; cnt++)
                                {
                                    string uuidRow = tableGrid.SelectedRows[cnt].Cells[nameof(EI.Despatch.uuid)].Value.ToString();

                                    string oldFolderPath = Singl.DespatchAdviceDalGet.getDespatch(uuidRow, nameof(EI.Direction.DRAFT)).folderPath;

                                    //yenı folderpath olustur
                                    string newFolderPath = FolderControl.createDespatchDocPath(ıdContentModel.newIdArr[cnt], nameof(EI.Direction.OUT),
                                                                                               nameof(EI.DocumentType.XML)); // yenı path db ye yazılır



                                    //db de yenı id,direction,folderpath,statenote guncellenır
                                    if (Singl.DespatchAdviceDalGet.updateDespatchIdDirectionFolderPathStateNote(uuidRow, nameof(EI.Direction.DRAFT),
                                                                                                                ıdContentModel.newIdArr[cnt], nameof(EI.Direction.OUT), newFolderPath, nameof(EI.StatusType.SEND)) == 1)
                                    {
                                        //eskı folderPathdekı dosyayı konumdan sıler
                                        FolderControl.deleteFileFromPath(oldFolderPath);

                                        //yenı folderpath ile yenı id eklenmıs xmli diske kaydet
                                        FolderControl.writeFileOnDiskWithString(ıdContentModel.newXmlContentArr[cnt], newFolderPath);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Güncel bilgileri Db ye kaydetme işlemi basarısız,İşlemi tekrar gerceklestırınız" + tableGrid.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(ıdContentModel.newIdArr.Last());

                                //datagrıd listesini guncelle
                                gridUpdateDespatchList(Singl.DespatchAdviceDalGet.getDespatchList(despactDirection));

                                MessageBox.Show(Lang.succesful);//"basarılı"
                            }
                        }
                        frmDialogIdSelectAlias.Dispose();
                    }
                    frmDialogSelectSeriName.Dispose();
                }
            }


            catch (FaultException <REQUEST_ERRORType> ex)
            {
                if (ex.Detail.ERROR_CODE == 2005)
                {
                    Singl.authControllerGet.Login(FrmLogin.usurname, FrmLogin.password);
                }
                MessageBox.Show(Lang.operationFailed + ex.Detail.ERROR_SHORT_DES, "ProcessingFault", MessageBoxButtons.OK, MessageBoxIcon.Error); //işlem basarısız
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException)
            {
                MessageBox.Show(Lang.dbFault, "DataBaseFault", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 23
0
        public GCDevice AddDevice(string folder)
        {
            GCError.ClearLastError();

            // check if the folder contains a device
            if (!FolderControl.IsDevicePath(folder))
            {
                GCError.SetLastError("Invalid device folder.");
                return(null);
            }

            // load device information from DeviceDir file
            GCDevice device = FolderControl.LoadDevice(folder);

            if (device == null)
            {
                GCError.SetLastError("Invalid device index file.");
                return(null);
            }

            // check whether a same device has already been installed
            // (if we do not do this, license control on max interface count will be useless.
            if (DeviceTable.HasSameDevice(device))
            {
                GCError.SetLastError("Device (Type: " + device.Directory.Header.Type.ToString()
                                     + ", Direction: " + device.Directory.Header.Direction.ToString()
                                     + ") has already been installed.");
                return(null);
            }

            // insert device information into database
            if (!DeviceTable.InsertDevice(device))
            {
                GCError.SetLastError("Insert database failed.");
                return(null);
            }

            // get device id for return;
            device.DeviceID = DeviceTable.GetMaxID();
            if (device.DeviceID < 1)
            {
                GCError.SetLastError("Invalid device ID.");
                return(null);
            }

            // create device folder
            string folderName = DevicesFolder + "\\" + device.DeviceName;

            try
            {
                FolderControl.DeleteDevice(folderName);     //according to defect EK_HI00045030 , 2006/11/20
                Directory.CreateDirectory(folderName);
            }
            catch (Exception err)
            {
                GCError.SetLastError(err);
                GCError.SetLastError("Cannot create directory " + folderName);
                DeviceTable.DeleteDevice(device.DeviceID);
                return(null);
            }

            // copy device files
            string sourceFile = "";
            string targetFile = "";

            try
            {
                sourceFile = device.FolderPath + "\\" + DeviceDirManager.IndexFileName;
                targetFile = folderName + "\\" + DeviceDirManager.IndexFileName;
                File.Copy(sourceFile, targetFile);

                foreach (DeviceFile f in device.Directory.Files)
                {
                    sourceFile = device.FolderPath + "\\" + f.Location;
                    targetFile = folderName + "\\" + f.Location;

                    // support sub folder in device dir
                    string path = Path.GetDirectoryName(targetFile);
                    if (!Directory.Exists(path))
                    {
                        if (Directory.CreateDirectory(path) == null)
                        {
                            GCError.SetLastError("Cannot create folder " + path);
                            return(null);
                        }
                    }

                    File.Copy(sourceFile, targetFile);
                }
            }
            catch (Exception err)
            {
                GCError.SetLastError(err);
                GCError.SetLastError("Cannot copy file from " + sourceFile + " to " + targetFile);
                DeviceTable.DeleteDevice(device.DeviceID);
                return(null);
            }

            // update DeviceDir: save device id
            GCDevice newDevice = FolderControl.LoadDevice(folderName);

            newDevice.Directory.Header.ID = device.DeviceID.ToString();
            if (!FolderControl.SaveDevice(newDevice))
            {
                GCError.SetLastError("Update device index file failed.");
                return(null);
            }

            // update device record
            device.FolderPath = folderName;
            if (!DeviceTable.UpdateDevice(device))
            {
                GCError.SetLastError("Update database failed.");
                return(null);
            }

            return(device);
        }
Esempio n. 24
0
        private void btnCreditNoteView_Click(object sender, EventArgs e)
        {
            try
            {
                string       uuid    = tableGrid.SelectedRows[0].Cells[nameof(EI.SelfEmploymentReceipt.uuid)].Value.ToString();
                CONTENT_TYPE docType = CONTENT_TYPE.XML;

                if (rdViewHtml.Checked) //html
                {
                    string xmlContent = Singl.smmControllerGet.getSmmContentXml(uuid);
                    if (xmlContent != null)
                    {
                        FrmView previewInvoices = new FrmView(xmlContent, nameof(EI.SelfEmploymentReceipt.SelfEmploymentReceipts));
                        previewInvoices.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show(Lang.cantGetContent);//content dıskten sılınmıs ve servısten getırılemedı
                    }
                }
                else  //html degılse
                {
                    if (rdViewXml.Checked) // xml ise
                    {
                        docType = CONTENT_TYPE.XML;
                    }
                    else //hicbirini secmezse pdf  görüntülenecektır
                    {
                        docType = CONTENT_TYPE.PDF;
                    }
                    /////////////
                    byte[] content = Singl.smmControllerGet.getSmmWithType(uuid, docType);
                    if (content != null)
                    {
                        string path = FolderControl.smmFolderPath + uuid + "." + docType;
                        FolderControl.writeFileOnDiskWithByte(content, path);
                        System.Diagnostics.Process.Start(path);
                    }
                    else
                    {
                        MessageBox.Show(Lang.cantGetContent);//content dıskten sılınmıs ve servısten getırılemedı
                    }
                }
            }
            catch (FaultException <SERVICES.serviceCreditNote.REQUEST_ERRORType> ex)  //archive req error
            {
                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());
            }
        }
        private void btnLoadDespatch_Click(object sender, EventArgs e)
        {
            try
            {
                //db den getırılen serı Namelerı comboboxda sectır
                FrmDialogSelectItem frmDialogIdSeriName = new FrmDialogSelectItem(true, "");
                if (frmDialogIdSeriName.ShowDialog() == DialogResult.OK)
                {
                    IdArrContentArrModel idArrContentArrModel = createInvListWithNewId(frmDialogIdSeriName.selectedValue); //load ınvda  direction degıstırmıyoruz o yuzden false

                    if (idArrContentArrModel != null)
                    {
                        string errorMessage = Singl.despatchControllerGet.loadDespatchToService();

                        if (errorMessage != null) //  basarısızsa
                        {
                            MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else //servıse yukleme ıslemı basarılıysa
                        {
                            for (int cnt = 0; cnt < tableGrid.SelectedRows.Count; cnt++)
                            {
                                string uuidRow = tableGrid.SelectedRows[cnt].Cells[nameof(EI.Invoice.uuid)].Value.ToString();

                                //yenı ıd ile yenı folderpath olustur
                                string newFolderPath = FolderControl.createDespatchDocPath(idArrContentArrModel.newIdArr[cnt], nameof(EI.Direction.DRAFT), nameof(EI.DocumentType.XML));

                                string oldFolderPath = Singl.DespatchAdviceDalGet.getDespatch(uuidRow, nameof(EI.Direction.DRAFT)).folderPath;


                                //db verileri guncelle
                                if (Singl.DespatchAdviceDalGet.updateDespatchIdCdateStatusGibCodeStateNoteFolderPath(uuidRow, nameof(EI.Direction.DRAFT),
                                                                                                                     idArrContentArrModel.newIdArr[cnt], DateTime.Now, nameof(EI.StatusType.LOAD) + " - " + nameof(EI.SubStatusType.SUCCEED),
                                                                                                                     -1, nameof(EI.StatusType.LOAD), newFolderPath) == 1)
                                {
                                    //yenı olust. folderpath ıle xml ı dıske kaydet
                                    FolderControl.writeFileOnDiskWithString(idArrContentArrModel.newXmlContentArr[cnt], newFolderPath);

                                    //eskı folderPathdekı dosyayı konumdan sıler
                                    FolderControl.deleteFileFromPath(oldFolderPath);
                                }
                                else
                                {
                                    MessageBox.Show("Güncel bilgileri Db ye kaydetme işlemi basarısız,İşlemi tekrar gerceklestırınız" + tableGrid.SelectedRows[cnt].Cells[nameof(EI.Despatch.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(idArrContentArrModel.newIdArr.Last());

                            // db den cekılen taslak faturaları datagrıdde listele
                            gridUpdateDespatchList(Singl.DespatchAdviceDalGet.getDespatchList(nameof(EI.Direction.DRAFT)));

                            MessageBox.Show(Lang.successLoad);//"yukleme basarılı"
                        }
                    }
                    frmDialogIdSeriName.Dispose();
                }
            }
            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)
            {
                MessageBox.Show(Lang.dbFault, "DataBaseFault", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Esempio n. 26
0
        private void btnCreateDespatch_Click(object sender, EventArgs e)
        {
            try
            {
                //bos eleamn olmaması
                if (validEmptyComponent())
                {
                    //tutar hesapla
                    calculateTotalAmount();

                    //kullanıcı bılgılerı getır
                    getUserInformationOnDb();

                    //////////UBL OLUSTURMA ISLEMI////////
                    DespatchAdviceUbl despatch = new DespatchAdviceUbl(gridPrice.RowCount, dateTimeDespatchDate.Value.Date, Convert.ToDateTime(cmbDespatchTime.Text),
                                                                       txtOrderId.Text, dateTimeOrderDate.Value.Date);


                    PartyType supParty;
                    PartyType cusParty;
                    string    schemaType;

                    //SUPPLİER  PARTY OLUSTURULMASI
                    supParty = despatch.createParty(partyName, cityName, telephone, mail);
                    if (senderVknTc.Length == 10) //sup vkn
                    {
                        schemaType = nameof(EI.VknTckn.VKN);
                        despatch.addPartyTaxSchemeOnParty(supParty);
                    }
                    else  //sup tckn .. add person metodu eklenır
                    {
                        schemaType = nameof(EI.VknTckn.TCKN);
                        despatch.addPersonOnParty(supParty, firstName, familyName);
                    }
                    despatch.addPartyIdentification(supParty, 1, schemaType, senderVknTc, "", "", "", "");
                    despatch.SetSupplierParty(supParty);

                    //CUST PARTY OLUSTURULMASI
                    cusParty = despatch.createParty(txtPartyName.Text, txtCity.Text, "", txtMail.Text);
                    if (msdVknTc.Text.Length == 10) //customer vkn
                    {
                        schemaType = nameof(EI.VknTckn.VKN);
                        despatch.addPartyTaxSchemeOnParty(cusParty);
                    }
                    else  //customer tckn
                    {
                        schemaType = nameof(EI.VknTckn.TCKN);
                        despatch.addPersonOnParty(cusParty, txtCustName.Text, txtCustSurname.Text);
                    }
                    despatch.addPartyIdentification(cusParty, 1, schemaType, msdVknTc.Text, "", "", "", "");
                    despatch.SetCustomerParty(cusParty);

                    //SHİPMENT
                    if (msdCarrierTcVkn.Text.Length == 10)
                    {
                        schemaType = nameof(EI.VknTckn.VKN);
                    }
                    else
                    {
                        schemaType = nameof(EI.VknTckn.TCKN);
                    }
                    despatch.createShipment(gridPrice.Rows.Count, txtPlate.Text, txtOrderId.Text, txtDriverName.Text, msdDriverTc.Text, dateTimeConsignmentDate.Value.Date, Convert.ToDateTime(cmbConsignmentTime.Text), schemaType, msdCarrierTcVkn.Text);


                    //INV LINE OLUSTURULMASI
                    foreach (DataGridViewRow row in gridPrice.Rows)
                    {
                        //Inv Lıne Olusturulması
                        //unıt code get fonk cagırılarak secılen bırımın unıt codu getırılırilerek aktarılır
                        despatch.addDespatchLine((row.Index + 1).ToString(), getUnitTimeCode(row.Cells[nameof(EI.InvLineGridRowClm.unit)].Value.ToString()), Convert.ToInt32(row.Cells[nameof(EI.InvLineGridRowClm.quantity)].Value),
                                                 row.Cells[nameof(EI.InvLineGridRowClm.productName)].Value.ToString(), Convert.ToDecimal(row.Cells[nameof(EI.InvLineGridRowClm.unitPrice)].Value), cmbMoneyType.Text);
                    }

                    despatch.setDespatchLines();


                    //olusturdugumuz nesne ubl turune cevrılır
                    var despatchUbl = despatch.baseDespatchUbl;

                    //xml olusturup dıske yazdır
                    string xmlPath = FolderControl.writeDiscDespatchConvertUblToXml(despatchUbl);

                    //xml olusturup yazdırma basarılı mı
                    if (xmlPath != null)
                    {
                        //db ye kaydet
                        if (Singl.DespatchAdviceDalGet.insertDespatchOnDbFromUbl(despatchUbl, xmlPath) == 1)
                        {
                            MessageBox.Show(xmlPath + "  irsaliye kaydedıldı");
                        }
                        else
                        {
                            MessageBox.Show("Db ye kaydetme başarısız");
                        }
                    }
                    else
                    {
                        MessageBox.Show("işlem basarısız");
                    }
                }
                else  //bos eleman varsa
                {
                    MessageBox.Show("yıldızlı alanları bos bırakmayınız");
                }
            }
            catch (FaultException <REQUEST_ERRORType> ex) //oib req error
            {
                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)
            {
                MessageBox.Show(Lang.dbFault, "DataBaseFault", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 27
0
 /// <summary>
 /// Creates a new object.
 /// </summary>
 /// <param name="model"></param>
 /// <param name="control"></param>
 /// <param name="getModelValue"></param>
 /// <param name="setModelValue"></param>
 public FolderStringBinder(TModel model, FolderControl control, Expression <Func <TModel, string> > getModelValue, Action <TModel, string> setModelValue)
     : base(model, control, getModelValue, setModelValue,
            r => (r.Folder ?? "").Trim(),
            (ctrl, val) => ctrl.Folder = (val ?? "").Trim())
 {
 }
Esempio n. 28
0
 private void btnFolder_Click(object sender, EventArgs e)
 {
     FolderControl.OpenFolder(AppSettings.GetAppSettings().load_folder);
 }
Esempio n. 29
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());
            }
        }