示例#1
0
    protected string RenderingLanguage(string content, string userCode, params string[] parameters)
    {
        try
        {
            content = ProcessMessage(content, parameters);
            if (userCode != null && userCode.Trim() != string.Empty)
            {
                User user = TheUserMgr.LoadUser(userCode, true, false);

                if (user != null && user.UserLanguage != null && user.UserLanguage != string.Empty)
                {
                    content = TheLanguageMgr.ProcessLanguage(content, user.UserLanguage);
                }
                else
                {
                    EntityPreference defaultLanguage = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_LANGUAGE);
                    content = TheLanguageMgr.ProcessLanguage(content, defaultLanguage.Value);
                }
            }
            else
            {
                EntityPreference defaultLanguage = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_LANGUAGE);
                content = TheLanguageMgr.ProcessLanguage(content, defaultLanguage.Value);
            }
        }
        catch (Exception ex)
        {
            return(content);
        }
        return(content);
    }
示例#2
0
 /*
  * 用于反射调用,参见GridView
  *
  */
 public string Render(String content)
 {
     if (CurrentUser != null && CurrentUser.UserLanguage != null && CurrentUser.UserLanguage != string.Empty)
     {
         content = TheLanguageMgr.ProcessLanguage(content, CurrentUser.UserLanguage);
     }
     else
     {
         EntityPreference defaultLanguage = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_LANGUAGE);
         content = TheLanguageMgr.ProcessLanguage(content, defaultLanguage.Value);
     }
     return(content);
 }
示例#3
0
        /// <summary>
        /// 导出数据函数
        /// </summary>
        /// <param name="FileType">导出文件MIME类型</param>
        /// <param name="FileName">导出文件的名称</param>
        protected void Export(GridView gridview, String FileType, String FileName)
        {
            /*
             * gridview.AllowPaging = false;
             * gridview.AllowSorting = false;
             */
            if (gridview.Rows.Count > 5000)
            {
                ShowWarningMessage("Common.Export.Warning.GreatThan5000", gridview.Rows.Count.ToString());
            }
            else if (gridview.Rows.Count == 0)
            {
                ShowWarningMessage("Common.GridView.NoRecordFound");
                return;
            }

            //gridview.DataBind();

            System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("ZH-CN", true);
            StringBuilder  sb  = new StringBuilder();
            StringWriter   sw  = new StringWriter(cultureInfo);
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            Page     page = new Page();
            HtmlForm form = new HtmlForm();

            gridview.EnableViewState = false;

            // Deshabilitar la validación de eventos, sólo asp.net 2
            page.EnableEventValidation = false;

            // Realiza las inicializaciones de la instancia de la clase Page que requieran los diseñadores RAD.
            page.DesignerInitialize();

            page.Controls.Add(form);

            form.Controls.Add(gridview);

            page.RenderControl(htw);

            Response.Clear();
            Response.Buffer = true;

            //      Response.ContentType = "application/vnd.ms-excel";
            //Response.AddHeader("Content-Disposition", "attachment;filename=data.xls");
            Response.AppendHeader("Content-Disposition", "attachment;filename="
                                  + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8));

            //设置输出流HttpMiME类型(导出文件格式)
            Response.ContentType = FileType;
            //Response.Charset = "UTF-8";
            //设定输出字符集
            Response.Charset = "GB2312";
            //Response.ContentEncoding = Encoding.Default;
            Response.ContentEncoding = System.Text.Encoding.UTF8;

            string content = sw.ToString();

            if (CurrentUser != null && CurrentUser.UserLanguage != null && CurrentUser.UserLanguage != string.Empty)
            {
                content = TheLanguageMgr.ProcessLanguage(content, CurrentUser.UserLanguage);
            }
            else
            {
                EntityPreference defaultLanguage = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_LANGUAGE);
                content = TheLanguageMgr.ProcessLanguage(content, defaultLanguage.Value);
            }

            Response.Write(content);
            Response.End();
            Response.Flush();

            /*
             *          gridview.AllowPaging = true;
             *          gridview.AllowSorting = true;
             */
            //gridview.DataBind();
        }