C#.NET 大型企業信息化系統集成快速開發平臺 4.2 版本 - 基於數據庫資源的多語言實現

之前的開發平臺裏,是用xml語言包實現了多語言功能,如今新的平臺裏進行了調整,把多語言包資源放在數據庫表裏實現了。數據庫

 

咱們系統預留了多語言的配置全局變量、能夠經過配置這個參數達到切換多語言的目的數組

咱們在選項管理裏增長一個多語言選擇的選項目,而後有哪些語言資源就加上去數據庫設計

下面的表是多語言的數據庫設計表結構this

下面圖是多語言的數據庫裏的資源設置狀況spa

這個是多語言的設置管理界面參考設計

下面是多語言的管理窗體位置code

多語言例子程序參考:xml

        /// <summary>
        /// 獲取多語言
        /// </summary>
        public void GetLanguage()
        {
            this.grbLanguage.Text = this.GetLanguage(this.grbLanguage);
            this.lblLanguageCode.Text = this.GetLanguage(this.lblLanguageCode) + ":";
            this.lblMessageCode.Text = this.GetLanguage(this.lblMessageCode) + ":";
            this.lblCaption.Text = this.GetLanguage(this.lblCaption) + ":";
            this.btnAdd.Text = this.GetLanguage(this.btnAdd);
            this.btnSave.Text = this.GetLanguage(this.btnSave);
            this.btnCancel.Text = this.GetLanguage(this.btnCancel);
        }

        public string GetLanguage(Control control)
        {
            string result = string.Empty;
            string key = this.Name + "." + control.Name;
            string caption = control.Text;
            result = ClientCache.Instance.GetLanguage(this.UserInfo, key, BaseSystemInfo.CurrentLanguage, caption);
            return result;
        }

多語言接口程序參考:blog

//-----------------------------------------------------------------
// All Rights Reserved , Copyright (C) 2015 , Hairihan TECH, Ltd. 
//-----------------------------------------------------------------

using System.Data;
using System.ServiceModel;
using System.Collections.Generic;

namespace DotNet.IService
{
    using DotNet.Utilities;
    using DotNet.Model;

    /// <summary>
    /// ILanguageService
    /// 多語言接口
    /// 
    /// 修改紀錄
    /// 
    ///        2015.02.24 版本:1.0 JiRiGaLa 建立主鍵。
    ///        
    /// <author>
    ///        <name>JiRiGaLa</name>
    ///        <date>2015.02.24</date>
    /// </author> 
    /// </summary>
    [ServiceContract]
    public interface ILanguageService
    {
        /// <summary>
        /// 獲取實體
        /// </summary>
        /// <param name="userInfo">用戶</param>
        /// <param name="id">主鍵</param>
        /// <returns>實體</returns>
        [OperationContract]
        BaseLanguageEntity GetObject(BaseUserInfo userInfo, string id);

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="userInfo">用戶</param>
        /// <param name="entity">實體</param>
        /// <param name="statusCode">返回狀態碼</param>
        /// <param name="statusMessage">返回狀態信息</param>
        /// <returns>主鍵</returns>
        [OperationContract]
        string Add(BaseUserInfo userInfo, BaseLanguageEntity entity, out string statusCode, out string statusMessage);

        /// <summary>
        /// 編輯
        /// </summary>
        /// <param name="userInfo">用戶</param>
        /// <param name="entity">實體</param>
        /// <param name="statusCode">返回狀態碼</param>
        /// <param name="statusMessage">返回狀態信息</param>
        /// <returns>影響行數</returns>
        [OperationContract]
        int Update(BaseUserInfo userInfo, BaseLanguageEntity entity, out string statusCode, out string statusMessage);

        /// <summary>
        /// 設置多語言
        /// </summary>
        /// <param name="userInfo">用戶</param>
        /// <param name="messageCode">語言編號</param>
        /// <param name="enUS">英文</param>
        /// <param name="zhCN">簡體中文</param>
        /// <param name="zhTW">繁體中文</param>
        /// <returns>影響行數</returns>
        [OperationContract]
        int SetLanguage(BaseUserInfo userInfo, string messageCode, string enUS, string zhCN, string zhTW);

        /// <summary>
        /// 按編號獲取多語言
        /// </summary>
        /// <param name="userInfo">用戶</param>
        /// <param name="messageCode">語言編號</param>
        /// <returns>列表</returns>
        List<BaseLanguageEntity> GetLanguageByMessageCode(BaseUserInfo userInfo, string messageCode);

        /// <summary>
        /// 批量打刪除標誌
        /// </summary>
        /// <param name="userInfo">用戶</param>
        /// <param name="ids">主鍵數組</param>
        /// <returns>影響行數</returns>
        [OperationContract]
        int SetDeleted(BaseUserInfo userInfo, string[] ids);

        /// <summary>
        /// 批量保存
        /// </summary>
        /// <param name="userInfo">用戶</param>
        /// <param name="list">列表</param>
        /// <returns>影響行數</returns>
        [OperationContract]
        int BatchSave(BaseUserInfo userInfo, List<BaseLanguageEntity> list);
    }
}
相關文章
相關標籤/搜索