/// <summary> /// To store the soft skill survey ws data to db. /// </summary> /// <param name="surveryorEmail">email of the surveyor who attent the survey</param> /// <param name="softSkillTestId">1 for ws getProfile() and 2 for ws GetSkillProfile</param> /// <param name="softSkillTestQuiz">S for ws getProfile() and N for ws GetSkillProfile</param> /// <returns></returns> public async Task <int> InsertSoftSkillTestWSResultAsync(GetWSResultDto getWSResultDto) { try { SoftskillsTestWsResult sstwr = new SoftskillsTestWsResult(); sstwr.SsktestresTestId = getWSResultDto.SoftSkillTestId; sstwr.SsktestresPlayField1 = (decimal)getWSResultDto.P; sstwr.SsktestresPlayField2 = (decimal)getWSResultDto.L; sstwr.SsktestresPlayField3 = (decimal)getWSResultDto.A; sstwr.SsktestresPlayField4 = (decimal)getWSResultDto.Y; sstwr.SsktestresProfilo = getWSResultDto.ProfileIdProp; sstwr.SsktestresTipoTestQuiz = getWSResultDto.SoftSkillTestQuiz; sstwr.SsktestresRisDataRisposta = DateTime.Now; sstwr.SsktestresInsTimestamp = DateTime.Now; sstwr.SsktestresModTimestamp = DateTime.Now; if (getWSResultDto.RichId != null) { sstwr.SsktestresRichId = getWSResultDto.RichId; } if (sstwr.SsktestresRichId == null) { Risorse risorse = await _unitOfWork.Risorse .FirstOrDefaultAsync(c => c.RisEmail.Contains(getWSResultDto.SurveyorEmail)); sstwr.SsktestresRisId = risorse?.RisId; } _unitOfWork.SoftskillsTestWsResult.Add(sstwr); await _unitOfWork.CompleteAsync(); return(sstwr.SsktestresId); } catch (Exception e) { throw; } }
public GetWSResultDto returnGetSkillProfileWSResultDto(List <int> skillCodeArray, string richId) { // Declaring an empty array of ArrayOfInt SoftSkill.ArrayOfInt iArray = new SoftSkill.ArrayOfInt(); for (int i = 0; i < 6; i++) { // Assigning the data into the list iArray.Add(skillCodeArray[i]); } // Setting up the configuration for consuming web service SoftSkill.wsTestPlayPublicSoapClient.EndpointConfiguration endpointConfiguration = new SoftSkill.wsTestPlayPublicSoapClient.EndpointConfiguration(); // Consuming the web service providing necessary credentials. SoftSkill.wsTestPlayPublicSoapClient wsTestPlayPublicSoapClient = new SoftSkill.wsTestPlayPublicSoapClient(endpointConfiguration, "http://wsplay.laborplay.com/wsTestPlayPublic.asmx"); // Let the system some time to get the data. Added for testing System.Threading.Thread.Sleep(5000); // Retrieving the web servince result by consuming the service. var result = wsTestPlayPublicSoapClient.GetSkillsProfileAsync(iArray); // Let the system some time to get the data. Added for testing System.Threading.Thread.Sleep(5000); try { // Declaring and initializing the web service result data to dto object. GetWSResultDto getSkillProfileWSResultDto = new GetWSResultDto(); // Assigning the value of P from web service result getSkillProfileWSResultDto.P = result.Result.Body.GetSkillsProfileResult.P; // Assigning the value of L from web service result getSkillProfileWSResultDto.L = result.Result.Body.GetSkillsProfileResult.L; // Assigning the value of A from web service result. getSkillProfileWSResultDto.A = result.Result.Body.GetSkillsProfileResult.A; // Assigning the value of Y from web service result. getSkillProfileWSResultDto.Y = result.Result.Body.GetSkillsProfileResult.Y; // Assigning the value of Profile Id from web service result. getSkillProfileWSResultDto.ProfileIdProp = result.Result.Body.GetSkillsProfileResult.ProfileIDProp; // Assigning static 2 as the value of soft skill test id to define // that which method is calling from the web service. getSkillProfileWSResultDto.SoftSkillTestId = 2; // Assigning static N following the requirement. getSkillProfileWSResultDto.SoftSkillTestQuiz = "N"; // Assigning the rich id following the retrieved rich id by ris_id. getSkillProfileWSResultDto.RichId = richId; // Returning the web service result dto object. return(getSkillProfileWSResultDto); } catch { // Retrieving the result that are come from the web service rather than the expected one. var wsResult = "Id: " + result.Id + "\n Status: " + result.Status; // Creating mail body along with the retrieved result. var mailbody = "<br />Hello " + "Isabella" + " Pinzauti" + ",<br /><br /> <br/>" + "Here is the web service provided result for GetSkillsProfile : <br /> " + wsResult + "<br /><br /><b> N.B: Please do not reply in this mail </b><br /><br /> Thanks, <br /> Talent Team"; // Initiating the mail address. _emailManager.To.Add("*****@*****.**"); // Initiating the mail subject. _emailManager.Subject = "Web_Service_Issue_Talent"; // Initiating the mail body. _emailManager.Body = mailbody.ToString(); // Sending the mail _emailManager.Send(); // Returning null as the web service doens't provide the expected result. return(null); } }
public GetWSResultDto returnGetProfileWSResultDto([FromBody] SurveyData surveyData) { // Setting up the configuration for consuming web service SoftSkill.wsTestPlayPublicSoapClient.EndpointConfiguration endpointConfiguration = new SoftSkill.wsTestPlayPublicSoapClient.EndpointConfiguration(); // Consuming the web service providing necessary credentials. SoftSkill.wsTestPlayPublicSoapClient wsTestPlayPublicSoapClient = new SoftSkill.wsTestPlayPublicSoapClient(endpointConfiguration, "http://wsplay.laborplay.com/wsTestPlayPublic.asmx"); // Converting the answer array to web service supported ArrayOfInt1 format // Declaring an empty array of ArrayOfInt1 SoftSkill.ArrayOfInt1 iSelectListArray = new SoftSkill.ArrayOfInt1(); for (int i = 0; i < 52; i++) { // Assigning the data into the list iSelectListArray.Add(Int32.Parse(surveyData.SelectListArray[i])); } // Calling the web service GetProfile var result = wsTestPlayPublicSoapClient.GetProfileAsync( Int32.Parse(surveyData.FeedbackArray[0]), Int32.Parse(surveyData.FeedbackArray[1]), bool.Parse(surveyData.FeedbackArray[2]), bool.Parse(surveyData.FeedbackArray[3]), bool.Parse(surveyData.FeedbackArray[4]), bool.Parse(surveyData.FeedbackArray[5]), bool.Parse(surveyData.FeedbackArray[6]), bool.Parse(surveyData.FeedbackArray[7]), iSelectListArray ); try { // Declaring and initializing the web service result data to dto object. GetWSResultDto getProfileWSResultDto = new GetWSResultDto(); // Assigning the value of P from web service result getProfileWSResultDto.P = result.Result.Body.GetProfileResult.P; // Assigning the value of L from web service result getProfileWSResultDto.L = result.Result.Body.GetProfileResult.L; // Assigning the value of A from web service result getProfileWSResultDto.A = result.Result.Body.GetProfileResult.A; // Assigning the value of Y from web service result getProfileWSResultDto.Y = result.Result.Body.GetProfileResult.Y; getProfileWSResultDto.ProfileIdProp = result.Result.Body.GetProfileResult.ProfileIDProp; // Assigning static 2 as the value of soft skill test id to define // that which method is calling from the web service. getProfileWSResultDto.SoftSkillTestId = 1; // Assigning static S following the requirement. getProfileWSResultDto.SoftSkillTestQuiz = "S"; getProfileWSResultDto.SurveyorEmail = surveyData.Email; return(getProfileWSResultDto); } catch { // Retrieving the error data when the web service is failed to // response properly. var wsResult = "Id: " + result.Id + "\n Status: " + result.Status; // Initiating static mail header. var mailbody = "<br />Hello " + "Isabella" + " Pinzauti" + ",<br /><br /> <br/>" + "Here is the web service provided result for GetProfile : <br /> " + wsResult + "<br /><br /><b> N.B: Please do not reply in this mail </b><br /><br /> Thanks, <br /> Talent Team"; // Initiating the static mail address to whom the error informing // mail will be sent. _emailManager.To.Add("*****@*****.**"); // Initiating the mail subject. _emailManager.Subject = "Web_Service_Issue_Talent"; // Initiating the mail body _emailManager.Body = mailbody.ToString(); // Sending the mail to the recipient. _emailManager.Send(); // Returning null as didn't get any result from web service. return(null); } }