Ejemplo n.º 1
0
        // TO DO: Export finalized statement doc to xml.
        /// <summary>
        /// Export to xml
        /// </summary>
        /// <param name="fileName">The file to export</param>
        /// <param name="documents">The list of documents to export</param>
        /// <param name="Debug">The log where debug messages will go.</param>
        public static void Export <TBasicDoc>(
            string fileName,
            KeyedDocs <TBasicDoc> documents,
            ILog Debug
            ) where TBasicDoc : BasicDoc, iDocType_Takes_StringMap <TBasicDoc>, new()
        {
            // Export the XML
            Debug.Write("Exporting XML");
#if DEBUG
            using (Stream saveWorkOrders = File.Open($"{fileName}.xml", FileMode.Create))
#else
            using (Stream saveWorkOrders = File.Open(fileName, FileMode.Create))
#endif
            {
                // Save Work Orders
                var xmlWorkOrders = new XmlSerializer(typeof(List <TBasicDoc>));
                xmlWorkOrders.Serialize(saveWorkOrders, documents);
            }
            // Create the Uluro result file
            FileStream   fileStream     = File.Open($"{fileName}.result", FileMode.Create);
            Stream       saveResultFile = fileStream;
            StreamWriter streamWriter   = new StreamWriter(saveResultFile);
            TextWriter   resultWriter   = streamWriter;
            resultWriter.WriteLine("result=0");
        }
        public MergedStatementRecord(
            KeyedDocs <InvoiceData> M691_Invoices
            , KeyedDocs <MemberRecord> M690_MemberFiles
            , KeyedDocs <BalFwdRecord> M504A_BalanceForwards
            ) : base(null, new string[] { "AccountID", "StartDate" }.ToList(), true)
        {
            // instantiate AMSR with pre-filtered records:
            // instantiate AMSR by member file
            // populate statements
            // populate balances forward and any missing fields for blank statements

            throw new NotImplementedException();
        }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            try
            {
                // Get customer rules defined in preprocessor definitions.

                GetPreprocessorDefinitions();

                SetTempDir(args[0]);
                string[] files = ZipFiles.GetFiles(args[0]);

                atrio = new AtrioPreProcess(files);
                atrio.SetDebug(args[0]);

                atrio = new AtrioPreProcess(files);

                // get files into temp directory

                CheckFiles(atrio.Files); // len check for implementation Statement/WelcomeLetters

                // input data to 691, 504A, 690
                docs = PopulateDocs(atrio.Files);

                // TO DO: process them separately by filtering business rules
                // TO DO: process them together by key-based business rules
                atrio.ProcessDocs(docs);
                throw new Exception("Finish implementing ProcessDocs.");
                /**********************************/


                // only remove debug if completes.
                Debug.Remove();
            }
            catch (Exception err)
            {
                string    Message           = err.Message;
                string    StackTrace        = err.StackTrace;
                string    SourceApplication = err.Source;
                Exception inner             = err.InnerException;
                var       DataDictionary    = err.Data;
                Console.Write(String.Format("Error:\n\n{0}", err.ToString()));
            }
            finally
            {
                CleanUp();
            }
        }
