public static PageDigest[][] ToPageDigests(this Template projectTemplateMetadata) { List <PageDigest[]> projectPageDigests = new List <PageDigest[]>(); var viewIdToViewMap = new Dictionary <int, View>(); foreach (var view in projectTemplateMetadata.Project.Views) { viewIdToViewMap[view.ViewId] = view; var pages = new Page[0]; pages = pages.Union(view.Pages).ToArray(); int numberOfPages = pages.Length; var pageDigests = new PageDigest[numberOfPages]; for (int i = 0; i < numberOfPages; ++i) { var pageMetadata = pages[i]; string pageName = pageMetadata.Name; int pageId = pageMetadata.PageId.Value; int position = pageMetadata.Position; int viewId = pageMetadata.ViewId; bool isRelatedView = viewIdToViewMap[viewId].IsRelatedView; string formId = viewIdToViewMap[viewId].FormId; string formName = viewIdToViewMap[viewId].Name; pageDigests[i] = new PageDigest(pageName, pageId, position, formId, formName, viewId, isRelatedView, pageMetadata.Fields); } projectPageDigests.Add(pageDigests); } return(projectPageDigests.ToArray()); }
public int PageIdFromPageNumber(string formId, int pageNumber) { PageDigest pageDigest = GetPageDigestByPageNumber(formId, pageNumber); var pageId = pageDigest != null ? pageDigest.PageId : 0; return(pageId); }
public PageDigest GetPageDigestByPageId(string formId, int pageId) { PageDigest pageDigest = null; var pageDigests = PageDigests.SingleOrDefault(d => d[0].FormId == formId); if (pageDigests != null) { pageDigest = pageId > 0 ? pageDigests.Single(d => d.PageId == pageId) : pageDigests.FirstOrDefault(); } return(pageDigest); }
public virtual Form GetForm(SurveyInfoDTO surveyInfo, int pageNumber, SurveyAnswerDTO surveyAnswer, List <SurveyAnswerDTO> surveyAnswerList, List <SurveyInfoDTO> surveyInfoList, bool isAndroid) { // Save last values for subsequent calls from ValidateAll in SurveyController SurveyAnswerList = surveyAnswerList; SurveyInfoList = surveyInfoList; var surveyId = CurrentFormId = surveyInfo.SurveyId; FormDigest currentFormDigest = GetFormDigest(surveyId); PageDigest currentPageDigest = GetPageDigestByPageNumber(surveyId, pageNumber); var pageId = currentPageDigest.PageId; string formId = currentFormDigest.FormId; string formName = currentFormDigest.FormName; FormResponseDetail formResponseDetail = surveyAnswer.ResponseDetail != null ? surveyAnswer.ResponseDetail : new FormResponseDetail { FormId = formId, FormName = formName }; PageResponseDetail pageResponseDetail = formResponseDetail.GetPageResponseDetailByPageId(pageId); var form = new Form(); form.PageId = pageId.ToString(); form.IsAndroid = isAndroid; form.ResponseId = surveyAnswer.ResponseId; form.FormName = surveyAnswer.FormName; form.FormId = surveyAnswer.FormId; form.ParentResponseId = surveyAnswer.ParentResponseId; form.ParentFormName = surveyAnswer.ParentFormName; form.ParentFormId = surveyAnswer.ParentFormId; form.RootResponseId = surveyAnswer.RootResponseId; form.RootFormName = surveyAnswer.RootFormName; form.RootFormId = surveyAnswer.RootFormId; form.SurveyInfo = surveyInfo; //Watermark if (form.SurveyInfo.IsDraftMode) { form.IsDraftModeStyleClass = "draft"; } form.CurrentPage = pageNumber; form.NumberOfPages = currentFormDigest.NumberOfPages; double _Width, _Height; var orientationIsPortrait = currentFormDigest.Orientation == "Portrait"; _Height = orientationIsPortrait ? currentFormDigest.Height : currentFormDigest.Width; _Width = orientationIsPortrait ? currentFormDigest.Width : currentFormDigest.Height; //Add checkcode to Form string checkcode = currentFormDigest.CheckCode; StringBuilder javaScript = new StringBuilder(); StringBuilder VariableDefinitions = new StringBuilder(); string defineFormat = "cce_Context.define(\"{0}\", \"{1}\", \"{2}\", \"{3}\");"; string defineNumberFormat = "cce_Context.define(\"{0}\", \"{1}\", \"{2}\", new Number({3}));"; if (surveyAnswerList != null && surveyAnswerList.Count > 0) { form.FormCheckCodeObj = form.GetRelateCheckCodeObj(GetRelateFormObj(surveyAnswerList, surveyInfoList), checkcode); } else { form.FormCheckCodeObj = form.GetCheckCodeObj(surveyInfo.GetFieldDigests(surveyId), formResponseDetail, checkcode); } form.HiddenFieldsList = formResponseDetail.HiddenFieldsList; form.HighlightedFieldsList = formResponseDetail.HighlightedFieldsList; form.DisabledFieldsList = formResponseDetail.DisabledFieldsList; form.RequiredFieldsList = formResponseDetail.RequiredFieldsList; form.FormCheckCodeObj.GetVariableJavaScript(VariableDefinitions); form.FormCheckCodeObj.GetSubroutineJavaScript(VariableDefinitions); string pageName = currentPageDigest.PageName; //Generate page level Java script (Before) javaScript.Append(GetPageLevelJS(pageNumber, form, pageName, "Before")); //Generate page level Java script (After) javaScript.Append(GetPageLevelJS(pageNumber, form, pageName, "After")); SetProviderSpecificProperties(form, _Height, _Width); var responseQA = pageResponseDetail != null ? pageResponseDetail.ResponseQA : new Dictionary <string, string>(); //if (responseQA.Count == 0) //{ // var pageFieldAttributes = GetPageFieldAttributesByPageId(surveyId, pageId); // responseQA = new Dictionary<string, string>(); // foreach (var fieldAttributes in pageFieldAttributes.Values) // { // if (fieldAttributes.Value != null) // { // responseQA.Add(fieldAttributes.FieldName.ToLower(), fieldAttributes.Value); // } // } //} AddFormFields(surveyInfo, pageId, responseQA, form, _Width, _Height, checkcode, javaScript); form.FormJavaScript = VariableDefinitions.ToString() + "\n" + javaScript.ToString(); return(form); }