예제 #1
0
        protected override void OnLoad(EventArgs e)
        {
            try
            {
                base.OnLoad(e);
                if (this.IsPostBack == false)
                {
                    if (string.IsNullOrEmpty(Request.Params["surveyid"]))
                    {
                        throw new ArgumentNullException("surveyid");
                    }
                    if (string.IsNullOrEmpty(Request.Params["language"]))
                    {
                        throw new ArgumentNullException("language");
                    }

                    this.Surveyid      = Int32.Parse(Request.Params["surveyid"]);
                    this.TextsLanguage = Int16.Parse(Request.Params["language"]);
                    /*we check the validity of the language:*/
                    if (BuiltinLanguages.GetLanguageById(this.TextsLanguage) == null)
                    {
                        throw new ArgumentException(string.Format("Invalid languageId {0}!", this.TextsLanguage));
                    }

                    try
                    {
                        if (!string.IsNullOrEmpty(Request.Params["pageId"]))
                        {
                            this.SurveyPageId         = Int16.Parse(Request.Params["pageId"]);
                            this.m_selectedSurveyPage = SurveyManager.GetSurveyPageById(this.Surveyid, this.SurveyPageId, this.TextsLanguage);
                        }
                    }
                    catch
                    {
                        this.SurveyPageId         = default(Int16);
                        this.m_selectedSurveyPage = null;
                    }

                    FillPageSelector();
                }
            }
            catch
            {
                Response.Redirect("~/clay/mysurveys/mysurveys.aspx", true);
            }
        }
예제 #2
0
        protected string GetTextsLanguageStrip()
        {
            StringBuilder sb = new StringBuilder();

            foreach (var lang in this.SelectedSurvey.SupportedLanguages)
            {
                if (lang.LanguageId == BuiltinLanguages.Invariant.LanguageId)
                {
                    continue;
                }
                var _url = string.Format("~/clay/mysurveys/Design_Survey.aspx?surveyid={0}&language={1}", this.SelectedSurvey.SurveyId, lang.LanguageId);
                var _src = string.Format("~/content/flags/{0}", BuiltinLanguages.GetLanguageThumbnail(lang.LanguageId));
                sb.AppendFormat("<a title=\"Design the {0} version of the survey!\" href=\"{1}\"><img alt=\"{2}\" src=\"{3}\"></a>", HttpUtility.HtmlEncode(lang.EnglishName), this.ResolveClientUrl(_url), HttpUtility.HtmlEncode(lang.EnglishName), this.ResolveClientUrl(_src));
                sb.Append("&nbsp;&nbsp;");
            }

            return(sb.ToString());
        }
예제 #3
0
        protected override void OnLoad(EventArgs e)
        {
            try
            {
                if (!this.IsPostBack)
                {
                    //Πρέπει στο url να υπάρχει ένα language
                    string _value = this.Request.Params["language"];
                    if (!string.IsNullOrEmpty(_value))
                    {
                        var languageId = Int16.Parse(_value);
                        this.SelectedLanguage = BuiltinLanguages.GetLanguageById(languageId);
                    }
                    else
                    {
                        this.SelectedLanguage = BuiltinLanguages.Invariant;
                    }
                    if (this.SelectedLanguage == null)
                    {
                        throw new VLException("language is invalid!");
                    }


                    //Πρέπει στο url να υπάρχει ένα QuestionId
                    _value = this.Request.Params["QuestionId"];
                    if (!string.IsNullOrEmpty(_value))
                    {
                        var questionId = Int32.Parse(_value);
                        this.SelectedQuestion = LibraryManager.GetLibraryQuestionById(questionId, this.SelectedLanguage.LanguageId);
                    }
                    if (this.SelectedQuestion == null)
                    {
                        throw new VLException("QuestionId is invalid!");
                    }


                    SetValues(this.SelectedQuestion);
                }
            }
            catch (Exception ex)
            {
                this.Response.Redirect("list.aspx");
            }
        }
