Exemple #1
0
        //SurveyInfoBO
        public static PageInfoBO GetSurveySize(List <SurveyInfoBO> resultRows, int BandwidthUsageFactor, int ResponseMaxSize = -1)
        {
            PageInfoBO result = new PageInfoBO();

            int     NumberOfRows           = 0;
            int     ResponsesTotalsize     = 0;
            decimal AvgResponseSize        = 0;
            decimal NumberOfResponsPerPage = 0;

            if (resultRows.Count > 0)
            {
                NumberOfRows       = resultRows.Count;
                ResponsesTotalsize = (int)resultRows.Select(x => x.TemplateXMLSize).Sum();

                AvgResponseSize = (int)resultRows.Select(x => x.TemplateXMLSize).Average();
                // NumberOfResponsPerPage = (int)Math.Ceiling((ResponseMaxSize * (BandwidthUsageFactor / 100)) / AvgResponseSize);

                NumberOfResponsPerPage = (int)Math.Ceiling((int)(ResponseMaxSize * (BandwidthUsageFactor * 0.01)) / AvgResponseSize);

                result.PageSize      = (int)Math.Ceiling(NumberOfResponsPerPage);
                result.NumberOfPages = (int)Math.Ceiling(NumberOfRows / NumberOfResponsPerPage);
            }



            return(result);
        }
        public PageInfoBO GetResponseSurveySize(List <string> SurveyResponseIdList, string SurveyId, DateTime pClosingDate, int BandwidthUsageFactor, bool IsDraftMode = false, int pSurveyType = -1, int pPageNumber = -1, int pPageSize = -1, int pResponseMaxSize = -1)
        {
            List <SurveyResponseBO> SurveyResponseBOList = this.SurveyResponseDao.GetSurveyResponseSize(SurveyResponseIdList, SurveyId, pClosingDate, IsDraftMode, pSurveyType, pPageNumber, pPageSize, pResponseMaxSize);
            PageInfoBO result = new PageInfoBO();

            result = Epi.Web.BLL.Common.GetSurveySize(SurveyResponseBOList, BandwidthUsageFactor, pResponseMaxSize);
            return(result);
        }
        public PageInfoBO GetSurveyResponseSize(List <string> SurveyResponseIdList, Guid UserPublishKey, int BandwidthUsageFactor, int PageNumber = -1, int PageSize = -1, int ResponseMaxSize = -1)
        {
            List <SurveyResponseBO> SurveyResponseBOList = this.SurveyResponseDao.GetSurveyResponseSize(SurveyResponseIdList, UserPublishKey, PageNumber, PageSize, ResponseMaxSize);

            PageInfoBO result = new PageInfoBO();

            result = Epi.Web.BLL.Common.GetSurveySize(SurveyResponseBOList, BandwidthUsageFactor, ResponseMaxSize);
            return(result);
        }
Exemple #4
0
        public PageInfoBO GetSurveySizeInfo(List <string> pIdList, int BandwidthUsageFactor, int pResponseMaxSize = -1)
        {
            List <SurveyInfoBO> SurveyInfoBOList = this.SurveyInfoDao.GetSurveySizeInfo(pIdList, -1, -1, pResponseMaxSize);

            PageInfoBO result = new PageInfoBO();

            result = GetSurveySize(SurveyInfoBOList, BandwidthUsageFactor, pResponseMaxSize);
            return(result);
        }
Exemple #5
0
        public PageInfoBO GetSurveySizeInfo(List <string> SurveyInfoIdList, DateTime pClosingDate, string Okey, int BandwidthUsageFactor, int pSurveyType = -1, int pPageNumber = -1, int pPageSize = -1, int pResponseMaxSize = -1)
        {
            string EncryptedKey = Cryptography.Encrypt(Okey);

            List <SurveyInfoBO> SurveyInfoBOList = this.SurveyInfoDao.GetSurveySizeInfo(SurveyInfoIdList, pClosingDate, EncryptedKey, pSurveyType, pPageNumber, pPageSize, pResponseMaxSize);

            PageInfoBO result = new PageInfoBO();

            result = Epi.Web.SurveyAPI.BLL.Common.GetSurveySize(SurveyInfoBOList, BandwidthUsageFactor, pResponseMaxSize);
            return(result);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        public SurveyInfoResponse GetSurveyInfo(SurveyInfoRequest pRequest)
        {
            try
            {
                SurveyInfoResponse result = new SurveyInfoResponse(pRequest.RequestId);
                //Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = new EF.EntitySurveyInfoDao();
                //Epi.Web.BLL.SurveyInfo implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao);

                Epi.Web.Enter.Interfaces.DataInterfaces.IDaoFactory    entityDaoFactory = new EFwcf.EntityDaoFactory();
                Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao    = entityDaoFactory.SurveyInfoDao;
                Epi.Web.BLL.SurveyInfo implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao);

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

                //Validate UserPublishKey exists
                if (pRequest.Criteria.UserPublishKey == null)
                {
                    return(result);
                }

                var           criteria     = pRequest.Criteria as SurveyInfoCriteria;
                string        sort         = criteria.SortExpression;
                List <string> SurveyIdList = new List <string>();
                foreach (string id in criteria.SurveyIdList)
                {
                    SurveyIdList.Add(id.ToUpper());
                }



                List <SurveyInfoBO> SurveyBOList = new List <SurveyInfoBO>();
                //  int ResponseMaxSize = 16384;
                int ResponseMaxSize      = Int32.Parse(ConfigurationManager.AppSettings["maxBytesPerRead"]);
                int BandwidthUsageFactor = Int32.Parse(ConfigurationManager.AppSettings["BandwidthUsageFactor"]);


                Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao entityDaoFactory1 = new EFwcf.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)
                {
                    if (pRequest.Criteria.ReturnSizeInfoOnly == true)
                    {
                        // add BandwidthUsageFactor
                        PageInfoBO PageInfoBO = implementation.GetSurveySizeInfo(SurveyIdList, criteria.ClosingDate, criteria.OrganizationKey.ToString(), BandwidthUsageFactor, criteria.SurveyType, criteria.PageNumber, criteria.PageSize, ResponseMaxSize);
                        result.PageSize      = PageInfoBO.PageSize;
                        result.NumberOfPages = PageInfoBO.NumberOfPages;
                    }
                    else
                    {
                        SurveyBOList = implementation.GetSurveyInfo(SurveyIdList, criteria.ClosingDate, criteria.OrganizationKey.ToString(), criteria.SurveyType, criteria.PageNumber, criteria.PageSize);//Default
                        foreach (SurveyInfoBO surveyInfoBO in SurveyBOList)
                        {
                            result.SurveyInfoList.Add(Mapper.ToDataTransferObject(surveyInfoBO));
                        }
                    }
                }
                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);
            }
        }
        /// <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);
            }
        }