Exemplo n.º 1
0
        /// <summary>
        /// Exports the specified instance properties to the provided stream.
        /// </summary>
        /// <param name="qif">The <seealso cref="T:QifDom"/> to export.</param>
        /// <param name="stream">Stream.</param>
        /// <param name="encoding">Encoding.</param>
        /// <remarks>This will overwrite an existing file.</remarks>
        public static void ExportStream(QifDom qif, Stream stream, Encoding encoding = null)
        {
            encoding = encoding ?? Encoding.UTF8;

            using (StreamWriter writer = new StreamWriter(stream, encoding, 512, true))
            {
                writer.AutoFlush = true;

                AccountListLogic.Export(writer, qif.AccountListTransactions);
                AssetLogic.Export(writer, qif.AssetTransactions);
                BankLogic.Export(writer, qif.BankTransactions);
                CashLogic.Export(writer, qif.CashTransactions);
                CategoryListLogic.Export(writer, qif.CategoryListTransactions);
                ClassListLogic.Export(writer, qif.ClassListTransactions);
                CreditCardLogic.Export(writer, qif.CreditCardTransactions);
                InvestmentLogic.Export(writer, qif.InvestmentTransactions);
                LiabilityLogic.Export(writer, qif.LiabilityTransactions);
                MemorizedTransactionListLogic.Export(writer, qif.MemorizedTransactionListTransactions);
            }
        }
Exemplo n.º 2
0
Arquivo: QifDom.cs Projeto: rolek/qif
        /// <summary>
        /// Exports the specified instance properties to the specified file.
        /// </summary>
        /// <param name="qif">The <seealso cref="T:QifDom"/> to export.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="encoding">
        /// The encoding to use when exporting the QIF file. This defaults to UTF8
        /// when not specified.
        /// </param>
        /// <remarks>This will overwrite an existing file.</remarks>
        public static void ExportFile(QifDom qif, string fileName, Encoding encoding = null)
        {
            if (File.Exists(fileName))
            {
                File.SetAttributes(fileName, FileAttributes.Normal);
            }

            using (StreamWriter writer = new StreamWriter(fileName, false, encoding ?? Encoding.UTF8))
            {
                writer.AutoFlush = true;

                AccountListLogic.Export(writer, qif.AccountListTransactions, qif.Configuration);
                AssetLogic.Export(writer, qif.AssetTransactions, qif.Configuration);
                BankLogic.Export(writer, qif.BankTransactions, qif.Configuration);
                CashLogic.Export(writer, qif.CashTransactions, qif.Configuration);
                CategoryListLogic.Export(writer, qif.CategoryListTransactions, qif.Configuration);
                ClassListLogic.Export(writer, qif.ClassListTransactions, qif.Configuration);
                CreditCardLogic.Export(writer, qif.CreditCardTransactions, qif.Configuration);
                InvestmentLogic.Export(writer, qif.InvestmentTransactions, qif.Configuration);
                LiabilityLogic.Export(writer, qif.LiabilityTransactions, qif.Configuration);
                MemorizedTransactionListLogic.Export(writer, qif.MemorizedTransactionListTransactions, qif.Configuration);
            }
        }