Beispiel #1
0
        public Hashtable CreateSPReport(List<CallReport> groupCallReport)
        {
            Hashtable sp = new Hashtable();

            // get the call report for each group
            foreach (CallReport cr in groupCallReport)
            {
                if (sp.ContainsKey(cr.ServiceProvider))
                {
                    // add to the data
                    CumulativeReport r = (CumulativeReport)sp[cr.ServiceProvider];
                    r.TotalCalls = cr.TotalsReport.TotalCalls + r.TotalCalls;
                    r.TotalCallTime = cr.TotalsReport.TotalCallTime + r.TotalCallTime;
                    r.TotalInboundCalls = cr.TotalsReport.TotalInboundCalls + r.TotalInboundCalls;
                    r.TotalOutboundCalls = cr.TotalsReport.TotalOutboundCalls + r.TotalOutboundCalls;
                    r.TotalInternationalCalls = cr.TotalsReport.TotalInternationalCalls + r.TotalInternationalCalls;
                    // update the hashtable
                    sp[cr.ServiceProvider] = r;
                }
                else
                {
                    // create the key, value
                    CumulativeReport r = new CumulativeReport();
                    r.TotalCalls = cr.TotalsReport.TotalCalls;
                    r.TotalCallTime = cr.TotalsReport.TotalCallTime;
                    r.TotalInboundCalls = cr.TotalsReport.TotalInboundCalls;
                    r.TotalOutboundCalls = cr.TotalsReport.TotalOutboundCalls;
                    r.TotalInternationalCalls = cr.TotalsReport.TotalInternationalCalls;

                    // update the hashtable
                    sp.Add(cr.ServiceProvider, r);
                }

            }

            return sp;
        }
Beispiel #2
0
        public Hashtable CreateSPReport(List <CallReport> groupCallReport)
        {
            Hashtable sp = new Hashtable();

            // get the call report for each group
            foreach (CallReport cr in groupCallReport)
            {
                if (sp.ContainsKey(cr.ServiceProvider))
                {
                    // add to the data
                    CumulativeReport r = (CumulativeReport)sp[cr.ServiceProvider];
                    r.TotalCalls              = cr.TotalsReport.TotalCalls + r.TotalCalls;
                    r.TotalCallTime           = cr.TotalsReport.TotalCallTime + r.TotalCallTime;
                    r.TotalInboundCalls       = cr.TotalsReport.TotalInboundCalls + r.TotalInboundCalls;
                    r.TotalOutboundCalls      = cr.TotalsReport.TotalOutboundCalls + r.TotalOutboundCalls;
                    r.TotalInternationalCalls = cr.TotalsReport.TotalInternationalCalls + r.TotalInternationalCalls;
                    // update the hashtable
                    sp[cr.ServiceProvider] = r;
                }
                else
                {
                    // create the key, value
                    CumulativeReport r = new CumulativeReport();
                    r.TotalCalls              = cr.TotalsReport.TotalCalls;
                    r.TotalCallTime           = cr.TotalsReport.TotalCallTime;
                    r.TotalInboundCalls       = cr.TotalsReport.TotalInboundCalls;
                    r.TotalOutboundCalls      = cr.TotalsReport.TotalOutboundCalls;
                    r.TotalInternationalCalls = cr.TotalsReport.TotalInternationalCalls;

                    // update the hashtable
                    sp.Add(cr.ServiceProvider, r);
                }
            }

            return(sp);
        }
