Example #1
0
 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);
        }
        public List <SourceTableDTO> GetSourceTables(string SurveyId)
        {
            //List<SourceTableBO> list = new List<SourceTableBO>();
            SourceTablesResponse   SourceTables           = new SourceTablesResponse();
            SurveyControlsResponse SurveyControlsResponse = new SurveyControlsResponse();

            try
            {
                Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = new EntitySurveyInfoDao();
                SurveyInfo Implementation = new BLL.SurveyInfo(ISurveyInfoDao);
                SourceTables.List = Common.ObjectMapping.Mapper.ToSourceTableDTO(Implementation.GetSourceTables(SurveyId));
            }
            catch (Exception ex)
            {
                SurveyControlsResponse.Message = "Error";
                throw ex;
            }
            return(SourceTables.List);
        }
Example #5
0
        public SurveyControlsResponse GetSurveyControlList(string SurveyId)
        {
            SurveyControlsResponse SurveyControlsResponse = new SurveyControlsResponse();

            if (!string.IsNullOrEmpty(SurveyId))
            {
                SurveyInfoBO SurveyInfoBO = new SurveyInfoBO();
                try
                {
                    SurveyInfoBO = GetSurveyInfoById(SurveyId);
                }
                catch (Exception ex)
                {
                    SurveyControlsResponse.Message = "Survey doesn’t exist.";
                }
                List <SurveyControlDTO> SurveyControlList = new List <SurveyControlDTO>();
                SurveyControlList = GetSurveyControls(SurveyInfoBO);
                SurveyControlsResponse.SurveyControlList = SurveyControlList;
            }
            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);
            }
        }
Example #7
0
        public string GetSurveyResponseJson(Epi.Web.Common.BusinessObject.SurveyResponseBO surveyAnswer, SurveyControlsResponse List)
        {
            if (!string.IsNullOrEmpty(surveyAnswer.XML))
            {
                ResponseDetail Responsedetail = new ResponseDetail();

                // var ChildFormsHierarchy = FormsHierarchyDTOList.Where(x => x.IsRoot == false);
                Dictionary <string, object> ResponseQA     = new Dictionary <string, object>();
                Dictionary <string, object> RootResponseQA = new Dictionary <string, object>();


                XDocument xdoc          = XDocument.Parse(surveyAnswer.XML);
                int       NumberOfPages = GetNumberOfPags(surveyAnswer.XML);

                Responsedetail.ResponseId = surveyAnswer.ResponseId;
                Responsedetail.FormId     = surveyAnswer.SurveyId;
                //if (FormsHierarchyDTOList.Count() > 0)
                //{
                //    Responsedetail.OKey = FormsHierarchyDTOList[0].SurveyInfo.OrganizationKey.ToString().Substring(0, 8);
                //}
                for (int i = 1; NumberOfPages + 1 > i; i++)
                {
                    try
                    {
                        var _FieldsTypeIDs = from _FieldTypeID in
                                             xdoc.Descendants("Page")

                                             where _FieldTypeID.Attribute("PageNumber").Value == (i).ToString()
                                             select _FieldTypeID;

                        var _PageFieldsTypeIDs = from _FieldTypeID1 in
                                                 _FieldsTypeIDs.Descendants("ResponseDetail")

                                                 select _FieldTypeID1;
                        foreach (var item in _PageFieldsTypeIDs)
                        {
                            if (!string.IsNullOrEmpty(item.Value))
                            {
                                try
                                {
                                    string ControlId        = item.Attribute("QuestionName").Value;
                                    bool   IsCheckBox       = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType == "CheckBox");
                                    bool   ISNumericTextBox = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType == "NumericTextBox");

                                    if (ISNumericTextBox && !string.IsNullOrEmpty(item.Value))
                                    {
                                        string uiSep = ".";
                                        if (item.Value.Contains(uiSep))
                                        {
                                            RootResponseQA.Add(item.Attribute("QuestionName").Value, Convert.ToDecimal(item.Value));
                                        }
                                        else
                                        {
                                            RootResponseQA.Add(item.Attribute("QuestionName").Value, Convert.ToInt64(item.Value));
                                        }
                                    }
                                    else if (IsCheckBox)
                                    {
                                        bool Ischecked = false;
                                        if (item.Value == "Yes")
                                        {
                                            RootResponseQA.Add(item.Attribute("QuestionName").Value, !Ischecked);
                                        }
                                        else
                                        {
                                            RootResponseQA.Add(item.Attribute("QuestionName").Value, Ischecked);
                                        }
                                    }
                                    else
                                    {
                                        RootResponseQA.Add(item.Attribute("QuestionName").Value, item.Value);
                                    }
                                }
                                catch (System.Exception ex)
                                {
                                }
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                    }
                }
                Responsedetail.ResponseQA = RootResponseQA;



                var json = JsonConvert.SerializeObject(Responsedetail);

                return(json);
            }
            else
            {
                return("");
            }
        }
