コード例 #1
0
ファイル: UpdateService.cs プロジェクト: kevingoetz/SoDotCash
        /// <summary>
        /// Merge transactions read from an OFX file into the specified account. 
        /// This form takes an already open and positioned stream ready for OFX read operations.
        /// </summary>
        /// <param name="account">The account to merge transactions into</param>
        /// <param name="ofxFileStream">Open and positioned readable stream containing an OFX statement</param>
        public static void MergeOfxFileIntoAccount(Account account, Stream ofxFileStream)
        {
            using (BackgroundTaskTracker.BeginTask("Importing Transactions"))
            {

                // Deserialize the OFX file data to an object form
                var converter = new OFX1ToOFX2Converter(ofxFileStream);
                string errorMessage;

                var statements = OFX.Types.Statement.CreateFromOFXResponse(converter.ConvertToOFX(), out errorMessage);

                if (!String.IsNullOrEmpty(errorMessage) || !String.IsNullOrWhiteSpace(errorMessage))
                {
                    MessageBox.Show(errorMessage, "Error");
                }

                else
                    foreach (var statement in statements)
                        MergeStatementTransactionsIntoAccount(account, statement);
            }

        }
コード例 #2
0
ファイル: OFXTest.cs プロジェクト: rhadman/SoDotCash
        public void TestOfx1Invalid()
        {
            using (var stream = new FileStream("test_cc_2.ofx", FileMode.Open))
            {
                OFX1ToOFX2Converter converter = new OFX1ToOFX2Converter(stream);

                // Deserialize the XML data 
                var obj = converter.ConvertToOFX();

                // Expect: 2 response sets
                Assert.IsNotNull(obj.Items);
                Assert.AreEqual(obj.Items.Length, 2);

                // Expect: Response message set 0 is SignonResponse
                Assert.IsInstanceOfType(obj.Items[0], typeof(SignonResponseMessageSetV1));

                // Parses the response to ensure it's valid, and records response data to trace log
                DumpStatement(Statement.CreateFromOFXResponse(obj));

            }
        }
コード例 #3
0
ファイル: UpdateService.cs プロジェクト: rhadman/SoDotCash
        /// <summary>
        /// Merge transactions read from an OFX file into the specified account. 
        /// This form takes an already open and positioned stream ready for OFX read operations.
        /// </summary>
        /// <param name="account">The account to merge transactions into</param>
        /// <param name="ofxFileStream">Open and positioned readable stream containing an OFX statement</param>
        public static void MergeOfxFileIntoAccount(Account account, Stream ofxFileStream)
        {
            using (BackgroundTaskTracker.BeginTask("Importing Transactions"))
            {

                // Deserialize the OFX file data to an object form
                var converter = new OFX1ToOFX2Converter(ofxFileStream);

                // Convert file into statements
                try
                {
                    var statements = OFX.Types.Statement.CreateFromOFXResponse(converter.ConvertToOFX());

                    // Merge statements
                    foreach (var statement in statements)
                        MergeStatementTransactionsIntoAccount(account, statement);

                }
                catch (OfxException ex)
                {
                    MessageBox.Show(ex.Message, "Error");
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show("The provided OFX file could not be parsed.", "Error");
                }

            }

        }