示例#1
0
 /// <summary>
 /// 构造器
 /// </summary>
 /// <param name="loginer">当前登录用户</param>
 public dalAttachFile(Loginer loginer)
     : base(loginer)
 {
     _KeyName = tb_sys_AttachFile.__KeyName; //主键字段
      _TableName = tb_sys_AttachFile.__TableName;//表名
      _ModelType = typeof(tb_sys_AttachFile);
 }
示例#2
0
 /// <summary>
 /// 构造器
 /// </summary>
 /// <param name="loginer">当前登录用户</param>
 public dalSystemProfile(Loginer loginer)
     : base(loginer)
 {
     _KeyName = tb_sys_SystemProfile.__KeyName; //主键字段
      _TableName = tb_sys_SystemProfile.__TableName;//表名
      _ModelType = typeof(tb_sys_SystemProfile);
 }
示例#3
0
 public dalUser(Loginer loginer)
     : base(loginer)
 {
     _KeyName = tb_sys_User.__KeyName; //主键字段
     _TableName = tb_sys_User.__TableName;//表名
     _ModelType = typeof(tb_sys_User);
 }
示例#4
0
 /// <summary>
 /// 构造器
 /// </summary>
 /// <param name="loginer">当前登录用户</param>
 public dalMenuBar(Loginer loginer)
     : base(loginer)
 {
     _KeyName = tb_sys_Fun_MenuBar.__KeyName; //主键字段
      _TableName = tb_sys_Fun_MenuBar.__TableName;//表名
      _ModelType = typeof(tb_sys_Fun_MenuBar);
 }
示例#5
0
 public dalFunction(Loginer loginer)
     : base(loginer)
 {
     _TableName = tb_sys_Function.__TableName;
     _KeyName = tb_sys_Function.__KeyName;
     _ModelType = typeof(tb_sys_Function);
 }
示例#6
0
 public dalItemPropDesc(Loginer loginer)
     : base(loginer)
 {
     _KeyName = tb_t_ItemPropDesc.__KeyName; //主键字段
     _TableName = tb_t_ItemPropDesc.__TableName;//表名
     _ModelType = typeof(tb_t_ItemPropDesc);//字典表ORM
 }
示例#7
0
 /// <summary>
 /// 构造器
 /// </summary>
 /// <param name="loginer">当前登录用户</param>
 public dalDbLink(Loginer loginer)
     : base(loginer)
 {
     _KeyName = tb_sys_DbLink.__KeyName; //主键字段
      _TableName = tb_sys_DbLink.__TableName;//表名
      _ModelType = typeof(tb_sys_DbLink);
 }
示例#8
0
 public dalCompanyInfo(Loginer loginer)
     : base(loginer)
 {
     _TableName = tb_sys_CompanyInfo.__TableName;
     _KeyName = tb_sys_CompanyInfo.__KeyName;
     _ModelType = typeof(tb_sys_CompanyInfo);
 }
示例#9
0
 public dalItemClass(Loginer loginer)
     : base(loginer)
 {
     _KeyName = tb_t_ItemClass.__KeyName; //主键字段
     _TableName = tb_t_ItemClass.__TableName;//表名
     _ModelType = typeof(tb_t_ItemClass);//字典表ORM
 }
示例#10
0
        /// <summary>
        /// 检查用户登录凭证,验证通过才允许访问后台数据.
        /// </summary>
        /// <param name="loginer">用户登录凭证</param>
        /// <returns></returns>
        public static Loginer ValidateLoginer(byte[] loginer)
        {
            //用户登录信息的长度小于伪码长度,数据包无效!
            if (loginer.Length < PREFIX_LEN + SUFFIX_LEN)
            {
                return(null);
            }

            try
            {
                //用户登录信息的长度
                byte[] objectArrar = new byte[loginer.Length - (PREFIX_LEN + SUFFIX_LEN)];

                //复制用户登录信息的数据包(去掉前后伪码)
                Array.Copy(loginer, PREFIX_LEN, objectArrar, 0, objectArrar.Length);

                //转换为用户对象
                Loginer user = (Loginer)ZipTools.DecompressionObject(objectArrar);
                if (user.Account.Length >= 1) //系统限制用户帐号的长度必须大于或等于1位
                {
                    return(user);             //转换成功,返回用户对象.
                }
                else
                {
                    throw new Exception("用户帐号不正确!");
                }
            }
            catch
            {
                throw new Exception("验证用户资料失败!");
            }
        }
