//adding the callreport to the table
        public async Task SaveCallReportAsync()
        {
            using (var context = new CompliXperAppContext())
            {
                context.Add <CallReport>(NewCallReport);
                await context.SaveChangesAsync();

                ////get the lastes call report
                CallReport lastReport = await context.CallReport
                                        .OrderByDescending(r => r.CallReportId)
                                        .FirstAsync();

                ////get the lastes call report

                List <CallReportResponse> responses = new List <CallReportResponse>();
                foreach (QuestionandResponse qr in QR)
                {
                    responses.Add(
                        new CallReportResponse
                    {
                        Response     = qr.Response,
                        QuestionId   = qr.QuestionId,
                        CallReportId = lastReport.CallReportId
                    }
                        );
                }
                lastReport.Responses = responses;
                //add the responses to the DB
                await context.AddRangeAsync(responses);

                await context.SaveChangesAsync();
            }
        }
Ejemplo n.º 2
0
        public IActionResult GetCallReport()
        {
            CallReport report = new CallReport();

            report.generatedReport(_env.WebRootPath);
            return(Ok(new { msg = "Report Generated" }));
        }
Ejemplo n.º 3
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
        }
Ejemplo n.º 4
0
        public async Task <int> UploadReport(string datestr, [FromBody] object[][] data)
        {
            AuthController.ValidateAndGetCurrentUserName(this.HttpContext.Request);

            DateTime date = DateTime.ParseExact(datestr, "yyyy-MM-dd", null);

            var calllogs = await context.CallLogs
                           .Where(log => log.ReqDateTime.Year == date.Year && log.ReqDateTime.Month == date.Month && log.ReqDateTime.Day == date.Day)
                           .ToListAsync();

            int newRecords = 0;

            for (int i = 1; i < data.Length; i++)
            {
                CallReport callReport = new CallReport();

                callReport.CallType = data[i][0].ToString();
                DateTime time_part = DateTime.Parse(data[i][1].ToString());
                callReport.Time        = new DateTime(date.Year, date.Month, date.Day, time_part.Hour, time_part.Minute, time_part.Second);
                callReport.Extension   = data[i][2].ToString();
                callReport.Source      = data[i][3].ToString();
                callReport.Destination = data[i][4].ToString();
                callReport.Duration    = data[i][5].ToString();
                callReport.Seconds     = int.Parse(data[i][6].ToString());
                callReport.Cost        = decimal.Parse(data[i][7].ToString());

                var tmpCall = await context.CallReports.FirstOrDefaultAsync(call => call.Time == callReport.Time && call.Extension == callReport.Extension && call.Destination == callReport.Destination && call.Source == callReport.Source && call.Duration == callReport.Duration);

                if (tmpCall == null)
                {
                    var related = false;
                    foreach (CallLog log in calllogs)
                    {
                        if (log.Request.Contains(callReport.Extension) &&
                            log.Request.Contains(callReport.Destination) &&
                            log.ReqDateTime.Day == callReport.Time.Day &&
                            log.ReqDateTime.Hour == callReport.Time.Hour &&
                            Math.Abs(log.ReqDateTime.Minute - callReport.Time.Minute) < 2
                            )
                        {
                            related = true;
                            break;
                        }
                    }

                    if (related)
                    {
                        context.CallReports.Add(callReport);
                        await context.SaveChangesAsync();

                        newRecords++;
                    }
                }
            }

            return(newRecords);
        }
        async void GetCallReportDetails(CallReport report)
        {
            CallReport = null;
            await App.Current.MainPage.Navigation.PushAsync(new CompliXpertAppMasterDetailPage()
            {
                Detail = new NavigationPage(new CallReportDetailsScreen())
            });

            MessagingCenter.Send <CallReportListViewModel, CallReport>(this, Message.CallReportLoaded, report);
        }
Ejemplo n.º 6
0
        private async void GetCallReportDetailScreenAsync()
        {
            await App.Current.MainPage.Navigation.PushAsync(new CompliXpertAppMasterDetailPage()
            {
                Detail = new NavigationPage(new CallReportDetailsScreen())
            });

            MessagingCenter.Send <CallReportListScreenViewModel, CallReport>(this, Message.CallReportLoaded, callReportSelected);
            CallReportSelected = null;
        }
Ejemplo n.º 7
0
 public IHttpActionResult GetCallReportForEmployee(int id)
 {
     try
     {
         CallReport report = new CallReport();
         report.generateSpecificEmployeeReport(id);
         return(Ok("report generated"));
     }
     catch (Exception ex)
     {
         return(BadRequest("Report Generation Failed -" + ex.Message));
     }
 }