Beispiel #3
0
        /// <summary>
        /// public method to create a call report stat for each user
        /// the default interval starts daily at midnight up until time now
        /// the following parameters are calculated for each user in the list
        /// 
        /// Total Outbound
        /// Total Inbound
        /// Total Call Duration
        /// Average Call Duration
        /// 
        /// </summary>
        public CallReport CreateUserCallReport(List<Subscriber> subList, DateTime reportTime, DateTime endTime)
        {
            // our base reference time that we calculate from midnight every day
            DateTime referenceTime = new DateTime(DateTime.Now.Year, reportTime.Month , reportTime.Day, reportTime.Hour, 0, 0);

            // call report list for all users
            List<UserCallReport> userCallReportList = new List<UserCallReport>();

            // initiate our group cumulative report object; contains the running totals for the group of users
            CumulativeReport gcr = new CumulativeReport();

            // get the time that we are running at
            string timeString = DateTime.Now.ToString();

            // our reference time that we calculate from
            DateTime timeNow = DateTime.Now;

            // the call report with the userCallReportList and the cumulative totals
            CallReport cr = new CallReport();
            cr.StartTime = referenceTime;
            cr.EndTime = endTime;
            cr.ReportTime = timeNow;

            int indx = 0;

            // get the call date for each user in the list
            foreach (Subscriber s in subList)
            {
                // get all cdrs for this user from the reference time to present
                DataSet ds = _db.GetCdrsForPhoneNumber(s.PhoneNumber, reportTime, endTime);

                // For each User the following calculations are performed :  userId : field 3
                //
                // Total Inbound Calls : total number of inbound calls determined from the "direction" field 5 (terminating)
                // Total Outbound Calls : total number of outbound calls determined from the direction field 5 (originating)
                // Total Call Time : the total of inbound/outbound call times calculated from each of the CDRs for this user
                // Call Time : answerTime - releaseTime ( field 13 - field 12 )
                // Average Call Time : Call Time / Total Number of Calls
                //

                // user call report some inits
                UserCallReport ucr = new UserCallReport();
                ucr.UserNumber = s.PhoneNumber;
                ucr.Group = s.Group;
                ucr.ServiceProvider = s.ServiceProvider;

                int totalIn = 0;
                int totalOut = 0;
                int totalIntlOrig = 0;
                TimeSpan totalCallDuration = new TimeSpan();

                // for each CDR we update our report values
                foreach (DataTable myTable in ds.Tables)
                {
                    ucr.TotalCalls = myTable.Rows.Count.ToString();

                    foreach (DataRow myRow in myTable.Rows)
                    {
                        if (myRow.ItemArray[6].Equals("Originating"))
                        {
                            totalOut++;
                            // log the originating  international call
                            if (myRow.ItemArray[19].Equals("internat"))
                                totalIntlOrig++;
                        }
                        else if (myRow.ItemArray[6].Equals("Terminating"))
                            totalIn++;
                        // get the call duration for this call
                        DateTime d1 = (DateTime)myRow.ItemArray[10];
                        DateTime d2 = (DateTime)myRow.ItemArray[14];
                        TimeSpan callDuration = d2.Subtract(d1);

                        // calculate total call duration for this user
                        totalCallDuration = totalCallDuration.Add(callDuration);

                    }

                }

                // user totals
                ucr.TotalInboundCalls = totalIn.ToString();
                ucr.TotalOutboundCalls = totalOut.ToString();
                ucr.TotalInternationalCalls = totalIntlOrig.ToString();
                ucr.TotalCallTime = totalCallDuration.ToString();
                if ((totalIn + totalOut) != 0)
                {
                    double avg = totalCallDuration.TotalMinutes / (totalIn + totalOut);
                    ucr.AverageCallTime = String.Format("{0}", avg);
                }

                indx++;

                // store the userReport in the list
                userCallReportList.Add(ucr);

                // maintain the group totals here
                gcr.TotalCalls = gcr.TotalCalls + Convert.ToInt32( ucr.TotalCalls );
                gcr.TotalCallTime = gcr.TotalCallTime.Add(totalCallDuration);
                gcr.TotalInboundCalls = gcr.TotalInboundCalls + Convert.ToInt32( ucr.TotalInboundCalls );
                gcr.TotalOutboundCalls = gcr.TotalOutboundCalls + Convert.ToInt32( ucr.TotalOutboundCalls );
                gcr.TotalInternationalCalls = gcr.TotalInternationalCalls + Convert.ToInt32( ucr.TotalInternationalCalls );

            }// get next user

            // copy the usercall report list
            cr.UserCallReportList = userCallReportList;

            if ((gcr.TotalCalls) != 0)
            {
                double gavg = gcr.TotalCallTime.TotalMinutes / gcr.TotalCalls;
                gcr.AverageCallTime = gavg.ToString("F3");
            }
            // copy the group cumulative total as well
            cr.TotalsReport = gcr;

            return cr;
        }
