예제 #1
0
파일: User.cs 프로젝트: radtek/PecsSystem
        /// <summary>
        /// Gets users from the lsc database
        /// </summary>
        /// <param name="lscId">lscId</param>
        /// <param name="lscName">lscName</param>
        /// <param name="userId">userId</param>
        /// <param name="connectionString">connectionString</param>
        /// <returns></returns>
        public List <LscUserInfo> GetUsers(int lscId, string lscName, int?userId, string connectionString)
        {
            SqlParameter[] parms = { new SqlParameter("@UserId", SqlDbType.Int) };
            parms[0].Value = DBNull.Value;
            if (userId.HasValue)
            {
                parms[0].Value = userId.Value;
            }

            var lscUsers = new List <LscUserInfo>();

            SqlHelper.TestConnection(connectionString);
            using (var rdr = SqlHelper.ExecuteReader(connectionString, CommandType.Text, SqlText.Sql_Lsc_Get_Users, parms)) {
                while (rdr.Read())
                {
                    var lscUser = new LscUserInfo();
                    lscUser.LscID       = lscId;
                    lscUser.LscName     = lscName;
                    lscUser.UserID      = ComUtility.DBNullInt32Handler(rdr["UserID"]);
                    lscUser.UserName    = ComUtility.DBNullStringHandler(rdr["UserName"]);
                    lscUser.UID         = ComUtility.DBNullStringHandler(rdr["UID"]);
                    lscUser.OpLevel     = ComUtility.DBNullUserLevelHandler(rdr["OpLevel"]);
                    lscUser.LimitTime   = ComUtility.DBNullDateTimeHandler(rdr["LimitTime"]);
                    lscUser.TelePhone   = ComUtility.DBNullStringHandler(rdr["TelePhone"]);
                    lscUser.MobilePhone = ComUtility.DBNullStringHandler(rdr["MobilePhone"]);
                    lscUser.Email       = ComUtility.DBNullStringHandler(rdr["Email"]);
                    lscUser.Address     = ComUtility.DBNullStringHandler(rdr["Address"]);
                    lscUser.PostalCode  = ComUtility.DBNullStringHandler(rdr["PostalCode"]);
                    lscUser.Remark      = ComUtility.DBNullStringHandler(rdr["Remark"]);
                    lscUser.Enabled     = ComUtility.DBNullBooleanHandler(rdr["Enabled"]);
                    lscUsers.Add(lscUser);
                }
            }
            return(lscUsers);
        }
예제 #2
0
        /// <summary>
        /// Built Group Tree
        /// </summary>
        /// <param name="userData">userData</param>
        /// <param name="lscUser">lscUser</param>
        private string BuiltGroupTree(CscUserInfo userData, LscUserInfo lscUser)
        {
            try {
                var udGroupNodes = new List <UDGroupTreeInfo>();
                if (UDGroupID != WebUtility.DefaultInt32)
                {
                    var udGroupId = UDGroupID;
                    var group     = lscUser.UDGroups.Find(udg => { return(udg.UDGroupID == udGroupId); });
                    if (group != null)
                    {
                        udGroupNodes = group.UDGroupNodes.FindAll(udg => { return(udg.NodeType != EnmNodeType.Dev); });
                    }
                }

                var nonDevNodes = lscUser.Group.GroupNodes.FindAll(gt => { return(gt.NodeType != EnmNodeType.Dev); });
                var devNodes    = lscUser.Group.GroupNodes.FindAll(gt => { return(gt.NodeType == EnmNodeType.Dev); });
                if (StaTypeComboBox.SelectedIndex > 0)
                {
                    nonDevNodes = nonDevNodes.FindAll(gt => { return(gt.NodeType != EnmNodeType.Sta || gt.Remark.Contains(StaTypeComboBox.SelectedItem.Text)); });
                }
                if (DevTypeComboBox.SelectedIndex > 0)
                {
                    devNodes = devNodes.FindAll(gt => { return(gt.Remark.Contains(DevTypeComboBox.SelectedItem.Text)); });
                }
                if (!String.IsNullOrEmpty(FilterTextField.Text.Trim()))
                {
                    if (FilterTypeComboBox.SelectedItem.Value.Equals("0"))
                    {
                        nonDevNodes = nonDevNodes.FindAll(gt => { return(gt.NodeType != EnmNodeType.Sta || gt.NodeName.Contains(FilterTextField.Text.Trim())); });
                    }
                    else if (FilterTypeComboBox.SelectedItem.Value.Equals("1"))
                    {
                        devNodes = devNodes.FindAll(gt => { return(gt.NodeName.Contains(FilterTextField.Text.Trim())); });
                    }
                }

                var root = new Ext.Net.TreeNode();
                root.Text              = "动力环境监控中心系统";
                root.NodeID            = "-1&-1";
                root.Icon              = Icon.House;
                root.Leaf              = false;
                root.Expanded          = true;
                root.SingleClickExpand = true;
                root.CustomAttributes.Add(new ConfigItem("TreeNodeType", ((int)EnmNodeType.Null).ToString(), ParameterMode.Raw));
                UDGSettingCenterPanel.Root.Clear();
                UDGSettingCenterPanel.Root.Add(root);
                BuiltGroupTreeCallback(nonDevNodes, devNodes, root, 0, udGroupNodes);

                var cacheKey      = WebUtility.GetCacheKeyName(userData, "udg-setting-devs");
                var cacheDuration = Int32.Parse(WebConfigurationManager.AppSettings["MaxCacheDuration"]);
                HttpRuntime.Cache.Insert(cacheKey, devNodes, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(cacheDuration), CacheItemPriority.Default, null);
                return(UDGSettingCenterPanel.Root.ToJson());
            } catch { throw; }
        }
