Exemple #1
0
        /// <summary>
        /// RequiredFieldValidator控件翻译,从数据库中取值
        /// </summary>
        /// <param name="button">要翻译的服务器控件</param>
        /// <param name="keyCode">字典键值</param>
        /// <param name="defaultText">默认值</param>
        public static void TranslationRequiredFieldValidatorDB(System.Web.UI.WebControls.RequiredFieldValidator rfv, string keyCode, string defaultText)
        {
            string tlText = string.Empty;

            tlText = Translate(keyCode);
            if (tlText == "")
            {
                tlText = defaultText;
            }
            rfv.ErrorMessage = tlText;
        }
Exemple #2
0
        /// <summary>
        /// 服务器控件的翻译,从数据库中取值
        /// </summary>
        /// <param name="control">要翻译的控件</param>
        /// <param name="items">二维数组型参数,第二维第一个为字典键值,第二个为默认值</param>
        public void TranControlsDB(object control, string[][] items)
        {
            switch (control.GetType().ToString())       //
            {
            case "System.Web.UI.WebControls.GridView":
                System.Web.UI.WebControls.GridView gv = (System.Web.UI.WebControls.GridView)control;
                Translation.TranslationGridViewDB(gv, items);
                break;

            case "System.Web.UI.WebControls.DataGrid":
                System.Web.UI.WebControls.DataGrid dg = (System.Web.UI.WebControls.DataGrid)control;
                Translation.TranslationDataGridDB(dg, items);
                break;

            case "System.Web.UI.WebControls.RadioButtonList":
                System.Web.UI.WebControls.RadioButtonList rbl = (System.Web.UI.WebControls.RadioButtonList)control;
                Translation.TranslationRadioButtonListDB(rbl, items);
                break;

            case "System.Web.UI.WebControls.DropDownList":
                System.Web.UI.WebControls.DropDownList ddl = (System.Web.UI.WebControls.DropDownList)control;
                Translation.TranslationDropDownListDB(ddl, items);
                break;

            case "System.Web.UI.WebControls.CheckBoxList":
                System.Web.UI.WebControls.CheckBoxList chkl = (System.Web.UI.WebControls.CheckBoxList)control;
                Translation.TranslationCheckBoxListDB(chkl, items);
                break;

            case "System.Web.UI.WebControls.Button":
                System.Web.UI.WebControls.Button button = (System.Web.UI.WebControls.Button)control;
                Translation.TranslationButtonDB(button, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.LinkButton":
                System.Web.UI.WebControls.LinkButton lbtn = (System.Web.UI.WebControls.LinkButton)control;
                Translation.TranslationLinkButtonDB(lbtn, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.ImageButton":
                System.Web.UI.WebControls.ImageButton imgBtn = (System.Web.UI.WebControls.ImageButton)control;
                Translation.TranslationImageButtonDB(imgBtn, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.HyperLink":
                System.Web.UI.WebControls.HyperLink hl = (System.Web.UI.WebControls.HyperLink)control;
                Translation.TranslationHyperLinkDB(hl, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.Label":
                System.Web.UI.WebControls.Label label = (System.Web.UI.WebControls.Label)control;
                Translation.TranslationLabelDB(label, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.CheckBox":
                System.Web.UI.WebControls.CheckBox chk = (System.Web.UI.WebControls.CheckBox)control;
                Translation.TranslationCheckBoxDB(chk, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.RadioButton":
                System.Web.UI.WebControls.RadioButton rbtn = (System.Web.UI.WebControls.RadioButton)control;
                Translation.TranslationRadioButtonDB(rbtn, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.RequiredFieldValidator":
                System.Web.UI.WebControls.RequiredFieldValidator rfv = (System.Web.UI.WebControls.RequiredFieldValidator)control;
                Translation.TranslationRequiredFieldValidatorDB(rfv, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.RangeValidator":
                System.Web.UI.WebControls.RangeValidator rv = (System.Web.UI.WebControls.RangeValidator)control;
                Translation.TranslationRangeValidatorDB(rv, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.CompareValidator":
                System.Web.UI.WebControls.CompareValidator cv = (System.Web.UI.WebControls.CompareValidator)control;
                Translation.TranslationCompareValidatorDB(cv, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.RegularExpressionValidator":
                System.Web.UI.WebControls.RegularExpressionValidator rev = (System.Web.UI.WebControls.RegularExpressionValidator)control;
                Translation.TranslationRegularExpressionValidatorDB(rev, items[0][0], items[0][1]);
                break;
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        protected void mainInterface(anmar.SharpWebMail.CTNInbox inbox)
        {
            this.newattachmentPH                      = (System.Web.UI.WebControls.PlaceHolder) this.SharpUI.FindControl("newattachmentPH");
            this.attachmentsPH                        = (System.Web.UI.WebControls.PlaceHolder) this.SharpUI.FindControl("attachmentsPH");
            this.confirmationPH                       = (System.Web.UI.WebControls.PlaceHolder) this.SharpUI.FindControl("confirmationPH");
            this.newMessagePH                         = (System.Web.UI.WebControls.PlaceHolder) this.SharpUI.FindControl("newMessagePH");
            this.newMessageWindowAttachFile           = (System.Web.UI.HtmlControls.HtmlInputFile) this.SharpUI.FindControl("newMessageWindowAttachFile");
            this.newMessageWindowAttachmentsList      = (System.Web.UI.WebControls.CheckBoxList) this.SharpUI.FindControl("newMessageWindowAttachmentsList");
            this.newMessageWindowAttachmentsAddedList = (System.Web.UI.WebControls.DataList) this.SharpUI.FindControl("newMessageWindowAttachmentsAddedList");

            this.FCKEditor = (FredCK.FCKeditorV2.FCKeditor) this.SharpUI.FindControl("FCKEditor");
            this.fromname  = (System.Web.UI.HtmlControls.HtmlInputText) this.SharpUI.FindControl("fromname");
            this.fromemail = (System.Web.UI.HtmlControls.HtmlInputText) this.SharpUI.FindControl("fromemail");
            this.subject   = (System.Web.UI.HtmlControls.HtmlInputText) this.SharpUI.FindControl("subject");
            this.toemail   = (System.Web.UI.HtmlControls.HtmlInputText) this.SharpUI.FindControl("toemail");

#if MONO
            System.Web.UI.WebControls.RequiredFieldValidator rfv = (System.Web.UI.WebControls.RequiredFieldValidator) this.SharpUI.FindControl("ReqbodyValidator");
            rfv.Enabled = false;
            this.Validators.Remove(rfv);
#endif

            this.newMessageWindowConfirmation = (System.Web.UI.WebControls.Label) this.SharpUI.FindControl("newMessageWindowConfirmation");

            this.SharpUI.refreshPageImageButton.Click += new System.Web.UI.ImageClickEventHandler(refreshPageButton_Click);

            // Disable PlaceHolders
            this.attachmentsPH.Visible  = false;
            this.confirmationPH.Visible = false;

            // Disable some things
            this.SharpUI.nextPageImageButton.Enabled = false;
            this.SharpUI.prevPageImageButton.Enabled = false;
            // Get mode
            if (Page.Request.QueryString["mode"] != null)
            {
                try {
                    this._message_mode = (anmar.SharpWebMail.UI.MessageMode)System.Enum.Parse(typeof(anmar.SharpWebMail.UI.MessageMode), Page.Request.QueryString["mode"], true);
                } catch (System.Exception) {}
            }
            // Get message ID
            System.String msgid = System.Web.HttpUtility.HtmlEncode(Page.Request.QueryString["msgid"]);
            System.Guid   guid  = System.Guid.Empty;
            if (msgid != null)
            {
                guid = new System.Guid(msgid);
            }
            if (!this.IsPostBack && !guid.Equals(System.Guid.Empty))
            {
                System.Object[] details = inbox[guid];
                if (details != null)
                {
                    if (this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.None))
                    {
                        this._message_mode = anmar.SharpWebMail.UI.MessageMode.reply;
                    }
                    this._headers = (anmar.SharpMimeTools.SharpMimeHeader)details[13];
                    if (!this.IsPostBack)
                    {
                        bool html_content = this.FCKEditor.CheckBrowserCompatibility();

                        this.subject.Value = System.String.Concat(this.SharpUI.LocalizedRS.GetString(System.String.Concat(this._message_mode, "Prefix")), ":");
                        if (details[10].ToString().ToLower().IndexOf(this.subject.Value.ToLower()) != -1)
                        {
                            this.subject.Value = details[10].ToString().Trim();
                        }
                        else
                        {
                            this.subject.Value = System.String.Concat(this.subject.Value, " ", details[10]).Trim();
                        }
                        // Get the original message
                        inbox.CurrentFolder = details[18].ToString();
                        System.IO.MemoryStream            ms      = inbox.GetMessage((int)details[1], msgid);
                        anmar.SharpMimeTools.SharpMessage message = null;
                        if (ms != null && ms.CanRead)
                        {
                            System.String path = null;
                            if (this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.forward))
                            {
                                path = Session["sharpwebmail/read/message/temppath"].ToString();
                                path = System.IO.Path.Combine(path, msgid);
                                path = System.IO.Path.GetFullPath(path);
                            }
                            bool attachments = false;
                            if (this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.forward))
                            {
                                attachments = (bool)Application["sharpwebmail/send/message/forwardattachments"];
                            }
                            message = new anmar.SharpMimeTools.SharpMessage(ms, attachments, html_content, path);
                            ms.Close();
                        }
                        ms = null;
                        if (this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.reply))
                        {
                            // From name if present on original message's To header
                            // and we don't have it already
                            if (Session["DisplayName"] == null)
                            {
                                foreach (anmar.SharpMimeTools.SharpMimeAddress address in (System.Collections.IEnumerable)details[8])
                                {
                                    if (address["address"] != null && address["address"].Equals(User.Identity.Name) &&
                                        address["name"].Length > 0 && !address["address"].Equals(address["name"]))
                                    {
                                        this.fromname.Value = address["name"];
                                        break;
                                    }
                                }
                            }
                            // To addresses
                            foreach (anmar.SharpMimeTools.SharpMimeAddress address in (System.Collections.IEnumerable)details[9])
                            {
                                if (address["address"] != null && !address["address"].Equals(User.Identity.Name))
                                {
                                    if (this.toemail.Value.Length > 0)
                                    {
                                        this.toemail.Value += ", ";
                                    }
                                    this.toemail.Value += address["address"];
                                }
                            }
                        }
                        else if (this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.forward))
                        {
                            // If the original message has attachments, preserve them
                            if (message != null && message.Attachments != null && message.Attachments.Count > 0)
                            {
                                this.bindAttachments();
                                foreach (anmar.SharpMimeTools.SharpAttachment attachment in message.Attachments)
                                {
                                    if (attachment.SavedFile == null)
                                    {
                                        continue;
                                    }
                                    this.AttachmentSelect(System.IO.Path.Combine(attachment.SavedFile.Directory.Name, attachment.SavedFile.Name));
                                }
                                this.Attach_Click(this, null);
                            }
                        }
                        // Preserve the original body and some properties
                        if (message != null)
                        {
                            System.Text.StringBuilder sb_body  = new System.Text.StringBuilder();
                            System.String             line_end = null;
                            if (html_content)
                            {
                                line_end = "<br />\r\n";
                            }
                            else
                            {
                                line_end = "\r\n";
                            }
                            sb_body.Append(this.SharpUI.LocalizedRS.GetString(System.String.Concat(this._message_mode, "PrefixBody")));
                            sb_body.Append(line_end);
                            sb_body.Append(this.SharpUI.LocalizedRS.GetString("newMessageWindowFromNameLabel"));
                            sb_body.Append(" ");
                            sb_body.Append(message.From);
                            sb_body.Append(" [mailto:");
                            sb_body.Append(message.FromAddress);
                            sb_body.Append("]");
                            sb_body.Append(line_end);
                            sb_body.Append(this.SharpUI.LocalizedRS.GetString("newMessageWindowDateLabel"));
                            sb_body.Append(" ");
                            sb_body.Append(message.Date.ToString());
                            sb_body.Append(line_end);
                            sb_body.Append(this.SharpUI.LocalizedRS.GetString("newMessageWindowToEmailLabel"));
                            sb_body.Append(" ");
                            if (html_content)
                            {
                                sb_body.Append(System.Web.HttpUtility.HtmlEncode(message.To.ToString()));
                            }
                            else
                            {
                                sb_body.Append(message.To);
                            }
                            sb_body.Append(line_end);
                            sb_body.Append(this.SharpUI.LocalizedRS.GetString("newMessageWindowSubjectLabel"));
                            sb_body.Append(" ");
                            sb_body.Append(message.Subject);
                            sb_body.Append(line_end);
                            sb_body.Append(line_end);
                            if (!message.HasHtmlBody && html_content)
                            {
                                sb_body.Append("<pre>");
                            }
                            sb_body.Append(message.Body);
                            if (!message.HasHtmlBody && html_content)
                            {
                                sb_body.Append("</pre>");
                            }
                            if (this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.reply))
                            {
                                if (html_content)
                                {
                                    sb_body.Insert(0, System.String.Concat("<blockquote style=\"", Application["sharpwebmail/send/message/replyquotestyle"], "\">"));
                                    sb_body.Append("</blockquote>");
                                }
                                else
                                {
                                    sb_body.Insert(0, Application["sharpwebmail/send/message/replyquotechar"].ToString());
                                    sb_body.Replace("\n", System.String.Concat("\n", Application["sharpwebmail/send/message/replyquotechar"]));
                                }
                            }
                            sb_body.Insert(0, line_end);
                            sb_body.Insert(0, " ");
                            this.FCKEditor.Value = sb_body.ToString();
                        }
                    }
                    details = null;
                }
            }
            else if (!this.IsPostBack)
            {
                System.String to = Page.Request.QueryString["to"];
                if (to != null && to.Length > 0)
                {
                    this.toemail.Value = to;
                }
            }
            if (this.fromname.Value.Length > 0 || this.IsPostBack)
            {
                Session["DisplayName"] = this.fromname.Value;
            }
            if (this.fromname.Value.Length == 0 && Session["DisplayName"] != null)
            {
                this.fromname.Value = Session["DisplayName"].ToString();
            }
            if (this.fromemail.Value.Length > 0 || this.IsPostBack)
            {
                Session["DisplayEmail"] = this.fromemail.Value;
            }
        }