public void Setup()
        {
            _response = JsonConvert.DeserializeObject <CampaignSummary>(File.ReadAllText(Json));

            var mock = new Mock <IHaloSession>();

            mock.Setup(m => m.Get <CampaignSummary>(It.IsAny <string>()))
            .ReturnsAsync(_response);

            _mockSession = mock.Object;
        }
        private List <CallEvent> filterCallHistory(CampaignSummary cs)
        {
            List <CallEvent> agentEvents = new List <CallEvent>();

            foreach (CallEvent ce in cs.CallEvents)
            {
                if (ce.AgentID == AgentID)
                {
                    agentEvents.Add(ce);
                }
            }
            return(agentEvents);
        }
        private List <Agent> filterAgents(CampaignSummary cs)
        {
            List <Agent> agents = new List <Agent>();

            for (int i = 1; i < cs.Agents.Count; i++)
            {
                Agent agent = cs.Agents[i];
                if (AgentID == 0)
                {
                    agents.Add(agent);
                }
                else
                {
                    if (agent.AgentID == AgentID)
                    {
                        agents.Add(agent);
                    }
                }
            }
            return(agents);
        }
        // Encodes the SummarizedAgentResultsReport as an HTML document
        //
        // NOTE: this is not a full HTML document containing a 'body',
        // 'html' tag etc. The entire report is written into a 'div'
        // that uses CSS style information that is found in the
        // 'callhistoryreport.css' file.
        //
        // NOTE: In the future it would be good to pick all this HTML
        // up from a template engine and remove it directly from this
        // code. This was was the "get it done now" approach.
        override public string encodeHTMLReport(Campaign campaign,
                                                string startDate,
                                                string endDate,
                                                string startTime,
                                                string endTime)
        {
            CampaignSummary cs = new CampaignSummary(campaign,
                                                     DateTime.Parse(startDate),
                                                     DateTime.Parse(endDate),
                                                     DateTime.Parse(startTime),
                                                     DateTime.Parse(endTime));

            string agentName = "All Agents";

            if (AgentID > 0)
            {
                Agent agent = new Agent(campaign, AgentID);
                agentName = agent.AgentName;
            }
            List <Agent> agents = filterAgents(cs);

            error = false;
            string html = "<div class=\"summarizedAgentResultsReport\">";

            //
            /// Show the report header/information
            //
            html += "<div>";
            html += "  <p id=\"summarizedAgentResultsHeader\">Summarized Agent Results Report By Agent</p>";
            html += "  <div style=\"position: relative; margin-top: 15px;\">";
            html += "    <div style=\"height: 80px; width: 790px;\">";
            html += "      	<div style=\"text-align: left;\">";
            html += "      		<span class=\"summarizedAgentResultsSecHeader\" style=\"margin-left: 100px; font-size: large; text-decoration: none\">";
            html += "        	For Campaign: &nbsp&nbsp&nbsp "+ campaign.Description;
            html += "      		</span>";
            html += "      	</div>";
            html += "      	<div style=\"text-align: left;\">";
            html += "      		<span class=\"summarizedAgentResultsSecHeader\" style=\"margin-left: 100px; font-size: large; text-decoration: none\">";
            html += "        	Agent: &nbsp&nbsp&nbsp "+ agentName;
            html += "      		</span>";
            html += "      	</div>";
            html += "      	<div style=\"text-align: left;\">";
            html += "      		<span class=\"summarizedAgentResultsSecHeader\" style=\"margin-left: 100px; font-size: large; text-decoration: none\">";
            html += "        	&nbsp";
            html += "      		</span>";
            html += "      	</div>";
            html += "    </div>";
            html += "    <div style=\"position: absolute; left: 800px; top: -10px; width: 170px; font-weight: bold\">";
            html += "      <div style=\"text-align: right;\">";
            html += "        <p style=\"\">Start Date: " + startDate + "</p>";
            html += "        <p style=\"\">End Date: " + endDate + "</p>";
            html += "      </div>";
            html += "      <p style=\"text-decoration: underline\">Between Times</p>";
            html += "      <div style=\"text-align: right;\">";
            html += "        <p style=\"\">Start Time: " + startTime + " </p>";
            html += "        <p style=\"\">End Time: " + endTime + "</p>";
            html += "      </div>";
            html += "    </div>";
            html += "  </div>";
            html += "</div>";

            // Display the Dialer results for agent
            html += "<div id=\"summarizedAgentsResultsHeaderTop\" style=\"position: relative; height: 20px; margine-bottom: 20px\">";
            html += "  <span style=\"position: absolute; left: 20px; width: 50px; text-align: center\">Agent</span>";
            html += "  <span style=\"position: absolute; left: 70px; width: 200px; text-align: left\">&nbsp</span>";
            html += "  <span style=\"position: absolute; left: 270px; width: 60px; text-align: center\">Total</span>";
            html += "  <span style=\"position: absolute; left: 330px; width: 60px; text-align: center\">Leads</span>";
            html += "  <span style=\"position: absolute; left: 390px; width: 60px; text-align: center\">Leads</span>";
            html += "  <span style=\"position: absolute; left: 460px; width: 60px; text-align: center\">&nbsp</span>";
            html += "  <span style=\"position: absolute; left: 500px; width: 60px; text-align: center\">Pres.</span>";
            html += "  <span style=\"position: absolute; left: 560px; width: 60px; text-align: center\">Leads</span>";
            html += "  <span style=\"position: absolute; left: 620px; width: 60px; text-align: center\">Pres.</span>";
            html += "  <span style=\"position: absolute; left: 680px; width: 60px; text-align: center\">Leads/</span>";
            html += "  <span style=\"position: absolute; left: 745px; width: 60px; text-align: center\">Dialed</span>";
            html += "  <span style=\"position: absolute; left: 815px; width: 60px; text-align: center\">Man</span>";
            html += "  <span style=\"position: absolute; left: 880px; width: 60px; text-align: center\">Pause</span>";
            html += "  <span style=\"position: absolute; left: 940px; width: 60px; text-align: center\">Talk</span>";
            html += "</div>";

            html += "<div id=\"summarizedAgentsResultsHeaderBottom\" style=\"position: relative; height: 20px; margine-bottom: 20px\">";
            html += "  <span style=\"position: absolute; left: 20px; width: 50px; text-align: center\">ID</span>";
            html += "  <span style=\"position: absolute; left: 70px; width: 200px; text-align: left\">Agent Name</span>";
            html += "  <span style=\"position: absolute; left: 270px; width: 60px; text-align: center\">Calls</span>";
            html += "  <span style=\"position: absolute; left: 330px; width: 60px; text-align: center\">(Sales)</span>";
            html += "  <span style=\"position: absolute; left: 390px; width: 60px; text-align: center\">/hr</span>";
            html += "  <span style=\"position: absolute; left: 460px; width: 60px; text-align: left\">Pres.</span>";
            html += "  <span style=\"position: absolute; left: 500px; width: 60px; text-align: center\">/hr</span>";
            html += "  <span style=\"position: absolute; left: 560px; width: 60px; text-align: center\">%</span>";
            html += "  <span style=\"position: absolute; left: 620px; width: 60px; text-align: center\">%</span>";
            html += "  <span style=\"position: absolute; left: 680px; width: 60px; text-align: center\">Pres. %</span>";
            html += "  <span style=\"position: absolute; left: 745px; width: 60px; text-align: center\">Hrs.</span>";
            html += "  <span style=\"position: absolute; left: 815px; width: 60px; text-align: center\">Hrs.</span>";
            html += "  <span style=\"position: absolute; left: 880px; width: 60px; text-align: center\">Time</span>";
            html += "  <span style=\"position: absolute; left: 940px; width: 60px; text-align: center\">%</span>";
            html += "</div>";

            foreach (Agent curAgent in agents)
            {
                html += "<div id=\"summarizedAgentsResultsRow\" style=\"position: relative; height: 20px\">";
                html += String.Format("  <span style=\"position: absolute; left: 20px; width: 50px; text-align: center\">{0}</span>", curAgent.AgentID);
                html += String.Format("  <span style=\"position: absolute; left: 70px; width: 200px; text-align: left\">{0}</span>", curAgent.AgentName);
                html += String.Format("  <span style=\"position: absolute; left: 270px; width: 60px; text-align: center\">{0}</span>", curAgent.TotalCalls);
                html += String.Format("  <span style=\"position: absolute; left: 330px; width: 60px; text-align: center\">{0}</span>", curAgent.Leads);
                html += String.Format("  <span style=\"position: absolute; left: 390px; width: 60px; text-align: center\">{0:0.##}</span>", curAgent.LeadsPerHour);
                html += String.Format("  <span style=\"position: absolute; left: 460px; width: 60px; text-align: left\">{0}</span>", curAgent.Presentations);
                html += String.Format("  <span style=\"position: absolute; left: 500px; width: 60px; text-align: center\">{0:0.##}</span>", curAgent.PresentationsPerHour);
                html += String.Format("  <span style=\"position: absolute; left: 560px; width: 60px; text-align: center\">{0:##%}</span>", curAgent.LeadsPerCall);
                html += String.Format("  <span style=\"position: absolute; left: 620px; width: 60px; text-align: center\">{0:##%}</span>", curAgent.PresentationsPerCall);
                html += String.Format("  <span style=\"position: absolute; left: 680px; width: 60px; text-align: center\">{0:##%}</span>", curAgent.LeadsPerPresentation);
                html += String.Format("  <span style=\"position: absolute; left: 745px; width: 60px; text-align: center\">{0}</span>", Agent.FormatTimeValue(curAgent.DialingHours));
                html += String.Format("  <span style=\"position: absolute; left: 815px; width: 60px; text-align: center\">{0}</span>", Agent.FormatTimeValue(curAgent.ManHours));
                html += String.Format("  <span style=\"position: absolute; left: 880px; width: 60px; text-align: center\">{0}</span>", Agent.FormatTimeValue(curAgent.PauseTime));
                html += String.Format("  <span style=\"position: absolute; left: 940px; width: 60px; text-align: center\">{0:##%}</span>", curAgent.TalkPercentage);
                html += "</div>";
            }

            html += "<div id=\"summarizedAgentsResultsFooter\" style=\"position: relative; height: 20px; margine-bottom: 20px\">";
            html += String.Format("  <span style=\"position: absolute; left: 270px; width: 60px; text-align: center\">{0}</span>", cs.Agents[0].TotalCalls);
            html += String.Format("  <span style=\"position: absolute; left: 330px; width: 60px; text-align: center\">{0}</span>", cs.Agents[0].Leads);
            html += String.Format("  <span style=\"position: absolute; left: 390px; width: 60px; text-align: center\">{0:0.##}</span>", cs.Agents[0].LeadsPerHour);
            html += String.Format("  <span style=\"position: absolute; left: 460px; width: 60px; text-align: left\">{0}</span>", cs.Agents[0].Presentations);
            html += String.Format("  <span style=\"position: absolute; left: 500px; width: 60px; text-align: center\">{0:0.##}</span>", cs.Agents[0].PresentationsPerHour);
            html += String.Format("  <span style=\"position: absolute; left: 560px; width: 60px; text-align: center\">{0:##%}</span>", cs.Agents[0].LeadsPerCall);
            html += String.Format("  <span style=\"position: absolute; left: 620px; width: 60px; text-align: center\">{0:##%}</span>", cs.Agents[0].PresentationsPerCall);
            html += String.Format("  <span style=\"position: absolute; left: 680px; width: 60px; text-align: center\">{0:##%}</span>", cs.Agents[0].LeadsPerPresentation);
            html += String.Format("  <span style=\"position: absolute; left: 745px; width: 60px; text-align: center\">{0}</span>", Agent.FormatTimeValue(cs.Agents[0].DialingHours));
            html += String.Format("  <span style=\"position: absolute; left: 815px; width: 60px; text-align: center\">{0}</span>", Agent.FormatTimeValue(cs.Agents[0].ManHours));

            html += String.Format("  <span style=\"position: absolute; left: 880px; width: 60px; text-align: center\">{0}</span>", Agent.FormatTimeValue(cs.Agents[0].PauseTime));

            html += String.Format("  <span style=\"position: absolute; left: 940px; width: 60px; text-align: center\">{0:##%}</span>", cs.Agents[0].TalkPercentage);
            html += "</div>";

            // End of document
            html += "</div>\n\n";
            return(html);
        }
        // Encodes the CallHistoryReport as an HTML document
        override public string encodeHTMLReport(Campaign campaign,
                                                string startDate,
                                                string endDate,
                                                string startTime,
                                                string endTime)
        {
            CampaignSummary cs = new CampaignSummary(campaign,
                                                     DateTime.Parse(startDate),
                                                     DateTime.Parse(endDate),
                                                     DateTime.Parse(startTime),
                                                     DateTime.Parse(endTime));

            Agent            agent = new Agent(campaign, AgentID);
            List <CallEvent> calls = filterCallHistory(cs);

            error = false;
            string html = "<div class=\"callHistoryReport\">";

            //
            /// Show the report header/information
            //
            html += "<div>";
            html += "  <p id=\"callHistoryReportHeader\">Call History Report By Agent</p>";
            html += "  <div style=\"position: relative; margin-top: 15px;\">";
            html += "    <div style=\"height: 80px; width: 790px;\">";
            html += "      	<div style=\"text-align: left;\">";
            html += "      		<span class=\"callHistorySecHeader\" style=\"margin-left: 100px; font-size: large; text-decoration: none\">";
            html += "        	For Campaign: &nbsp&nbsp&nbsp "+ campaign.Description;
            html += "      		</span>";
            html += "      	</div>";
            html += "      	<div style=\"text-align: left;\">";
            html += "      		<span class=\"callHistorySecHeader\" style=\"margin-left: 100px; font-size: large; text-decoration: none\">";
            html += "        	Agent: &nbsp&nbsp&nbsp "+ agent.AgentName;
            html += "      		</span>";
            html += "      	</div>";
            html += "      	<div style=\"text-align: left;\">";
            html += "      		<span class=\"callHistorySecHeader\" style=\"margin-left: 100px; font-size: large; text-decoration: none\">";
            html += "        	Total Calls: &nbsp&nbsp&nbsp "+ calls.Count;
            html += "      		</span>";
            html += "      	</div>";
            html += "    </div>";
            html += "    <div style=\"position: absolute; left: 800px; top: -10px; width: 170px; font-weight: bold\">";
            html += "      <div style=\"text-align: right;\">";
            html += "        <p style=\"\">Start Date: " + startDate + "</p>";
            html += "        <p style=\"\">End Date: " + endDate + "</p>";
            html += "      </div>";
            html += "      <p style=\"text-decoration: underline\">Between Times</p>";
            html += "      <div style=\"text-align: right;\">";
            html += "        <p style=\"\">Start Time: " + startTime + " </p>";
            html += "        <p style=\"\">End Time: " + endTime + "</p>";
            html += "      </div>";
            html += "    </div>";
            html += "  </div>";
            html += "</div>";

            // Display the Dialer results for agent
            html += "<div id=\"callHistoryResultsHeader\">";
            html += "  <span style=\"padding-left: 20px\">Date and Time</span>";
            html += "  <span style=\"position: absolute; left: 195px; width: 100px; text-align: left\">Phone Number</span>";
            html += "  <span style=\"position: absolute; left: 350px; width: 100px; text-align: left\">Call Result</span>";
            html += "  <span style=\"position: absolute; left: 600px; width: 100px; text-align: center\">Call Duration</span>";
            html += "  <span style=\"position: absolute; left: 740px; width: 100px; text-align: center\">Unique Key</span>";
            html += "</div>";
            foreach (CallEvent ce in calls)
            {
                html += "<div id=\"callHistoryResultsRow\">";
                html += String.Format("  <span style=\"width: 100px; padding-left: 20px\">{0}</span>", ce.CallDate);
                html += String.Format("  <span style=\"position: absolute; left: 200px; width: 100px; text-align: left\">{0}</span>", ce.PhoneNumber);
                html += String.Format("  <span style=\"position: absolute; left: 350px; width: 250px; text-align: left; text-align: left\">{0}</span>", ce.ResultCodeDescription);
                double callDuration = (ce.CallDuration / 3600);
                html += String.Format("  <span style=\"position: absolute; left: 610px; width: 100px; text-align: left\">{0}</span>", Agent.FormatTimeValue(callDuration));
                html += String.Format("  <span style=\"position: absolute; left: 760px; width: 100px; text-align: left\">{0}</span>", ce.CallListID);
                html += "</div>";
            }

            // End of document
            html += "</div>\n\n";
            return(html);
        }
        // Encodes the CallHistoryReport as an HTML document
        //
        // NOTE: This report has not been finished.
        override public string encodeHTMLReport(Campaign campaign,
                                                string startDate,
                                                string endDate,
                                                string startTime,
                                                string endTime)
        {
            string   campaignName = "All Campaigns";
            Agent    agent        = new Agent(campaign, AgentID);
            Agent    summaryAgent = new Agent(campaign, 0);
            Campaign loader       = new Campaign();
            List <CampaignSummary> activeCampaigns = new List <CampaignSummary>();

            if (CampaignID > 0)
            {
                List <RainmakerData> campaigns = loader.GetDataSet("CampaignID=" + CampaignID, null);
                campaign     = (Campaign)campaigns.GetRange(0, 1).ToArray()[0];
                campaignName = campaign.Description;
                CampaignSummary cs = new CampaignSummary(campaign,
                                                         DateTime.Parse(startDate),
                                                         DateTime.Parse(endDate),
                                                         DateTime.Parse(startTime),
                                                         DateTime.Parse(endTime));
                Agent curAgent = Agent.FindAgent(cs.Agents, AgentID);
                if (curAgent != null)
                {
                    summaryAgent = curAgent;
                }
            }
            else
            {
                Campaign [] campaigns = (Campaign [])loader.GetDataSet(null, null).ToArray();
                foreach (Campaign curCampaign in campaigns)
                {
                    CampaignSummary cs = new CampaignSummary(curCampaign,
                                                             DateTime.Parse(startDate),
                                                             DateTime.Parse(endDate),
                                                             DateTime.Parse(startTime),
                                                             DateTime.Parse(endTime));
                    Agent curAgent = Agent.FindAgent(cs.Agents, AgentID);
                    if ((curAgent != null) && curAgent.TotalCalls > 0)
                    {
                        activeCampaigns.Add(cs);
                    }
                    summaryAgent.Add(curAgent);
                }
            }
            error = false;
            string html = "<div class=\"agentDialerResultsReport\">";

            //
            /// Show the report header/information
            //
            html += "<div>";
            html += "  <p id=\"agentDialerResultsReportHeader\">Agent Dialer Results Report By Agent</p>";
            html += "  <div style=\"position: relative; margin-top: 15px;\">";
            html += "    <div style=\"height: 80px; width: 790px;\">";
            html += "      	<div style=\"text-align: left;\">";
            html += "      		<span class=\"agentDialerResultsSecHeader\" style=\"margin-left: 100px; font-size: large; text-decoration: none\">";
            html += "        	For Campaign: &nbsp&nbsp&nbsp "+ campaignName;
            html += "      		</span>";
            html += "      	</div>";
            html += "      	<div style=\"text-align: left;\">";
            html += "      		<span class=\"agentDialerResultsSecHeader\" style=\"margin-left: 100px; font-size: large; text-decoration: none\">";
            html += "        	Agent: &nbsp&nbsp&nbsp "+ agent.AgentName;
            html += "      		</span>";
            html += "      	</div>";
            html += "      	<div style=\"text-align: left;\">";
            html += "      		<span class=\"agentDialerResultsSecHeader\" style=\"margin-left: 100px; font-size: large; text-decoration: none\">";
            html += "        	Total Calls: &nbsp&nbsp&nbsp 0";
            html += "      		</span>";
            html += "      	</div>";
            html += "    </div>";
            html += "    <div style=\"position: absolute; left: 800px; top: -10px; width: 170px; font-weight: bold\">";
            html += "      <div style=\"text-align: right;\">";
            html += "        <p style=\"\">Start Date: " + startDate + "</p>";
            html += "        <p style=\"\">End Date: " + endDate + "</p>";
            html += "      </div>";
            html += "      <p style=\"text-decoration: underline\">Between Times</p>";
            html += "      <div style=\"text-align: right;\">";
            html += "        <p style=\"\">Start Time: " + startTime + " </p>";
            html += "        <p style=\"\">End Time: " + endTime + "</p>";
            html += "      </div>";
            html += "    </div>";
            html += "  </div>";
            html += "</div>";


            // Display the the summary information header
            html += "<div id=\"agentDialerResultsHeaderTop\" style=\"position: relative; height: 20px; margine-bottom: 20px\">";
            html += "  <span style=\"position: absolute; left: 20px; width: 50px; text-align: center\">Agent</span>";
            html += "  <span style=\"position: absolute; left: 70px; width: 200px; text-align: left\">&nbsp</span>";
            html += "  <span style=\"position: absolute; left: 200px; width: 60px; text-align: center\">Leads</span>";
            html += "  <span style=\"position: absolute; left: 280px; width: 60px; text-align: center\">Leads</span>";
            html += "  <span style=\"position: absolute; left: 380px; width: 60px; text-align: center\">&nbsp</span>";
            html += "  <span style=\"position: absolute; left: 460px; width: 60px; text-align: center\">Pres./</span>";
            html += "  <span style=\"position: absolute; left: 550px; width: 60px; text-align: center\">Leads/</span>";
            html += "  <span style=\"position: absolute; left: 670px; width: 90px; text-align: center\">Presentations</span>";
            html += "  <span style=\"position: absolute; left: 800px; width: 140px; text-align: center\">Leads/</span>";
            html += "</div>";

            html += "<div id=\"agentDialerResultsHeaderBottom\" style=\"position: relative; height: 20px; margine-bottom: 20px\">";
            html += "  <span style=\"position: absolute; left: 20px; width: 50px; text-align: center\">ID</span>";
            html += "  <span style=\"position: absolute; left: 70px; width: 200px; text-align: left\">Agent Name</span>";
            html += "  <span style=\"position: absolute; left: 200px; width: 60px; text-align: center\">(Sales)</span>";
            html += "  <span style=\"position: absolute; left: 280px; width: 60px; text-align: center\">(Sales)/hr</span>";
            html += "  <span style=\"position: absolute; left: 380px; width: 60px; text-align: left\">Pres.</span>";
            html += "  <span style=\"position: absolute; left: 460px; width: 60px; text-align: center\">/hr</span>";
            html += "  <span style=\"position: absolute; left: 550px; width: 60px; text-align: center\">Sales %</span>";
            html += "  <span style=\"position: absolute; left: 670px; width: 90px; text-align: center\">%</span>";
            html += "  <span style=\"position: absolute; left: 800px; width: 140px; text-align: center\">Presentations %</span>";
            html += "</div>";
// JMA: End Insert


// JMA: Start Print Campaign Summaries



            // End of document
            html += "</div>\n\n";
            return(html);
        }