コード例 #1
0
/// <summary>
/// method to create a group call report
/// we get the unique groupids in the system and then for each group we get
/// the users in the group and create a call report for each user in the group.
/// from this, we can generate either a group summary report or a group report including
/// the details of each user.
/// </summary>
/// <param name="reportTime"></param>
/// <returns></returns>
        public List <CallReport> CreateGroupCallReport(DateTime reportTime, DateTime endTime)
        {
            // call report for each group in the system
            List <CallReport> groupCallReportList = new List <CallReport>();

            Hashtable spInfo = new Hashtable();

            List <string> groupList = _db.GetGroupIds(reportTime, endTime);

            // get the call report for each group
            foreach (string groupId in groupList)
            {
                // get the list of users in each group
                List <Subscriber> userList = _db.GetUsersInGroup(groupId, reportTime, endTime);

                // get the call report for the list of users in the group
                CallReport groupCallReport = this.CreateUserCallReport(userList, reportTime, endTime);
                groupCallReport.GroupId = groupId;
                if (userList.Count > 0)
                {
                    groupCallReport.ServiceProvider = userList[0].ServiceProvider;
                }

                // add the group call report to our list
                groupCallReportList.Add(groupCallReport);
            }

            return(groupCallReportList);
        }
コード例 #2
0
ファイル: ReportFormatter.cs プロジェクト: nuevollc/Nuevo
        /// <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>
        private void SendCallReportNotificationHtml(CallReport cr, string title, string toList)
        {
            try
            {
                string To = toList;
                StringBuilder sbb = new StringBuilder("Call Stats From : " + cr.StartTime.ToString("g"));
                sbb.Append(" To : " + cr.EndTime.ToString("g") + "Report Created at: " + cr.ReportTime.ToString("g"));
                string Subject = sbb.ToString();
                MailAddress Bcc = new MailAddress(_bccEmailList);

                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>User ID</b></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><b>User Number</b></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><b>Ext.</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> 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> ");

                // 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();
                }

                foreach (UserCallReport userReport in cr.UserCallReportList)
                {
                    bod.Append(@"<tr> ");
                    //bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.UserName + "</font></td>");
                    // bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.UserId + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.UserNumber + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.UserExtension + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.TotalOutboundCalls + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.TotalInboundCalls + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.TotalCallTime + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.AverageCallTime + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.TotalCalls + "</font></td>");
                    bod.Append(@"</tr>");

                }
                bod.Append(@"<tr> ");
                bod.Append(@"<td colspan=""3"" bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>Totals</strong></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.TotalCallTime.ToString() + "</strong></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""></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>");

                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 (SystemException se)
            {// exception handling
                LogFileMgr.Instance.WriteToLogFile("CdrProcessor::SendNotification():ECaught:" + se.Message);
            }
        }
コード例 #3
0
ファイル: CdrReportProcessor.cs プロジェクト: nuevollc/Nuevo
        /// <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;
        }