예제 #3
0
파일: User.cs 프로젝트: radtek/PecsSystem
        /// <summary>
        /// Method to get LSC user
        /// </summary>
        /// <param name="uId">uId</param>
        /// <param name="pwd">pwd</param>
        public List <LscUserInfo> GetUser(string uId, string pwd)
        {
            SqlParameter[] parms = { new SqlParameter("@UID", SqlDbType.VarChar, 20),
                                     new SqlParameter("@PWD", SqlDbType.VarChar, 20) };
            parms[0].Value = uId;
            if (pwd == null)
            {
                parms[1].Value = DBNull.Value;
            }
            else
            {
                parms[1].Value = pwd;
            }

            var lscUsers = new List <LscUserInfo>();

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_USER_GETUSER, parms)) {
                while (rdr.Read())
                {
                    var lscUser = new LscUserInfo();
                    lscUser.LscID                 = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                    lscUser.LscName               = ComUtility.DBNullStringHandler(rdr["LscName"]);
                    lscUser.UserID                = ComUtility.DBNullInt32Handler(rdr["UserID"]);
                    lscUser.UserName              = ComUtility.DBNullStringHandler(rdr["UserName"]);
                    lscUser.UID                   = ComUtility.DBNullStringHandler(rdr["UID"]);
                    lscUser.OpLevel               = ComUtility.DBNullUserLevelHandler(rdr["OpLevel"]);
                    lscUser.LimitTime             = ComUtility.DBNullDateTimeHandler(rdr["LimitTime"]);
                    lscUser.TelePhone             = ComUtility.DBNullStringHandler(rdr["TelePhone"]);
                    lscUser.MobilePhone           = ComUtility.DBNullStringHandler(rdr["MobilePhone"]);
                    lscUser.Email                 = ComUtility.DBNullStringHandler(rdr["Email"]);
                    lscUser.Address               = ComUtility.DBNullStringHandler(rdr["Address"]);
                    lscUser.PostalCode            = ComUtility.DBNullStringHandler(rdr["PostalCode"]);
                    lscUser.Remark                = ComUtility.DBNullStringHandler(rdr["Remark"]);
                    lscUser.AlarmSoundFiterItem   = ComUtility.DBNullAlarmSoundFiterItemHandler(rdr["AlarmSoundFiterItem"]);
                    lscUser.AlarmStaticFiterItem  = ComUtility.DBNullAlarmStaticFiterItemHandler(rdr["AlarmStaticFiterItem"]);
                    lscUser.ActiveValuesFiterItem = ComUtility.DBNullActiveValuesFiterItemHandler(rdr["ActiveValuesFiterItem"]);
                    lscUser.Group                 = null;
                    lscUser.UDGroups              = null;
                    lscUser.Enabled               = ComUtility.DBNullBooleanHandler(rdr["Enabled"]);
                    lscUsers.Add(lscUser);
                }
            }
            return(lscUsers);
        }