Пример #1
0
        /// <summary>
        /// Returns list of all transactions in OFX document
        /// </summary>
        /// <param name="doc">OFX document</param>
        /// <returns>List of transactions found in OFX document</returns>
        public override void ImportTransactions(OFXDocumentParser parser, OFXDocument ofx, XmlDocument doc)
        {
            XmlNodeList transactionNodes = null;
            var         xpath            = parser.GetXPath(AccountType, OFXDocumentParser.OFXSection.TRANSACTIONS);

            ofx.StatementStart = doc.GetValue(xpath + "//DTSTART").ToDate();
            ofx.StatementEnd   = doc.GetValue(xpath + "//DTEND").ToDate();

            transactionNodes = doc.SelectNodes(xpath + "//STMTTRN");

            foreach (XmlNode node in transactionNodes)
            {
                Transactions.Add(new BankTransaction(node, ofx.Currency));
            }
        }
Пример #2
0
 public override void ImportTransactions(OFXDocumentParser parser, OFXDocument ofx, XmlDocument doc)
 {
 }
Пример #3
0
        /// <summary>
        /// Returns list of all transactions in OFX document
        /// </summary>
        /// <param name="doc">OFX document</param>
        /// <returns>List of transactions found in OFX document</returns>
        public override void ImportTransactions(OFXDocumentParser parser, OFXDocument ofx, XmlDocument doc)
        {
            XmlNodeList transactionNodes = null;
            var         xpath            = parser.GetXPath(ofx.AccType, OFXDocumentParser.OFXSection.TRANSACTIONS);

            ofx.StatementStart = doc.GetValue(xpath + "//DTSTART").ToDate();
            ofx.StatementEnd   = doc.GetValue(xpath + "//DTEND").ToDate();

            //Import Income Transactions
            transactionNodes = doc.SelectNodes(xpath + "//INCOME");
            foreach (XmlNode node in transactionNodes)
            {
                Transactions.Add(new IncomeTransaction(node, ofx.Currency));
            }

            //Import Cash Transfer Transactions
            transactionNodes = doc.SelectNodes(xpath + "//INVBANKTRAN");
            foreach (XmlNode node in transactionNodes)
            {
                Transactions.Add(new InvestmentTransferTransaction(node, ofx.Currency));
            }

            //Import Stock Transfer Transactions
            transactionNodes = doc.SelectNodes(xpath + "//TRANSFER");
            foreach (XmlNode node in transactionNodes)
            {
                Transactions.Add(new StockTransferTransaction(node, ofx.Currency));
            }

            //Import Buy Stock Transactions
            transactionNodes = doc.SelectNodes(xpath + "//BUYSTOCK");
            foreach (XmlNode node in transactionNodes)
            {
                Transactions.Add(new BuySellStockTransaction(node, ofx.Currency));
            }

            //Import Buy Option Transactions
            transactionNodes = doc.SelectNodes(xpath + "//BUYOPT");
            foreach (XmlNode node in transactionNodes)
            {
                Transactions.Add(new BuySellStockOptionTransaction(node, ofx.Currency));
            }

            //Import Sell Stock Transactions
            transactionNodes = doc.SelectNodes(xpath + "//SELLSTOCK");
            foreach (XmlNode node in transactionNodes)
            {
                Transactions.Add(new BuySellStockTransaction(node, ofx.Currency));
            }

            //Import Buy Option Transactions
            transactionNodes = doc.SelectNodes(xpath + "//SELLOPT");
            foreach (XmlNode node in transactionNodes)
            {
                Transactions.Add(new BuySellStockOptionTransaction(node, ofx.Currency));
            }

            //Import Sell Other Stock Transactions
            transactionNodes = doc.SelectNodes(xpath + "//SELLOTHER");
            foreach (XmlNode node in transactionNodes)
            {
                Transactions.Add(new BuySellStockTransaction(node, ofx.Currency));
            }
        }
Пример #4
0
 public abstract void ImportTransactions(OFXDocumentParser parser, OFXDocument ofx, XmlDocument doc);
Пример #5
0
        private void ImportOFX()
        {
            OFXDocumentParser ofxParser = new OFXDocumentParser();
            OFXDocument ofxDoc = null;
            //FileStream myStream = null;
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.InitialDirectory = "C:\\Documents and Settings\\gregory.poirson\\Meus documentos";
            ofd.Filter = "ofx files (*.ofx)|*.ofx|All files (*.*)|*.*";
            ofd.FilterIndex = 1;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    String source = PrepareSgmlOfx.PrepareArquivo(ofd.FileName);
                    Cursor.Current = Cursors.WaitCursor;
                    ofxDoc = ofxParser.Import(source);

                    FillAccountInfo(ofxDoc);

                    Cursor.Current = Cursors.Default;
                    //if ((myStream = (FileStream)ofd.OpenFile()) != null)
                    //{
                    //    using (myStream)
                    //    {
                    //        Cursor.Current = Cursors.WaitCursor;
                    //        ofxDoc = ofxParser.Import(myStream);

                    //        FillAccountInfo(ofxDoc);

                    //        Cursor.Current = Cursors.Default;
                    //    }
                    //}
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }