private void GetStudyResponse(HttpContext context) { LinkOverviewResponseType responseType = LinkOverviewResponseType.XML; if (context.Request.Params["ResponseType"] != null) { // Get the response type from the request xml document. responseType = (LinkOverviewResponseType)Enum.Parse( typeof(LinkOverviewResponseType), context.Request.Params["ResponseType"] ); } int idLanguage = 2057; if (context.Request.Params["IdLanguage"] != null) { idLanguage = int.Parse(context.Request.Params["IdLanguage"]); } int linked = Global.Core.VariableLinks.GetCount(); int variables = Global.Core.Variables.GetCount(); int unLinkedVariableCount = variables - linked; int linkedC = Global.Core.CategoryLinks.GetCount(); int variablesC = Global.Core.Categories.GetCount(); int unLinkedCCount = variablesC - linkedC; var study = Global.Core.Studies.GetCount(); var result = Global.Core.Studies.Get(); if (responseType == LinkOverviewResponseType.XML) { // Create a new string builder that build the xml string for the dimension definition. StringBuilder xmlBuilder = new StringBuilder(); xmlBuilder.Append("<Response>"); for (int i = 0; i < result.Count(); i++) { var sName = result[i].Name; var responseCount = Global.Core.Respondents.GetCount("IdStudy", result[i].Id); xmlBuilder.Append(string.Format( "<StudyDetails studyName=\"{0}\" responseCount=\"{1}\">", sName, responseCount)); xmlBuilder.Append("</StudyDetails>"); } xmlBuilder.Append("</Response>"); context.Response.Write(xmlBuilder); } else { //StudyRepondents[] studyResponse = null; //for (int i = 0; i < result.Count(); i++) //{ // var responseCount = Global.Core.Respondents.GetCount("IdStudy", result[i].Id); // studyResponse = new StudyRepondents[]{ // new StudyRepondents(){ // study = result[i].Name, // responseCount = responseCount // } // }; //} var objectToSerialize = new RootRespondents(); List <StudyRepondents> resultList = new List <StudyRepondents>(); for (int i = 0; i < result.Count(); i++) { var responseCount = Global.Core.Respondents.GetCount("IdStudy", result[i].Id); var studyRespondents = new StudyRepondents { study = result[i].Name, responseCount = responseCount }; resultList.Add(studyRespondents); } objectToSerialize.values = resultList; context.Response.Write(new JavaScriptSerializer().Serialize(objectToSerialize)); } // Set the content type of the http response to plain text. context.Response.ContentType = "text/plain"; }
private void ProcessReport(HttpContext context) { LinkOverviewResponseType responseType = LinkOverviewResponseType.XML; if (context.Request.Params["ResponseType"] != null) { // Get the response type from the request xml document. responseType = (LinkOverviewResponseType)Enum.Parse( typeof(LinkOverviewResponseType), context.Request.Params["ResponseType"] ); } int idLanguage = 2057; if (context.Request.Params["IdLanguage"] != null) { idLanguage = int.Parse(context.Request.Params["IdLanguage"]); } int linked = Global.Core.VariableLinks.GetCount(); int variables = Global.Core.Variables.GetCount(); int unLinkedVariableCount = variables - linked; int linkedC = Global.Core.CategoryLinks.GetCount(); int variablesC = Global.Core.Categories.GetCount(); int unLinkedCCount = variablesC - linkedC; var study = Global.Core.Studies.GetCount(); if (responseType == LinkOverviewResponseType.XML) { // Create a new string builder that build the xml string for the dimension definition. StringBuilder xmlBuilder = new StringBuilder(); xmlBuilder.Append("<Response>"); xmlBuilder.Append(string.Format( "<LinkedVariable linkedCount=\"{0}\" UnLinkedCount=\"{1}\" Total=\"{2}\">", linked, unLinkedVariableCount, variables)); xmlBuilder.Append("</LinkedVariable>"); xmlBuilder.Append(string.Format( "<LinkedCategory linkedCount=\"{0}\" UnLinkedCount=\"{1}\" Total=\"{2}\">", linkedC, unLinkedCCount, variablesC)); xmlBuilder.Append("</LinkedCategory>"); xmlBuilder.Append(string.Format( "<Studies Total=\"{0}\" >", study)); xmlBuilder.Append("</Studies>"); xmlBuilder.Append("</Response>"); context.Response.Write(xmlBuilder); } else { //var linkOverView = new LinkOverviewHelper[] //{ // new LinkOverviewHelper(){ // linkedVariables = linked, // unLinkedVariables=unLinkedVariableCount, // linkedCategories = linkedC, // unLinkedCategories=unLinkedVariableCount, // studies=study // } //}; var objectToSerialize = new RootObject(); objectToSerialize.values = new List <LinkOverviewHelper> { new LinkOverviewHelper { studies = study, linkedVariables = linked, unLinkedVariables = unLinkedVariableCount, linkedCategories = linkedC, unLinkedCategories = unLinkedVariableCount }, }; context.Response.Write(new JavaScriptSerializer().Serialize(objectToSerialize)); } // Set the content type of the http response to plain text. context.Response.ContentType = "text/plain"; }