public bool HasResponse(string SurveyId, string ResponseId)
        {
            SurveyAnswerCriteria SurveyAnswerCriteria = new SurveyAnswerCriteria();

            SurveyAnswerCriteria.SurveyId           = SurveyId;
            SurveyAnswerCriteria.SurveyAnswerIdList = new List <string>();
            SurveyAnswerCriteria.SurveyAnswerIdList.Add(ResponseId);

            return(this.SurveyResponseDao.HasResponse(SurveyAnswerCriteria));
        }
        public List <SurveyResponseBO> GetSurveyResponseById(SurveyAnswerCriteria Criteria, List <SurveyInfoBO> SurveyBOList = null)
        {
            //Check if this Response exists in EWE DataBase
            Guid Id                        = new Guid(Criteria.SurveyAnswerIdList[0]);
            bool ResponseExists            = this.SurveyResponseDao.ISResponseExists(Id);
            List <SurveyResponseBO> result = new List <SurveyResponseBO>();

            if (ResponseExists)
            {
                result = this.SurveyResponseDao.GetSurveyResponse(Criteria.SurveyAnswerIdList, Criteria.UserPublishKey);
            }
            else
            {
                //Get Form Name
                // string
                //Retrieve response data sets from Epi 7 DataBase
                SurveyAnswerCriteria SurveyAnswerCriteria = new Enter.Common.Criteria.SurveyAnswerCriteria();
                SurveyAnswerCriteria.GetAllColumns = true;
                SurveyAnswerCriteria.SurveyId      = Criteria.SurveyId;
                SurveyAnswerCriteria.SurveyAnswerIdList.Add(Criteria.SurveyAnswerIdList[0]);
                SurveyAnswerCriteria.PageSize     = 1;
                SurveyAnswerCriteria.PageNumber   = 1;
                SurveyAnswerCriteria.IsSqlProject = Criteria.IsSqlProject;
                result = this.SurveyResponseDao.GetFormResponseByFormId(SurveyAnswerCriteria);
                if (result[0].SqlData != null)
                {
                    var DataList = result[0].SqlData.ToList();
                    DataList.RemoveAt(0);

                    //Build Response Xml
                    PreFilledAnswerRequest Request = new PreFilledAnswerRequest();
                    Request.AnswerInfo.ResponseId = new Guid(Criteria.SurveyAnswerIdList[0]);
                    Request.AnswerInfo.SurveyId   = new Guid(Criteria.SurveyId);
                    Request.AnswerInfo.UserId     = Criteria.UserId;
                    Request.AnswerInfo.SurveyQuestionAnswerList = new Dictionary <string, string>();
                    foreach (var item in DataList)
                    {
                        Request.AnswerInfo.SurveyQuestionAnswerList.Add(item.Key, item.Value);
                    }

                    //  Request.AnswerInfo.OrganizationKey = new Guid ( "a4b6a687-610d-442a-a80c-d1c781087181");
                    var response = SetSurveyAnswer(Request);
                }
                // string Xml = CreateResponseXml(  Request,  SurveyBOList);

                //Insert response xml into EWE

                result = this.SurveyResponseDao.GetSurveyResponse(Criteria.SurveyAnswerIdList, Criteria.UserPublishKey);
            }
            return(result);
        }
        public List <SurveyResponseBO> GetFormResponseListById(SurveyAnswerCriteria criteria)
        {
            List <SurveyResponseBO> result = null;

            //int PageSize;
            if (criteria.IsMobile)
            {
                criteria.PageSize = Int32.Parse(ConfigurationManager.AppSettings["RESPONSE_PAGE_SIZE_Mobile"]);
            }
            else
            {
                criteria.PageSize = Int32.Parse(ConfigurationManager.AppSettings["RESPONSE_PAGE_SIZE"]);
            }
            result = this.SurveyResponseDao.GetFormResponseByFormId(criteria);
            return(result);
        }
示例#4
0
        public List <SurveyResponseBO> GetFormResponseListById(SurveyAnswerCriteria criteria)
        {
            List <SurveyResponseBO> result = null;

            //int PageSize;
            if (criteria.IsMobile)
            {
                criteria.PageSize = AppSettings.GetIntValue(AppSettings.Key.MobileResponsePageSize);
            }
            else
            {
                criteria.PageSize = AppSettings.GetIntValue(AppSettings.Key.ResponsePageSize);
            }
            result = this.SurveyResponseDao.GetFormResponseByFormId(criteria);
            return(result);
        }
        public int GetNumberOfPages(SurveyAnswerCriteria Criteria)
        {
            //int PageSize;
            if (Criteria.IsMobile)
            {
                Criteria.PageSize = Int32.Parse(ConfigurationManager.AppSettings["RESPONSE_PAGE_SIZE_Mobile"]);
            }
            else
            {
                Criteria.PageSize = Int32.Parse(ConfigurationManager.AppSettings["RESPONSE_PAGE_SIZE"]);
            }
            int result = this.SurveyResponseDao.GetFormResponseCount(Criteria);

            if (Criteria.PageSize > 0)
            {
                result = (result + Criteria.PageSize - 1) / Criteria.PageSize;
            }
            return(result);
        }
