Esempio n. 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);

                            // for testing on monthly summary and 4 hours get added on the sub call
                            DateTime rReportTime = new DateTime(2015, 08, 03, 0, 0, 0);
                            DateTime rEndTime    = new DateTime(2015, 08, 04, 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(_dept, rReportTime.Add(fourHours), rEndTime.Add(fourHours));

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

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

            finally
            {
            }// finally
        }