示例#11
0
        /// <summary>
        /// 加密用户登录凭证
        /// </summary>
        /// <param name="user">当前用户登录信息</param>
        /// <returns></returns>
        public static byte[] EncryptLoginer(Loginer user)
        {
            byte[] user_byte = ZipTools.CompressionObject(user);
            byte[] result    = new byte[user_byte.Length + PREFIX_LEN + SUFFIX_LEN];

            byte[] prefix = GetByteData(PREFIX_LEN);
            byte[] suffix = GetByteData(SUFFIX_LEN);

            Array.Copy(user_byte, 0, result, PREFIX_LEN, user_byte.Length);           //复制用户数据
            Array.Copy(prefix, 0, result, 0, prefix.Length);                          //复制头部伪码
            Array.Copy(suffix, 0, result, result.Length - SUFFIX_LEN, suffix.Length); //复制尾部伪码

            return(result);
        }
示例#12
0
        private const int SUFFIX_LEN = 8; /*预设伪造8位的数据(校验码)*/

        #endregion Fields

        #region Methods

        /// <summary>
        /// 加密用户登录凭证
        /// </summary>
        /// <param name="user">当前用户登录信息</param>
        /// <returns></returns>
        public static byte[] EncryptLoginer(Loginer user)
        {
            byte[] user_byte = ZipTools.CompressionObject(user);
            byte[] result = new byte[user_byte.Length + PREFIX_LEN + SUFFIX_LEN];

            byte[] prefix = GetByteData(PREFIX_LEN);
            byte[] suffix = GetByteData(SUFFIX_LEN);

            Array.Copy(user_byte, 0, result, PREFIX_LEN, user_byte.Length); //复制用户数据
            Array.Copy(prefix, 0, result, 0, prefix.Length); //复制头部伪码
            Array.Copy(suffix, 0, result, result.Length - SUFFIX_LEN, suffix.Length); //复制尾部伪码

            return result;
        }
示例#13
0
        public bool Login(LoginUser loginUser)
        {
            string novellAccount = NovellLdapTools.NovellWhoAmI();

            //获取当前Novell用户及组. 通过groups获取用户权限数据
            //string[] groups = NovellLdapTools.NovellGetGroups(ref novellAccount);

            if (string.IsNullOrEmpty(novellAccount))
                throw new CustomException("获取Novell本地用户登录资料失败!");

            _User.Text = novellAccount; //显示当前Novell帐号
            _User.Update();

            loginUser.Account = novellAccount;

            IBridge_User bridge = BridgeFactory.CreateUserBridge();

            //调用数据访问层的接口检查用户登录
            DataTable dt = bridge.Login(loginUser, Char.Parse(LoginUserType.N.ToString()));
            if (dt.Rows.Count == 0) throw new CustomException("Novell用户'" + novellAccount + "'没有建立权限关联!");
            DataRow row = dt.Rows[0];

            Loginer user = new Loginer();
            user.Account = ConvertEx.ToString(row[tb_sys_User.FAccount]);
            user.AccountName = ConvertEx.ToString(row[tb_sys_User.FUserName]);
            user.FlagAdmin = ConvertEx.ToString(row[tb_sys_User.FFlagAdmin]);
            user.Email = ConvertEx.ToString(row[tb_sys_User.FMail]);
            user.Fid = ConvertEx.ToString(row[tb_sys_User.FID]);
            user.LoginTime = DateTime.Now;
            user.MachineName = GetComputerinfo.GetHostName();
            user.IPAddress = GetComputerinfo.GetIP();
            user.CardNo = ConvertEx.ToString(row[tb_sys_User.FCardNo]);

            user.DbType = loginUser.DbType;
            user.DataSetName = loginUser.DataSetDBName;
            Loginer.CurrentUser = user;//保存当前用户
            IBridge_CommonService comBridge = BridgeFactory.CreateCommonServiceBridge();
            comBridge.WriteLogOP("0", "0", "登录系统", "");
            SystemAuthentication.UserAuthorities = bridge.Getb_sys_UserAuthorities(user);//下载用户权限

            return true;
        }
