/// <summary>
 /// Parse the source text for pipe token and replace
 /// the token with the correct text depending on the
 /// given survey answers
 /// </summary>
 public string PipeValuesInText(int questionId, string sourceText, VoterAnswersData.VotersAnswersDataTable surveyAnswers, string languageCode)
 {
     Regex regex = new Regex(@"\[{2}((\S)+)\]{2}");
     if (surveyAnswers != null)
     {
         Match match = regex.Match(sourceText);
         if (match.Success)
         {
             if (HttpContext.Current != null)
             {
                 if (HttpContext.Current.Cache["NSurvey:PipeData"] == null)
                 {
                     HttpContext.Current.Cache.Insert("NSurvey:PipeData", new Surveys().GetSurveyPipeDataFromQuestionId(questionId), null, DateTime.Now.AddMinutes(1.0), TimeSpan.Zero);
                 }
                 this._pipeData = (PipeData) HttpContext.Current.Cache["NSurvey:PipeData"];
             }
             else
             {
                 this._pipeData = new Surveys().GetSurveyPipeDataFromQuestionId(questionId);
             }
             while (match.Success)
             {
                 string str = match.Groups[1].ToString();
                 if (str.Length > 0)
                 {
                     PipeData.QuestionsRow[] rowArray = (PipeData.QuestionsRow[]) this._pipeData.Questions.Select("QuestionPipeAlias='" + str + "'");
                     if (rowArray.Length > 0)
                     {
                         sourceText = sourceText.Replace("[[" + str + "]]", this.PipeQuestionAnswers(rowArray[0].QuestionId, surveyAnswers, languageCode));
                     }
                     else
                     {
                         PipeData.AnswersRow[] rowArray2 = (PipeData.AnswersRow[]) this._pipeData.Answers.Select("AnswerPipeAlias='" + str + "'");
                         if (rowArray2.Length > 0)
                         {
                             sourceText = sourceText.Replace("[[" + str + "]]", this.PipeAnswerText(rowArray2[0].AnswerId, surveyAnswers));
                         }
                     }
                 }
                 match = match.NextMatch();
             }
         }
         match = regex.Match(sourceText);
         if ((match.Length > 0) && (this.previousMatchCount != match.Length))
         {
             this.previousMatchCount = match.Length;
             return this.PipeValuesInText(questionId, sourceText, surveyAnswers, languageCode);
         }
     }
     return sourceText;
 }
 public void RemoveQuestionsRow(PipeData.QuestionsRow row)
 {
     base.Rows.Remove(row);
 }
 public QuestionsRowChangeEvent(PipeData.QuestionsRow row, DataRowAction action)
 {
     this.eventRow = row;
     this.eventAction = action;
 }
 public void AddQuestionsRow(PipeData.QuestionsRow row)
 {
     base.Rows.Add(row);
 }
 public AnswersRowChangeEvent(PipeData.AnswersRow row, DataRowAction action)
 {
     this.eventRow = row;
     this.eventAction = action;
 }
 public void RemoveAnswersRow(PipeData.AnswersRow row)
 {
     base.Rows.Remove(row);
 }
 public void AddAnswersRow(PipeData.AnswersRow row)
 {
     base.Rows.Add(row);
 }
 /// <summary>
 /// Returns all the data need to handle 
 /// and process question / answer piping
 /// </summary>
 public PipeData GetSurveyPipeDataFromQuestionId(int questionId)
 {
     PipeData pipeData = new PipeData();
    DbConnection.db.LoadDataSet("vts_spSurveyGetPipeDataFromQuestionId", pipeData, new string[] { "Questions", "Answers" }, new SqlParameter("@QuestionId", questionId).SqlValue);
     return pipeData;
 }