Beispiel #4
0
        /// <summary>
        /// method to send out a CDR report notification via HTML
        /// this method includes some private parameters not included in the External email notification method
        /// </summary>
        public void SendGroupReportSummaryViaHtml(List <CallReport> gr, string title, string toList, Hashtable spReport)
        {
            try
            {
                // add 8 hours to our time zone, pull from the db
                TimeSpan eightHours = new TimeSpan(8, 0, 0);

                // get one report to get the times
                CallReport r1 = gr[0];

                DateTime st = r1.StartTime.Subtract(eightHours);
                DateTime et = r1.EndTime.Subtract(eightHours);

                StringBuilder sbb = new StringBuilder("Call Stats From : " + st.ToString("g"));
                sbb.Append(" To : " + et.ToString("g") + " Report Created at: " + r1.ReportTime.ToString("g"));
                string Subject = sbb.ToString();

                StringBuilder bod = new StringBuilder(@" <!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">");
                bod.Append(@"<html xmlns=""http://www.w3.org/1999/xhtml"">");
                bod.Append(@"<head><meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"" /></head>");
                bod.Append(@"<body>");
                bod.Append(@"<table cellspacing=""0"" cellpadding=""2"" border=""1"">");

                bod.Append(@"<tr bgcolor=""EEEEEE"">");;
                bod.Append(@"<td colspan=""8"" align=""center""><img src=""http://trumobility.com/wp-content/themes/trumobility/images/logo.gif"" alt=""Kendall"" border=""0"" /></td>");
                bod.Append(@"</tr>");
                bod.Append(@"<tr bgcolor=""EEEEEE"">");
                bod.Append(@"<td colspan=""8"" align=""center""><font face=""verdana"" size=""2""><strong>Call Statistics - " + title + "</strong></font></td>");
                bod.Append(@"</tr>");
                bod.Append(@"<tr>");
                bod.Append(@"<td bgcolor=""CCFFCC"" colspan=""8"" align=""center""><font face=""verdana"" size=""1"" color=""Blue"">" + sbb.ToString() + "</font>");
                bod.Append(@"</tr>");
                bod.Append(@"<tr>");
                //bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><b>User Name</b></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><b>Group</b></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><b>ServiceProvider</b></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><b>Total <br> Outbound</b></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><b>Total <br> Inbound</b></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><b>Total <br> International</b></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><b>Total <br> Call Time</b></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><b>Avg <br> Call Time</b></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><b>Total Calls</b></font></td>");
                bod.Append(@"</tr>");

                bod.Append(@"<tr>");
                bod.Append(@"<td colspan=""8""><hr></td>");
                bod.Append(@"</tr> ");

                Hashtable sp_cumulative = new Hashtable();

                // for the service providers do a summary followed by the details
                //
                foreach (DictionaryEntry de in spReport)
                {
                    CumulativeReport r = (CumulativeReport)de.Value;
                    bod.Append(@"<tr> ");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""> ServiceProvider Summary </font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + de.Key.ToString() + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>" + r.TotalOutboundCalls.ToString() + "</strong></font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>" + r.TotalInboundCalls.ToString() + "</strong></font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>" + r.TotalInternationalCalls.ToString() + "</strong></font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>" + r.TotalCallTime.ToString("c") + "</strong></font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong> </strong></font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>" + r.TotalCalls.ToString() + "</strong></font></td>");
                    //bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>" + reportTotals.totalCumulativeCalls.ToString() + "</strong></font></td>");
                    bod.Append(@"</tr>");
                }

                // add space
                bod.Append(@"<tr>");
                bod.Append(@"<td colspan=""8""><hr></td>");
                bod.Append(@"</tr> ");

                foreach (CallReport cr in gr)
                {
                    // sort by totaloutbound calls, if only doing internal, then it is a daily report, not cumulative
                    if (m_generateExternalCallReport)
                    {
                        cr.UserCallReportList.Sort(UserCallReport.CompareByTotalCalls);
                        cr.UserCallReportList.Reverse();
                    }
                    else
                    {
                        cr.UserCallReportList.Sort(UserCallReport.CompareByTotalCalls);
                        cr.UserCallReportList.Reverse();
                    }

                    bod.Append(@"<tr> ");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + cr.GroupId + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + cr.ServiceProvider + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>" + cr.TotalsReport.TotalOutboundCalls.ToString() + "</strong></font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>" + cr.TotalsReport.TotalInboundCalls.ToString() + "</strong></font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>" + cr.TotalsReport.TotalInternationalCalls.ToString() + "</strong></font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>" + cr.TotalsReport.TotalCallTime.ToString("c") + "</strong></font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>" + cr.TotalsReport.AverageCallTime + "</strong></font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>" + cr.TotalsReport.TotalCalls.ToString() + "</strong></font></td>");
                    //bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>" + reportTotals.totalCumulativeCalls.ToString() + "</strong></font></td>");
                    bod.Append(@"</tr>");
                }// for each group

                bod.Append(@"<td colspan=""8"" align=""center""><font face=""verdana"" size=""1"" ");
                bod.Append(@"<br>");
                bod.Append(@"<font color=""Red""><b>NOTE : </b></font>");
                bod.Append(@"These numbers reflect traffic on the TruMobility Network only.</font></td>");
                bod.Append(@"<br>");
                bod.Append(@"</table>");

                // end of BODY and our HTML format
                bod.Append(@"</body></html>");

                SendNotification(toList, Subject, bod.ToString());
            }
            catch (System.Exception se)
            {// exception handling
                LogFileMgr.Instance.WriteToLogFile("ReportFormatter::SendGroupReportViaHtml():ECaught:" + se.Message);
            }
        }
Beispiel #5
0
        /// <summary>
        /// public method to create a call report stat for each user
        /// the default interval starts daily at midnight up until time now
        /// the following parameters are calculated for each user in the list
        ///
        /// Total Outbound
        /// Total Inbound
        /// Total Call Duration
        /// Average Call Duration
        ///
        /// </summary>
        public CallReport CreateUserCallReport(List <Subscriber> subList, DateTime reportTime, DateTime endTime)
        {
            // our base reference time that we calculate from midnight every day
            DateTime referenceTime = new DateTime(DateTime.Now.Year, reportTime.Month, reportTime.Day, reportTime.Hour, 0, 0);

            // call report list for all users
            List <UserCallReport> userCallReportList = new List <UserCallReport>();

            // initiate our group cumulative report object; contains the running totals for the group of users
            CumulativeReport gcr = new CumulativeReport();

            // get the time that we are running at
            string timeString = DateTime.Now.ToString();

            // our reference time that we calculate from
            DateTime timeNow = DateTime.Now;

            // the call report with the userCallReportList and the cumulative totals
            CallReport cr = new CallReport();

            cr.StartTime  = referenceTime;
            cr.EndTime    = endTime;
            cr.ReportTime = timeNow;

            int indx = 0;

            // get the call date for each user in the list
            foreach (Subscriber s in subList)
            {
                // get all cdrs for this user from the reference time to present
                DataSet ds = _db.GetCdrsForPhoneNumber(s.PhoneNumber, reportTime, endTime);

                // For each User the following calculations are performed :  userId : field 3
                //
                // Total Inbound Calls : total number of inbound calls determined from the "direction" field 5 (terminating)
                // Total Outbound Calls : total number of outbound calls determined from the direction field 5 (originating)
                // Total Call Time : the total of inbound/outbound call times calculated from each of the CDRs for this user
                // Call Time : answerTime - releaseTime ( field 13 - field 12 )
                // Average Call Time : Call Time / Total Number of Calls
                //

                // user call report some inits
                UserCallReport ucr = new UserCallReport();
                ucr.UserNumber      = s.PhoneNumber;
                ucr.Group           = s.Group;
                ucr.ServiceProvider = s.ServiceProvider;

                int      totalIn           = 0;
                int      totalOut          = 0;
                int      totalIntlOrig     = 0;
                TimeSpan totalCallDuration = new TimeSpan();

                // for each CDR we update our report values
                foreach (DataTable myTable in ds.Tables)
                {
                    ucr.TotalCalls = myTable.Rows.Count.ToString();

                    foreach (DataRow myRow in myTable.Rows)
                    {
                        if (myRow.ItemArray[6].Equals("Originating"))
                        {
                            totalOut++;
                            // log the originating  international call
                            if (myRow.ItemArray[19].Equals("internat"))
                            {
                                totalIntlOrig++;
                            }
                        }
                        else if (myRow.ItemArray[6].Equals("Terminating"))
                        {
                            totalIn++;
                        }
                        // get the call duration for this call
                        DateTime d1           = (DateTime)myRow.ItemArray[10];
                        DateTime d2           = (DateTime)myRow.ItemArray[14];
                        TimeSpan callDuration = d2.Subtract(d1);

                        // calculate total call duration for this user
                        totalCallDuration = totalCallDuration.Add(callDuration);
                    }
                }

                // user totals
                ucr.TotalInboundCalls       = totalIn.ToString();
                ucr.TotalOutboundCalls      = totalOut.ToString();
                ucr.TotalInternationalCalls = totalIntlOrig.ToString();
                ucr.TotalCallTime           = totalCallDuration.ToString();
                if ((totalIn + totalOut) != 0)
                {
                    double avg = totalCallDuration.TotalMinutes / (totalIn + totalOut);
                    ucr.AverageCallTime = String.Format("{0}", avg);
                }

                indx++;

                // store the userReport in the list
                userCallReportList.Add(ucr);

                // maintain the group totals here
                gcr.TotalCalls              = gcr.TotalCalls + Convert.ToInt32(ucr.TotalCalls);
                gcr.TotalCallTime           = gcr.TotalCallTime.Add(totalCallDuration);
                gcr.TotalInboundCalls       = gcr.TotalInboundCalls + Convert.ToInt32(ucr.TotalInboundCalls);
                gcr.TotalOutboundCalls      = gcr.TotalOutboundCalls + Convert.ToInt32(ucr.TotalOutboundCalls);
                gcr.TotalInternationalCalls = gcr.TotalInternationalCalls + Convert.ToInt32(ucr.TotalInternationalCalls);
            }// get next user

            // copy the usercall report list
            cr.UserCallReportList = userCallReportList;

            if ((gcr.TotalCalls) != 0)
            {
                double gavg = gcr.TotalCallTime.TotalMinutes / gcr.TotalCalls;
                gcr.AverageCallTime = gavg.ToString("F3");
            }
            // copy the group cumulative total as well
            cr.TotalsReport = gcr;

            return(cr);
        }