示例#14
0
        /// <summary>
        /// 获取表的最大ID
        /// </summary>
        /// <param name="sTableName"></param>
        /// <returns></returns>
        public static string GetTableID(string sDBName, string sTableName, string sFieldID,Loginer cUer)
        {
            string sql = "";
            if (cUer.DbType == DbAcessTyp.SQLServer)
                sql = string.Format("SELECT isnull(max({0})+1,1) FROM {1} ", sFieldID, sTableName);
            else
                sql = string.Format("SELECT nvl(max({0})+1,1) FROM {1} ", sFieldID, sTableName);

            return new DataBaseLayer(sDBName).GetSingle(sql).ToString();
        }
示例#15
0
        public bool LoginByCard(LoginUser loginUser)
        {
            string userPrincipalName = DomainLdapTools.GetCurrentUserPrincipalName();

            if (string.IsNullOrEmpty(userPrincipalName))
                throw new CustomException("获取本地域用户资料失败!");

            _User.Text = userPrincipalName; //显示当前Domain帐号
            _User.Update();

            loginUser.Account = userPrincipalName;

            IBridge_User bridge = BridgeFactory.CreateUserBridge();

            //调用数据访问层的接口检查用户登录
            DataTable dt = bridge.LoginByCard(loginUser, Char.Parse(LoginUserType.W.ToString()));
            if (dt.Rows.Count == 0) throw new CustomException("域用户'" + userPrincipalName + "'没有建立权限关联!");
            DataRow row = dt.Rows[0];

            Loginer user = new Loginer();
            user.Account = ConvertEx.ToString(row[tb_sys_User.FAccount]);
            user.AccountName = ConvertEx.ToString(row[tb_sys_User.FUserName]);
            user.FlagAdmin = ConvertEx.ToString(row[tb_sys_User.FFlagAdmin]);
            user.Email = ConvertEx.ToString(row[tb_sys_User.FMail]);
            user.Fid = ConvertEx.ToString(row[tb_sys_User.FID]);
            user.LoginTime = DateTime.Now;
            user.MachineName = GetComputerinfo.GetHostName();
            user.IPAddress = GetComputerinfo.GetIP();
            user.CardNo = ConvertEx.ToString(row[tb_sys_User.FCardNo]);

            user.DbType = loginUser.DbType;
            user.DataSetName = loginUser.DataSetDBName;
            Loginer.CurrentUser = user;//保存当前用户

            //登录日志
            IBridge_CommonService comBridge = BridgeFactory.CreateCommonServiceBridge();
            comBridge.WriteLogOP("0", "0", "登录系统", "");

            //下载用户权限
            SystemAuthentication.UserAuthorities = bridge.Getb_sys_UserAuthorities(user);

            return true;
        }
示例#16
0
        /// <summary>
        /// 获取当前用户的系统权限
        /// </summary>
        /// <param name="user">当前用户</param>
        /// <returns></returns>
        public DataTable Getb_sys_UserAuthorities(Loginer user)
        {
            string sql = "SELECT UA.FID, UA.FUGID, UA.FunctionID, UA.FAuths, UA.FModelID,UA.FMenu, U.FNumber  GNumber, U.FName  GName, F.FNumber  FNum, F.FName FName,F.FMODELID  FROM  sys_UG_Auth  UA INNER JOIN sys_UserGroup  U ON UA.FUGID = U.FID left outer JOIN  sys_Function  F ON UA.FunctionID = F.FID " +
                         "  where UA.FUGID in (SELECT     UG.FUserGroupID  FROM  sys_User_Group  UG INNER JOIN    sys_User  U ON UG.FUserID = U.FID  WHERE     (U.FID = '" + user.Fid + "')) ";

            DataTable dt = new DataBaseLayer(_Loginer.DBName).ExecuteQueryDataTable(sql);
            return dt;
        }
示例#17
0
 /// <summary>
 /// 构造器
 /// </summary>
 /// <param name="loginer">当前用户登录信息</param>
 public dalBaseDataDict(Loginer loginer)
     : base(loginer)
 {
 }