コード例 #4
0
ファイル: ReportFormatter.cs プロジェクト: nuevollc/Nuevo
        /// <summary>
        /// method to generate the excel call report format for each group
        /// </summary>
        /// <param name="reportList"></param>configurable parameter in the config file
        /// <param name="theReportTime"></param>
        /// <param name="referenceTime"></param>
        public void GenerateExcelCallReportForGroups(List <CallReport> reportList, string fileName)
        {
            string comma = ",";

            DateTime date      = DateTime.Now;
            string   rFileName = fileName + date.Year.ToString() + date.Month.ToString()
                                 + date.Day.ToString() + date.Hour.ToString() + date.Minute.ToString() +
                                 ".csv";

            // create the subject
            // 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 = reportList[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 sb = new StringBuilder("ServiceProvider, GroupId, TotalCallsOut, TotalCallsIn, TotalInternationalCalls,TotalCallTime, AvgCallTime, TotalCalls" + "\r\n");

            foreach (CallReport cr in reportList)
            {
                sb.Append(cr.ServiceProvider + comma);
                sb.Append(cr.GroupId + comma);
                sb.Append(cr.TotalsReport.TotalOutboundCalls.ToString() + comma);
                sb.Append(cr.TotalsReport.TotalInboundCalls.ToString() + comma);
                sb.Append(cr.TotalsReport.TotalInternationalCalls.ToString() + comma + cr.TotalsReport.TotalCallTime.ToString("c") + comma + cr.TotalsReport.AverageCallTime + comma);
                sb.Append(cr.TotalsReport.TotalCalls.ToString() + "\r\n");  // add the new line
            }

            LogFileMgr.Instance.WriteToFile(rFileName, sb.ToString());

            // send the file in an email
            string      From = _from;
            MailAddress Bcc  = new MailAddress(this._bccEmailList);
            // Create a message and set up the recipients.
            MailMessage message = new MailMessage(
                From,
                _excelCallReportToEmailList,
                Subject,
                "See the attached daily call report spreadsheet.");

            // Create  the file attachment for this e-mail message.
            Attachment data = new Attachment(rFileName, MediaTypeNames.Application.Octet);
            // Add time stamp information for the file.not needed hombre
            ContentDisposition disposition = data.ContentDisposition;

            disposition.CreationDate     = System.IO.File.GetCreationTime(rFileName);
            disposition.ModificationDate = System.IO.File.GetLastWriteTime(rFileName);
            disposition.ReadDate         = System.IO.File.GetLastAccessTime(rFileName);
            // Add the file attachment to this e-mail message.
            message.Attachments.Add(data);

            //Send the message.
            SmtpClient client = new SmtpClient(this._smtpserver);

            // Add credentials if the SMTP server requires them.
            //client.Credentials = CredentialCache.DefaultNetworkCredentials;

            try
            {
                client.Send(message);
            }
            catch (System.Net.Mail.SmtpException sme)
            {
                LogFileMgr.Instance.WriteToLogFile("CdrProcessor::SendNotification():ECaught:" + sme.Message);
            }
            // Display
        }
コード例 #5
0
ファイル: ReportFormatter.cs プロジェクト: nuevollc/Nuevo
        /// <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>
        private void SendCallReportNotificationHtml(CallReport cr, string title, string toList)
        {
            try
            {
                string        To  = toList;
                StringBuilder sbb = new StringBuilder("Call Stats From : " + cr.StartTime.ToString("g"));
                sbb.Append(" To : " + cr.EndTime.ToString("g") + "Report Created at: " + cr.ReportTime.ToString("g"));
                string      Subject = sbb.ToString();
                MailAddress Bcc     = new MailAddress(_bccEmailList);

                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>User ID</b></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><b>User Number</b></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><b>Ext.</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> 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> ");

                // 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();
                }

                foreach (UserCallReport userReport in cr.UserCallReportList)
                {
                    bod.Append(@"<tr> ");
                    //bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.UserName + "</font></td>");
                    // bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.UserId + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.UserNumber + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.UserExtension + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.TotalOutboundCalls + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.TotalInboundCalls + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.TotalCallTime + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.AverageCallTime + "</font></td>");
                    bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1"">" + userReport.TotalCalls + "</font></td>");
                    bod.Append(@"</tr>");
                }
                bod.Append(@"<tr> ");
                bod.Append(@"<td colspan=""3"" bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""><strong>Totals</strong></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.TotalCallTime.ToString() + "</strong></font></td>");
                bod.Append(@"<td bgcolor=""CCFFCC"" align=""center""><font face=""verdana"" size=""1""></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>");

                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 (SystemException se)
            {// exception handling
                LogFileMgr.Instance.WriteToLogFile("CdrProcessor::SendNotification():ECaught:" + se.Message);
            }
        }
コード例 #6
0
ファイル: ReportFormatter.cs プロジェクト: nuevollc/Nuevo
        /// <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);
            }
        }
コード例 #7
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);
        }