public async Task <LoadEligibleEmployeesResponse.Response> LoadEligibleEmployees(string tenantId, string jSession, string PersonNumber, string ShiftSwapDate, string StartTime, string EndTime) { try { string xmlRequest = CreateLoadEligibleEmpRequest(PersonNumber, ShiftSwapDate, ShiftSwapDate, StartTime, EndTime); TenantMapEntity tenantMapEntity = await azureTableStorageHelper.ExecuteQueryUsingPointQueryAsync <TenantMapEntity>(Constants.ActivityChannelId, tenantId); var tupleResponse = await ApiHelper.Instance.SendSoapPostRequest(tenantMapEntity.EndpointUrl, ApiConstants.SoapEnvOpen, xmlRequest, ApiConstants.SoapEnvClose, jSession); LoadEligibleEmployeesResponse.Response Response = processEligibleEmployeesResponse(tupleResponse.Item1); return(Response); } catch (Exception) { throw; } }
/// <summary> /// Filter shifts option based on employees and job roles. /// </summary> /// <param name="context">dialog context.</param> /// <param name="allJobs">All the available jobs for swapping.</param> /// <param name="empList">All the available employees for swapping jobs.</param> /// <returns>basic filter card card.</returns> public AdaptiveCard GetFilterCard(IDialogContext context, JobResponse.JobResponse.Response allJobs, EligibleEmpResponse.Response empList) { var obj = context.PrivateConversationData.GetValue <SwapShiftObj>("SwapShiftObj"); string fullPath = HttpContext.Current.Server.MapPath("/Cards/AdaptiveCards/SwapShift/SearchFilterCard.json"); var adaptiveCard = File.ReadAllText(fullPath); var row = "{\"title\": \"{Text}\",\"value\": \"{Value}\"}"; var rows = new StringBuilder(); AdaptiveCard card; // Populate Eligible Employees if (empList != null && empList.Person != null) { for (int i = 0; i < empList.Person.Count(); i++) { if (i == 0 && empList.Person.Count() > 1) { rows.Append("{\"title\": \"All Employees\",\"value\":\"" + string.Join(",", empList.Person.Select(c => c.PersonNumber)) + "\" }, "); var item = row.Replace("{Text}", empList.Person[i].FullName); item = item.Replace("{Value}", empList.Person[i].PersonNumber); item += ", "; rows.Append(item); } else if (i == empList.Person.Count() - 1) { var item = row.Replace("{Text}", empList.Person[i].FullName); item = item.Replace("{Value}", empList.Person[i].PersonNumber); rows.Append(item); } else { var item = row.Replace("{Text}", empList.Person[i].FullName); item = item.Replace("{Value}", empList.Person[i].PersonNumber); item += ", "; rows.Append(item); } } adaptiveCard = adaptiveCard.Replace("{AllEmps}", rows.ToString()); adaptiveCard = adaptiveCard.Replace("{noEmpsFound}", string.Empty); adaptiveCard = adaptiveCard.Replace("{EmployeeValue}", obj.SelectedEmployee ?? string.Join(",", empList.Person.Select(c => c.PersonNumber))); rows.Clear(); } else { adaptiveCard = adaptiveCard.Replace("{noEmpsFound}", KronosResourceText.NoEmpForSwap); adaptiveCard = adaptiveCard.Replace("{rows}", string.Empty); adaptiveCard = adaptiveCard.Replace("{AllEmps}", string.Empty); rows.Clear(); } if (allJobs == null) { adaptiveCard = adaptiveCard.Replace("{noJobsFound}", KronosResourceText.NoJobForSwap); adaptiveCard = adaptiveCard.Replace("{rows}", string.Empty); adaptiveCard = adaptiveCard.Replace("{AllJobs}", string.Empty); rows.Clear(); } else { var allJobList = allJobs.OrgJobPath; for (int i = 0; i < allJobList.Count(); i++) { if (i == 0 && allJobList.Count() > 1) { rows.Append("{\"title\": \"All Jobs\",\"Value\": \"" + string.Join(",", allJobList.Select(c => c.FullPath)) + "\" }, "); var item = row.Replace("{Text}", allJobList[i].FullPath); item = item.Replace("{Value}", allJobList[i].FullPath); item = item.Replace("{Value}", allJobList[i].FullPath); item += ", "; rows.Append(item); } else if (i == allJobList.Count() - 1) { var item = row.Replace("{Text}", allJobList[i].FullPath); item = item.Replace("{Value}", allJobList[i].FullPath); rows.Append(item); } else { var item = row.Replace("{Text}", allJobList[i].FullPath); item = item.Replace("{Value}", allJobList[i].FullPath); item += ", "; rows.Append(item); } } adaptiveCard = adaptiveCard.Replace("{AllJobs}", rows.ToString()); adaptiveCard = adaptiveCard.Replace("{noJobsFound}", string.Empty); adaptiveCard = adaptiveCard.Replace("{JobsValue}", obj.SelectedJob ?? string.Join(",", allJobList.Select(c => c.FullPath))); } card = AdaptiveCard.FromJson(adaptiveCard).Card; return(card); }