示例#18
0
        /// <summary>
        /// 跟据ORM类全名自动创建DAL对象实例
        /// </summary>
        /// <param name="loginer">当前登录用户</param>
        /// <param name="ORM_TypeName">ORM类的命名空间</param>
        /// <returns></returns>
        public static dalBaseDataDict CreateDalByORM(Loginer loginer, string ORM_TypeName)
        {
            if (String.IsNullOrEmpty(ORM_TypeName)) throw new CustomException("ORM类名为空,无法创建实例!");
            if (_LoadedDalTypes == null) _LoadedDalTypes = new Hashtable(); //创建哈希表实例
            Type _DAL_Type = null; //DAL类定义
            bool IsFind = false;

            //哈希表存在该类,从哈希表取出.
            if (_LoadedDalTypes.ContainsKey(ORM_TypeName))
                _DAL_Type = _LoadedDalTypes[ORM_TypeName] as Type;
            else
            {
                //
                //哈希表不存在,表示第一次加载,需要从CSFramework3.Server.DataAccess程序集中查询该类
                //
                //获取DataAccess程序集中所有Public类
                //Type[] types = typeof(dalBaseDataDict).Assembly.GetExportedTypes();
                Type[] types ;
                string[] files = System.IO.Directory.GetFiles(SG.Parameters.SGParameter.sAppPath, "SG.Server.DataAccess*.dll");
                for (int i = 0; i < files.Length; i++)
                {
                    Assembly _assembly = Assembly.LoadFrom(files[i]);

                    // 获取程序集中所有公共类型
                    types = _assembly.GetExportedTypes();

                    //枚举程序集中所有Public类
                    foreach (Type T in types)
                    {
                        //只查找dalBaseDataDict的子类
                        if (false == T.IsSubclassOf(typeof(dalBaseDataDict))) continue;

                        //查找DefaultORM_UpdateMode特性
                        object[] atts = T.GetCustomAttributes(typeof(DefaultORM_UpdateMode), false);
                        if ((atts == null) || (atts.Length == 0)) continue;

                        //该类有定义DefaultORM_UpdateMode特性
                        DefaultORM_UpdateMode att = atts[0] as DefaultORM_UpdateMode;
                        if (false == att.IsOverrideClass) continue; //仅查找具体类(子类)

                        //比较ORM的全名是否相同
                        if (att.ORM.FullName.ToUpper() == ORM_TypeName.ToUpper())
                        {
                            _DAL_Type = T;
                            IsFind = true;
                            break;
                        }
                    }
                    if (IsFind)
                        break;
                }

                //第一次加载后添加到哈希表中, 基于性能优化.
                if (_DAL_Type != null) _LoadedDalTypes.Add(ORM_TypeName, _DAL_Type);
            }

            //没有找到指定的数据层,预设为数据字典基类
            if (_DAL_Type == null) _DAL_Type = typeof(dalBaseDataDict);

            //创建DAL实例
            object instance = _DAL_Type.Assembly.CreateInstance(_DAL_Type.FullName, true,
                BindingFlags.CreateInstance, null,
                 new object[] { loginer }, CultureInfo.CurrentCulture, null);

            if (instance is dalBaseDataDict)
                return instance as dalBaseDataDict;
            else
                //查出的类非dalBaseDataDict派生类,重新生成dalBaseDataDict类实例
                return new dalBaseDataDict(loginer);
        }
示例#19
0
        /// <summary>
        /// 跟据DAL类名创建数据层实例
        /// </summary>
        /// <param name="loginer">当前登录用户</param>
        /// <param name="derivedClassName">DAL类名</param>
        /// <returns></returns>
        public static IBridge_DataDict CreateDalByClassName(Loginer loginer, string derivedClassName)
        {
            Type T = typeof(dalBaseDataDict).Assembly.GetType(derivedClassName, true, true);

            object[] args = new object[] { loginer }; //参数

            object dal = T.Assembly.CreateInstance(derivedClassName, true, BindingFlags.CreateInstance,
                null, args, CultureInfo.CurrentCulture, null);

            return dal as IBridge_DataDict;
        }
示例#20
0
        public DataTable Getb_sys_UserAuthorities(Loginer user)
        {
            using (SGBaseUser_WClient client = SoapClientFactory.CreateSGBaseUser_WClient())
            {
                byte[] loginTicket = WebServiceSecurity.EncryptLoginer(Loginer.CurrentUser);

                byte[] receivedData = client.U_GetUserAuthorities(loginTicket);
                return ZipTools.DecompressionDataSet(receivedData).Tables[0];
            }
        }