示例#6
0
        public SurveyAnswerResponse GetFormResponseList(SurveyAnswerRequest surveyAnswerRequest)
        {
            try
            {
                SurveyAnswerResponse result = new SurveyAnswerResponse(surveyAnswerRequest.RequestId);

                SurveyResponseProvider surveyResponseImplementation = new SurveyResponseProvider(_surveyResponseDao);

                SurveyAnswerCriteria criteria = surveyAnswerRequest.Criteria;
                criteria.GridPageSize = AppSettings.GetIntValue(criteria.IsMobile ? AppSettings.Key.MobileResponsePageSize : AppSettings.Key.ResponsePageSize);

                ResponseGridQueryResultBO responseGridQueryResultBO = surveyResponseImplementation.GetFormResponseListByFormId(surveyAnswerRequest.ResponseContext, criteria);
                //Query The number of records
                result.NumberOfResponses        = responseGridQueryResultBO.NumberOfResponsesReturnedByQuery;
                result.NumberOfPages            = responseGridQueryResultBO.NumberOfPages;
                result.NumberOfResponsesPerPage = responseGridQueryResultBO.NumberOfResponsesPerPage;
                result.QuerySetToken            = responseGridQueryResultBO.QuerySetToken;

                var surveyResponseList = responseGridQueryResultBO.SurveyResponseBOList;
                result.SurveyResponseList = surveyResponseList.ToSurveyAnswerDTOList();

                surveyAnswerRequest.Criteria.FormResponseCount = result.NumberOfResponses;

                //Query The number of records
                //result.NumberOfPages = surveyResponseImplementation.GetNumberOfPages(surveyAnswerRequest.Criteria);

                //Get form info
                Epi.Cloud.BLL.FormInfo formInfoImplementation = new Epi.Cloud.BLL.FormInfo(_formInfoDao);
                var formInfoBO = formInfoImplementation.GetFormInfoByFormId(surveyAnswerRequest.Criteria.SurveyId, surveyAnswerRequest.Criteria.UserId);
                result.FormInfo = formInfoBO.ToFormInfoDTO();

                return(result);
            }
            catch (Exception ex)
            {
                CustomFaultException customFaultException = new CustomFaultException();
                customFaultException.CustomMessage = ex.Message;
                customFaultException.Source        = ex.Source;
                customFaultException.StackTrace    = ex.StackTrace;
                customFaultException.HelpLink      = ex.HelpLink;
                return(null);
            }
        }
        public List <SurveyResponseBO> GetResponsesByRelatedFormId(string ResponseId, SurveyAnswerCriteria Criteria)
        {
            List <SurveyResponseBO> SurveyResponseBO = new List <SurveyResponseBO>();

            SurveyResponseBO = this.SurveyResponseDao.GetResponsesByRelatedFormId(ResponseId, Criteria);


            return(SurveyResponseBO);
        }
        public int GetNumberOfResponses(SurveyAnswerCriteria Criteria)
        {
            int result = this.SurveyResponseDao.GetFormResponseCount(Criteria);

            return(result);
        }
        public ResponseGridQueryResultBO GetFormResponseListByFormId(IResponseContext responseContext, SurveyAnswerCriteria criteria)
        {
            criteria.GridPageSize = AppSettings.GetIntValue(criteria.IsMobile ? AppSettings.Key.MobileResponsePageSize : AppSettings.Key.ResponsePageSize);
            ResponseGridQueryResultBO result = _surveyResponseDao.GetFormResponseByFormId(responseContext, criteria);

            return(result);
        }
        public List <SurveyResponseBO> GetSurveyResponseById(IResponseContext responseContext, SurveyAnswerCriteria criteria, List <SurveyInfoBO> surveyBOList = null)
        {
            List <SurveyResponseBO> result = _surveyResponseDao.GetSurveyResponse(responseContext);

            return(result);
        }
        public int GetNumberOfResponses(SurveyAnswerCriteria criteria)
        {
            int result = _surveyResponseDao.GetFormResponseCount(criteria.SurveyId);

            return(result);
        }
