예제 #1
0
        }// public void LogFileError(string msg)

        private Strata8.Wireless.Cdr.Rating.Record01 ProcessRecordType01(string line)
        {
            // construct the record
            Record01 r = new Record01(line);

            return(r);
        }
예제 #2
0
        private const string ReceivingCarrierSidBid = "00133"; // Table 12-4A, Airtouch Cellular Great Lakes

        /// <summary>
        /// method used to create the CIBER header Record 01
        /// </summary>
        /// <returns></returns>
        public Record01 CreateBatchHeaderRecord()
        {
            // for testing, create an example header format
            //string hdrExample = "010705210290653885493251010310152001208040784     EX0433";
            /// example = "01 070521 029 33333 01151 25 1 01 031015 2 00 1 208040784     EX0433";
            /// RecordType =                    01
            /// CreationDate =                  070521
            /// BatchSequenceNumber =           030
            ///
            /// this field is used to identify the market and consequently the carrier that provided
            /// services to a roaming mobile station after handing off from an anchor system.
            /// SendingCarrierSID/BID :         10789  //OnWaves SID/BID
            ///
            /// This field is used to identify the intended recipient of a batch of CIBER records
            /// ReceivingCarrierSID/BID :       00133  // WTF is this??
            ///
            ///
            /// CIBER record release number :   25
            /// Original Return Indicator :     1
            /// Currency Type :                 01
            /// SettlePeriod :                  031015
            /// clearinghouseid :               0
            /// CIBER Batch Reject reason code: 00
            /// Batch contents :                1 //
            /// LocalCarrierReserved :          208040784     EX0433
            ///

            // keep the batch sequence number in a database somewhere so we can track it
            String batchSequenceNumber = "037"; // to be used on 01-16-2009

            // create a batch date and settlement date
            DateTime d    = DateTime.Now;
            string   yy   = d.Year.ToString().Substring(2, 2);
            string   dd   = d.Day.ToString("D2");
            string   mm   = d.Month.ToString("D2");
            string   hour = d.Hour.ToString();
            string   batchCreationDate = yy + mm + dd;

            // always settle on the 15th, for now assuming 3 mos for settlement expiration
            int    settlementMonth = (d.Month + 3) % 12;
            string sm = String.Format("{0:D2}", settlementMonth);

            // for now user 2009, update this to use modulo as well
            string settlementPeriod = "09" + sm + "15";

            string carrierFiller = String.Empty.PadRight(20, this.blank_pad);
            string systemFiller  = String.Empty.PadRight(144, this.blank_pad);
            string filler        = carrierFiller + systemFiller;

            // dynamic fields are the ReceivingCarrierSidBid
            StringBuilder strb = new StringBuilder(Record01Type + batchCreationDate + batchSequenceNumber + SendingCarrierSidBid);

            strb.Append(ReceivingCarrierSidBid + CiberRecordReleaseNumber + OriginalReturnIndicator + CurrencyType);
            strb.Append(settlementPeriod + ClearingHouseId + CiberBatchRejectReasonCode + BatchContents + filler);

            Ciber.Record01 r1 = new Record01(strb.ToString());

            //write it to a file for now
            //cfw.WriteToFile( r1.ToCiberStringFormat() );

            // Ciber Record Info used across the Records
            cri.BatchCreationDate        = r1.BatchCreationDate;
            cri.BatchSequenceNumber      = r1.BatchSequenceNumber;
            cri.SendingCarrierSidBid     = r1.SendingCarrierSIDBID;
            cri.ReceivingCarrierSidBid   = r1.ReceivingCarrierSIDBID;
            cri.CiberRecordReleaseNumber = r1.CiberRecordReleaseNumber;
            cri.CurrencyType             = r1.CurrencyType;
            cri.ClearinghouseId          = r1.ClearingHouseId;
            cri.SettlementPeriod         = r1.SettlementPeriod;

            return(r1);
        }