Ejemplo n.º 4
0
            , KeyedDocs <DocM504A_BalFwdRecord> > PopulateDocs(string[] files)
        {
            // each will be a dictionary of documents indexed by their respective IDs.
            Dictionary <AcctID, DocM691_Invoice> MCSB691
                = new Dictionary <AcctID, DocM691_Invoice>();
            KeyedDocs <DocM691_Invoice>                M691Records = null;
            KeyedDocs <DocM690_MemberRecord>           M690Records = null;
            KeyedDocs <DocM504A_BalFwdRecord>          M504Records = null;
            Dictionary <AcctID, DocM504A_BalFwdRecord> MCSB504A    =
                new Dictionary <AcctID, DocM504A_BalFwdRecord>();
            var MCSB691_Primitive = new List <string>();
            var MSCB690_CSVData   = new Dictionary <string, List <StringMap> >();

            DocType docType;
            string  filename
            , fileExtension;

            foreach (string filePath in files)
            {
                filename      = Path.GetFileName(filePath);
                fileExtension = Path.GetExtension(filePath);
                docType       = IdentifyDoc(filename);

                // put each document type into its headersource (struct of Stringmap and headers list)
                switch (docType)
                {
                case (DocType.M691):

                    MCSB691_Primitive = ImportRows(filename);
                    HeaderSource <List <StringMap>, List <string> > src691 =
                        DocM691_Invoice.ParseM691(MCSB691_Primitive.ToArray());
                    M691Records = new KeyedDocs <DocM691_Invoice>(src691);
                    break;

                case (DocType.M690):

                    var M690sByAcctID = ImportCSVWithHeader(
                        filePath
                        , primaryKey: "Group Billing Acct ID"
                        , delimiter: "|"
                        , useQuotes: false);
                    M690Records = new KeyedDocs <DocM690_MemberRecord>(M690sByAcctID);
                    break;

                case (DocType.M504A):
                    string[] headers = DocM504A_BalFwdRecord.headers;

                    var M504AsByAcctID = ImportCSVWithHeader(
                        filePath
                        , primaryKey: "Account Id"
                        , ","
                        , useQuotes: true
                        , headers);

                    M504Records = new KeyedDocs <DocM504A_BalFwdRecord>(M504AsByAcctID);
                    break;

                case (DocType.Error):
                    throw new Exception($"Unexpected file found: {filePath}");
                }
            }
            return(new ValueTuple <
                       KeyedDocs <DocM691_Invoice>
                       , KeyedDocs <DocM690_MemberRecord>
                       , KeyedDocs <DocM504A_BalFwdRecord> >(
                       M691Records, M690Records, M504Records));
        }
Ejemplo n.º 5
0
            , KeyedDocs <BalFwdRecord> > PopulateDocs(string[] files)
        {
            // each will be a dictionary of documents indexed by their respective IDs.
            KeyedDocs <InvoiceData>  InvoiceData = null;
            KeyedDocs <MemberRecord> MemberData  = null;
            KeyedDocs <BalFwdRecord> BalFwdData  = null;
            var MCSB691_Primitive = new List <string>();

            DocType docType;
            string  filename
            , fileExtension;

            foreach (string filePath in files)
            {
                filename      = Path.GetFileName(filePath);
                fileExtension = Path.GetExtension(filePath);
                docType       = IdentifyDoc(filename);

                // put each document type into its headersource (struct of Stringmap and headers list)
                switch (docType)
                {
                case (DocType.Statement):

                    MCSB691_Primitive = ImportRows(filename);
                    HeaderSource <List <StringMap>, List <string> > src691 =
                        Specific.InvoiceData.ParseM691(MCSB691_Primitive.ToArray());
                    InvoiceData = new KeyedDocs <InvoiceData>(src691);
                    break;

                case (DocType.BalanceForward):

                    var M690sByAcctID = ImportCSVWithHeader(
                        filePath
//                            , primaryKey: "Group Billing Acct ID"
                        , delimiter: "|"
                        , useQuotes: false);
                    MemberData = new KeyedDocs <MemberRecord>(M690sByAcctID);
                    break;

                case (DocType.Members):
                    string[] headers = BalFwdRecord.headers;

                    var M504AsByAcctID = ImportCSVWithHeader(
                        filePath
//                            , primaryKey: "Account Id"
                        , ","
                        , useQuotes: true
                        , headers);

                    BalFwdData = new KeyedDocs <BalFwdRecord>(M504AsByAcctID);
                    break;

                case (DocType.Error):
                    throw new Exception($"Unexpected file found: {filePath}");
                }
            }
            return(new ValueTuple <
                       KeyedDocs <InvoiceData>
                       , KeyedDocs <MemberRecord>
                       , KeyedDocs <BalFwdRecord> >(
                       InvoiceData, MemberData, BalFwdData));
        }