示例#12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        public SurveyAnswerResponse GetFormResponseList(SurveyAnswerRequest pRequest)
        {
            try
            {
                SurveyAnswerResponse result = new SurveyAnswerResponse(pRequest.RequestId);


                Epi.Web.Interfaces.DataInterfaces.IDaoFactory        entityDaoFactory   = new EF.EntityDaoFactory();
                Epi.Web.Interfaces.DataInterfaces.ISurveyResponseDao ISurveyResponseDao = entityDaoFactory.SurveyResponseDao;
                Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao     ISurveyInfoDao     = entityDaoFactory.SurveyInfoDao;
                Epi.Web.BLL.SurveyResponse Implementation = new Epi.Web.BLL.SurveyResponse(ISurveyResponseDao, ISurveyInfoDao);

                SurveyAnswerCriteria criteria = pRequest.Criteria;
                //result.SurveyResponseList = Mapper.ToDataTransferObject(Implementation.GetFormResponseListById(pRequest.Criteria.SurveyId, pRequest.Criteria.PageNumber, pRequest.Criteria.IsMobile));
                result.SurveyResponseList = Mapper.ToDataTransferObject(Implementation.GetFormResponseListById(criteria));//Pain point
                //Query The number of records

                //result.NumberOfPages = Implementation.GetNumberOfPages(pRequest.Criteria.SurveyId, pRequest.Criteria.IsMobile);
                //result.NumberOfResponses = Implementation.GetNumberOfResponses(pRequest.Criteria.SurveyId);

                result.NumberOfPages     = Implementation.GetNumberOfPages(pRequest.Criteria);
                result.NumberOfResponses = Implementation.GetNumberOfResponses(pRequest.Criteria);

                //Get form info
                //Interfaces.DataInterface.IFormInfoDao surveyInfoDao = new EF.EntityFormInfoDao();
                //Epi.Web.BLL.FormInfo ImplementationFormInfo = new Epi.Web.BLL.FormInfo(surveyInfoDao);
                //result.FormInfo = Mapper.ToFormInfoDTO(ImplementationFormInfo.GetFormInfoByFormId(pRequest.Criteria.SurveyId, false, pRequest.Criteria.UserId));


                SurveyInfoResponse response = new SurveyInfoResponse(pRequest.RequestId);


                Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = entityDaoFactory.SurveyInfoDao;
                Epi.Web.BLL.SurveyInfo surveyInfo = new Epi.Web.BLL.SurveyInfo(surveyInfoDao);

                if (!ValidRequest(pRequest, response, Validate.All))
                {
                    return(result);
                }


                List <string> SurveyIdList = new List <string>();

                SurveyIdList.Add(pRequest.Criteria.SurveyId.ToUpper());

                List <SurveyInfoBO> bo = surveyInfo.GetSurveyInfoById(SurveyIdList);

                result.SurveyInfo = Mapper.ToDataTransferObject(bo)[0];



                return(result);
            }
            catch (Exception ex)
            {
                CustomFaultException customFaultException = new CustomFaultException();
                customFaultException.CustomMessage = ex.Message;
                customFaultException.Source        = ex.Source;
                customFaultException.StackTrace    = ex.StackTrace;
                customFaultException.HelpLink      = ex.HelpLink;
                throw new FaultException <CustomFaultException>(customFaultException);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        public SurveyAnswerResponse GetSurveyAnswer(SurveyAnswerRequest pRequest)
        {
            try
            {
                SurveyAnswerResponse result = new SurveyAnswerResponse(pRequest.RequestId);
                //Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyResponseDao surveyInfoDao = new EF.EntitySurveyResponseDao();
                //Epi.Web.BLL.SurveyResponse Implementation = new Epi.Web.BLL.SurveyResponse(surveyInfoDao);

                Epi.Web.Enter.Interfaces.DataInterfaces.IDaoFactory        entityDaoFactory   = new EF.EntityDaoFactory();
                Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyResponseDao ISurveyResponseDao = entityDaoFactory.SurveyResponseDao;
                Epi.Web.BLL.SurveyResponse Implementation = new Epi.Web.BLL.SurveyResponse(ISurveyResponseDao);



                //Get Organization Info
                Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao entityDaoFactory1 = new EF.EntityOrganizationDao();
                //Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = entityDaoFactory.SurveyInfoDao;
                Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao surveyInfoDao1 = entityDaoFactory1;

                Epi.Web.BLL.Organization implementation1 = new Epi.Web.BLL.Organization(surveyInfoDao1);

                bool ISValidOrg = implementation1.ValidateOrganization(pRequest.Criteria.OrganizationKey.ToString());



                if (ISValidOrg)

                {
                    // Validate client tag, access token, and user credentials
                    if (!ValidRequest(pRequest, result, Validate.All))
                    {
                        return(result);
                    }

                    SurveyAnswerCriteria criteria = pRequest.Criteria;


                    if (criteria.UserPublishKey == null)
                    {
                        return(result);
                    }


                    Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = new EF.EntitySurveyInfoDao();
                    Epi.Web.BLL.SurveyInfo SurveyInfo = new Epi.Web.BLL.SurveyInfo(surveyInfoDao);



                    //List<string> SurveyIdList = new List<string>();

                    //SurveyIdList.Add(criteria.SurveyId);


                    bool validSurvey = false;
                    // if (string.IsNullOrEmpty(criteria.SurveyId.ToString()))
                    // {
                    validSurvey = SurveyInfo.IsSurveyInfoValidByOrgKeyAndPublishKey(criteria.SurveyId, criteria.OrganizationKey.ToString(), criteria.UserPublishKey, criteria.UserId);

                    //}

                    if (validSurvey == true)
                    {
                        //Guid UserPublishKey = SurveyInfo.GetSurveyInfoById(criteria.SurveyId).UserPublishKey;

                        //if (criteria.UserPublishKey != UserPublishKey)
                        //{
                        //    return result;
                        //}


                        List <string> IdList = new List <string>();

                        foreach (string id in criteria.SurveyAnswerIdList)
                        {
                            IdList.Add(id.ToUpper());
                        }
                        //string sort = criteria.SortExpression;

                        //if (request.LoadOptions.Contains("SurveyInfos"))
                        //{
                        //    IEnumerable<SurveyInfoDTO> SurveyInfos;
                        //    if (!criteria.IncludeOrderStatistics)
                        //    {
                        //        SurveyInfos = Implementation.GetSurveyInfos(sort);
                        //    }
                        //    else
                        //    {
                        //        SurveyInfos = Implementation.GetSurveyInfosWithOrderStatistics(sort);
                        //    }

                        //    response.SurveyInfos = SurveyInfos.Select(c => Mapper.ToDataTransferObject(c)).ToList();
                        //}

                        int ResponseMaxSize = Int32.Parse(ConfigurationManager.AppSettings["maxBytesPerRead"]);

                        int BandwidthUsageFactor = Int32.Parse(ConfigurationManager.AppSettings["BandwidthUsageFactor"]);

                        if (pRequest.Criteria.ReturnSizeInfoOnly == true)
                        {
                            // call BLL with a list of records

                            PageInfoBO PageInfoBO = Implementation.GetResponseSurveySize(IdList, criteria.SurveyId, criteria.DateCompleted, BandwidthUsageFactor, criteria.IsDraftMode, criteria.StatusId, -1, -1, ResponseMaxSize);



                            result.PageSize      = PageInfoBO.PageSize;
                            result.NumberOfPages = PageInfoBO.NumberOfPages;
                        }
                        else
                        {
                            List <SurveyResponseBO> SurveyResponseBOList = Implementation.GetSurveyResponse
                                                                           (
                                IdList,
                                criteria.SurveyId,
                                criteria.DateCompleted,
                                criteria.StatusId,
                                criteria.IsDraftMode
                                                                           );



                            foreach (SurveyResponseBO surveyResponseBo in SurveyResponseBOList)
                            {
                                // if (surveyResponseBo.UserPublishKey == criteria.UserPublishKey)
                                //if (UserPublishKey == criteria.UserPublishKey)
                                //{
                                result.SurveyResponseList.Add(Mapper.ToDataTransferObject(surveyResponseBo));
                                //  }
                            }
                        }

                        /*
                         * if (string.IsNullOrEmpty(pRequest.Criteria.SurveyId))
                         * {
                         *  result.SurveyResponseList = Mapper.ToDataTransferObject(Implementation.GetSurveyResponseById(pRequest.Criteria.SurveyAnswerIdList));
                         * }
                         * else
                         * {
                         *  result.SurveyResponseList = Mapper.ToDataTransferObject(Implementation.GetSurveyResponseBySurveyId(pRequest.Criteria.SurveyAnswerIdList));
                         * }*/
                    }
                    else
                    {
                        if (criteria.UserId != -1 && criteria.UserPublishKey == Guid.Empty)
                        {
                            result.Message = "InvalidUserId";
                        }
                        if (criteria.UserId == -1 && criteria.UserPublishKey != Guid.Empty)
                        {
                            result.Message = "InvalidPublishKey";
                        }
                    }
                }
                else
                {
                    result.Message = "Organization Key not found";
                }

                return(result);
            }
            catch (Exception ex)
            {
                CustomFaultException customFaultException = new CustomFaultException();
                customFaultException.CustomMessage = ex.Message;
                customFaultException.Source        = ex.Source;
                customFaultException.StackTrace    = ex.StackTrace;
                customFaultException.HelpLink      = ex.HelpLink;
                throw new FaultException <CustomFaultException>(customFaultException);
            }
        }