예제 #3
0
        public void ProcessTheFile(string fileName)
        {
            // MAF only supports type01, 22 and 98.
            m_logger.WriteToLogFile("-NFORMATIONAL::MAFFileReader::ProcessTheFile():Entered");

            string type01 = "01";
            string type02 = "02";
            string type22 = "22";
            string type32 = "32";
            string type97 = "97";
            string type98 = "98";


            try
            {
                using (StreamReader sr = new StreamReader(fileName))
                {
                    char[] buff        = new char[2];
                    int    recordCount = 1;

                    //string str = sr.ReadToEnd();
                    while ((sr.Read(buff, 0, 2) != 0))
                    {
                        string recordType = buff[0].ToString() + buff[1].ToString();

                        if (recordType.Equals(type01))
                        {
                            // type 01, 02 record length = 200
                            // read the rest of the type 01 record
                            char[] buff1 = new char[200];

                            // first two elements are 01
                            sr.Read(buff1, 2, 198);
                            buff1[0] = buff[0];
                            buff1[1] = buff[1];

                            StringBuilder sb = new StringBuilder();

                            // process type 01 record
                            foreach (char c in buff1)
                            {
                                sb.Append(c.ToString());
                            }

                            Record01 r01 = new Record01(sb.ToString());
                            //WriteToFile(@"d:\apps\data\test.dat", sb.ToString() );
                        }
                        else if (recordType.Equals(type22))
                        {
                            // type 22, record length = 547
                            // read the rest of the type 01 record
                            char[] buff22 = new char[547];
                            sr.Read(buff22, 2, 545);
                            buff22[0] = buff[0];
                            buff22[1] = buff[1];

                            StringBuilder sb = new StringBuilder();
                            // process type 22 record
                            foreach (char c in buff22)
                            {
                                sb.Append(c.ToString());
                            }

                            Record22 r22 = new Record22(sb.ToString());

                            // update the database with the following parameters for reporting
                            UpdateDb(r22);
                            // FileWriter.Instance.WriteToLogFile( sb.ToString() );
                        }
                        else if (recordType.Equals(type32))
                        {
                            // type 32, record length = 567
                        }
                        else if (recordType.Equals(type02))
                        {
                            // type 22, record length = 200
                        }
                        else if (recordType.Equals(type97))
                        {
                            // type 97, record length = 200
                        }
                        else if (recordType.Equals(type98))
                        {
                            // type 98, record length = 200
                            // read the rest of the type 01 record
                            char[] buff98 = new char[200];
                            sr.Read(buff98, 2, 198);
                            buff98[0] = buff[0];
                            buff98[1] = buff[1];

                            StringBuilder sb = new StringBuilder();
                            // process type 22 record
                            foreach (char c in buff98)
                            {
                                sb.Append(c.ToString());
                            }

                            Record98 r98 = new Record98(sb.ToString());
                            // WriteToFile( "test", sb.ToString() );
                            break;
                        }
                        else
                        {
                            //
                        }

                        // increment our record count
                        recordCount++;
                    } // while loop - end of file
                }     //using sr
            }         //try
            catch (SystemException se)
            {
                m_logger.WriteToLogFile("-NEXCEPTION::MAFFileReader::ProcessTheFile():ECaught:" + se.Message + se.StackTrace);
            }
            m_logger.WriteToLogFile("-NFORMATIONAL::MAFFileReader::ProcessTheFile()Exiting");
        }// ReadTheFile
