/// <summary> /// SearchCallsByAppName calibration layer /// </summary> /// <param name="search"></param> /// <returns></returns> public CallDetailsResponseData SearchCallsByAppName(CalibrationPageSearch search) { var sqlCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CC_ProdConn"].ConnectionString); var dbconn = new WebApi.Entities.CC_ProdEntities(); string userName = ""; if (HttpContext.Current.Request.UrlReferrer.Host.Contains("localhost") && HttpContext.Current.Request.UrlReferrer.Port == 51268) { userName = "******";// HttpContext.Current.User.Identity.Name; } else { userName = HttpContext.Current.User.Identity.Name; } SqlCommand sqlComm = new SqlCommand(); sqlComm.Connection = sqlCon; sqlComm.CommandText = "[ApiCallSearch]"; sqlComm.CommandType = CommandType.StoredProcedure; sqlComm.Parameters.AddWithValue("@number_days", 7); sqlComm.Parameters.AddWithValue("@userName", userName); sqlComm.Parameters.AddWithValue("@hidePending", true); sqlComm.Parameters.AddWithValue("@hideEdited", true); sqlComm.Parameters.AddWithValue("@includeMissed", true); if (search != null) { sqlComm.Parameters.AddWithValue("@SearchQuery", search.searchText); sqlComm.Parameters.AddWithValue("@appName", search.filters.appName); sqlComm.Parameters.AddWithValue("@scorecardId", search.filters.scorecardId); sqlComm.Parameters.AddWithValue("@pagenum", search.pagination.pagenum); sqlComm.Parameters.AddWithValue("@pagerows", search.pagination.pagerows); sqlComm.Parameters.AddWithValue("@start", DateTime.Parse(search.range.start)); sqlComm.Parameters.AddWithValue("@end", DateTime.Parse(search.range.end)); if (search.sorting != null) { sqlComm.Parameters.AddWithValue("@OrderByColumn", search.sorting.sortBy); sqlComm.Parameters.AddWithValue("@sortOrder", (search.sorting.sortOrder == "desc") ? (false) : (true)); } } List <CallDetailV2> callDetailsList = new List <CallDetailV2>(); sqlCon.Open(); SqlDataReader reader = sqlComm.ExecuteReader(); while (reader.Read()) { try { var callSystemData = (new CallSystemData() { callId = reader.IsDBNull(reader.GetOrdinal("callId")) ? (int?)null : int.Parse(reader.GetValue(reader.GetOrdinal("callId")).ToString()), callType = reader.GetValue(reader.GetOrdinal("calltype")).ToString(), callReviewStatus = (reader.GetValue(reader.GetOrdinal("callReviewStatus")).ToString()), callAudioUrl = reader.GetValue(reader.GetOrdinal("callAudioUrl")).ToString(), callAudioLength = reader.IsDBNull(reader.GetOrdinal("callAudioLength")) ? (float?)null : float.Parse(reader.GetValue(reader.GetOrdinal("callAudioLength")).ToString()), websiteUrl = reader.GetValue(reader.GetOrdinal("websiteUrl")).ToString(), scorecardId = reader.IsDBNull(reader.GetOrdinal("scorecardId")) ? (int?)null : int.Parse(reader.GetValue(reader.GetOrdinal("scorecardId")).ToString()), scorecardName = reader.GetValue(reader.GetOrdinal("scorecardName")).ToString(), scorecardFailScore = reader.IsDBNull(reader.GetOrdinal("scorecardFailScore")) ? (int?)null : int.Parse(reader.GetValue(reader.GetOrdinal("scorecardFailScore")).ToString()), receivedDate = reader.IsDBNull(reader.GetOrdinal("receivedDate")) ? (DateTime?)null : (DateTime?)reader.GetDateTime(reader.GetOrdinal("receivedDate")), reviewDate = reader.IsDBNull(reader.GetOrdinal("reviewDate")) ? (DateTime?)null : (DateTime?)reader.GetDateTime(reader.GetOrdinal("reviewDate")), reviewerUserRole = reader.GetValue(reader.GetOrdinal("reviewerUserRole")).ToString(), reviewerName = reader.GetValue(reader.GetOrdinal("reviewerName")).ToString(), calibratorId = reader.GetValue(reader.GetOrdinal("calibratorId")).ToString(), calibratorName = reader.GetValue(reader.GetOrdinal("calibratorName")).ToString(), missedItemsCount = reader.IsDBNull(reader.GetOrdinal("missedItemsCount")) ? (int?)null : int.Parse(reader.GetValue(reader.GetOrdinal("missedItemsCount")).ToString()), agentScore = reader.IsDBNull(reader.GetOrdinal("agentScore")) ? (float?)null : float.Parse(reader.GetValue(reader.GetOrdinal("agentScore")).ToString()), callFailed = ((reader.GetValue(reader.GetOrdinal("callFailed")).ToString() == "Pass") ? (false) : (true)), reviewCommentsPresent = ((reader.GetValue(reader.GetOrdinal("reviewCommentsPresent")).ToString() == "0") ? (false) : (true)), notificationCommentsPresent = ((reader.GetValue(reader.GetOrdinal("notificationCommentsPresent")).ToString() == "0") ? (false) : (true)), notificationStatus = (reader.GetValue(reader.GetOrdinal("notificationStatus")).ToString().ToLower()), xId = reader.IsDBNull(reader.GetOrdinal("x_id")) ? (int?)null : int.Parse(reader.GetValue(reader.GetOrdinal("x_id")).ToString()), inernalAdded = bool.Parse(reader.GetValue(reader.GetOrdinal("inernalAdded")).ToString()), externalAdded = bool.Parse(reader.GetValue(reader.GetOrdinal("externalAdded")).ToString()), missedItems = new List <CallMissedItem>() }); var callMetaData = (new CallMetaData() { callDate = reader.IsDBNull(reader.GetOrdinal("callDate")) ? (DateTime?)null : (DateTime?)reader.GetDateTime(reader.GetOrdinal("callDate")), agentGroup = reader.GetValue(reader.GetOrdinal("agentGroup")).ToString(), campaign = reader.GetValue(reader.GetOrdinal("campaign")).ToString(), agentName = reader.GetValue(reader.GetOrdinal("agentName")).ToString(), sessionId = reader.GetValue(reader.GetOrdinal("sessionId")).ToString(), profileId = reader.GetValue(reader.GetOrdinal("profileId")).ToString(), prospectFirstName = reader.GetValue(reader.GetOrdinal("prospectFirstName")).ToString(), prospectLastName = reader.GetValue(reader.GetOrdinal("prospectLastName")).ToString(), prospectPhone = reader.GetValue(reader.GetOrdinal("prospectPhone")).ToString(), prospectEmail = reader.GetValue(reader.GetOrdinal("prospectEmail")).ToString(), }); callDetailsList.Add(new CallDetailV2() { metaData = callMetaData, systemData = callSystemData }); } catch (Exception ex) { throw ex; } } List <CallMissedItem> MissedItemList = new List <CallMissedItem>(); if (reader.NextResult()) { while (reader.Read()) { try { MissedItemList.Add(new CallMissedItem() { itemDescription = reader.GetValue(reader.GetOrdinal("itemDescription")).ToString(), position = float.Parse(reader.GetValue(reader.GetOrdinal("q_pos")).ToString()), callId = int.Parse(reader.GetValue(reader.GetOrdinal("CallID")).ToString()) }); } catch { } } foreach (var item in callDetailsList) { item.systemData.missedItems = new List <CallMissedItem>(); item.systemData.missedItems.AddRange(from v in MissedItemList where v.callId == item.systemData.callId select v); item.callMissedItems = item.systemData.missedItems; } } CallDetailsResponseData CallDetailsLst = new CallDetailsResponseData(); CallDetailsLst.itemsTotal = callDetailsList.Count; CallDetailsLst.calls = callDetailsList; return(CallDetailsLst); }
//[Authorize(Roles = "getMyModules")] public CallDetailsResponseData SearchCallsByAppName([FromBody] CalibrationPageSearch search) { CalibrationLayer calibrationLayer = new CalibrationLayer(); return(calibrationLayer.SearchCallsByAppName(search)); }