Example #8
0
        public string GetSurveyResponseJson(Epi.Web.Common.DTO.SurveyAnswerDTO surveyAnswer, List <FormsHierarchyDTO> FormsHierarchyDTOList, SurveyControlsResponse List)
        {
            if (!string.IsNullOrEmpty(surveyAnswer.XML))
            {
                ResponseDetail Responsedetail = new ResponseDetail();

                var ChildFormsHierarchy = FormsHierarchyDTOList.Where(x => x.IsRoot == false);
                Dictionary <string, object> ResponseQA     = new Dictionary <string, object>();
                Dictionary <string, object> RootResponseQA = new Dictionary <string, object>();


                XDocument xdoc          = XDocument.Parse(surveyAnswer.XML);
                int       NumberOfPages = GetNumberOfPags(surveyAnswer.XML);

                Responsedetail.ResponseId = surveyAnswer.ResponseId;
                Responsedetail.FormId     = surveyAnswer.SurveyId;
                if (FormsHierarchyDTOList.Count() > 0)
                {
                    Responsedetail.OKey = FormsHierarchyDTOList[0].SurveyInfo.OrganizationKey.ToString().Substring(0, 8);
                }
                for (int i = 1; NumberOfPages + 1 > i; i++)
                {
                    try
                    {
                        var _FieldsTypeIDs = from _FieldTypeID in
                                             xdoc.Descendants("Page")

                                             where _FieldTypeID.Attribute("PageNumber").Value == (i).ToString()
                                             select _FieldTypeID;

                        var _PageFieldsTypeIDs = from _FieldTypeID1 in
                                                 _FieldsTypeIDs.Descendants("ResponseDetail")

                                                 select _FieldTypeID1;
                        foreach (var item in _PageFieldsTypeIDs)
                        {
                            if (!string.IsNullOrEmpty(item.Value))
                            {
                                try
                                {
                                    string ControlId        = item.Attribute("QuestionName").Value;
                                    bool   IsCheckBox       = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType == "CheckBox");
                                    bool   ISNumericTextBox = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType == "NumericTextBox");

                                    if (ISNumericTextBox && !string.IsNullOrEmpty(item.Value))
                                    {
                                        string uiSep = ".";
                                        if (item.Value.Contains(uiSep))
                                        {
                                            RootResponseQA.Add(item.Attribute("QuestionName").Value, Convert.ToDecimal(item.Value));
                                        }
                                        else
                                        {
                                            RootResponseQA.Add(item.Attribute("QuestionName").Value, Convert.ToInt64(item.Value));
                                        }
                                    }
                                    else if (IsCheckBox)
                                    {
                                        bool Ischecked = false;
                                        if (item.Value == "Yes")
                                        {
                                            RootResponseQA.Add(item.Attribute("QuestionName").Value, !Ischecked);
                                        }
                                        else
                                        {
                                            RootResponseQA.Add(item.Attribute("QuestionName").Value, Ischecked);
                                        }
                                    }
                                    else
                                    {
                                        RootResponseQA.Add(item.Attribute("QuestionName").Value, item.Value);
                                    }
                                }
                                catch (System.Exception ex)
                                {
                                }
                            }
                            else
                            {
                                RootResponseQA.Add(item.Attribute("QuestionName").Value, "");
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                    }
                }
                Responsedetail.ResponseQA = RootResponseQA;

                foreach (var child in ChildFormsHierarchy)
                {
                    List <SurveyAnswerDTO> childResponses = child.ResponseIds;
                    foreach (var childresponse in childResponses)
                    {
                        ResponseDetail childresponseDetail = new ResponseDetail();
                        childresponseDetail.FormId           = childresponse.SurveyId;
                        childresponseDetail.ResponseId       = childresponse.ResponseId;
                        childresponseDetail.ParentResponseId = childresponse.RelateParentId;
                        childresponseDetail.ParentFormId     = childresponse.ParentRecordId;
                        ResponseQA = new Dictionary <string, object>();
                        ResponseQA.Add("FKEY", childresponse.RelateParentId);
                        ResponseQA.Add("ResponseId", childresponse.ResponseId);

                        XDocument xdochild           = XDocument.Parse(childresponse.XML);
                        int       NumberOfPagesChild = GetNumberOfPags(childresponse.XML);
                        for (int i = 1; NumberOfPagesChild + 1 > i; i++)
                        {
                            var _FieldsTypeIDs = from _FieldTypeID in
                                                 xdochild.Descendants("Page")

                                                 where _FieldTypeID.Attribute("PageNumber").Value == (i).ToString()
                                                 select _FieldTypeID;

                            var _PageFieldsTypeIDs = from _FieldTypeID1 in
                                                     _FieldsTypeIDs.Descendants("ResponseDetail")

                                                     select _FieldTypeID1;

                            foreach (var item in _PageFieldsTypeIDs)
                            {
                                try
                                {
                                    string ControlId        = item.Attribute("QuestionName").Value;
                                    bool   IsCheckBox       = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType == "CheckBox");
                                    bool   ISNumericTextBox = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType == "NumericTextBox");
                                    if (ISNumericTextBox && item.Value != null)
                                    {
                                        string uiSep = CultureInfo.CurrentUICulture.NumberFormat.NumberDecimalSeparator;
                                        if (item.Value.Contains(uiSep))
                                        {
                                            ResponseQA.Add(item.Attribute("QuestionName").Value, Convert.ToDecimal(item.Value));
                                        }
                                        else
                                        {
                                            ResponseQA.Add(item.Attribute("QuestionName").Value, Convert.ToInt32(item.Value));
                                        }
                                    }
                                    else if (IsCheckBox)
                                    {
                                        bool Ischecked = false;
                                        if (item.Value == "Yes")
                                        {
                                            ResponseQA.Add(item.Attribute("QuestionName").Value, !Ischecked);
                                        }
                                        else
                                        {
                                            ResponseQA.Add(item.Attribute("QuestionName").Value, Ischecked);
                                        }
                                    }
                                    else
                                    {
                                        ResponseQA.Add(item.Attribute("QuestionName").Value, item.Value);
                                    }
                                    ResponseQA.Add(item.Attribute("QuestionName").Value, item.Value);
                                }
                                catch (System.Exception ex)
                                {
                                }
                            }
                        }

                        childresponseDetail.ResponseQA = ResponseQA;
                        Responsedetail.ChildResponseDetailList.Add(childresponseDetail);
                    }
                }

                var json = JsonConvert.SerializeObject(Responsedetail);

                return(json);
            }
            else
            {
                return("");
            }
        }
