Example #1
0
        //用户功能权限判断
        protected internal bool _Check_Permission_usr(typePermission_PowerRobot usrPermission, Msg msg, Power_Robot pPower = null)
        {
            //提取权限设置
            bool bPermission = false;

            if (pPower == null)
            {
                pPower = _Permission.Get_Permission(_Permission._configTag, msg.GetNameGroup(), msg.GetNameUser(), msg.usrPlat.ToString());
            }
            if (pPower != null)
            {
                //权限判断
                if ((usrPermission & pPower.UsrPermission) == usrPermission)
                {
                    bPermission = true;
                }
            }

            //无操作权限提示
            if (bPermission == false)
            {
                this.NotifyMsg("权限不足,请联系管理员!", msg, "权限检测(" + this.Title + ")");
            }
            return(bPermission);
        }
Example #2
0
        //行情查询
        protected internal bool _Done_Quote_query(Msg msg, RobotCmd pRobotCmd, typePermission_PowerRobot pPermission = typePermission_PowerRobot.ReadOnly)
        {
            //用户权限判断
            Power_Robot pPowerRobot = pRobotCmd.CmdInfos.PowerRobot;

            if (!this._Check_Permission_usr(pPermission, msg, pPowerRobot))
            {
                return(false);
            }


            //提取行情API配置
            string            stockName    = ((CmdInfos_QuoteQuantify)pRobotCmd.CmdInfos).StockName;
            List <Data_Quote> lstDataQuote = Quote_Manager._Manager.QuoteQuery.Query(stockName);

            if (lstDataQuote == null)
            {
                this.NotifyMsg(string.Format("行情(stockName)查询识别!", stockName), msg, "行情信息");
                return(false);
            }

            //循环生成数据对象
            foreach (var pQuote in lstDataQuote)
            {
                string strMsg = pQuote.GetMsg_Perfix();
                zxcConsoleHelper.Debug(true, "行情信息:\n{0}", strMsg);
                this.NotifyMsg(strMsg, msg, "行情信息");
            }
            return(true);
        }
Example #3
0
        //积分添加
        protected internal bool _Done_Points_operation(Msg msg, RobotCmd pRobotCmd, typePermission_PowerRobot pPermission = typePermission_PowerRobot.Writable, string strReasonDetial = "")
        {
            //用户权限判断
            Power_Robot pPowerRobot = pRobotCmd.CmdInfos.PowerRobot;

            if (!this._Check_Permission_usr(pPermission, msg, pPowerRobot))
            {
                return(false);
            }

            //积分操作
            bool           checkPoints = pRobotCmd.CmdInfos.NoteLabel == "兑换" ? true : false;
            Data_PointsLog pDataLog    = _growthPoints.Add_Points((CmdInfos_PointsGrowth)pRobotCmd.CmdInfos, pPowerRobot.NameUserAlias, checkPoints);

            if (pDataLog != null)
            {
                string strPerfix = pDataLog.PointExChange > 0 ? "恭喜!" : "很遗憾!";
                string strMidfix = pDataLog.PointExChange > 0 ? "获得" + pDataLog.PointsNote_Label + "!" : pDataLog.PointsNote_Label == "兑换" ? "兑换成功!" : "被" + pDataLog.PointsNote_Label + "!";

                string strNumExChange = pDataLog.PointExChange > 0 ? "+" + pDataLog.PointExChange.ToString() : pDataLog.PointExChange.ToString();
                string strExchange    = pDataLog.PointExChange > 0 ? "新增" : "被扣除";
                string strReason      = strExchange.Replace("被", "") + "原由";
                string strRemark      = string.IsNullOrEmpty(pDataLog.Remark) ? "" : string.Format("({0}).", pDataLog.Remark);
                if (pDataLog.PointsNote_Label == "兑换")
                {
                    strReason = "兑换内容";
                }
                else if (pDataLog.PointsNote_Label == "奖励")
                {
                    strReason = "奖励原由";
                }

                if (pDataLog.IsValid)
                {
                    string strMsg = string.Format("{0}「{1}」{2} 个宝贝分.", strPerfix, pDataLog.PointsUser, strNumExChange);
                    strMsg = string.Format("{0}\n{1}:{2}{3}\n审核人:{4}\n当前分:{5} 宝贝分", strMsg, strReason, strReasonDetial != "" ? strReasonDetial : pDataLog.PointsNote, strRemark, pDataLog.PointsUser_OP, pDataLog.PointsNow);

                    zxcConsoleHelper.Debug(true, "宝贝分变动:{0}\n{1}", strMidfix, strMsg);
                    this.NotifyMsg(strMsg, msg, "宝贝分变动:" + strMidfix);
                    return(true);
                }
                else
                {
                    string strMsg = string.Format("{0}:{1}{2} \n兑换消耗:{3} 宝贝分 \n兑换失败:当前 {4} 宝贝分,不足以兑换.", strReason, pDataLog.PointsNote, strRemark, strNumExChange, pDataLog.PointsNow);
                    zxcConsoleHelper.Debug(true, "宝贝分提示:兑换失败!\n{0}", strMsg);
                    this.NotifyMsg(strMsg, msg, "宝贝分提示:兑换失败!");
                }
            }
            return(false);
        }
