public override bool Init(string[] strCmds) { //"@新增 5分 放学自觉读书" if (strCmds.Length < 3) { if (PowerRobot == null) { return(base.Init(strCmds)); } Power_Robot_UserSet pUserSet = this.PowerRobot.UserSets.Find(e => e.SetTag == strCmds[0]); if (pUserSet == null) { return(base.Init(strCmds)); } CmdPermission = pUserSet.SetPermission; PointsNum = Convert.ToInt32(pUserSet.SetValue); NoteInfo = pUserSet.SetTag; NoteLabel = pUserSet.SetLabel; Remark = pUserSet.Remark; if (Remark == "" && strCmds.Length > 1) { Remark = strCmds[1]; } strCmds = new[] { strCmds[0], PointsNum.ToString(), NoteInfo, Remark }; } else { PointsNum = Convert.ToInt32(strCmds[1].Replace("分", "")); if (strCmds[0] == "宝贝分") { NoteInfo = strCmds[2]; if (strCmds.Length > 3) { NoteLabel = strCmds[3]; } else { if (NoteInfo.Contains("赠送")) { NoteLabel = "赠送"; } else { NoteLabel = PointsNum >= 0 ? "奖励" : "惩罚"; } } } } this.IsVaild = true; return(base.Init(strCmds)); }
public override bool Init(string[] strCmds) { //"@新增 5分 放学自觉读书" if (strCmds.Length < 2) { Power_Robot_UserSet pUserSet = this.PowerRobot.UserSets.Find(e => e.SetTag == strCmds[0]); if (pUserSet == null) { return(false); } //CmdPermission = pUserSet.SetPermission; } else { StockName = strCmds[1]; } this.IsVaild = true; return(base.Init(strCmds)); }
/// <summary>权限新增 /// </summary> /// <returns></returns> public virtual bool Add_Permission(string nameRobot, string nameGroup, string usrID, string usrNameAlias, string usrPlat, bool isValid, string bindTag, string usrPermission = "0", List <Power_Robot_UserSet> userSets = null) { usrPermission = usrPermission == "" ? "0" : usrPermission; typePermission_PowerRobot pPermission = (typePermission_PowerRobot)Enum.Parse(typeof(typePermission_PowerRobot), Convert.ToString(usrPermission)); Power_Robot pPowerInfo = new Power_Robot() { NameRobot = nameRobot, NameUser = usrID, NameUserAlias = usrNameAlias, NameGroup = nameGroup, UsrPlat = usrPlat, UsrPermission = pPermission, IsValid = isValid, BindTag = bindTag }; if (userSets != null) { foreach (var item in userSets) { Power_Robot_UserSet pUserSet = pPowerInfo.UserSets.Find(e => e.SetTag == item.SetTag); if (pUserSet != null) { //pPowerInfo.UserSets.Remove(pUserSet); pUserSet.SetValue = item.SetValue; pUserSet.SetPermission = item.SetPermission; pUserSet.IsValid = item.IsValid; pUserSet.SetLabel = item.SetLabel; pUserSet.Remark = item.Remark; } else { pPowerInfo.UserSets.Add((Power_Robot_UserSet)item.Clone()); } } } Robot_Manager._dbRobot._powerRobot.Add(pPowerInfo, true, true, false); return(true); }
protected internal virtual bool Init() { //实例生效->未初始?-> 默认配置生成(群组有效?、全部群组有效?、群组全员有效?、私聊有效?、私聊全员有效?) -> 已初始; if (this.IsInited) { return(true); } string path = _configPerFix + ":" + _configMidFix; string title = _configDataCache.config[path + ":Title"] + ""; if (title == "") { return(false); } this.IsValid = Convert.ToBoolean(_configDataCache.config[path + ":IsValid"] + ""); this.IsShieldSys = Convert.ToBoolean(_configDataCache.config[path + ":IsShieldSys"] + ""); ValidMaxTime = Convert.ToInt32(_configDataCache.config[path + ":ValidMaxTime"] + ""); this.IsSingleUse = Convert.ToBoolean(_configDataCache.config[path + ":IsSingleUse"] + ""); this.IsBackProc = Convert.ToBoolean(_configDataCache.config[path + ":IsBackProc"] + ""); this.IsValid_Group = Convert.ToBoolean(_configDataCache.config[path + ":IsValid_Group"] + ""); this.IsValid_GroupAll = Convert.ToBoolean(_configDataCache.config[path + ":IsValid_GroupAll"] + ""); this.IsValid_GroupAll_UserALL = Convert.ToBoolean(_configDataCache.config[path + ":IsValid_GroupAll_UserALL"] + ""); this.IsValid_Personal = Convert.ToBoolean(_configDataCache.config[path + ":IsValid_Personal"] + ""); this.IsValid_PersonalAll = Convert.ToBoolean(_configDataCache.config[path + ":IsValid_PersonalAll"] + ""); this._bindTag = _configDataCache.config[path + ":BindTag"] + ""; //同步用户信息-群组 string name = _configTag; int ind = 0; string IsValid_GroupName = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":nameGroup"] + ""; while (IsValid_GroupName != "") { string usrPlat = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":usrPlat"] + ""; string bindTag = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":bindTag"] + ""; bindTag = bindTag == "" ? this._bindTag : bindTag; //同步用户自定义设置信息 List <Power_Robot_UserSet> userSets = new List <Power_Robot_UserSet>(); int indusrSet = 0; string usrSetTag = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":bindSetInfos:" + indusrSet.ToString() + ":setTag"]; while (usrSetTag != null) { string usrSetValue = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":bindSetInfos:" + indusrSet.ToString() + ":setValue"] + ""; string strValid = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":bindSetInfos:" + indusrSet.ToString() + ":isValid"] + ""; string setLabel = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":bindSetInfos:" + indusrSet.ToString() + ":setLabel"] + ""; string strRemark = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":bindSetInfos:" + indusrSet.ToString() + ":remark"] + ""; bool isValid = strValid == "" ? false : Convert.ToBoolean(strValid); string strPermission = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":bindSetInfos:" + indusrSet.ToString() + ":setPermission"] + ""; typePermission_PowerRobot setPermission = (typePermission_PowerRobot)Enum.Parse(typeof(typePermission_PowerRobot), Convert.ToString(strPermission)); Power_Robot_UserSet pUserSet = new Power_Robot_UserSet() { SetTag = usrSetTag, SetValue = usrSetValue, IsValid = isValid, SetLabel = setLabel, Remark = strRemark, SetPermission = setPermission }; userSets.Add(pUserSet); indusrSet++; usrSetTag = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":bindSetInfos:" + indusrSet.ToString() + ":setTag"]; } //同步用户信息 int indusr = 0; string nameUser = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":usrsSet:" + indusr.ToString() + ":nameUser"]; while (nameUser != null) { string nameUserAlias = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":usrsSet:" + indusr.ToString() + ":nameUserAlias"] + ""; string usrPermission = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":usrsSet:" + indusr.ToString() + ":usrPermission"] + ""; string strValid = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":usrsSet:" + indusr.ToString() + ":isValid"] + ""; string strBindTag = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":usrsSet:" + indusr.ToString() + ":bindTag"] + ""; strBindTag = strBindTag == "" ? bindTag : strBindTag; bool isValid = strValid == "" ? false : Convert.ToBoolean(strValid); this.Add_Permission(name, IsValid_GroupName, nameUser, nameUserAlias, usrPlat, isValid, strBindTag, usrPermission, userSets); indusr++; nameUser = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":usrsSet:" + indusr.ToString() + ":nameUser"]; } if (IsValid_PersonalAll) { this.Add_Permission(name, IsValid_GroupName, "", "", usrPlat, true, bindTag, "1", userSets); } ind++; IsValid_GroupName = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":nameGroup"] + ""; } //同步用户信息-个人 ind = 0; string IsValid_PersonalName = _configDataCache.config[path + ":IsValid_PersonalNames:" + ind.ToString() + ":nameUser"] + ""; while (IsValid_PersonalName != "") { string nameUserAlias = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":nameUserAlias"] + ""; string usrPlat = _configDataCache.config[path + ":IsValid_PersonalNames:" + ind.ToString() + ":usrPlat"] + ""; string usrPermission = _configDataCache.config[path + ":IsValid_GroupNames:" + ind.ToString() + ":usrPermission"] + ""; string strValid = _configDataCache.config[path + ":IsValid_PersonalNames:" + ind.ToString() + ":isValid"] + ""; string bindTag = _configDataCache.config[path + ":IsValid_PersonalNames:" + ind.ToString() + ":bindTag"] + ""; bool isValid = strValid == "" ? false : Convert.ToBoolean(strValid); bindTag = bindTag == "" ? this._bindTag : bindTag; this.Add_Permission(name, "", IsValid_PersonalName, nameUserAlias, usrPlat, isValid, bindTag, usrPermission); ind++; IsValid_PersonalName = _configDataCache.config[path + ":IsValid_PersonalNames:" + ind.ToString() + ":nameUser"] + ""; } this.IsInited = true; return(true); }