public void AttachPhoto(String nickname, String password, String askQuestionID, Int32 indexOrder, String photoBase64String) { if (String.IsNullOrEmpty(nickname)) { throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } if (String.IsNullOrEmpty(askQuestionID)) { throw new ArgumentNullException("askQuestionID"); } if (String.IsNullOrEmpty(photoBase64String)) { throw new ArgumentNullException("photoBase64String"); } if (indexOrder < 1 || indexOrder > 3) { throw new ArgumentException(Resources.Argument_InvalidIndexOrder); } var member = Member.GetMemberViaNicknamePassword(nickname, password); var aaf = AskAFriend.GetAskAFriendByWebAskAFriendID(member.MemberID, askQuestionID); if (aaf == null) { throw new ArgumentException( String.Format(CultureInfo.CurrentCulture, Resources.Argument_InvalidAskQuestionID, askQuestionID)); } data.Photo.ProcessAAFPhoto(member, aaf, photoBase64String, indexOrder); aaf.Save(); }
public void GenerateTop10Lister() { AskAFriend[] aafTop10 = AskAFriend.GetTopAAFQuestions(1, 10); StringBuilder sbHTMLList = new StringBuilder(); for (int i = 0; i < aafTop10.Length; i++) { StringBuilder sbHTMLItem = new StringBuilder(); object[] parameters = new object[7]; parameters[0] = aafTop10[i].WebAskAFriendID; parameters[1] = aafTop10[i].DefaultImage.FullyQualifiedURL; parameters[2] = aafTop10[i].Question; parameters[3] = TimeDistance.TimeAgo(aafTop10[i].WentLiveDT); parameters[4] = aafTop10[i].TotalVotes.ToString(); parameters[5] = aafTop10[i].Member.NickName; string HTMLItem = @"<li><a href='AskAFriend.aspx?q={0}'><strong>{2}</strong></a><br /> <span class='metadata'>By: {5} Total Votes: {4}</span> </li>" ; sbHTMLItem.AppendFormat(HTMLItem, parameters); sbHTMLList.Append(sbHTMLItem.ToString()); } DefaultTop10Lister = sbHTMLList.ToString(); }
private void AAFResponse(int QuestionResponseValue) { AskAFriend AAF = CurrentAskAFriend; if (AAF != null) { //bool IsAllowed = AskAFriend.IsVoteValueAllowed(AAF, QuestionResponseValue); bool IsAllowed = true; // only add the vote if a valid response was sent to the server if (IsAllowed) { AskAFriendResponse AAFResponse = new AskAFriendResponse(); AAFResponse.AskAFriendID = AAF.AskAFriendID; Member me = (Member)Session["Member"]; if (me != null) { AAFResponse.MemberID = me.MemberID; } AAFResponse.Result = QuestionResponseValue; AAFResponse.Save(); AAF.TotalVotes++; AAF.Save(); } } }
public AskQuestion[] GetQuestions(String nickname, String password) { if (String.IsNullOrEmpty(nickname)) { throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } var ids = AskAFriend.GetAskQuestionIDs(Member.GetMemberViaNicknamePassword(nickname, password).MemberID); var idsLength = ids.Length; var result = new AskQuestion[idsLength]; for (var i = 0; i < idsLength; i++) { var question = AskAFriend.GetAskQuestion(ids[i]); if (question == null) { throw new ArgumentException(String.Format(Resources.Argument_AskQuestionNotExist, ids[i])); } result[i] = CreateQuestion(question); } return(result); }
private static int GetObjectID(CommentType type, string WebID) { if (type == CommentType.Wall) { Member m = Member.GetMemberViaWebMemberID(WebID); return(m.MemberID); } else if (type == CommentType.Photo) { Photo p = Photo.GetPhotoByWebPhotoIDWithJoin(WebID); return(p.PhotoID); } else if (type == CommentType.Video) { Video v = Video.GetVideoByWebVideoIDWithJoin(WebID); return(v.VideoID); } else if (type == CommentType.AskAFriend) { AskAFriend aaf = AskAFriend.GetAskAFriendByWebAskAFriendID(WebID); return(aaf.AskAFriendID); } else if (type == CommentType.Blog) { BlogEntry blog = BlogEntry.GetBlogEntryByWebBlogEntryID(WebID); return(blog.BlogEntryID); } return(-1); }
public static string GetAAFTitle(AskAFriend InitialAAF) { if (InitialAAF == null) { return(Prefix); } return(Prefix + "ask - " + RegexPatterns.FormatHTMLTitleAllowQuestionMark(InitialAAF.Question)); }
/// <summary> /// Forward to the next question /// </summary> public AjaxAskAFriend NextQuestion() { LastAskAFriend = CurrentAskAFriend; CurrentAskAFriend = AskAFriend.GetNextQuestion(); return(GenarateAjaxAskAFriend()); }
public void DeleteAskQuestion(String webAskQuestionID) { if (String.IsNullOrEmpty(webAskQuestionID)) { throw new ArgumentNullException("webAskQuestionID"); } AskAFriend.Delete(webAskQuestionID); }
private static AskQuestion CreateQuestion(AskAFriend askAFriend) { return(new AskQuestion() { ID = askAFriend.AskAFriendID, Question = Text2Mobile.Filter(askAFriend.Question), DTCreated = askAFriend.SubmittedDT.ToTicksString() }); }
public void CompleteQuestion(String nickname, String password, String askQuestionID) { if (String.IsNullOrEmpty(nickname)) { throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } if (String.IsNullOrEmpty(askQuestionID)) { throw new ArgumentNullException("askQuestionID"); } var member = Member.GetMemberViaNicknamePassword(nickname, password); var memberID = member.MemberID; var aaf = AskAFriend.GetAskAFriendByWebAskAFriendID(askQuestionID); var makeLive = false; if (aaf.ResponseType == (Int32)AskResponseType.MultipleSelect) { // Must have at least 2 photos. if (aaf.Photo.Count > 1) { makeLive = true; } else { throw new ArgumentException(Resources.Argument_InvalidAskMultipleSelectPhotoCount); } } else { if (aaf.Photo.Count > 0) { makeLive = true; } else { throw new ArgumentException(Resources.Argument_InvalidAskPhotoCount); } } if (makeLive) { aaf.WentLiveDT = DateTime.Now; aaf.SubmittedDT = DateTime.Now; aaf.Active = true; aaf.Save(); } }
public AskQuestionConfirm SubmitQuestion( String nickname, String password, String questionText, Int32 numberOfPhotos, Int32 responseType, String[] customResponses, Int32 durationType, Boolean isPrivate) { if (String.IsNullOrEmpty(nickname)) { throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } if (String.IsNullOrEmpty(questionText)) { throw new ArgumentNullException("questionText"); } var member = Member.GetMemberViaNicknamePassword(nickname, password); var aaf = new AskAFriend() { WebAskAFriendID = Misc.UniqueID.NewWebID(), MemberID = member.MemberID, RejectScore = 10, Question = Server.HtmlEncode(questionText), NumberOfPhotos = numberOfPhotos, ResponseType = responseType, Active = false, Duration = durationType, IsPrivate = isPrivate, SubmittedIP = HttpContext.Current.Request.UserHostAddress }; if (customResponses != null) { aaf.ResponseA = (customResponses.Length > 0) ? Server.HtmlEncode(customResponses[0]) : String.Empty; aaf.ResponseB = (customResponses.Length > 1) ? Server.HtmlEncode(customResponses[1]) : String.Empty; } aaf.Save(); var result = new AskQuestionConfirm() { AskQuestionID = aaf.WebAskAFriendID, AdvertURL = @"http://www.google.co.uk/images/firefox/tshirt.gif", AdvertImage = "" }; return(result); }
public Int32[] GetQuestionIDs(String nickname, String password) { if (String.IsNullOrEmpty(nickname)) { throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } return(AskAFriend.GetAskQuestionIDs(Member.GetMemberViaNicknamePassword(nickname, password).MemberID)); }
/// <summary> /// Create the AddThis bookmarks html /// </summary> /// <param name="askAFriend"></param> /// <returns></returns> public string GenarateBookmarks(AskAFriend askAFriend) { StringBuilder sbBookmarks = new StringBuilder(); object[] bookmarkParameters = new object[2]; bookmarkParameters[0] = askAFriend.WebAskAFriendID; bookmarkParameters[1] = askAFriend.Question; sbBookmarks.AppendFormat(@"<script type='text/javascript'>addthis_pub = 'Next2Friends';var addThisWebPhotoID = '';</script> <a href='http://www.addthis.com/bookmark.php' onmouseover=""return addthis_open(this, '', 'http://www.next2friends.com/ask/{0}'+addThisWebPhotoID, '{1}')"" onmouseout='addthis_close()' onclick='return addthis_sendto()'><img src='http://s9.addthis.com/button1-bm.gif' width='125' height='16' border='0' alt='' /></a><script type='text/javascript' src='http://s7.addthis.com/js/152/addthis_widget.js'></script>", bookmarkParameters); return(sbBookmarks.ToString()); }
public void DeleteAllUserAskQuestions(String nickname, String password) { if (String.IsNullOrEmpty(nickname)) { throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } foreach (var item in AskAFriend.GetAAFQuestionByMemberIDSinceLastIDWithJoin(Member.GetMemberViaNicknamePassword(nickname, password).MemberID, null)) { DeleteAskQuestion(item.WebAskAFriendID); } }
public void SkipQuestion(String nickname, String password, Int32 questionID) { if (String.IsNullOrEmpty(nickname)) { throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } var member = Member.GetMemberViaNicknamePassword(nickname, password); AskAFriend.SkipAskQuestion(questionID); }
/// <summary> /// render the HTML comments /// </summary> public string GenarateComments(AskAFriend askAFriend) { AjaxAAFComment[] commentList = AjaxAAFComment.GetAAFCommentsByAskAFriendIDWithJoin(askAFriend.AskAFriendID); StringBuilder sbComments = new StringBuilder(); for (int i = 0; i < 10; i++) { if (commentList.Length <= i) { break; } sbComments.Append(commentList[i].ToHTML()); } return(sbComments.ToString()); }
public static AskAFriend ExtractAskAFriendFromURL(Page page, HttpContext context) { string strWebAskAfriendIDURL = page.Request.Params["q"]; string strWebAskAFriendItem = (context.Items["WebAskID"] != null) ? context.Items["WebAskID"].ToString() : null; AskAFriend DefaultAskAFriend = null; if (strWebAskAfriendIDURL != null) { DefaultAskAFriend = AskAFriend.GetAskAFriendByWebAskAFriendID(strWebAskAfriendIDURL); //AskAFriend.GetAskAFriendByWebAskAFriendID(strAAFQuestion); } else if (strWebAskAFriendItem != null) { //DefaultAskAFriend = AskAFriend.GetAskAFriendByAskAFriendIDWithJoin(strWebAskAFriendItem); DefaultAskAFriend = AskAFriend.GetAskAFriendByWebAskAFriendID(strWebAskAFriendItem); } return(DefaultAskAFriend); }
public AskResponse GetResponse(String nickname, String password, Int32 questionID) { if (String.IsNullOrEmpty(nickname)) { throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } var member = Member.GetMemberViaNicknamePassword(nickname, password); var question = AskAFriend.GetAskAFriendByAskAFriendIDWithJoin(questionID); var response = new AskResponse() { AskQuestionID = question.AskAFriendID, Question = Text2Mobile.Filter(question.Question), PhotoBase64Binary = ResourceProcessor.GetThumbnailBase64String(question.DefaultPhotoResourceFile.SavePath), ResponseValues = AskAFriend.GetAskAFriendResult(question).ToArray(), ResponseType = question.ResponseType, Average = 0, CustomResponses = new String[2] }; /* Set the average value (only applicable if the ResponseType is Rate1To10). */ for (var i = 0; i < response.ResponseValues.Length; i++) { response.Average += response.ResponseValues[i]; } response.Average = response.Average / Convert.ToDouble(response.ResponseValues.Length); /* Custom responses will be blank strings if not applicable. */ response.CustomResponses[0] = Text2Mobile.Filter(question.ResponseA); response.CustomResponses[1] = Text2Mobile.Filter(question.ResponseB); return(response); }
public AskQuestion GetQuestion(String nickname, String password, Int32 questionID) { if (String.IsNullOrEmpty(nickname)) { throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } var member = Member.GetMemberViaNicknamePassword(nickname, password); var askAFriend = AskAFriend.GetAskQuestion(questionID); if (askAFriend == null) { throw new ArgumentException(String.Format(Resources.Argument_AskQuestionNotExist, questionID)); } return(CreateQuestion(askAFriend)); }
public void VoteForQuestion(String nickname, String password, Int32 questionID, Int32 result) { if (String.IsNullOrEmpty(nickname)) { Log.Logger("VoteForQuestion: nickname is null or empty.", Identifier); throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { Log.Logger("VoteForQuestion: password is null or empty.", Identifier); throw new ArgumentNullException("password"); } Log.Logger(String.Format("VoteForQuestion: nickname = \"{0}\".", nickname), Identifier); Log.Logger(String.Format("VoteForQuestion: password = \"{0}\".", password), Identifier); Log.Logger(String.Format("VoteForQuestion: questionID = \"{0}\".", questionID), Identifier); Log.Logger(String.Format("VoteForQuestion: result = \"{0}\".", result), Identifier); var member = Member.GetMemberViaNicknamePassword(nickname, password); AskAFriend.VoteForAskQuestion(member.MemberID, questionID, result); }
public AjaxAskAFriend SkipQuestion() { //All situations in this method //1. if we destroyed session object //2. should we skip this question if anything goes wrong, if yes should //I return NextQuestion try { AskAFriend AAF = CurrentAskAFriend; if (AAF != null) { //AAF.SkipAAFQuestion(); AAF.SkipAskQuestion(); } } catch (Exception ex) { Next2Friends.Data.Trace.Tracer(ex.ToString(), "AAF SkipQuestion"); } return(NextQuestion()); }
/// <summary> /// render the HTML form responses /// </summary> public string GenarateAnswers(AskAFriend askAFriend) { bool HasntYetVoted = false; if (member != null) // it means if memeber is null HasntYetVoted=false { HasntYetVoted = AskAFriendResponse.HasntYetVoted(member, CurrentAskAFriend); } HasntYetVoted = true; StringBuilder sbHTML = new StringBuilder(); //if (!IsPermalink && HasntYetVoted) if (true) { // base on type of the question we should generate answers // base on premaLink or not we give the user chance to vote or not // Should we disable voting for anymouse users if (askAFriend.ResponseType == (int)AskResponseType.YesNo) { //why we are using li string photo = askAFriend.Photo[0].PhotoResourceFile.FullyQualifiedURL; sbHTML.AppendFormat(@"<li> <input type='radio' value='1' name='rbResponse' onclick='SubmitResponse(1);' > Yes <input type='radio' value='2' name='rbResponse' onclick='SubmitResponse(2);'> No <br /> <img src='/{0}' alt='' /> </li>" , photo); } else if (askAFriend.ResponseType == (int)AskResponseType.AB) { object[] parameters = new object[3]; ///AAF.Photo[0].PhotoResourceFile.FullyQualifiedURL is empty parameters[0] = askAFriend.Photo[0].PhotoResourceFile.FullyQualifiedURL; parameters[1] = askAFriend.ResponseA; parameters[2] = askAFriend.ResponseB; sbHTML.AppendFormat(@" <li> <input type='radio' name='rbResponse' value='1' onclick='SubmitResponse(1);'> {1} <input type='radio' name='rbResponse' value='2' onclick='SubmitResponse(2);'> {2} <br /> <img src='/{0}' alt='' /> </li>" , parameters); } else if (askAFriend.ResponseType == (int)AskResponseType.RateTo10) { string photo = askAFriend.Photo[0].PhotoResourceFile.FullyQualifiedURL; sbHTML.AppendFormat(@"<li> <input type='radio' name='rbResponse' value='1' onclick='SubmitResponse(1)'> 1 <input type='radio' name='rbResponse' value='2' onclick='SubmitResponse(2)'> 2 <input type='radio' name='rbResponse' value='3' onclick='SubmitResponse(3)'> 3 <input type='radio' name='rbResponse' value='4' onclick='SubmitResponse(4)'> 4 <input type='radio' name='rbResponse' value='5' onclick='SubmitResponse(5)'> 5 <input type='radio' name='rbResponse' value='6' onclick='SubmitResponse(6)'> 6 <input type='radio' name='rbResponse' value='7' onclick='SubmitResponse(7)'> 7 <input type='radio' name='rbResponse' value='8' onclick='SubmitResponse(8)'> 8 <input type='radio' name='rbResponse' value='9' onclick='SubmitResponse(9)'> 9 <input type='radio' name='rbResponse' value='10' onclick='SubmitResponse(10)'> 10 <br /> <img src='/{0}' alt='' /> </li>" , photo); } else if (askAFriend.ResponseType == (int)AskResponseType.MultipleSelect) { for (int i = 0; i < askAFriend.Photo.Count; i++) { sbHTML.AppendFormat("<li><input name='rbResponse' type='radio' value='{0}' onclick='SubmitResponse({0})'/><br /><img src='/{1}" + "' width='160' alt='' /></li>", i + 1, askAFriend.Photo[i].PhotoResourceFile.FullyQualifiedURL); } } } else { //permalink disables voting if (CurrentAskAFriend.ResponseType == (int)AskResponseType.MultipleSelect) { object[] parameters = new object[3]; parameters[0] = ""; parameters[1] = ""; parameters[2] = ""; try { parameters[0] = CurrentAskAFriend.Photo[0].PhotoResourceFile.FullyQualifiedURL; } catch { } try { parameters[1] = CurrentAskAFriend.Photo[1].PhotoResourceFile.FullyQualifiedURL; } catch { } try { parameters[2] = CurrentAskAFriend.Photo[2].PhotoResourceFile.FullyQualifiedURL; } catch { } sbHTML.AppendFormat(@"<li><img src='/{0}' width='160' alt='' /></li> <li><img src='/{1}' width='160' alt='' /></li> <li><img src='/{2}' width='160' alt='' /></li>" , parameters); } else { object[] parameters = new object[3]; parameters[0] = CurrentAskAFriend.Photo[0].PhotoResourceFile.FullyQualifiedURL; parameters[1] = CurrentAskAFriend.ResponseA; parameters[2] = CurrentAskAFriend.ResponseB; sbHTML.AppendFormat(@"<li><img src='/{0}' alt='' /> </li>" , parameters); } ///////////// } return(sbHTML.ToString()); }
/// <summary> /// Submits the AAF question /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { member = (Member)Session["Member"]; bool Go = true; System.Drawing.Image image1 = null; System.Drawing.Image image2 = null; System.Drawing.Image image3 = null; int NumberOfPhotos = 0; AskResponseType responseType = AskResponseType.None; #region Show Hide options if (rbCustom.Checked) { divCustomShowHide = "style='display:block;'"; divMultiShowHide = "style='display:none;'"; responseType = AskResponseType.AB; } else if (rbImageSelect.Checked) { divCustomShowHide = "style='display:none;'"; divMultiShowHide = "style='display:block;'"; responseType = AskResponseType.MultipleSelect; } else if (rbRate110.Checked) { divCustomShowHide = "style='display:none;'"; divMultiShowHide = "style='display:none;'"; responseType = AskResponseType.RateTo10; } else if (rbYesNo.Checked) { divCustomShowHide = "style='display:none;'"; divMultiShowHide = "style='display:none;'"; responseType = AskResponseType.YesNo; } #endregion #region Form Validation if (txtQuestion.Text == string.Empty) { litErrQuestion.Text = "<span class='formerror_msg'>Please enter your question</span>"; txtQuestion.CssClass = "form_txt formerror"; Go = false; } else { litErrQuestion.Text = string.Empty; txtQuestion.CssClass = "form_txt"; } if (!rbCustom.Checked && !rbImageSelect.Checked && !rbRate110.Checked && !rbYesNo.Checked) { litErrResponse.Text = "<span class='formerror_msg'>Please select a response</span>"; Go = false; } else { litErrResponse.Text = string.Empty; } if (rbCustom.Checked && txtCustomA.Text == string.Empty) { txtCustomA.CssClass = "form_txt formerror"; libCustomA.Text = "<span class='formerror_msg'>Please enter custom response A</span>"; Go = false; } else { txtCustomA.CssClass = "form_txt"; libCustomA.Text = string.Empty; } if (rbCustom.Checked && txtCustomB.Text == string.Empty) { txtCustomB.CssClass = "form_txt formerror"; libCustomB.Text = "<span class='formerror_msg'>Please enter custom response B</span>"; Go = false; } else { txtCustomB.CssClass = "form_txt"; libCustomB.Text = string.Empty; } bool ValidFile1 = true; try { image1 = new Bitmap(FileUpload1.FileContent); } catch { ValidFile1 = false; } if (!FileUpload1.HasFile) { FileUpload1.CssClass = "form_txt formerror"; litFileUpload1.Text = "<span class='formerror_msg'>Please select your photo to upload</span>"; Go = false; } else { FileUpload1.CssClass = "form_txt"; litFileUpload1.Text = string.Empty; } bool ValidFile2 = true; try { image2 = new Bitmap(FileUpload2.FileContent); } catch { ValidFile2 = false; } if (rbImageSelect.Checked && !ValidFile2) { FileUpload2.CssClass = "form_txt formerror"; litFileUpload2.Text = "<span class='formerror_msg'>Multi select requres at least 2 photos be uplaoded</span>"; Go = false; } else { FileUpload2.CssClass = "form_txt"; litFileUpload2.Text = string.Empty; } bool ValidFile3 = true; try { image3 = new Bitmap(FileUpload3.FileContent); } catch { ValidFile3 = false; } if (rbImageSelect.Checked) { spanPhotoNoValue = "1"; } #endregion if (ValidFile1) { NumberOfPhotos++; } if (ValidFile2) { NumberOfPhotos++; } if (ValidFile3) { NumberOfPhotos++; } AskAFriend AAF = new AskAFriend(); AAF.WebAskAFriendID = Next2Friends.Misc.UniqueID.NewWebID(); AAF.MemberID = member.MemberID; AAF.RejectScore = 10; AAF.Question = txtQuestion.Text; AAF.NumberOfPhotos = NumberOfPhotos; AAF.ResponseType = (int)responseType; AAF.Active = false; if (responseType == AskResponseType.AB) { AAF.ResponseA = txtCustomA.Text; AAF.ResponseB = txtCustomB.Text; } AAF.Duration = 0; AAF.IsPrivate = chbPrivate.Checked; AAF.SubmittedIP = HttpContext.Current.Request.UserHostAddress; if (Go) { AAF.Save(); int IndexOrder = 1; if (ValidFile1) { Photo.ProcessAAFPhoto(member, AAF, image1, IndexOrder++); } if (ValidFile2) { Photo.ProcessAAFPhoto(member, AAF, image2, IndexOrder++); } if (ValidFile3) { Photo.ProcessAAFPhoto(member, AAF, image3, IndexOrder++); } AAF.WentLiveDT = DateTime.Now; AAF.SubmittedDT = DateTime.Now; AAF.Active = true; AAF.Save(); // show the success message panelUpload.Visible = false; litSuccessful.Visible = true; } }
/// <summary> /// Render the html permalinks /// </summary> public string GenaratePermaLink(AskAFriend askAFriend) { return(string.Format("<input type='text' onclick='this.select();' style='width:430px' value='{0}'>", ServerURL + askAFriend.WebAskAFriendID)); }
public TabContents GenerateLister(int Page, string OrderBy) { Member member = (Member)Session["Member"]; AskAFriend[] AAFArr = AskAFriend.GetAAFQuestionsByMemberIDWithJoin(member.MemberID, OrderBy); IHaveNoQuestions = (AAFArr.Length > 0) ? false : true; StringBuilder sbHTMLList = new StringBuilder(); int PageSize = 500; int StartAt = (Page * PageSize) - PageSize; #region code for (int i = StartAt; i < StartAt + PageSize; i++) { if (AAFArr.Length <= i) { break; } StringBuilder sbHTMLItem = new StringBuilder(); object[] parameters = new object[7]; parameters[0] = AAFArr[i].WebAskAFriendID; parameters[1] = AAFArr[i].DefaultImage.FullyQualifiedURL; parameters[2] = AAFArr[i].Question; parameters[3] = TimeDistance.TimeAgo(AAFArr[i].WentLiveDT); parameters[4] = AAFArr[i].TotalVotes.ToString(); parameters[5] = ""; parameters[6] = ""; string HTMLItem = @"<li> <p class='aaf_img'><a href='AskAFriend.aspx?q={0}'><img src='{1}' alt='img' height='60' /></a></p> <h3><a href='AskAFriend.aspx?q={0}'>{2}</a></h3> <p class='metadata'> Submitted: {3} Total Votes: {4}</p> </li>" ; //By: <a href='view.aspx?m={6}'>{4}</a> sbHTMLItem.AppendFormat(HTMLItem, parameters); sbHTMLList.Append(sbHTMLItem.ToString()); } //StringBuilder sbPager = new StringBuilder(); //object[] PagerParameters = new object[4]; //PagerParameters[0] = TabType; //PagerParameters[1] = Page - 1; //PagerParameters[2] = Page + 1; //PagerParameters[3] = TabType; //if (Page != 1) // sbPager.AppendFormat("<a href='?t={3}&p={1}' class='previous'>Previous</a>", PagerParameters); //sbPager.AppendFormat("<a href='?t={3}&p={2}' class='next'>next</a>", PagerParameters); // create the TabContents to return TabContents tabContents = new TabContents(); tabContents.HTML = sbHTMLList.ToString(); //tabContents.PagerHTML = sbPager.ToString(); #endregion return(tabContents); }
protected void Page_Load(object sender, EventArgs e) { LoginUrl = @"signup.aspx?u=" + Request.Url.AbsoluteUri; AjaxPro.Utility.RegisterTypeForAjax(typeof(AskAFriendPage)); Comments1.CommentType = CommentType.AskAFriend; string Return = Request.Params["return"]; if (Return != null) { ReturnToDash = "true"; } //int t=0; //if(Session["t"]!=null) //{ // t=(int)Session["t"]; // t++; // Session["t"]=t; //} //else //{ // Session["t"]=0; //} //lblT.Text= t.ToString(); try { //string strAAFQuestion = Request.Params["q"]; AskAFriend askAFriend = null; askAFriend = ExtractPageParams.ExtractAskAFriendFromURL(this.Page, this.Context); if (askAFriend != null) { CurrentAskAFriend = askAFriend; LastAskAFriend = CurrentAskAFriend; IsPermalink = true; InitialAAF = GenarateAjaxAskAFriend(); AskAFriendWebId = InitialAAF.WebAskAFriendID; Comments1.ObjectWebId = AskAFriendWebId; return; } } catch { return; } InitialAAF = NextQuestion(); AskAFriendWebId = CurrentAskAFriend.WebAskAFriendID; Comments1.ObjectId = CurrentAskAFriend.AskAFriendID; Comments1.ObjectWebId = CurrentAskAFriend.WebAskAFriendID; }
public string GenarateResult(AskAFriend askAFriend) { if (askAFriend == null) { // return "Oops"; return(""); } List <int> resultArr = null; try { resultArr = AskAFriend.GetAskAFriendResult(askAFriend); } catch (Exception ex) { Next2Friends.Data.Trace.Tracer("CAskafriend line 284" + ex.Message, "AAF", "ost"); return("Oops"); } finally { } if (resultArr == null) { return(""); } StringBuilder sbLastAAF = new StringBuilder(); if (askAFriend.ResponseType == (int)AskResponseType.RateTo10) { object[] Lastparameters = new object[12]; Lastparameters[0] = (askAFriend.Question.Length > 28) ? askAFriend.Question.Substring(0, 28) + ".." : askAFriend.Question; Lastparameters[1] = askAFriend.Photo[0].PhotoResourceFile.FullyQualifiedURL; Lastparameters[2] = resultArr[0]; Lastparameters[3] = resultArr[1]; Lastparameters[4] = resultArr[2]; Lastparameters[5] = resultArr[3]; Lastparameters[6] = resultArr[4]; Lastparameters[7] = resultArr[5]; Lastparameters[8] = resultArr[6]; Lastparameters[9] = resultArr[7]; Lastparameters[10] = resultArr[8]; Lastparameters[11] = resultArr[9]; sbLastAAF.AppendFormat(@" <div class='aaf_next'> <p>{0}</p> <img src='/{1}' style='width:100px;' alt='{0}' /> <ul class='bar_graph clearfix'> <li> 1<div class='bar' style='width: {2}px;'></div> 2<div class='bar' style='width: {3}px;'></div> 3<div class='bar' style='width: {4}px;'></div> 4<div class='bar' style='width: {5}px;'></div> 5<div class='bar' style='width: {6}px;'></div> 6<div class='bar' style='width: {7}px;'></div> 7<div class='bar' style='width: {8}px;'></div> 8<div class='bar' style='width: {9}px;'></div> 9<div class='bar' style='width: {10}px;'></div> 10<div class='bar' style='width: {11}px;'></div> </li> </ul></div>" , Lastparameters); } else { object[] Lastparameters = new object[7]; Lastparameters[0] = (askAFriend.Question.Length > 28) ? askAFriend.Question.Substring(0, 28) + ".." : askAFriend.Question; Lastparameters[1] = askAFriend.Photo[0].PhotoResourceFile.FullyQualifiedURL; if (askAFriend.ResponseType == (int)AskResponseType.YesNo) { Lastparameters[2] = "Yes"; Lastparameters[3] = "No"; } else if (askAFriend.ResponseType == (int)AskResponseType.AB) { Lastparameters[2] = askAFriend.ResponseA; Lastparameters[3] = askAFriend.ResponseB; } else if (askAFriend.ResponseType == (int)AskResponseType.MultipleSelect) { if (askAFriend.NumberOfPhotos == 2) { } // Lastparameters[6] = askAFriend.ResponseB; } Lastparameters[4] = resultArr[0]; Lastparameters[5] = resultArr[1]; if (askAFriend.ResponseType == (int)AskResponseType.MultipleSelect) { sbLastAAF.AppendFormat(@"<div class='aaf_next'> <p>{0}</p> <img src='/{1}' style='width:100px;' alt='' /> <ul class='bar_graph clearfix'> {2}<div class='bar' style='width: {4}px;'></div> {3}<div class='bar' style='width: {5}px;'></div> </ul></div>" , Lastparameters); } else { sbLastAAF.AppendFormat(@"<div class='aaf_next'> <p>{0}</p> <img src='/{1}' style='width:100px;' alt='' /> <ul class='bar_graph clearfix'> {2}<div class='bar' style='width: {4}px;'></div> {3}<div class='bar' style='width: {5}px;'></div> </ul></div>" , Lastparameters); } } return(sbLastAAF.ToString()); }