Ejemplo n.º 8
0
 public IHttpActionResult GetCallReport()
 {
     try
     {
         CallReport report = new CallReport();
         report.doIt();
         return(Ok("call report generated"));
     }
     catch (Exception ex)
     {
         return(BadRequest("Report Generation failed - " + ex.Message));
     }
 }
Ejemplo n.º 9
0
 public IHttpActionResult GetCallReport()
 {
     try
     {
         CallReport rep = new CallReport();
         rep.doIt();
         return(Ok("report generated"));
     }
     catch (Exception e)
     {
         //Trace.WriteLine("Error " + e.Message);
         return(BadRequest("Retrieve failed - Couldn't generate report" + e.Message));
     }
 }
Ejemplo n.º 10
0
        /// <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);

            // 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, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).Subtract(days);
            DateTime eTime       = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 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(eightHours), eTime.Add(eightHours));

            _reportFormatter.GenerateExcelUserCallReport(groupCallReport.UserCallReportList, emailList);
        }
Ejemplo n.º 11
0
/// <summary>
/// method to create a group call report
/// 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 CallReport CreateGroupCallReport(string groupId, DateTime reportTime, DateTime endTime)
        {
            // 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;
            }

            return(groupCallReport);
        }
Ejemplo n.º 12
0
        //really an update call report
        public async Task SaveCallReportAsync()
        {
            using (var context = new CompliXperAppContext())
            {
                IsBusy = true;
                //retrieving entity by id
                CallReport report = await context.CallReport
                                    .SingleAsync(r => r.CallReportId == Report.CallReportId);

                report.CallDate    = Report.CallDate;
                report.CreatedDate = DateTime.Now;
                report.Position    = Report.Position;
                report.Reference   = Report.Reference;
                List <CallReportResponse> responses = new List <CallReportResponse>();
                foreach (var qr in QuestionandResponses)
                {
                    responses.Add(
                        new CallReportResponse
                    {
                        Response     = qr.Response,
                        QuestionId   = qr.QuestionId,
                        CallReportId = report.CallReportId,
                        ResponseId   = qr.ResponseId
                    }
                        );
                }
                context.CallReportResponse.UpdateRange(responses);

                try
                {
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateException e)
                {
                    Console.WriteLine(e.InnerException);
                }

                IsBusy = false;
                await App.Current.MainPage.Navigation.PopToRootAsync();

                MessagingCenter.Send <CallReportDetailsViewModel, int?>(this, Message.AccountNumber, Report.AccountNumber);
            }
        }
        //constructor
        public CreateCallReportViewModel()
        {
            Notes   = new List <Note>();
            _notes  = new List <Note>();
            Persons = new List <Person>();
            persons = new List <Person>();


            SaveCallReportCommand = new Command(async() => await SaveNewCallReportAsync(), () => canSave);

            AddNoteCommand = new Command(async() => await AddNoteAsync());

            AddPersonCommand = new Command(async() => await AddPersonAsync());
            //must instantiate new call report to take in the new data
            NewCallReport = new CallReport
            {
                CallDate    = DateTime.Now,
                CreatedDate = DateTime.Now
            };

            Subscribe();
        }