示例#21
0
        public byte[] U_LoginByCard(byte[] validationTicket, byte[] loginUser, char LoginUserType)
        {
            bool pass = WebServiceSecurity.ValidateLoginIdentity(validationTicket);

            //检查校验码成功,有效的登录请求.
            if (pass)
            {
                LoginUser userInfo = ZipTools.DecompressionObject(loginUser) as LoginUser;
                Loginer lg = new Loginer();
                lg.DbType = userInfo.DbType;
                lg.DBName = userInfo.DBName;
                DataTable dt = new dalUser(lg).LoginByCard(userInfo, LoginUserType);
                return ZipTools.CompressionDataSet(DataConverter.TableToDataSet(dt));
            }
            else
                return null;
        }
示例#22
0
 /// <summary>
 /// 构造器
 /// </summary>
 /// <param name="loginer">当前用户登录信息</param>
 /// <param name="ORM">数据字典的ORM类</param>
 public dalBaseDataDict(Loginer loginer, Type ORM_Type)
     : base(loginer)
 {
     this.ORM = ORM_Type;
 }
示例#23
0
        public bool LoginByCard(LoginUser loginUser)
        {
            //调用数据访问层的接口检查用户登录
            //用户登录前尚未创建Loginer对象,所有传null值
            IBridge_User bridge = BridgeFactory.CreateUserBridge();
            DataTable data = bridge.LoginByCard(loginUser, Char.Parse(LoginUserType.S.ToString()));
            if (data.Rows.Count == 0) throw new CustomException("登录失败,请检查卡号!");
            DataRow row = data.Rows[0];

            //用户实例,登录成功
            Loginer user = new Loginer();
            user.Account = ConvertEx.ToString(row[tb_sys_User.FAccount]);
            user.AccountName = ConvertEx.ToString(row[tb_sys_User.FUserName]);
            user.FlagAdmin = ConvertEx.ToString(row[tb_sys_User.FFlagAdmin]);
            user.Email = ConvertEx.ToString(row[tb_sys_User.FMail]);
            user.Fid = ConvertEx.ToString(row[tb_sys_User.FID]);
            user.LoginTime = DateTime.Now;
            user.MachineName = GetComputerinfo.GetHostName();
            user.IPAddress = GetComputerinfo.GetIP();
            user.CardNo = ConvertEx.ToString(row[tb_sys_User.FCardNo]);

            //参数:dataSet: 帐套编号, 从帐套字典表获取DBName,DataSetID,DataSetName三个字段的值
            //给下面三个属性赋值
            user.DBName = loginUser.DBName; //重要:在数据层根据DBName设置连接数据库
            user.DataSetID = loginUser.DataSetID;
            user.DbType = loginUser.DbType;
            user.DataSetName = loginUser.DataSetDBName;
            Loginer.CurrentUser = user;//保存当前用户
            IBridge_CommonService comBridge = BridgeFactory.CreateCommonServiceBridge();
            comBridge.WriteLogOP("0", "0", "登录系统", "");
            SystemAuthentication.UserAuthorities = bridge.Getb_sys_UserAuthorities(user); //下载用户权限

            return true;
        }
示例#24
0
 /// <summary>
 /// 构造器
 /// </summary>
 /// <param name="loginer">当前用户登录信息</param>
 /// <param name="tableName">字典表名</param>
 public dalBaseDataDict(Loginer loginer, string tableName)
     : base(loginer)
 {
     _TableName = tableName;
 }
示例#25
0
 /// <summary>
 /// 构造器
 /// </summary>
 /// <param name="loginer">当前用户登录信息</param>
 /// <param name="tableName">字典表名</param>
 /// <param name="keyName">主键字段名</param>
 /// <param name="modelType">数据字典的ORM类</param>
 public dalBaseDataDict(Loginer loginer, string tableName, string keyName, Type modelType)
     : base(loginer)
 {
     _ModelType = modelType;
     _TableName = tableName;
     _KeyName = keyName;
 }
示例#26
0
 /// <summary>
 /// 构造器
 /// </summary>
 /// <param name="loginer">当前登录的用户</param>
 public dalBase(Loginer loginer)
 {
     _Loginer = loginer;
 }
示例#27
0
 public dalUserGroup(Loginer loginer)
     : base(loginer)
 {
 }
示例#28
0
 public dalCommon(Loginer user)
     : base(user)
 {
 }
示例#29
0
 public dalEditLogHistory(Loginer loginer)
 {
     _Loginer = loginer;
 }
示例#30
0
 public dalExtGridControl(Loginer loginer)
     : base(loginer)
 {
 }
示例#31
0
 public DataTable GetUserAuthorities(Loginer user)
 {
     return _MyBridge.Getb_sys_UserAuthorities(user);
 }