public SurveyControlsResponse GetSurveyControlList(SurveyControlsRequest pRequest) { try { SurveyControlsResponse ControlListObj = new SurveyControlsResponse(); //_iDataService.GetSurveyControlList(pRequest); return(ControlListObj); } catch (FaultException <CustomFaultException> cfe) { throw cfe; } catch (FaultException fe) { throw fe; } catch (CommunicationException ce) { throw ce; } catch (TimeoutException te) { throw te; } catch (Exception ex) { throw ex; } }
/// <summary> /// Inserts SurveyResponse /// </summary> /// <param name="SurveyResponseApiModel"></param> /// <returns>response </returns> public PreFilledAnswerResponse SetSurveyAnswer(SurveyResponseApiModel request) { PreFilledAnswerResponse response; SurveyControlsResponse SurveyControlsResponse = new SurveyControlsResponse(); SurveyControlsRequest surveyControlsRequest = new SurveyControlsRequest(); surveyControlsRequest.SurveyId = request.SurveyId.ToString(); try { Interfaces.DataInterfaces.ISurveyResponseDao SurveyResponseDao = new EntitySurveyResponseDao(); Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = new EntitySurveyInfoDao(); BLL.SurveyResponse Implementation = new BLL.SurveyResponse(SurveyResponseDao, ISurveyInfoDao); PreFilledAnswerRequest prefilledanswerRequest = new PreFilledAnswerRequest(); Dictionary <string, string> Values = new Dictionary <string, string>(); prefilledanswerRequest.AnswerInfo.UserPublishKey = request.PublisherKey; prefilledanswerRequest.AnswerInfo.OrganizationKey = request.OrgKey; prefilledanswerRequest.AnswerInfo.SurveyId = request.SurveyId; prefilledanswerRequest.AnswerInfo.UserPublishKey = request.PublisherKey; List <SurveyInfoBO> SurveyBOList = GetSurveyInfo(prefilledanswerRequest); GetRootFormId(prefilledanswerRequest); prefilledanswerRequest.AnswerInfo.SurveyId = request.SurveyId; SurveyControlsResponse = GetSurveyControlsList(surveyControlsRequest); Dictionary <string, string> FilteredAnswerList = new Dictionary <string, string>(); var radiolist = SurveyControlsResponse.SurveyControlList.Where(x => x.ControlType == "GroupBoxRadioList"); FilteredAnswerList = ProcessModforRadioControls(radiolist, request.SurveyQuestionAnswerListField); var checkboxLsit = SurveyControlsResponse.SurveyControlList.Where(x => x.ControlType == "CheckBox"); FilteredAnswerList = ProcessValforCheckBoxControls(checkboxLsit, FilteredAnswerList); var yesNoList = SurveyControlsResponse.SurveyControlList.Where(x => x.ControlType == "YesNo"); FilteredAnswerList = ProcessValforYesNoControls(yesNoList, FilteredAnswerList); var legalvalList = SurveyControlsResponse.SurveyControlList.Where(x => x.ControlType == "LegalValues"); FilteredAnswerList = ProcessValforLegalControls(legalvalList, FilteredAnswerList); foreach (KeyValuePair <string, string> entry in FilteredAnswerList) { Values.Add(entry.Key, entry.Value); } prefilledanswerRequest.AnswerInfo.SurveyQuestionAnswerList = Values; response = Implementation.SetSurveyAnswer(prefilledanswerRequest); return(response); } catch (Exception ex) { PassCodeDTO DTOList = new PassCodeDTO(); response = new PreFilledAnswerResponse(DTOList); if (response.ErrorMessageList != null) { response.ErrorMessageList.Add("Failed", "Failed to insert Response"); } response.Status = ((BLL.SurveyResponse.Message) 1).ToString(); return(response); } }
public SurveyControlsResponse GetSurveyControlsList(SurveyControlsRequest pRequestMessage) { SurveyControlsResponse SurveyControlsResponse = new SurveyControlsResponse(); try { Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = new EntitySurveyInfoDao(); SurveyInfo Implementation = new BLL.SurveyInfo(ISurveyInfoDao); SurveyControlsResponse = Implementation.GetSurveyControlsforApi(pRequestMessage.SurveyId); } catch (Exception ex) { SurveyControlsResponse.Message = "Error"; throw ex; } return(SurveyControlsResponse); }
/// <summary> /// Updates SurveyResponse /// </summary> /// <param name="SurveyResponseApiModel",name="ResponseId"></param> /// <returns>response </returns> public PreFilledAnswerResponse Update(SurveyResponseApiModel request, string ResponseId) { PreFilledAnswerResponse response; SurveyControlsResponse SurveyControlsResponse = new SurveyControlsResponse(); SurveyControlsRequest surveyControlsRequest = new SurveyControlsRequest(); surveyControlsRequest.SurveyId = request.SurveyId.ToString(); try { Interfaces.DataInterfaces.ISurveyResponseDao SurveyResponseDao = new EntitySurveyResponseDao(); Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = new EntitySurveyInfoDao(); BLL.SurveyResponse Implementation = new BLL.SurveyResponse(SurveyResponseDao, ISurveyInfoDao); PreFilledAnswerRequest prefilledanswerRequest = new PreFilledAnswerRequest(); Dictionary <string, string> Values = new Dictionary <string, string>(); prefilledanswerRequest.AnswerInfo.UserPublishKey = request.PublisherKey; prefilledanswerRequest.AnswerInfo.OrganizationKey = request.OrgKey; prefilledanswerRequest.AnswerInfo.SurveyId = request.SurveyId; prefilledanswerRequest.AnswerInfo.UserPublishKey = request.PublisherKey; List <SurveyInfoBO> SurveyBOList = GetSurveyInfo(prefilledanswerRequest); GetRootFormId(prefilledanswerRequest); prefilledanswerRequest.AnswerInfo.SurveyId = request.SurveyId; SurveyControlsResponse = GetSurveyControlsList(surveyControlsRequest); Dictionary <string, string> FilteredAnswerList = new Dictionary <string, string>(); var radiolist = SurveyControlsResponse.SurveyControlList.Where(x => x.ControlType == "GroupBoxRadioList"); FilteredAnswerList = ProcessModforRadioControls(radiolist, request.SurveyQuestionAnswerListField); var checkboxLsit = SurveyControlsResponse.SurveyControlList.Where(x => x.ControlType == "CheckBox"); FilteredAnswerList = ProcessValforCheckBoxControls(checkboxLsit, FilteredAnswerList); var yesNoList = SurveyControlsResponse.SurveyControlList.Where(x => x.ControlType == "YesNo"); FilteredAnswerList = ProcessValforYesNoControls(yesNoList, FilteredAnswerList); var legalvalList = SurveyControlsResponse.SurveyControlList.Where(x => x.ControlType == "LegalValues"); FilteredAnswerList = ProcessValforLegalControls(legalvalList, FilteredAnswerList); var updatedtime = FilteredAnswerList.Where(x => x.Key.ToLower() == "_updatestamp").FirstOrDefault(); var Responsekey = FilteredAnswerList.Where(x => x.Key.ToLower() == "responseid" || x.Key.ToLower() == "id").FirstOrDefault().Key; var fkey = FilteredAnswerList.Where(x => x.Key.ToLower() == "fkey").FirstOrDefault(); foreach (KeyValuePair <string, string> entry in FilteredAnswerList) { Values.Add(entry.Key, entry.Value); } try { var survey = Implementation.GetSurveyResponseById(new List <string> { ResponseId }, request.PublisherKey); } catch (Exception ex) { prefilledanswerRequest.AnswerInfo.SurveyQuestionAnswerList = Values; response = Implementation.SetSurveyAnswer(prefilledanswerRequest); response.Status = "Created"; return(response); } Values.Remove(Responsekey); if (updatedtime.Key != null) { Values.Remove(updatedtime.Key); } if (fkey.Key != null) { Values.Remove(fkey.Key); } prefilledanswerRequest.AnswerInfo.SurveyQuestionAnswerList = Values; Dictionary <string, string> ErrorMessageList = new Dictionary <string, string>(); string Xml = Implementation.CreateResponseXml(prefilledanswerRequest, SurveyBOList); // ErrorMessageList = Implementation.ValidateResponse(SurveyBOList, prefilledanswerRequest); // if (fkey.Key != null) { try { var survey = Implementation.GetSurveyResponseById(new List <string> { fkey.Value }, request.PublisherKey); } catch (Exception ex) { SurveyResponseBO surveyresponsebO = new SurveyResponseBO(); surveyresponsebO.SurveyId = SurveyBOList[0].ParentId; surveyresponsebO.ResponseId = fkey.Value.ToString(); surveyresponsebO.XML = " "; surveyresponsebO.Status = 3; surveyresponsebO.RecrodSourceId = (int)ValidationRecordSourceId.MA; surveyresponsebO.DateUpdated = DateTime.Now; surveyresponsebO.DateCreated = surveyresponsebO.DateUpdated; surveyresponsebO.DateCompleted = surveyresponsebO.DateUpdated; surveyresponsebO = Implementation.InsertSurveyResponseApi(surveyresponsebO); } } if (ErrorMessageList.Count() > 0) { response = new PreFilledAnswerResponse(); response.ErrorMessageList = ErrorMessageList; response.ErrorMessageList.Add("SurveyId", request.SurveyId.ToString()); response.ErrorMessageList.Add("ResponseId", ResponseId); response.Status = ((Epi.Web.BLL.SurveyResponse.Message) 1).ToString(); Implementation.InsertErrorLog(response.ErrorMessageList); } SurveyResponseBO surveyresponseBO = new SurveyResponseBO(); SurveyResponseBO SurveyResponse = new SurveyResponseBO(); UserAuthenticationRequestBO UserAuthenticationRequestBO = new UserAuthenticationRequestBO(); surveyresponseBO.SurveyId = request.SurveyId.ToString(); surveyresponseBO.ResponseId = ResponseId.ToString(); surveyresponseBO.XML = Xml; System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); if (updatedtime.Key != null) { surveyresponseBO.DateUpdated = dateTime.AddMilliseconds(Convert.ToDouble(updatedtime.Value.ToString())).ToLocalTime(); surveyresponseBO.DateCompleted = dateTime.AddMilliseconds(Convert.ToDouble(updatedtime.Value.ToString())).ToLocalTime(); } else { surveyresponseBO.DateUpdated = DateTime.Now; surveyresponseBO.DateCompleted = DateTime.Now; } if (fkey.Key != null) { surveyresponseBO.RelateParentId = fkey.Value; } surveyresponseBO.Status = 3; SurveyResponse = Implementation.UpdateSurveyResponse(surveyresponseBO); UserAuthenticationRequestBO = Web.Common.ObjectMapping.Mapper.ToBusinessObject(ResponseId); Implementation.SavePassCode(UserAuthenticationRequestBO); //return Response string ResponseUrl = ConfigurationManager.AppSettings["ResponseURL"]; response = new PreFilledAnswerResponse(Web.Common.ObjectMapping.Mapper.ToDataTransferObjects(UserAuthenticationRequestBO)); response.SurveyResponseUrl = ResponseUrl + UserAuthenticationRequestBO.ResponseId; response.Status = ((Epi.Web.BLL.SurveyResponse.Message) 2).ToString(); return(response); } catch (Exception ex) { PassCodeDTO DTOList = new PassCodeDTO(); response = new PreFilledAnswerResponse(DTOList); if (response.ErrorMessageList != null) { response.ErrorMessageList.Add("Failed", "Failed to insert Response"); } response.Status = ((BLL.SurveyResponse.Message) 1).ToString(); return(response); } }
public SurveyControlsResponse GetSurveyControlList(SurveyControlsRequest pRequestMessage) { SurveyControlsResponse SurveyControlsResponse = _iSurveyInfoRepository.GetSurveyControlList(pRequestMessage); return(SurveyControlsResponse); }