Example #9
0
        internal static List <PrintModel> SetCommentLegalValues(List <PrintModel> QuestionAnswerList, SurveyControlsResponse List, SurveyInfoModel surveyInfoModel, SourceTablesResponse SourceTables)
        {
            try
            {
                XDocument xdoc = XDocument.Parse(surveyInfoModel.XML);
                var       Node = xdoc.Element("SourceTable");
                if (Node == null)
                {
                    xdoc = Epi.Web.Common.Xml.SurveyXml.AddSourceTableToXml(xdoc, SourceTables.List);
                }
                var CommentLegals = List.SurveyControlList.Where(x => x.ControlType == "CommentLegal");
                if (CommentLegals.Count() > 0)
                {
                    foreach (var item in CommentLegals)
                    {
                        List <string> CommentLegalValues = GetCommentLegalValues(xdoc, item.ControlId);
                        PrintModel    AnswerValue        = QuestionAnswerList.Where(x => x.ControlName == item.ControlId).Single();
                        QuestionAnswerList = SetValues(CommentLegalValues, AnswerValue, QuestionAnswerList);
                    }
                }
            }
            catch (Exception ex) {
                throw ex;
            }

            return(QuestionAnswerList);
        }
Example #10
0
        internal static List <PrintModel> GetQuestionAnswerList(string ResponseXml, SurveyControlsResponse List)
        {
            List <PrintModel> QuestionAnswerList = new List <PrintModel>();
            int NumberOfPages = GetNumberOfPags(ResponseXml);


            XDocument xdoc = XDocument.Parse(ResponseXml);



            for (int i = 1; NumberOfPages + 1 > i; i++)
            {
                var _FieldsTypeIDs = from _FieldTypeID in
                                     xdoc.Descendants("Page")

                                     where _FieldTypeID.Attribute("PageNumber").Value == (i).ToString()
                                     select _FieldTypeID;

                var _PageFieldsTypeIDs = from _FieldTypeID1 in
                                         _FieldsTypeIDs.Descendants("ResponseDetail")

                                         select _FieldTypeID1;


                foreach (var item in _PageFieldsTypeIDs)
                {
                    string ControlId        = item.Attribute("QuestionName").Value;
                    bool   Type             = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType != "Literal" && x.ControlType != "GroupBox");
                    bool   YesNoType        = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType == "YesNo");
                    bool   IsDate           = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType == "Date");
                    bool   ISNumericTextBox = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType == "NumericTextBox");
                    if (Type)
                    {
                        string     Question    = List.SurveyControlList.Single(x => x.ControlId == ControlId).ControlPrompt;
                        string     ControlType = List.SurveyControlList.Single(x => x.ControlId == ControlId).ControlType;
                        PrintModel PrintModel  = new PrintModel();

                        PrintModel.PageNumber  = i;
                        PrintModel.Question    = Question;
                        PrintModel.ControlName = ControlId;
                        PrintModel.ControlType = ControlType;
                        if (YesNoType)
                        {
                            if (item.Value == "1")
                            {
                                PrintModel.Value = "Yes";
                            }
                            else
                            {
                                PrintModel.Value = "No";
                            }
                        }
                        else if (IsDate)
                        {
                            CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
                            string      DateFormat     = currentCulture.DateTimeFormat.ShortDatePattern;
                            DateFormat = DateFormat.Remove(DateFormat.IndexOf("y"), 2);
                            var NewDateFormat = GetRightDateFormat(item.Value, "YYYY-MM-DD", DateFormat);
                            PrintModel.Value = NewDateFormat;
                        }
                        else if (ISNumericTextBox)
                        {
                            string uiSep         = CultureInfo.CurrentUICulture.NumberFormat.NumberDecimalSeparator;
                            string scriptNumeric = "";
                            if (uiSep == ".")
                            {
                                scriptNumeric = item.Value.Replace(',', '.');
                            }
                            if (uiSep == ",")
                            {
                                scriptNumeric = item.Value.Replace('.', ',');
                            }
                            PrintModel.Value = scriptNumeric;
                        }
                        else
                        {
                            PrintModel.Value = item.Value;
                        }

                        QuestionAnswerList.Add(PrintModel);
                    }
                }
            }



            return(QuestionAnswerList);
        }
Example #11
0
        public string GetSurveyResponseJson(Epi.Web.Common.DTO.SurveyAnswerDTO surveyAnswerDTO, List <FormsHierarchyDTO> FormsHierarchyDTOList, SurveyControlsResponse List)
        {
            SurveyResponseJson Implementation = new SurveyResponseJson();

            return(Implementation.GetSurveyResponseJson(surveyAnswerDTO, FormsHierarchyDTOList, List));
        }
Example #12
0
        public SurveyControlsResponse GetSurveyControlList(SurveyControlsRequest pRequestMessage)
        {
            SurveyControlsResponse SurveyControlsResponse = _iSurveyInfoRepository.GetSurveyControlList(pRequestMessage);

            return(SurveyControlsResponse);
        }