예제 #4
0
        }     // public void CloseDataConn( ref SqlConnection dataConnection )

        /// <summary>
        /// private method to parse the dids in the file
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        private ArrayList ReadTheFile(string fileName)
        {
            // make the array size (number of cdrs per file ) configurable
            System.Collections.ArrayList theControls = new System.Collections.ArrayList(1000);
            char[] sep        = new char[] { ',' };
            char[] trim       = new char[] { ' ' };
            int    lineNumber = 1;

            try
            {
                using (StreamReader sr = new StreamReader(fileName))
                {
                    String line;
                    bool   callHit = false;

                    while ((line = sr.ReadLine()) != null)
                    {
                        try
                        {
                            //// parse the line
                            //string[] controls = line.Split(sep);
                            //if (controls.GetLength(0) < 0)
                            //{
                            //    // we have a non-data line -- header or footer... so skip it
                            //    continue;
                            //}

                            //string did = controls[0].Trim().Replace(" ", String.Empty);
                            //// cache the record
                            //theControls.Add( did );
                            string recordType = line.Substring(0, 2);



                            switch (recordType)
                            {
                            case ("01"):
                            {
                                Console.WriteLine("Type 01 RecordType : Batch Header Record");
                                Record01 r = ProcessRecordType01(line);

                                // let us look and see
                                Console.WriteLine(r.ToString());
                                break;
                            }

                            case ("02"):
                            {
                                Console.WriteLine("Type 01 RecordType : ClearingHouse Batch Header Record");
                                Record02 r = ProcessRecordType02(line);

                                // let us look and see
                                Console.WriteLine(r.ToString());
                                break;
                            }

                            case ("22"):
                            {
                                Record22 r = new Record22(line);

                                if (r.CallDate.Equals("110816"))
                                {
                                    Console.WriteLine("Type 22 RecordType : Air and Toll Charges Record");
                                    Console.WriteLine(r.ToString());
                                    callHit = true;
                                }
                                //look and see for now
                                //Console.WriteLine(r.ToString());
                                break;
                            }

                            case ("52"):
                            {
                                Console.WriteLine("Type 52 RecordType : Billing OCC Charge Record");
                                //Record52 r = new Record52(line);

                                ////look and see for now
                                //Console.WriteLine(r.ToString());
                                break;
                            }

                            case ("98"):
                            {
                                Console.WriteLine("Type 98 RecordType : Batch Trailer Record");
                                Record98 r = ProcessRecordType98(line);

                                // let us look and see
                                if (callHit)
                                {
                                    Console.WriteLine(r.ToString());
                                    callHit = false;
                                }

                                break;
                            }

                            default:
                            {
                                break;
                            }
                            }
                            //Console.WriteLine(line.ToString());
                            lineNumber++;
                        }
                        catch (System.Exception ex)
                        {
                            string errorMsg = "Error in File>" + fileName + " Line>" + lineNumber;
                            if (line != null)
                            {// add the line information if available
                                errorMsg += "Line>" + line;
                            }
                            LogFileError(errorMsg + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
                        }
                    }
                }
            }// try
            catch (Exception e)
            {
                LogFileError(e.Message + "\r\n" + e.StackTrace);
            }// catch

            return(theControls);
        }// private void ParseTheDIDs()
예제 #5
0
        /// <summary>
        /// method used to create the CIBER header Record 01
        /// </summary>
        /// <returns></returns>
        public Record01 CreateBatchHeaderRecord()
        {
            // for testing, create an example header format
            //string hdrExample = "010705210290653885493251010310152001208040784     EX0433";
            /// example = "01 070521 029 33333 01151 25 1 01 031015 2 00 1 208040784     EX0433";
            /// RecordType =                    01
            /// CreationDate =                  070521
            /// BatchSequenceNumber =           030
            ///
            /// this field is used to identify the market and consequently the carrier that provided
            /// services to a roaming mobile station after handing off from an anchor system.
            /// SendingCarrierSID/BID :         10789  //OnWaves SID/BID
            ///
            /// This field is used to identify the intended recipient of a batch of CIBER records
            /// ReceivingCarrierSID/BID :       00133  // WTF is this??
            ///
            ///
            /// CIBER record release number :   25
            /// Original Return Indicator :     1
            /// Currency Type :                 01
            /// SettlePeriod :                  031015
            /// clearinghouseid :               0
            /// CIBER Batch Reject reason code: 00
            /// Batch contents :                1 //
            /// LocalCarrierReserved :          208040784     EX0433
            ///

            // keep the batch sequence number in a database somewhere so we can track it
            String batchSequenceNumber = "037"; // to be used on 01-16-2009

            // create a batch date and settlement date
            DateTime d = DateTime.Now;
            string yy = d.Year.ToString().Substring(2, 2);
            string dd = d.Day.ToString("D2");
            string mm = d.Month.ToString("D2");
            string hour = d.Hour.ToString();
            string batchCreationDate = yy + mm + dd;

            // always settle on the 15th, for now assuming 3 mos for settlement expiration
            int settlementMonth = (d.Month + 3) % 12;
            string sm = String.Format("{0:D2}", settlementMonth);

            // for now user 2009, update this to use modulo as well
            string settlementPeriod = "09" + sm + "15";

            string carrierFiller = String.Empty.PadRight(20 , this.blank_pad);
            string systemFiller = String.Empty.PadRight(144, this.blank_pad);
            string filler = carrierFiller + systemFiller;

            // dynamic fields are the ReceivingCarrierSidBid
            StringBuilder strb = new StringBuilder(Record01Type + batchCreationDate + batchSequenceNumber + SendingCarrierSidBid);
            strb.Append(ReceivingCarrierSidBid + CiberRecordReleaseNumber + OriginalReturnIndicator + CurrencyType);
            strb.Append( settlementPeriod + ClearingHouseId + CiberBatchRejectReasonCode + BatchContents  + filler ) ;

            Ciber.Record01 r1 = new Record01( strb.ToString() );

            //write it to a file for now
            //cfw.WriteToFile( r1.ToCiberStringFormat() );

            // Ciber Record Info used across the Records
            cri.BatchCreationDate = r1.BatchCreationDate;
            cri.BatchSequenceNumber = r1.BatchSequenceNumber;
            cri.SendingCarrierSidBid = r1.SendingCarrierSIDBID;
            cri.ReceivingCarrierSidBid = r1.ReceivingCarrierSIDBID;
            cri.CiberRecordReleaseNumber = r1.CiberRecordReleaseNumber;
            cri.CurrencyType = r1.CurrencyType;
            cri.ClearinghouseId = r1.ClearingHouseId;
            cri.SettlementPeriod = r1.SettlementPeriod;

            return r1;
        }