public void JsonPCallback() { string Callback = Request.QueryString["jsonp"]; if (!string.IsNullOrEmpty(Callback)) { var sessionsQuery = new SessionsQuery(); if (HttpContext.Current.Request["query"] != null) { sessionsQuery = HttpContext.Current.Request["query"].FromJson<SessionsQuery>(); } sessionsQuery.CodeCampYearId = Utils.CurrentCodeCampYear; sessionsQuery.WithTags = true; if (HttpContext.Current.Request["start"] != null && HttpContext.Current.Request["limit"] != null) { sessionsQuery.Start = Convert.ToInt32(HttpContext.Current.Request["start"]); sessionsQuery.Limit = Convert.ToInt32(HttpContext.Current.Request["limit"]); } var listData1 = new List<SessionsResult>(); var sessionsManager = new SessionsManager(); //if (HttpContext.Current.User.Identity.IsAuthenticated // && Utils.CheckUserIsAdmin()) { listData1 = sessionsManager.Get(sessionsQuery); for (int i = 0; i < listData1.Count; i++) { listData1[i].AdminComments = null; listData1[i].InterestCount = ""; listData1[i].InterestedCount = 0; listData1[i].NotInterestedCount = 0; listData1[i].PlanAheadCount = ""; listData1[i].PlanAheadCountInt = 0; listData1[i].SessionEvalsResults = null; listData1[i].SpeakerPictureUrl = "http://www.siliconvalley-codecamp.com/" + listData1[i].SpeakerPictureUrl; listData1[i].TitleWithPlanAttend = ""; listData1[i].Username = ""; listData1[i].WillAttendCount = 0; listData1[i].WikiURL = ""; listData1[i].SpeakersList = null; } } var listData2 = (from data in listData1 orderby data.SessionTime, data.Title.ToUpper() select data).ToList(); var ret = new { success = true, rows = listData2, total = sessionsQuery.OutputTotal }; //HttpContext.Current.Response.ContentType = "text/plain"; //HttpContext.Current.Response.Write(ret.ToJson()); // *** Do whatever you need //Response.Write(Callback + "( {\"x\":10 , \"y\":100} );"); Response.Write(Callback + "( " + ret.ToJson() + " );"); } Response.End(); }
public void JsonPCallback() { string Callback = Request.QueryString["jsonp"]; if (!string.IsNullOrEmpty(Callback)) { var attendeesQuery = new AttendeesQuery(); if (HttpContext.Current.Request["query"] != null) { attendeesQuery = HttpContext.Current.Request["query"].FromJson<AttendeesQuery>(); } //attendeesQuery.CodeCampYearId = Utils.CurrentCodeCampYear; // attendeesQuery.Id = 6061; attendeesQuery.PresentersOnly = true; attendeesQuery.CodeCampYearIds = new List<int>() {7}; int bioMaxLen = 4096; if (HttpContext.Current.Request["biomaxlen"] != null) { Int32.TryParse(HttpContext.Current.Request["biomaxlen"] ?? "", out bioMaxLen); } var attendeesManager = new AttendeesManager(); var listDataSpeakers = attendeesManager.Get(attendeesQuery); var sessionsManager = new SessionsManager(); var sessionsResults = sessionsManager.Get(new SessionsQuery() { CodeCampYearId = Utils.CurrentCodeCampYear }); //var xxx = listDataSpeakers.Where(a => a.Id == 6061).ToList(); //var yyy = sessionsResults.Where(a => a.Attendeesid == 6061).ToList(); var listDataResults = (from data in listDataSpeakers orderby data.UserLastName select new { AttendeesId = data.Id, data.UserFirstName, data.UserLastName, data.UserWebsite, data.PKID, UserBio = TruncateStringWithEllipse(data.UserBio,4090), UserBioShort = TruncateStringWithEllipse(data.UserBio, bioMaxLen), data.SpeakerPictureUrl, data.TwitterHandle // AFTER REMOVING ATTENDEESID FROM SESSION THIS BROKE. NEED TO FIX IF WE WANT TO // MAKE JSONP WORK AGAIN CORRECTLY //Sessions = (from data1 in sessionsResults // where data1.Attendeesid == data.Id && // data1.CodeCampYearId == Utils.CurrentCodeCampYear // select new // { // data1.Id, // data1.Title, // data1.Description, // data.UserFirstName, // data.UserLastName // }).ToList() }).ToList(); //var xx = listDataResults.Where(a => a.AttendeesId == 6061).ToList(); //foreach (var rec in listDataResults) //{ // if (bioMaxLen != 0) // { // int oriLen = rec.UserBio.Length; // if (oriLen > bioMaxLen) // { // rec.UserBio = rec.UserBio.Substring(0, bioMaxLen) + "..."; // } // } //} var ret = new { success = true, rows = listDataResults, total = attendeesQuery.OutputTotal }; Response.Write(Callback + "( " + ret.ToJson() + " );"); } Response.End(); }