AppGlobal.cs 4.1 KB
//----------------------------------------------------------------
// 
// 概述: 本文件作用是提供在整个应用程序域中提供全局变量
// 修改:替换过时方法ConfigurationSettings.GetConfig(CurrentLoginName) 
//          为 (IDictionary)ConfigurationManager.GetSection(CurrentLoginName) by 倪豪 2007-08-27
// ----------------------------------------------------------------

using System;
using System.Configuration;
using System.Collections;
namespace App
{
    /// <summary>
    /// AppGlobal 的摘要说明。
    /// </summary>
    public class AppGlobal
    {

        public static System.Collections.Hashtable UserConfig = new Hashtable();
        //添加用户属性名
        //每个属性的名字必须添加在此,可以避免属性名字重复
        //例:public const 属性名="属性名";
        public const string DateTime = "DateTime";//时间:在每次登录时会被更新本地Config文件的时间属性
        public const string Project = "Project";//项目:记录登录选择的项目
        public const string Language = "Language";//语言:登陆语言
        public const string BaseLine = "BaseLine";//基线
        public AppGlobal()
        {

        }
        //public bool SetUserAttribute(string AttributeName, object AttributeValue)
        //{
        //    GlobalConfig globalconfig = new GlobalConfig();
        //    string CurrentLoginName = Fuction.m_UserLogin;
        //    string NewValue = AttributeValue.ToString();
        //    if (globalconfig.ModifyUseConfig(CurrentLoginName, AttributeName, NewValue))
        //    {
        //        if (AppGlobal.UserConfig == null)
        //        {
        //            AppGlobal.UserConfig.Add(AttributeName, NewValue);
        //        }
        //        else
        //        {
        //            foreach (string f_useKey in AppGlobal.UserConfig.Keys)
        //            {
        //                if (f_useKey == AttributeName)
        //                {
        //                    AppGlobal.UserConfig.Remove(f_useKey);
        //                    AppGlobal.UserConfig.Add(AttributeName, NewValue);
        //                    return true;
        //                }
        //            }
        //            AppGlobal.UserConfig.Add(AttributeName, NewValue);
        //        }
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}
        ///// <summary>
        ///// 获取用户属性
        ///// </summary>
        ///// <param name="AttributeName"></param>
        ///// <returns></returns>
        //public string GetUserAttribute(string AttributeName)
        //{
        //    if (AppGlobal.UserConfig != null)
        //    {
        //        foreach (string f_useKey in AppGlobal.UserConfig.Keys)
        //        {
        //            if (f_useKey == AttributeName)
        //            {
        //                return AppGlobal.UserConfig[f_useKey].ToString();
        //            }
        //        }
        //    }
        //    string CurrentLoginName = Fuction.m_UserLogin;
        //    try
        //    {
        //        //IDictionary UseConfigTable = (IDictionary)ConfigurationSettings.GetConfig(CurrentLoginName);
        //        IDictionary UseConfigTable = (IDictionary)ConfigurationManager.GetSection(CurrentLoginName);
        //        string UseConfigAttribute = "";
        //        if (UseConfigTable[AttributeName] != null)
        //        {
        //            UseConfigAttribute = (string)UseConfigTable[AttributeName];
        //        }
        //        return UseConfigAttribute;
        //    }
        //    catch
        //    {
        //        return "";
        //    }
        //}
        ///// <summary>
        ///// 设置当前用户
        ///// </summary>
        ///// <param name="UserName">用户名</param>
        ///// <returns>是否成功</returns>
        //public bool SetUser(string UserName)
        //{
        //    GlobalConfig globalconfig = new GlobalConfig();
        //    if (globalconfig.CreateUseConfig(UserName))
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}
    }
}