コード例 #1
0
        protected static SkillSummaryList GetRTDSkillsSummary(string start, string end)
        {
            SkillSummaryList tmp = new SkillSummaryList();

            if (!string.IsNullOrEmpty(accessToken))
            {
                string apiURL = "/services/v11.0/skills/summary?startDate=" + start +
                                "&endDate=" + end;

                //baseURL was returned with your successful token request
                string endpoint            = baseURL + apiURL;
                string authorizationHeader = "Authorization:bearer " + accessToken;

                //Create the request object
                var request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(endpoint);
                request.Method      = "GET";
                request.ContentType = "application/x-www-form-urlencoded";

                //Add any and all necessary headers
                request.Headers.Add("Authorization", "bearer " + accessToken);
                //Accept is a reserved header, so you must modify it rather than add
                request.Accept = "application/json, text/javascript, */*; q=0.01";

                //Make the request
                try
                {
                    using (var response = (System.Net.HttpWebResponse)request.GetResponse())
                    {
                        string responseBody      = "";
                        int    statusCode        = (int)response.StatusCode;
                        string statusDescription = response.StatusDescription;
                        using (var responseStream = response.GetResponseStream())
                        {
                            if (responseStream != null)
                            {
                                using (var reader = new System.IO.StreamReader(responseStream))
                                {
                                    responseBody = reader.ReadToEnd();
                                }
                            }
                            tmp = JsonConvert.DeserializeObject <SkillSummaryList>(responseBody);
                        }
                    }
                }
                catch (System.Net.WebException webException)
                {
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
            }
            return(tmp);
        }
コード例 #2
0
        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
        }