public PublishReportResponse PublishReport(PublishReportRequest Request) { try { PublishReportResponse result = new PublishReportResponse(); Epi.Web.Interfaces.DataInterfaces.IReportDao IReportDao = new EF.EntityReportDao(); Epi.Web.BLL.Report Implementation = new Epi.Web.BLL.Report(IReportDao); ReportInfoBO ReportInfoBO = Mapper.ToReportInfoBO(Request.ReportInfo); Implementation.PublishReport(ReportInfoBO); result.Message = "The report was successfully published"; var ReportInfo = new ReportInfoDTO(); ReportInfo.ReportURL = ConfigurationManager.AppSettings["ReportURL"] + Request.ReportInfo.ReportId; result.Reports = new List <ReportInfoDTO>(); result.Reports.Add(ReportInfo); 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 CacheDependencyResponse GetCacheDependencyInfo(CacheDependencyRequest cacheDependencyRequest) { try { List <string> surveyKeys = cacheDependencyRequest.Criteria.SurveyIdList; CacheDependencyResponse response = new CacheDependencyResponse(surveyKeys); Epi.Web.Interfaces.DataInterfaces.IDaoFactory entityDaoFactory = new EF.EntityDaoFactory(); Epi.Web.Interfaces.DataInterfaces.ICacheDependencyInfoDao cacheDependencyInfoDao = entityDaoFactory.CacheDependencyInfoDao; Epi.Web.BLL.CacheDependencyInfo cacheDependencyInfo = new Epi.Web.BLL.CacheDependencyInfo(cacheDependencyInfoDao); List <CacheDependencyBO> bo = cacheDependencyInfo.GetCacheDependencyInfo(surveyKeys); List <CacheDependencyDTO> dto = Mapper.ToDataTransferObject(bo); Dictionary <string, DateTime> dictionary = new Dictionary <string, DateTime>(); foreach (CacheDependencyDTO item in dto) { dictionary.Add(item.SurveyId, item.LastUpdate); } response.SurveyDependency = dictionary; 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); } }
public PublishReportResponse DeleteReport(PublishReportRequest Request) { try { PublishReportResponse result = new PublishReportResponse(); Epi.Web.Interfaces.DataInterfaces.IReportDao IReportDao = new EF.EntityReportDao(); Epi.Web.BLL.Report Implementation = new Epi.Web.BLL.Report(IReportDao); ReportInfoBO ReportInfoBO = Mapper.ToReportInfoBO(Request.ReportInfo); Implementation.DeleteReport(ReportInfoBO); result.Message = "The report was successfully Deleted"; 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="pRequestMessage"></param> /// <returns></returns> public PublishResponse PublishSurvey(PublishRequest pRequest) { try { PublishResponse result = new PublishResponse(pRequest.RequestId); Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyInfoDao SurveyInfoDao = new EFwcf.EntitySurveyInfoDao(); Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao OrganizationDao = new EFwcf.EntityOrganizationDao(); Epi.Web.BLL.Publisher Implementation = new Epi.Web.BLL.Publisher(SurveyInfoDao, OrganizationDao); SurveyInfoBO surveyInfoBO = Mapper.ToBusinessObject(pRequest.SurveyInfo); SurveyRequestResultBO surveyRequestResultBO = Implementation.PublishSurvey(surveyInfoBO); result.PublishInfo = Mapper.ToDataTransferObject(surveyRequestResultBO); 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); } }
public PublishReportResponse GetSurveyReport(PublishReportRequest publishReportRequest) { PublishReportResponse PublishReportResponse = new PublishReportResponse(); try { Epi.Web.Interfaces.DataInterfaces.IReportDao IReportDao = new EF.EntityReportDao(); Epi.Web.BLL.Report Implementation = new Epi.Web.BLL.Report(IReportDao); var Result = Implementation.GetReport(publishReportRequest.ReportInfo.ReportId.ToString()); foreach (var item in Result) { PublishReportResponse.Reports.Add(Mapper.ToReportInfoDTO(item)); } return(PublishReportResponse); } 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); } }
public void UpdateResponseStatus(SurveyAnswerRequest request) { try { Epi.Web.Interfaces.DataInterfaces.ISurveyResponseDao SurveyResponseDao = new EF.EntitySurveyResponseDao(); Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = new EF.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyResponse Implementation = new Epi.Web.BLL.SurveyResponse(SurveyResponseDao, ISurveyInfoDao); //SurveyAnswerResponse response = new SurveyAnswerResponse(request.RequestId); SurveyResponseBO SurveyResponse = Mapper.ToSurveyResponseBOList(request.SurveyAnswerList, request.Criteria.UserId)[0]; List <SurveyResponseBO> SurveyResponseBOList = Implementation.GetSurveyResponseById(request.Criteria.SurveyAnswerIdList, Guid.Empty); SurveyResponseBO ResultList = Implementation.UpdateSurveyResponse(SurveyResponse); } 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); } }
public SurveyInfoResponse GetFormChildInfo(SurveyInfoRequest pRequest) { try { SurveyInfoResponse result = new SurveyInfoResponse(pRequest.RequestId); Epi.Web.Interfaces.DataInterfaces.IDaoFactory entityDaoFactory = new EF.EntityDaoFactory(); Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = entityDaoFactory.SurveyInfoDao; Epi.Web.BLL.SurveyInfo implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao); Dictionary <string, int> ParentIdList = new Dictionary <string, int>(); foreach (var item in pRequest.SurveyInfoList) { ParentIdList.Add(item.SurveyId, item.ViewId); } result.SurveyInfoList = Mapper.ToDataTransferObject(implementation.GetChildInfoByParentId(ParentIdList)); 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.Interfaces.DataInterfaces.ISurveyResponseDao surveyInfoDao = new EF.EntitySurveyResponseDao(); //Epi.Web.BLL.SurveyResponse Implementation = new Epi.Web.BLL.SurveyResponse(surveyInfoDao); 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); // Validate client tag, access token, and user credentials if (!ValidRequest(pRequest, result, Validate.All)) { return(result); } var criteria = pRequest.Criteria as SurveyAnswerCriteria; 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(); //} //if (pRequest.LoadOptions.Contains("SurveyInfo")) //{ List <SurveyResponseBO> List = Implementation.GetSurveyResponseById(pRequest.Criteria.SurveyAnswerIdList, pRequest.Criteria.UserPublishKey); result.SurveyResponseList = Mapper.ToDataTransferObject(List); //} 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); } }
public OrganizationResponse UpdateOrganizationInfo(OrganizationRequest request) { try { Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao IOrganizationDao = new EF.EntityOrganizationDao(); Epi.Web.BLL.Organization Implementation = new Epi.Web.BLL.Organization(IOrganizationDao); // Transform SurveyInfo data transfer object to SurveyInfo business object var Organization = Mapper.ToBusinessObject(request.Organization); var response = new OrganizationResponse(request.RequestId); // Validate client tag, access token, and user credentials if (Epi.Web.BLL.Common.ValidateAdmin(request.AdminSecurityKey.ToString())) { if (!ValidRequest(request, response, Validate.All)) { return(response); } if (Implementation.OrganizationNameExists(Organization.Organization, Organization.OrganizationKey, "Update")) { response.Message = "Organization name exists"; } else { var success = Implementation.UpdateOrganizationInfo(Organization); if (success) { response.Message = "Successfully added organization Key"; } else { response.Message = "Error"; return(response); } } return(response); } else { response.Message = "Invalid Admin Key"; 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); } }
public OrganizationResponse GetOrganizationByKey(OrganizationRequest request) { try { Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao IOrganizationDao = new EFwcf.EntityOrganizationDao(); Epi.Web.BLL.Organization Implementation = new Epi.Web.BLL.Organization(IOrganizationDao); // Transform SurveyInfo data transfer object to SurveyInfo business object OrganizationBO Organization = Mapper.ToBusinessObject(request.Organization); var response = new OrganizationResponse(request.RequestId); if (Epi.Web.BLL.Common.ValidateAdmin(request.AdminSecurityKey.ToString())) { // Validate client tag, access token, and user credentials if (!ValidRequest(request, response, Validate.All)) { return(response); } OrganizationBO OrganizationBO = Implementation.GetOrganizationByKey(Organization.OrganizationKey.ToString()); response.OrganizationList = new List <OrganizationDTO>(); (response.OrganizationList).Add(Mapper.ToDataTransferObjects(OrganizationBO)); return(response); } else { response.Message = "Invalid Admin Key"; 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); } }
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); } }
private List <AdminBO> GetOrganizationAdmins(SurveyInfoBO request) { List <AdminBO> AdminBOList = new List <AdminBO>(); try { Epi.Web.Interfaces.DataInterfaces.IAdminDao AdminDao = new EF.EntityAdminDao(); Epi.Web.BLL.Admin Implementation = new Epi.Web.BLL.Admin(AdminDao); AdminBOList = Implementation.GetAdminInfoByOrgKey(request.OrganizationKey.ToString()); } catch (Exception ex) { CustomFaultException customFaultException = new CustomFaultException(); customFaultException.CustomMessage = ex.Message; customFaultException.Source = ex.Source; customFaultException.StackTrace = ex.StackTrace; customFaultException.HelpLink = ex.HelpLink; } return(AdminBOList); }
/// <summary> /// Publish MetaData to Cloud /// </summary> /// <param name="pRequestMessage"></param> /// <returns></returns> public PublishResponse MetaDataToCloud(PublishRequest pRequest) { bool pCloud = true; MetaDataToCloud _publishMetaDataToCloud = new MetaDataToCloud(); try { //pRequest.RequestId = "2"; PublishResponse result = new PublishResponse(pRequest.RequestId); if (pCloud) { //Stop Web Job if (_publishMetaDataToCloud.StartAndStopWebJob(Constant.WebJob.Stop)) { //Update SurveyMetaData table in Cloud Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyInfoDao SurveyInfoDao = new EFwcf.EntitySurveyInfoDao(); Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao OrganizationDao = new EFwcf.EntityOrganizationDao(); Epi.Web.BLL.Publisher Implementation = new Epi.Web.BLL.Publisher(SurveyInfoDao, OrganizationDao); SurveyInfoBO surveyInfoBO = Mapper.ToBusinessObject(pRequest.SurveyInfo); SurveyRequestResultBO surveyRequestResultBO = Implementation.PublishSurvey(surveyInfoBO); result.PublishInfo = Mapper.ToDataTransferObject(surveyRequestResultBO); EpiCloudOperation(); } } else { } 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 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); } }
public bool IsValidOrgKey(SurveyInfoRequest request) { try { bool validSurvey = false; //var SurveyInfo = Mapper.ToBusinessObject(request.SurveyInfoList[0]); if (request.Criteria.SurveyIdList.Count == 0) { Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao organizationDao = new EFwcf.EntityOrganizationDao(); Epi.Web.BLL.Organization Implementation = new Epi.Web.BLL.Organization(organizationDao); Epi.Web.Enter.Common.BusinessObject.OrganizationBO ogranizationBO = Implementation.GetOrganizationByKey(request.Criteria.OrganizationKey.ToString()); if (ogranizationBO == null) { validSurvey = false; } else { validSurvey = true; } } else { Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = new EFwcf.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyInfo Implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao); validSurvey = Implementation.IsSurveyInfoValidByOrgKey(request.Criteria.SurveyIdList[0].ToString(), request.Criteria.OrganizationKey.ToString()); } return(validSurvey); } 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 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); } }
/// <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); } }
/// <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); } }
/// <summary> /// Set (add, update, delete) SurveyInfo value. /// </summary> /// <param name="request">SurveyResponse request message.</param> /// <returns>SurveyResponse response message.</returns> public SurveyAnswerResponse SetSurveyAnswer(SurveyAnswerRequest request) { try { Epi.Web.Interfaces.DataInterfaces.ISurveyResponseDao SurveyResponseDao = new EF.EntitySurveyResponseDao(); Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = new EF.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyResponse Implementation = new Epi.Web.BLL.SurveyResponse(SurveyResponseDao, ISurveyInfoDao); SurveyAnswerResponse response = new SurveyAnswerResponse(request.RequestId); // Validate client tag, access token, and user credentials if (!ValidRequest(request, response, Validate.All)) { return(response); } // Transform SurveyResponse data transfer object to SurveyResponse business object SurveyResponseBO SurveyResponse = Mapper.ToBusinessObject(request.SurveyAnswerList)[0]; // Validate SurveyResponse business rules if (request.Action != "Delete") { //if (!SurveyResponse.Validate()) //{ // response.Acknowledge = AcknowledgeType.Failure; // foreach (string error in SurveyResponse.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.Equals("Create", StringComparison.OrdinalIgnoreCase)) { Implementation.InsertSurveyResponse(SurveyResponse); response.SurveyResponseList.Add(Mapper.ToDataTransferObject(SurveyResponse)); } else if (request.Action.Equals("CreateChild", StringComparison.OrdinalIgnoreCase)) { Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao SurveyInfoDao = new EF.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyInfo Implementation1 = new Epi.Web.BLL.SurveyInfo(SurveyInfoDao); SurveyInfoBO SurveyInfoBO = Implementation1.GetParentInfoByChildId(SurveyResponse.SurveyId); Implementation.InsertChildSurveyResponse(SurveyResponse, SurveyInfoBO, request.SurveyAnswerList[0].RelateParentId); response.SurveyResponseList.Add(Mapper.ToDataTransferObject(SurveyResponse)); List <SurveyResponseBO> List = new List <SurveyResponseBO>(); List.Add(SurveyResponse); Implementation.InsertSurveyResponse(List, request.Criteria.UserId, true); } else if (request.Action.Equals("Update", StringComparison.OrdinalIgnoreCase)) { Implementation.UpdateSurveyResponse(SurveyResponse); response.SurveyResponseList.Add(Mapper.ToDataTransferObject(SurveyResponse)); } else if (request.Action.Equals("Delete", StringComparison.OrdinalIgnoreCase)) { var criteria = request.Criteria as SurveyAnswerCriteria; var survey = Implementation.GetSurveyResponseById(new List <string> { SurveyResponse.SurveyId }, SurveyResponse.UserPublishKey); foreach (SurveyResponseBO surveyResponse in survey) { try { if (Implementation.DeleteSurveyResponse(surveyResponse)) { response.RowsAffected += 1; } } 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); } }
/// <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); } }