示例#1
0
        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);
        }
示例#2
0
    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());
    }