예제 #4
0
 protected string GetTextsLanguageThumbnail()
 {
     return(this.ResolveClientUrl(string.Format("<img src=\"{0}/{1}\" alt=\"{2}\"/>", this.ResolveClientUrl("~/content/flags/"), BuiltinLanguages.GetLanguageThumbnail(this.TextsLanguage), BuiltinLanguages.GetLanguageById(this.TextsLanguage).EnglishName)));
 }
예제 #5
0
        protected override void OnLoad(EventArgs e)
        {
            try
            {
                if (this.IsPostBack == false)
                {
                    #region διαβάζουμε recipientKey, publicId, collectorId & language
                    //Περιμένουμε στις παραμέτρους της κλήσης ένα rkey (recipient.RecipientKey)
                    if (string.IsNullOrEmpty(Request.Params["rkey"]))
                    {
                        throw new VLException("RecipientKey does not exist. Invalid Call!");
                    }
                    this.RecipientKey = Request.Params["rkey"];

                    //Περιμένουμε στις παραμέτρους της κλήσης ένα pid (survey.PublicId)
                    if (string.IsNullOrEmpty(Request.Params["pid"]))
                    {
                        throw new VLException("PublicId does not exist. Invalid Call!");
                    }
                    this.PublicId = Request.Params["pid"];

                    //Περιμένουμε στις παραμέτρους της κλήσης ένα cid (collector.CollectorId)
                    if (string.IsNullOrEmpty(Request.Params["cid"]))
                    {
                        throw new VLException("CollectorId does not exist. Invalid Call!");
                    }
                    try
                    {
                        this.CollectorId = Int32.Parse(Request.Params["cid"], CultureInfo.InvariantCulture);
                    }
                    catch (Exception ex)
                    {
                        throw new VLException(string.Format("Invalid CollectorId. {0}!", ex.Message));
                    }

                    //Περιμένουμε στις παραμέτρους της κλήσης ένα lang
                    if (!string.IsNullOrEmpty(Request.Params["lang"]))
                    {
                        try
                        {
                            this.LanguageId = Int16.Parse(Request.Params["lang"], CultureInfo.InvariantCulture);
                            if (this.LanguageId != BuiltinLanguages.PrimaryLanguage.LanguageId && this.LanguageId != BuiltinLanguages.DefaultLanguage.LanguageId)
                            {
                                if (BuiltinLanguages.GetLanguageById(this.LanguageId) == null)
                                {
                                    throw new VLException("Invalid Language.");
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new VLException(string.Format("Invalid Language. {0}!", ex.Message));
                        }
                    }
                    #endregion
                }

                #region Διαβάζουμε απο την βάση μας Recipient, Collector και Survey
                this.Recipient = SurveyManager.GetRecipientByKey(this.RecipientKey);
                if (this.Recipient == null)
                {
                    throw new VLException("Recipient is invalid!");
                }

                this.Collector = SurveyManager.GetCollectorById(this.CollectorId, this.LanguageId);
                if (this.Collector == null)
                {
                    throw new VLException("Collector is invalid!");
                }

                this.Survey = SurveyManager.GetSurveyByPublicId(this.PublicId, this.LanguageId);
                if (this.Survey == null)
                {
                    throw new VLException("Survey is invalid!");
                }

                //Now all the above entities must be compatible:
                if (this.Recipient.Collector != this.Collector.CollectorId)
                {
                    throw new VLException("Recipient and Collector are invalid!");
                }
                if (this.Collector.Survey != this.Survey.SurveyId)
                {
                    throw new VLException("Collector and Survey are invalid!");
                }
                #endregion

                this.lnkSurvey.NavigateUrl = Utility.GetSurveyRuntimeURL(this.Survey, this.Collector, this.Recipient, false);

                this.QuestionPanel.Visible = true;
                this.ResultPanel.Visible   = false;
            }
            catch (Exception ex)
            {
                this.ErrorMessage          = ex.Message;
                this.QuestionPanel.Visible = false;
                this.ResultPanel.Visible   = false;
                this.ErrorPanel.Visible    = true;
            }
        }