Trim()

ExpandedBlockStart.gif ContractedBlock.gif   /**/ /// <summary>
InBlock.gif        
/// 通过User Name获取user id的table
InBlock.gif        
/// 如果有非法的user则提示用户修改并返回null
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="userNameList">user names  比如:Sammy Song;Lili Zhang;</param>
ExpandedBlockEnd.gif        
/// <returns>user table</returns>

None.gif          public  DataTable GetUserIDsForAdmin( string  userNameList)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
                 //对参数字符串处理,比如';;;;;; Sammy Song;;;;;;Lili Zhang;;;;;;' 这样的字符串,先Trim掉两边所有的分号,再把中间多个分号用正则替换成一个
InBlock.gif             userNameList = userNameList.Trim(';');
InBlock.gif            userNameList = Regex.Replace(userNameList, ";+", ";");
InBlock.gif            string[] userCheckString = userNameList.Split(';');
InBlock.gif            List<string> userCheckList = new List<string>();            
InBlock.gif            userCheckList.Add(userCheckString[0].ToLower());
InBlock.gif
InBlock.gif            //去除重复的名字
InBlock.gif            for (int i = 0; i < userCheckString.Length; i++)
ExpandedSubBlockStart.gif ContractedSubBlock.gif             dot.gif{
InBlock.gif                if (!userCheckList.Contains(userCheckString[i].ToLower()) && userCheckString[i].Trim() != "")
ExpandedSubBlockStart.gif ContractedSubBlock.gif                 dot.gif{
InBlock.gif                    userCheckList.Add(userCheckString[i].ToLower());
ExpandedSubBlockEnd.gif                }
ExpandedSubBlockEnd.gif            }
InBlock.gif
InBlock.gif            //获取user table
InBlock.gif            BenQ.Public.Web.WSC.Entity.Wscuser entityCheckUser = new BenQ.Public.Web.WSC.Entity.Wscuser();
InBlock.gif            entityCheckUser.QueryMode = true;
InBlock.gif            entityCheckUser.Account.In(userCheckString);
InBlock.gif            entityCheckUser.Active += true;
ExpandedSubBlockStart.gif ContractedSubBlock.gif            DataTable userTable = entityCheckUser.Query(new QString[]  dot.gif{ entityCheckUser.Userid, entityCheckUser.Account },
InBlock.gif                false, -1).Tables[0];
InBlock.gif
InBlock.gif            //返回的行数小于非重复user name的个数,则有非法的user name,提示用户出错
InBlock.gif            if (userTable.Rows.Count != userCheckList.Count)
ExpandedSubBlockStart.gif ContractedSubBlock.gif             dot.gif{
InBlock.gif                for (int j = 0; j < userTable.Rows.Count; j++)
ExpandedSubBlockStart.gif ContractedSubBlock.gif                 dot.gif{
InBlock.gif                    if (userCheckList.Contains(userTable.Rows[j]["account"].ToString().ToLower()))
ExpandedSubBlockStart.gif ContractedSubBlock.gif                     dot.gif{
InBlock.gif                        userCheckList.Remove(userTable.Rows[j]["account"].ToString().ToLower());
ExpandedSubBlockEnd.gif                    }
ExpandedSubBlockEnd.gif                }
InBlock.gif                string invalidUser = "";
InBlock.gif                for (int k = 0; k < userCheckList.Count; k++)
ExpandedSubBlockStart.gif ContractedSubBlock.gif                 dot.gif{
InBlock.gif                    invalidUser += "," + userCheckList[k];
ExpandedSubBlockEnd.gif                }
InBlock.gif                invalidUser = invalidUser.TrimStart(',');
InBlock.gif                this.showMessageInfo(this.getMessage("WM10005").Replace("%User%", invalidUser));
InBlock.gif                return null;
ExpandedSubBlockEnd.gif            }
InBlock.gif            //没有非法用户,
InBlock.gif            return userTable;
ExpandedBlockEnd.gif        }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值