Example #4
0
        //识字学习
        protected internal bool _Done_Points_StudyWord(Msg msg, RobotCmd pRobotCmd, typePermission_PowerRobot pPermission = typePermission_PowerRobot.Writable)
        {
            //用户权限判断
            Power_Robot pPowerRobot = pRobotCmd.CmdInfos.PowerRobot;

            if (!this._Check_Permission_usr(pPermission, msg, pPowerRobot))
            {
                return(false);
            }

            //汉字识字
            Word pWord = Word_Manager._Manager.GetWord_ByUser(pRobotCmd.CmdInfos.NoteUserTag);

            if (pWord == null)
            {
                this.NotifyMsg("字库汉字已经学完,请检查!", msg, "宝贝学习(识字)");
                return(false);
            }

            //信息提示
            CmdInfos_PointsGrowth pGrowthPoints = (CmdInfos_PointsGrowth)pRobotCmd.CmdInfos;
            string strMsg = string.Format("新汉字:【{0}】\n识字奖励:{1} 宝贝分.\n任务提示:回复字音,确认后获得奖励!\n发布人:{2}", pWord.WordStr, pGrowthPoints.PointsNum, pPowerRobot.NameUserAlias);

            this.NotifyMsg(strMsg, msg, "宝贝学习(识字)");


            //发送字形图片
            string strWordImg = pWord.Get_Image();

            this.NotifyMsg(strWordImg, msg, "", typeMsg.IMAGE);

            //发送字音文件
            string strWordSound = pWord.Get_Sound();

            this.NotifyMsg(strWordSound, msg, "", typeMsg.FILE);

            //发送字笔画gif
            //string strWordStrokesImg = pWord.Get_StrokesImage();
            //this.NotifyMsg(strWordStrokesImg, msg, "", typeMsg.IMAGE);

            //记录日志
            if (Word_Manager._Manager.InitWord_Record(pRobotCmd.CmdInfos.NoteUserTag, pWord, zxcStudy.Record.typeWordRecord.None, "已学"))
            {
                return(true);
            }
            return(false);
        }
Example #5
0
        //积分添加
        protected internal bool _Done_Quote_MonitorSet(Msg msg, RobotCmd pRobotCmd, typePermission_PowerRobot pPermission = typePermission_PowerRobot.ReadOnly)
        {
            //用户权限判断
            Power_Robot pPowerRobot = pRobotCmd.CmdInfos.PowerRobot;

            if (!this._Check_Permission_usr(pPermission, msg, pPowerRobot))
            {
                return(false);
            }


            //提取行情API配置
            string stockName = ((CmdInfos_QuoteQuantify)pRobotCmd.CmdInfos).StockName;

            if (string.IsNullOrEmpty(stockName))
            {
                this.NotifyMsg("未指定标的名称,无法配置!", msg, "行情信息");
                return(false);
            }

            //检查标的信息
            bool isValid = stockName.Substring(0, 1) != "-";

            stockName = stockName.Replace("+", "").Replace("-", "");
            StockInfo pStockInfo = Quote_Manager._Manager.Stocks.Get_StockInfo(stockName);

            if (pStockInfo == null)
            {
                this.NotifyMsg(string.Format("标的({0})未识别!情检查确认。", stockName), msg, "行情信息");
                return(false);
            }

            //更新API监测配置
            if (Quote_Manager._Manager.QuoteMonitor._MonitorSets.Updata_APISets(pStockInfo.StockID_TagSina, isValid))
            {
                MonitorSet pSet   = Quote_Manager._Manager.QuoteMonitor._MonitorSets.Get_MonitorSet(pStockInfo.StockID_TagSina);
                string     strMsg = string.Format("标的({0}) {1} 行情监测。", pStockInfo.StockName, pSet == null ? "已移除" : pSet.IsValid ? "已启动" : "已暂停");
                zxcConsoleHelper.Debug(true, "行情信息:\n{0}", strMsg);
                this.NotifyMsg(strMsg, msg, "行情信息");
            }
            return(true);
        }
Example #6
0
        /// <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);
        }
Example #7
0
        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);
        }
Example #8
0
        protected internal bool _Done_Points_StudyWord_ok(Msg msg, RobotCmd pRobotCmd, typePermission_PowerRobot pPermission = typePermission_PowerRobot.Writable)
        {
            //汉字识字
            Word        pWord   = Word_Manager._Manager.GetWord_ByUser(pRobotCmd.CmdInfos.NoteUserTag);
            Word_Record pRecord = Word_Manager._Manager._zxcWordRecords.Where(e => e.WordStr == pWord.WordStr && e.RecordType == typeWordRecord.None && e.IsDel == false).FirstOrDefault();

            if (pRecord == null)
            {
                this.NotifyMsg("当前没有正在学习的汉字,请检查!", msg, "宝贝学习(识字)");
                return(false);
            }

            //积分变动
            if (Word_Manager._Manager.InitWord_Record(pRobotCmd.CmdInfos.NoteUserTag, pWord, zxcStudy.Record.typeWordRecord.字形, "已学"))
            {
                _Done_Points_operation(msg, pRobotCmd, pPermission, string.Format("新识【{0}】字({1})", pWord.WordStr, zxcStudy.Record.typeWordRecord.字形.ToString()));
            }
            if (Word_Manager._Manager.InitWord_Record(pRobotCmd.CmdInfos.NoteUserTag, pWord, zxcStudy.Record.typeWordRecord.字音, "已学"))
            {
                _Done_Points_operation(msg, pRobotCmd, pPermission, string.Format("新识【{0}】字({1})", pWord.WordStr, zxcStudy.Record.typeWordRecord.字音.ToString()));
            }
            return(true);
        }