Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        public SurveyInfoResponse GetSurveyInfo(SurveyInfoRequest surveyInfoRequest)
        {
            try
            {
                SurveyInfoResponse response = new SurveyInfoResponse(surveyInfoRequest.RequestId);

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

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

                var           criteria     = surveyInfoRequest.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> bo = surveyInfo.GetSurveyInfoById(SurveyIdList);

                response.SurveyInfoList = Mapper.ToDataTransferObject(bo);

                return(response);
            }
            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>
        /// Set (add, update, delete) SurveyInfo value.
        /// </summary>
        /// <param name="request">SurveyInfoRequest request message.</param>
        /// <returns>SurveyInfoRequest response message.</returns>
        public SurveyInfoResponse SetSurveyInfo(SurveyInfoRequest request)
        {
            try
            {
                Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = new EFwcf.EntitySurveyInfoDao();

                Epi.Web.BLL.SurveyInfo Implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao);



                var response = new SurveyInfoResponse(request.RequestId);

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

                // Transform SurveyInfo data transfer object to SurveyInfo business object
                var SurveyInfo = Mapper.ToBusinessObject(request.SurveyInfoList[0]);

                // Validate SurveyInfo business rules

                if (request.Action != "Delete")
                {
                    //if (!SurveyInfo.Validate())
                    //{
                    //    response.Acknowledge = AcknowledgeType.Failure;

                    //    foreach (string error in SurveyInfo.ValidationErrors)
                    //        response.Message += error + Environment.NewLine;

                    //    return response;
                    //}
                }

                // Run within the context of a database transaction. Currently commented out.
                // The Decorator Design Pattern.
                //using (TransactionDecorator transaction = new TransactionDecorator())
                {
                    bool validSurvey = false;
                    //GetSurveyInfoByOrgKey
                    //validSurvey = Implementation.IsSurveyInfoValidByOrgKeyAndPublishKey(SurveyInfo.SurveyId, SurveyInfo.OrganizationKey.ToString(), SurveyInfo.UserPublishKey);
                    validSurvey = Implementation.IsSurveyInfoValidByOrgKey(SurveyInfo.SurveyId, SurveyInfo.OrganizationKey.ToString());

                    Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao entityDaoFactory1 = new EFwcf.EntityOrganizationDao();
                    Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao surveyInfoDao1    = entityDaoFactory1;
                    Epi.Web.BLL.Organization implementation1 = new Epi.Web.BLL.Organization(surveyInfoDao1);
                    bool ISValidOrg = implementation1.ValidateOrganization(SurveyInfo.OrganizationKey.ToString());

                    if (ISValidOrg)
                    {
                        if (validSurvey)
                        {
                            if (request.Action == "Create")
                            {
                                Implementation.InsertSurveyInfo(SurveyInfo);
                                response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo));
                            }
                            else if (request.Action == "Update")
                            {
                                Implementation.UpdateSurveyInfo(SurveyInfo);
                                response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo));
                                response.Message = SurveyInfo.StatusText;
                            }
                            else if (request.Action == "UpdateMode")
                            {
                                Implementation.UpdateSurveyInfo(SurveyInfo);
                                response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo));
                                response.Message = SurveyInfo.StatusText;
                                //ImplementationAdmin.SendEmailToAdmins(SurveyInfo);// This process does not apply for EWE.
                            }
                            else if (request.Action == "Delete")
                            {
                                var criteria = request.Criteria as SurveyInfoCriteria;
                                var survey   = Implementation.GetSurveyInfoById(SurveyInfo.SurveyId);

                                try
                                {
                                    if (Implementation.DeleteSurveyInfo(survey))
                                    {
                                        response.RowsAffected = 1;
                                    }
                                    else
                                    {
                                        response.RowsAffected = 0;
                                    }
                                }
                                catch
                                {
                                    response.RowsAffected = 0;
                                }
                            }
                        }
                        else
                        {
                            response.Message = "SurveyId And/or Publish Key are invalid.";
                        }
                    }
                    else
                    {
                        response.Message = "Organization Key is invalid.";
                    }
                }

                return(response);
            }
            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);
            }
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Set (add, update, delete) SurveyInfo value.
        /// </summary>
        /// <param name="request">SurveyInfoRequest request message.</param>
        /// <returns>SurveyInfoRequest response message.</returns>
        public SurveyInfoResponse SetSurveyInfo(SurveyInfoRequest request)
        {
            try
            {
                Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = new EF.EntitySurveyInfoDao();
                Epi.Web.BLL.SurveyInfo Implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao);


                var response = new SurveyInfoResponse(request.RequestId);

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

                // Transform SurveyInfo data transfer object to SurveyInfo business object
                var SurveyInfo = Mapper.ToBusinessObject(request.SurveyInfoList[0]);

                // Validate SurveyInfo business rules

                if (request.Action != "Delete")
                {
                    //if (!SurveyInfo.Validate())
                    //{
                    //    response.Acknowledge = AcknowledgeType.Failure;

                    //    foreach (string error in SurveyInfo.ValidationErrors)
                    //        response.Message += error + Environment.NewLine;

                    //    return response;
                    //}
                }

                // Run within the context of a database transaction. Currently commented out.
                // The Decorator Design Pattern.
                //using (TransactionDecorator transaction = new TransactionDecorator())
                {
                    if (request.Action == "Create")
                    {
                        if (request.Criteria.FileInputStream == null)
                        {
                            Implementation.InsertSurveyInfo(SurveyInfo);
                            response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo));
                        }
                        else
                        {
                            // Excel
                            string SurveyFile = Implementation.GetSurveyXml(request.Criteria.FileInputStream);
                            SurveyInfo.XML = SurveyFile;
                            Implementation.InsertSurveyInfo(SurveyInfo);
                            response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo));
                        }
                    }
                    else if (request.Action == "Update")
                    {
                        if (request.Criteria.FileInputStream == null)
                        {
                            Implementation.UpdateSurveyInfo(SurveyInfo);
                            response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo));
                        }
                        else
                        {
                            // Excel
                            string SurveyFile = Implementation.GetSurveyXml(request.Criteria.FileInputStream);
                            SurveyInfo.XML = SurveyFile;
                            Implementation.UpdateSurveyInfo(SurveyInfo);
                            response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo));
                        }
                    }
                    else if (request.Action == "Delete")
                    {
                        var criteria = request.Criteria as SurveyInfoCriteria;
                        var survey   = Implementation.GetSurveyInfoById(SurveyInfo.SurveyId);

                        try
                        {
                            if (Implementation.DeleteSurveyInfo(survey))
                            {
                                response.RowsAffected = 1;
                            }
                            else
                            {
                                response.RowsAffected = 0;
                            }
                        }
                        catch
                        {
                            response.RowsAffected = 0;
                        }
                    }
                }

                return(response);
            }
            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);
            }
        }