Ejemplo n.º 14
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.GetAllCdrsForPhoneNumber(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();

                // create a list to copy the cdrs into
                List <CallInfo> callInfo = new List <CallInfo>();

                // 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)
                    {
                        // create the call detail for the call
                        CallInfo cInfo = new CallInfo();

                        if (myRow.ItemArray[6].Equals("Originating"))
                        {
                            totalOut++;
                            cInfo.Direction = DirectionDescriptor.Outbound;
                            // log the originating  international call
                            if (myRow.ItemArray[19].Equals("internat"))
                            {
                                totalIntlOrig++;
                            }
                        }
                        else if (myRow.ItemArray[6].Equals("Terminating"))
                        {
                            totalIn++;
                            cInfo.Direction = DirectionDescriptor.Inbound;
                        }

                        // get the call duration for this call
                        // starttime,  releaseTime
                        DateTime d1 = (DateTime)myRow.ItemArray[10];
                        DateTime d2 = (DateTime)myRow.ItemArray[14];
                        cInfo.CallDate        = d1;
                        cInfo.AnswerIndicator = (String)myRow.ItemArray[12];
                        if (cInfo.AnswerIndicator.Equals("No"))
                        {
                            TimeSpan t = new TimeSpan(0);
                            cInfo.Duration = t;
                        }
                        else
                        {
                            TimeSpan callDuration = d2.Subtract(d1);
                            cInfo.Duration = callDuration;
                        }

                        cInfo.UserNumber    = (String)myRow.ItemArray[4];
                        cInfo.CallingNumber = (String)myRow.ItemArray[7];
                        cInfo.CalledNumber  = (String)myRow.ItemArray[9];

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

                        // save the call detail for this user
                        callInfo.Add(cInfo);
                    }
                }// end of the CDRs

                // copy the cdr list to the user report
                ucr.Calls = callInfo;

                // 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);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Report: report spam calls received to better tune our algorithms based upon spam calls you receive This returns information required to perform basic call blocking behaviors&lt;br /&gt;\r\n            Try with api_key &#39;demo&#39; and phone numbers 18008472911, 13157244022, 17275567300, 18008276655, and 12061231234 (last one not spam)
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="callReport">[FromBody] Call Report\r\n            PhoneNumber, \r\n            Caller name(optional), \r\n            Call category(optional), \r\n            Comment or tags(free text) (optional), \r\n            Unwanted call  - yes/no(optional),</param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task<ApiResponse<Object>> ReputationReportAsyncWithHttpInfo (CallReport callReport)
        {
            // verify the required parameter 'callReport' is set
            if (callReport == null) throw new ApiException(400, "Missing required parameter 'callReport' when calling ReputationReport");
            
    
            var localVarPath = "/api/2015-11-01/Report";
    
            var localVarPathParams = new Dictionary<String, String>();
            var localVarQueryParams = new Dictionary<String, String>();
            var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
            var localVarFormParams = new Dictionary<String, String>();
            var localVarFileParams = new Dictionary<String, FileParameter>();
            Object localVarPostBody = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json", "text/json", "application/xml", "text/xml"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
            if (localVarHttpHeaderAccept != null)
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            
            
            
            
            if (callReport.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(callReport); // http body (model) parameter
            }
            else
            {
                localVarPostBody = callReport; // byte array
            }

            

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, 
                Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, 
                localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int) localVarResponse.StatusCode;
 
            if (localVarStatusCode >= 400)
                throw new ApiException (localVarStatusCode, "Error calling ReputationReport: " + localVarResponse.Content, localVarResponse.Content);
            else if (localVarStatusCode == 0)
                throw new ApiException (localVarStatusCode, "Error calling ReputationReport: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);

            
            return new ApiResponse<Object>(localVarStatusCode,
                localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                null);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Report: report spam calls received to better tune our algorithms based upon spam calls you receive This returns information required to perform basic call blocking behaviors&lt;br /&gt;\r\n            Try with api_key &#39;demo&#39; and phone numbers 18008472911, 13157244022, 17275567300, 18008276655, and 12061231234 (last one not spam)
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="callReport">[FromBody] Call Report\r\n            PhoneNumber, \r\n            Caller name(optional), \r\n            Call category(optional), \r\n            Comment or tags(free text) (optional), \r\n            Unwanted call  - yes/no(optional),</param>
        /// <returns>Task of void</returns>
        public async System.Threading.Tasks.Task ReputationReportAsync (CallReport callReport)
        {
             await ReputationReportAsyncWithHttpInfo(callReport);

        }
Ejemplo n.º 17
0
 /// <summary>
 /// Report: report spam calls received to better tune our algorithms based upon spam calls you receive This returns information required to perform basic call blocking behaviors&lt;br /&gt;\r\n            Try with api_key &#39;demo&#39; and phone numbers 18008472911, 13157244022, 17275567300, 18008276655, and 12061231234 (last one not spam)
 /// </summary>
 /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="callReport">[FromBody] Call Report\r\n            PhoneNumber, \r\n            Caller name(optional), \r\n            Call category(optional), \r\n            Comment or tags(free text) (optional), \r\n            Unwanted call  - yes/no(optional),</param> 
 /// <returns></returns>
 public void ReputationReport (CallReport callReport)
 {
      ReputationReportWithHttpInfo(callReport);
 }
        private async void CallScreen(CompliXpertAppMasterDetailPageMenuItem menuItem)
        {
            MenuItem = null;
            var page = (Page)Activator.CreateInstance(menuItem.TargetType);

            if (menuItem.TargetType.FullName.Equals(typeof(CustomerListScreen).FullName))
            {
                App.Current.MainPage = new NavigationPage(new CompliXpertAppMasterDetailPage());
                await App.Current.MainPage.Navigation.PopToRootAsync();
            }
            else if (menuItem.TargetType.FullName.Equals(typeof(CreateCallReportScreen).FullName) == true || menuItem.TargetType.FullName.Equals(typeof(LoadingScreen).FullName) == true)
            {
                return;
            }
            //check target type for selectaccountforcallreport
            else if (menuItem.TargetType.FullName.Equals(typeof(SelectAccountforCallReport).FullName))
            {
                await App.Current.MainPage.Navigation.PushAsync(new CompliXpertAppMasterDetailPage()
                {
                    Detail = new NavigationPage(page)
                });

                //use messaging center here to send the customer for CreateCallReport
                MessagingCenter.Send <CompliXpertAppMasterDetailPageMasterViewModel, int>(this, Message.CustomerIdAttached, menuItem.Id);
            }
            //check to see if a note or attendee wants to be added
            else if (menuItem.TargetType.FullName.Equals(typeof(CallReportDetailsScreen).FullName))
            {
                using (CompliXperAppContext context = new CompliXperAppContext())
                {
                    CallReport callReport = (from callreport in context.CallReport
                                             where callreport.CallReportId == menuItem.Id
                                             select new CallReport
                    {
                        AccountNumber = callreport.AccountNumber,
                        AccountNumberNavigation = callreport.AccountNumberNavigation,
                        ApprovedBy = callreport.ApprovedBy,
                        ApprovedDate = callreport.ApprovedDate,
                        CallDate = callreport.CallDate,
                        CallReportId = callreport.CallReportId,
                        CallReportType = callreport.CallReportType,
                        CreatedOnMobile = callreport.CreatedOnMobile,
                        LastUpdated = callreport.LastUpdated,
                        LastUpdatedDate = callreport.LastUpdatedDate,
                        Notes = (from notes in context.Notes
                                 where notes.NoteId == callreport.CallReportId
                                 select notes).ToList(),
                        Officer = callreport.Officer,
                        Position = callreport.Position,
                        Reason = callreport.Reason,
                        Reference = callreport.Reference,
                        Responses = (from responses in context.CallReportResponse
                                     where responses.CallReportId == callreport.CallReportId
                                     select responses).ToList()
                    }).FirstOrDefault();

                    await App.Current.MainPage.Navigation.PushAsync(new CompliXpertAppMasterDetailPage()
                    {
                        Detail = new NavigationPage(page)
                    });

                    //use messaging center here to send the customer for CreateCallReport
                    MessagingCenter.Send <CompliXpertAppMasterDetailPageMasterViewModel, CallReport>(this, Message.CallReportLoaded, callReport);
                }
            }
            //this is the condition for any other menu choice
            else
            {
                await App.Current.MainPage.Navigation.PushAsync(new CompliXpertAppMasterDetailPage()
                {
                    Detail = new NavigationPage(page)
                });
            }
        }
Ejemplo n.º 19
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.GetAllCdrsForPhoneNumber(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();

                // create a list to copy the cdrs into
                List<CallInfo> callInfo = new List<CallInfo>();

                // 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)
                    {
                        // create the call detail for the call
                        CallInfo cInfo = new CallInfo();

                        if (myRow.ItemArray[6].Equals("Originating"))
                        {
                            totalOut++;
                            cInfo.Direction = DirectionDescriptor.Outbound;
                            // log the originating  international call
                            if (myRow.ItemArray[19].Equals("internat"))
                                totalIntlOrig++;
                        }
                        else if (myRow.ItemArray[6].Equals("Terminating"))
                        {
                            totalIn++;
                            cInfo.Direction = DirectionDescriptor.Inbound;
                        }

                        // get the call duration for this call
                        // starttime,  releaseTime
                        DateTime d1 = (DateTime)myRow.ItemArray[10];
                        DateTime d2 = (DateTime)myRow.ItemArray[14];
                        cInfo.CallDate = d1;
                        cInfo.AnswerIndicator = (String)myRow.ItemArray[12];
                        if (cInfo.AnswerIndicator.Equals("No"))
                        {
                            TimeSpan t = new TimeSpan(0);
                            cInfo.Duration = t;
                        }
                        else
                        {
                            TimeSpan callDuration = d2.Subtract(d1);
                            cInfo.Duration = callDuration;
                        }

                        cInfo.UserNumber = (String)myRow.ItemArray[4];
                        cInfo.CallingNumber = (String)myRow.ItemArray[7];
                        cInfo.CalledNumber = (String)myRow.ItemArray[9];

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

                        // save the call detail for this user
                        callInfo.Add(cInfo);
                    }

                }// end of the CDRs

                // copy the cdr list to the user report
                ucr.Calls = callInfo;

                // 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;
        }
Ejemplo n.º 20
0
        /// <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 toList)
        {
            string comma = ",";

            DateTime date      = DateTime.Now;
            string   rFileName = ReportFormatter._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(ReportFormatter._bccEmailList);
            // Create a message and set up the recipients.
            MailMessage message = new MailMessage(
                From,
                toList,
                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(ReportFormatter._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("ReportFormatter::SendNotification():ECaught:" + sme.Message);
            }
            // Display
        }