Exemplo n.º 1
0
        public async Task <IActionResult> submitSurvey([FromBody] SurveyData surveyData)
        {
            // checking whether the web service is responding properly or not.
            if (returnGetProfileWSResultDto(surveyData) == null)
            {
                // returning the exception result by mentioning the exact reason.
                var result = new
                {
                    error      = "Web Service Failed.",
                    error_type = "",
                    message    = "Web Service isn't responding properly."
                };
                return(BadRequest(result));
            }

            try
            {
                // Inserting into the softskill test web service result table.
                var softSkillTestWsId = await _softSkillManager.InsertSoftSkillTestWSResultAsync(returnGetProfileWSResultDto(surveyData));

                // creating the azioni object passing the related details and description.
                //var azioniDto =  await _utilityManager.GetAzioniDtoObject(User, "add", "soft skill web service result.");
                // logging the activity record by the user.
                //await _talentBLLWrapper.AzuiniBll.AzioniInsert(azioniDto);
                // Sending the feedback email to the surveyor mail
                // along with the answer provided by the surveyor against a set of question.

                sendFeedbackMail(surveyData);
                // creating the azioni object passing the related details and description.
                //var iAzioniDto =  await _utilityManager.GetAzioniDtoObject(User, "email", "survey_form");
                // logging the activity record by the user.
                //await _talentBLLWrapper.AzuiniBll.AzioniInsert(iAzioniDto);

                return(Ok("ok"));
            }
            catch (Exception x)
            {
                // Code block of Exception handling and logging into log_operazione table.
                var errorObj = await _utilityManager.ReturnErrorObj(x, User, "Submit Survey");

                // Returning the error object.
                return(BadRequest(errorObj));
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        public async void sendFeedbackMail(SurveyData surveyData)
        {
            // Static Number of Questions
            var numberOfQuestion = 60;
            // Static Number of Options
            var numberOfOption = 4;
            // Static Number of Gender Data
            var numberOfGender = 2;
            // Static Number of Dropdown data
            var numberOfDropdown = 5;
            // Declaring the empty mail content
            var mailContent = "";

            var i = 0;
            var j = 0;

            // Loop in the question array to load all the question along with the answers
            for (int x = 0; x < numberOfQuestion; x++)
            {
                // Embedding the specific questions to the mail content based on language.
                mailContent += "Q " + (x + 1) + ": " + returnQuestion(x + (numberOfQuestion * surveyData.LangIndex)) + " : <b>";
                // Checking whether the question is about general info or radio options or select list options.
                if (x < 2)
                {
                    // Checking whether this is first question which related to gender.
                    if (x == 0)
                    {
                        // Embedding the answers provided by the surveyor following the selcted language.
                        mailContent += returnSelectedGender((numberOfGender * surveyData.LangIndex) +
                                                            (Int32.Parse(surveyData.FeedbackArray[j])) - 1) + "</b><br />";
                        j++;
                    }
                    else
                    {
                        mailContent += returnDropDown((numberOfDropdown * surveyData.LangIndex) +
                                                      (Int32.Parse(surveyData.FeedbackArray[j])) - 1) + "</b><br />";
                        j++;
                    }
                }
                else
                {
                    // Cheking the whether these questions are radio option type or select type.
                    if (x < 8)
                    {
                        mailContent += surveyData.FeedbackArray[j] + "</b><br />";
                        j++;
                    }
                    else
                    {
                        mailContent += returnSelectedAnswer((numberOfOption * surveyData.LangIndex) +
                                                            (Int32.Parse(surveyData.SelectListArray[i])) - 1) + "</b><br />";
                        i++;
                    }
                }
            }

            // Creating the mail body by concatanating the surveyor name and others info along with the provided answers
            var mailbody = "<br />Dear " + surveyData.FirstName + " " + surveyData.LastName + ",<br /><br /> <br/>" + "Here is your provided feedback : <br /> " + mailContent + "<br /><br /><b> N.B:  Please do not reply in this mail </b><br /><br /> Thanks, <br /> Talent Team";

            // Initiating the recipient mail address.
            _emailManager.To.Add(surveyData.Email);
            // Initiating the mail subject.
            _emailManager.Subject = "Talent_Survey_Form";
            // Initiating the mail body.
            _emailManager.Body = mailbody.ToString();
            // Sending the mail to specific recipient.
            _emailManager.Send();

            // creating the azioni object passing the related details and description.
            var azioniDto = _utilityManager.GetAzioniDtoObject(User, "email", "survey_feedback_mail");
            // logging the activity record by the user.
            await _azioniManager.AzioniInsert(azioniDto);
        }