Beispiel #1
0
        /// <summary>
        /// processor thread that runs every interval to create the report
        /// </summary>
        private void ProcessCdrThread()
        {
            TimeSpan ts         = new TimeSpan(1, 0, 0, 0);
            TimeSpan eightHours = new TimeSpan(0, 8, 0, 0);
            TimeSpan fourHours  = new TimeSpan(0, 4, 0, 0);

            try
            {
                while (true)
                {
                    try
                    {
                        // check if our 24 hour interval has passed
                        if (m_keeper.DayPassed())
                        {
                            // call report from midnight
                            // generate from our cumulative configurable param start date
                            DateTime rReportTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).Subtract(ts);
                            DateTime rEndTime    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);

                            // create group call report
                            // right now we are assuming all users are on the timezone of -8 hours
                            CallReport groupCallReport = m_processor.CreateGroupCallReport(_group, rReportTime.Add(fourHours), rEndTime.Add(fourHours));

                            // create group call report
                            _reportFormatter.GenerateExcelUserCallReport(groupCallReport.UserCallReportList, m_emailList);
                        }
                    }//try
                    catch (System.Threading.ThreadAbortException)
                    {
                        LogFileMgr.Instance.WriteToLogFile("GroupReportProcessor::ProcessCdrThread():CdrProcessorSvc is stopping");
                        return;
                    }
                    catch (System.Exception ex)
                    {// generic exception
                        LogFileMgr.Instance.WriteToLogFile("GroupReportProcessor::ProcessCdrThread():ECaught:" + ex.Message);
                    }

                    System.Threading.Thread.Sleep(m_ReportInterval);
                }// while(true)
            }
            catch (System.Threading.ThreadAbortException tax)
            {
                LogFileMgr.Instance.WriteToLogFile("GroupReportProcessor::ProcessCdrThread():ECaught:" + tax.Message);
            }
            catch (System.Exception ex)
            {
                LogFileMgr.Instance.WriteToLogFile("GroupReportProcessor::ProcessCdrThread():ECaught:" + ex.Message);
            }// catch

            finally
            {
            }// finally
        }
        /// <summary>
        /// method to test the call report generation
        /// and email
        /// </summary>
        public void TestCallReport()
        {
            string   emailList  = System.Configuration.ConfigurationManager.AppSettings["EMailList"];
            TimeSpan eightHours = new TimeSpan(0, 8, 0, 0);
            TimeSpan days       = new TimeSpan(1, 0, 0, 0);
            TimeSpan fourHours  = new TimeSpan(0, 4, 0, 0);

            // generate from our cumulative configurable param start date
            // this is the default for the one day report (daily report)
            DateTime rReportTime = new DateTime(DateTime.Now.Year, 08, 01, 0, 0, 0);
            DateTime eTime       = new DateTime(DateTime.Now.Year, 08, 02, 0, 0, 0);

            // create group call report ,,, compensate for the user time zone that we are in
            CallReport groupCallReport = m_processor.CreateGroupCallReport(_group, rReportTime.Add(fourHours), eTime.Add(fourHours));

            _reportFormatter.GenerateExcelUserCallReport(groupCallReport.UserCallReportList, emailList);
        }