public static List <SkillRealTimeModel> SkillActivtyToSkillActivityRealTimeModel(SkillActivityList Record)
        {
            List <SkillRealTimeModel> returnRecord = new List <SkillRealTimeModel>();

            foreach (var item in Record.skillActivity)
            {
                SkillRealTimeModel single = new SkillRealTimeModel
                {
                    AgentsACW             = item.agentsACW,
                    AgentsAvailable       = item.agentsAvailable,
                    AgentsIdle            = item.agentsIdle,
                    AgentsLoggedIn        = item.agentsLoggedIn,
                    AgentsUnavailable     = item.agentsUnavailable,
                    ContactsActive        = item.contactsActive,
                    QueueCount            = item.queueCount,
                    InSLA                 = item.inSLA,
                    OutSLA                = item.outSLA,
                    ServiceLevel          = item.serviceLevel,
                    ServiceLevelGoal      = item.serviceLevelGoal,
                    ServiceLevelThreshold = item.serviceLevelThreshold,
                    CampaignId            = item.campaignId,
                    CampaignName          = item.campaignName,
                    SkillId               = item.skillId,
                    SkillName             = item.skillName
                };
                returnRecord.Add(single);
            }
            return(returnRecord);
        }
        public static void GenerateObservations(int duration, int pauseInterval, string timeFormat)
        {
            List <SkillRealTimeModel> totalList        = GetSkillActivities();
            SkillSummaryList          skillSummaryList = GetRTDSkillsSummary(DateTime.Now.AddHours(-4).ToString(), DateTime.Now.ToString());

            #region  CustomerLoyalty


            List <int> customerLoyaltyIds = new List <int> {
                352669, 352657, 346984, 355141, 355474, 355475, 355506, 352670
            };
            //for holdtime and longestqueue
            List <Skillsummary>      customerSkillList       = skillSummaryList.skillSummaries.Where(t => customerLoyaltyIds.Contains(Convert.ToInt32(t.skillId))).ToList();
            Dictionary <string, int> handLforcustomerloyalty = GetHoldTimeAndLongestQueue(customerSkillList);
            //for agents state and summary
            List <SkillRealTimeModel> CustomerLoyaltyList  = totalList.Where(t => customerLoyaltyIds.Contains(t.SkillId)).ToList();
            SkillRealTimeModel        customerLoyaltyModel = GetStreamingDataModel(CustomerLoyaltyList, 277692, "Customer Loyalty");
            customerLoyaltyModel.HoldTime     = handLforcustomerloyalty["HoldTime"];
            customerLoyaltyModel.LongestQueue = handLforcustomerloyalty["LongestQueue"];

            var jsonString    = JsonConvert.SerializeObject(customerLoyaltyModel);
            var postToPowerBi = HttpPostAsync("https://api.powerbi.com/beta/4b700a32-7025-4159-a131-8e9c9057f203/datasets/7a938ee1-f3f8-47b7-89c6-9f185235d469/rows?key=wfUHBqHwYBQH0wLyBIHLekvIeZ7Yt6KE8zQ7MlfTUf4O%2FNMgOVEhmHigfBIyuuRlV7Ueg0Tcbf8N3Lm2vyaq2A%3D%3D", "[" + jsonString + "]"); // Add brackets for Power BI



            #endregion



            #region  DataEntry
            List <int> dateEntryIds = new List <int> {
                352675, 352676, 352678, 352679, 491259
            };

            List <Skillsummary>       dataentrySkillList = skillSummaryList.skillSummaries.Where(t => dateEntryIds.Contains(Convert.ToInt32(t.skillId))).ToList();
            Dictionary <string, int>  handLfordataentry  = GetHoldTimeAndLongestQueue(dataentrySkillList);
            List <SkillRealTimeModel> DataEntryList      = totalList.Where(t => dateEntryIds.Contains(t.SkillId)).ToList();
            SkillRealTimeModel        DataEntryModel     = GetStreamingDataModel(DataEntryList, 277722, "Fluent - DataEntry");
            DataEntryModel.HoldTime     = handLfordataentry["HoldTime"];
            DataEntryModel.LongestQueue = handLfordataentry["LongestQueue"];
            var dataentryjsonString    = JsonConvert.SerializeObject(DataEntryModel);
            var postTodataentryPowerBi = HttpPostAsync("https://api.powerbi.com/beta/4b700a32-7025-4159-a131-8e9c9057f203/datasets/677f0ce8-bde2-42f5-a201-0d5f398c1623/rows?key=LtLYkLl8zjktsKDNrC8ominN9ClAMfLCkPzrMmbQggPxnZIqQcn7I2hUtdVDvZNnLnCAgtsIZR0gWc4ZtC9UOQ%3D%3D", "[" + dataentryjsonString + "]"); // Add brackets for Power BI
            #endregion
        }
        static SkillRealTimeModel GetStreamingDataModel(List <SkillRealTimeModel> Record, int campaignid, string campaignName)
        {
            SkillRealTimeModel returnRecord = new SkillRealTimeModel();

            returnRecord.CampaignId            = campaignid;
            returnRecord.CampaignName          = campaignName;
            returnRecord.AgentsACW             = Record.Sum(item => item.AgentsACW);
            returnRecord.AgentsAvailable       = Record.Sum(item => item.AgentsAvailable);
            returnRecord.AgentsIdle            = Record.Sum(item => item.AgentsIdle);
            returnRecord.AgentsLoggedIn        = Record.Sum(item => item.AgentsLoggedIn);
            returnRecord.AgentsUnavailable     = Record.Sum(item => item.AgentsUnavailable);
            returnRecord.AgentsWorking         = Record.Sum(item => item.AgentsWorking);
            returnRecord.ContactsActive        = Record.Sum(item => item.ContactsActive);
            returnRecord.QueueCount            = Record.Sum(item => item.QueueCount);
            returnRecord.InSLA                 = Record.Sum(item => item.InSLA);
            returnRecord.OutSLA                = Record.Sum(item => item.OutSLA);
            returnRecord.ServiceLevel          = Record.Sum(item => item.ServiceLevel) / Record.Count;
            returnRecord.ServiceLevelGoal      = Record.Sum(item => item.ServiceLevelGoal) / Record.Count;
            returnRecord.ServiceLevelThreshold = Record.Sum(item => item.ServiceLevelThreshold) / Record.Count;

            return(returnRecord);
        }