Beispiel #1
0
        /// <summary>
        /// Loads and return the Xml information either
        /// from cache or from the file specified by
        /// the Xml filename
        /// </summary>
        public virtual NSurveyDataSource GetXmlAnswers(string languageCode)
        {
            if ((this.FileName == null) || (this.FileName.Length <= 0))
            {
                return(new NSurveyDataSource());
            }
            NSurveyDataSource localizedXml = null;
            string            filePath     = this._context.Server.MapPath(GlobalConfig.XmlDataSourcePath + this.FileName);
            string            str2         = null;

            if ((languageCode != null) && (languageCode.Length > 0))
            {
                string[] strArray = languageCode.Split(new char[] { '-' });
                if (strArray.Length > 1)
                {
                    str2         = strArray[0];
                    localizedXml = this.GetLocalizedXml(filePath.Replace(".xml", "." + str2 + ".xml"));
                }
            }
            if (str2 == null)
            {
                string str3 = filePath.Replace(".xml", "." + CultureInfo.CurrentUICulture.TwoLetterISOLanguageName + ".xml");
                if (CultureInfo.CurrentUICulture.TwoLetterISOLanguageName != CultureInfo.InstalledUICulture.TwoLetterISOLanguageName)
                {
                    localizedXml = this.GetLocalizedXml(str3);
                }
            }
            if (localizedXml == null)
            {
                return(this.GetNeutralXml(filePath));
            }
            return(localizedXml);
        }
Beispiel #2
0
 /// <summary>
 /// Binds dropdownlist with the xml answers loaded
 /// from the publisher xml file value
 /// </summary>
 private void BindDropDownList(NSurveyDataSource xmlAnswers)
 {
     this._xmlAnswerDropDownList.DataSource      = xmlAnswers;
     this._xmlAnswerDropDownList.DataMember      = "XmlAnswer";
     this._xmlAnswerDropDownList.DataValueField  = "AnswerValue";
     this._xmlAnswerDropDownList.DataTextField   = "AnswerDescription";
     this._xmlAnswerDropDownList.EnableViewState = false;
     this._xmlAnswerDropDownList.DataBind();
 }
Beispiel #3
0
        /// <summary>
        /// Implemented from the abstract method of the parent class
        /// Is called to generate the "layout" and to place the child
        /// controls (eg:dropdownlist) in the tree
        /// </summary>
        /// <param name="xmlAnswers">the xml items loaded from the xml datasource file</param>
        protected override void GenerateXmlControl(NSurveyDataSource xmlAnswers)
        {
            if (this.ShowAnswerText)
            {
                if ((this.ImageUrl != null) && (this.ImageUrl.Length != 0))
                {
                    Image child = new Image();
                    child.ImageUrl   = this.ImageUrl;
                    child.ImageAlign = ImageAlign.Middle;
                    child.ToolTip    = this.Text;
                    this.Controls.Add(child);
                    this.Controls.Add(new LiteralControl("<br />"));
                }
                else if ((this.Text != null) && (this.Text.Length != 0))
                {
                    //JJ this.Controls.Add(new LiteralControl(string.Format("{0}<br />", this.Text)));
                    Label label = new Label();
                    label.Text     = string.Format("{0}", this.Text);
                    label.CssClass = "AnswerTextRender";
                    this.Controls.Add(label);

                    if (this.Mandatory)
                    {
                        this.Controls.Add(new LiteralControl("<div style='color:red; display:inline-flex;'>&nbsp; * &nbsp;</div>"));
                    }
                    this.Controls.Add(new LiteralControl("<br />"));
                }
            }
            this._xmlAnswerDropDownList = new DropDownList();
            if (xmlAnswers != null)
            {
                this._xmlAnswerDropDownList.DataSource      = xmlAnswers;
                this._xmlAnswerDropDownList.DataMember      = "XmlAnswer";
                this._xmlAnswerDropDownList.DataValueField  = "AnswerValue";
                this._xmlAnswerDropDownList.DataTextField   = "AnswerDescription";
                this._xmlAnswerDropDownList.EnableViewState = false;
                this._xmlAnswerDropDownList.DataBind();
                if ((this.DefaultText != null) && (this._xmlAnswerDropDownList.Items.FindByValue(this.DefaultText) != null))
                {
                    this._xmlAnswerDropDownList.SelectedValue = this.DefaultText;
                }
                if (this.HasSubscribers)
                {
                    this._xmlAnswerDropDownList.AutoPostBack = true;
                }
            }
            this.Controls.Add(this._xmlAnswerDropDownList);
            this.OnAnswerPublisherCreated(new AnswerItemEventArgs(this.GetUserAnswers()));
        }
 /// <summary>
 /// Returns the default language neutral Xml file
 /// </summary>
 /// <returns></returns>
 protected virtual NSurveyDataSource GetNeutralXml(string filePath)
 {
     if (this._context.Cache[this.FileName] == null)
     {
         if (!File.Exists(filePath))
         {
             return(null);
         }
         NSurveyDataSource source = new NSurveyDataSource();
         source.ReadXml(filePath);
         CacheDependency dependencies = new CacheDependency(filePath);
         this._context.Cache.Insert(this.FileName, source, dependencies);
     }
     return((NSurveyDataSource)this._context.Cache[this.FileName]);
 }
 /// <summary>
 /// Returns the localized Xml file
 /// </summary>
 /// <returns></returns>
 protected virtual NSurveyDataSource GetLocalizedXml(string filePath)
 {
     if (this._context.Cache[this.FileName + CultureInfo.CurrentUICulture.TwoLetterISOLanguageName] == null)
     {
         if (!File.Exists(filePath))
         {
             return(null);
         }
         NSurveyDataSource source = new NSurveyDataSource();
         source.ReadXml(filePath);
         CacheDependency dependencies = new CacheDependency(filePath);
         this._context.Cache.Insert(this.FileName + CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, source, dependencies);
     }
     return((NSurveyDataSource)this._context.Cache[this.FileName + CultureInfo.CurrentUICulture.TwoLetterISOLanguageName]);
 }
Beispiel #6
0
 /// <summary>
 /// Returns the default language neutral Xml file
 /// </summary>
 /// <returns></returns>
 protected virtual NSurveyDataSource GetNeutralXml(string filePath)
 {
     if (this._context.Cache[this.FileName] == null)
     {
         if (!File.Exists(filePath))
         {
             return(null);
         }
         NSurveyDataSource source = new NSurveyDataSource();
         source.ReadXml(XmlTextReader.Create(filePath, new XmlReaderSettings()
         {
             DtdProcessing = DtdProcessing.Ignore, XmlResolver = null
         }));
         CacheDependency dependencies = new CacheDependency(filePath);
         this._context.Cache.Insert(this.FileName, source, dependencies);
     }
     return((NSurveyDataSource)this._context.Cache[this.FileName]);
 }
 protected abstract void GenerateXmlControl(NSurveyDataSource xmlAnswers);