Ejemplo n.º 1
0
        public IEnumerable <CallRecord> GetCalls()
        {
            StreamReader      sr      = null;
            string            record  = "";
            List <CallRecord> records = new List <CallRecord>();
            CallRate          cr      = new CallRate(.05, .07, .09, 080000, 170000);//each call has the same call rate data

            //read in the data from the csv file
            using (sr = new StreamReader("CallRecords.csv"))
            {
                //while the line it's on isn't null...
                while ((record = sr.ReadLine()) != null)
                {
                    try
                    {
                        //add a new record with the callrate
                        records.Add(new CallRecord(record, cr));
                    }
                    catch (ArgumentException ae)
                    {
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            //return the list of records
            return(records);
        }
Ejemplo n.º 2
0
        public IEnumerable <CallRecord> GetCalls()
        {                                                              //testing data
            //create a call rate object
            CallRate cr = new CallRate(.05, .07, .09, 080000, 170000); //each call has the same call rate data

            return(new List <CallRecord>()
            {
                new CallRecord("LC,01312004,120400,4131,2076651928,2051118684,Y", cr),         //valid record
                new CallRecord("LC,12252015,140400,1132,2055551235,2051118684,Y", cr),         //valid record
                new CallRecord("LC,01272016,000312,4131,205555123,2051118684,Y", cr),          //bad from phone number, WORKS!
                new CallRecord("LC,01272016,000312,4131,2055551235,205111868,Y", cr),          //bad to phone number, WORKS!
                new CallRecord("LA,12252015,140400,4131,2055551235,2051118684,Y", cr),         //bad call type, WORKS!
                new CallRecord("LC,12252015,001404,not a number,2055551235,2051118684,Y", cr), //bad call duration, WORKS!
                new CallRecord("LC,01241999,140400,4131,2055551235,2051118684,L", cr),         //bad call complete status, WORKS!
                new CallRecord("LC,12252017,140400,4131,2055551235,2051118684,Y", cr),         //bad date, WORKS!
                new CallRecord("LC,12252015,not a number,1132,2055551235,2051118684,Y", cr),   //bad time (not a number), WORKS!
                new CallRecord("LD,12012015,140404,4131,2055551235,2051118684,Y", cr),         //LD during peak, WORKS!
                new CallRecord("LC,12252015,001465,1132,2055551235,2051118684,Y", cr),         //not a valid time, WORKS!
                new CallRecord("LD,12252015,040404,1120,2055551235,2051118684,Y", cr),         //LD during off peak, WORKS!
                new CallRecord("LD,12252015,163510,6131,1837261532,2051118684,N", cr),         //LD starts in peak, ends in off peak
                new CallRecord("LD,12252015,073505,4131,1837261532,2051118684,N", cr),         //LD starts in off peak, ends in peak
                new CallRecord("LD,12252015,073500,132,2076651928,2051118684,N", cr),          //valid record
                new CallRecord("LD,12252015,040400,1121,2055551235,2051118684,N", cr),         //valid record
                new CallRecord("LD,07232005,071000,3300,2055551235,2051118684,Y", cr),         //valid record
            });
        }
Ejemplo n.º 3
0
        public IEnumerable <CallRecord> GetCalls()
        {
            //make a list for the records
            var records = new List <CallRecord>();
            //create a callrate object
            CallRate cr  = new CallRate(.05, .07, .09, 080000, 170000);
            var      doc = new XmlDocument();

            //load the xml file
            doc.Load("CallRecords.xml");

            foreach (XmlNode node in doc.SelectNodes("//Calls")) //gets the outer node
            {
                foreach (XmlNode innerNode in node)              //gets its inner nodes
                {
                    XmlNodeList children = innerNode.ChildNodes; //gets each child node
                    //get each piece of data from the nodes
                    //since the constructor splits by the commas in the record to get each item,
                    //we need to add the comma for the constructor to read it properly
                    string callType        = children[0].InnerText + ",";
                    string callDate        = children[1].InnerText + ",";
                    string callTime        = children[2].InnerText + ",";
                    string callDuration    = children[3].InnerText + ",";
                    string fromPhoneNumber = children[4].InnerText + ",";
                    string toPhoneNumber   = children[5].InnerText + ",";
                    string completeStatus  = children[6].InnerText + ",";

                    //put everything together to create a callrecord object
                    string call = callType + callDate + callTime + callDuration + fromPhoneNumber +
                                  toPhoneNumber + completeStatus;
                    //add the call to the list of records
                    records.Add(new CallRecord(call, cr));
                }
            }
            //return the list of records
            return(records);
        }