Exemplo n.º 1
0
        static MutliLevelData getLotteryDic()
        {
            MutliLevelData ret    = new MutliLevelData();
            string         xml    = TextFileComm.getFileText("LotteryList.xml", "xml");
            XmlDocument    xmldoc = new XmlDocument();

            try
            {
                xmldoc.LoadXml(xml);
                XmlNode     root      = xmldoc.SelectSingleNode("root");
                XmlNodeList typenodes = root.SelectNodes("lotteryType/item");
                foreach (XmlNode typenode in typenodes)
                {
                    string  val  = XmlUtil.GetSubNodeText(typenode, "@value");
                    string  text = XmlUtil.GetSubNodeText(typenode, "@text");
                    KeyText k    = new KeyText(val, text);
                    if (ret.SubList.ContainsKey(k))
                    {
                        continue;
                    }
                    ret.SubList.Add(k, getNextLevel(root, val));
                }
            }
            catch (Exception ce)
            {
                return(ret);
            }
            return(ret);
        }
Exemplo n.º 2
0
        public static MutliLevelData createAValidateSubmitData(string yesVal, string strYes, string noVal, string strNo)
        {
            MutliLevelData ret = new MutliLevelData();

            ret.AddSub(yesVal, strYes, null);
            MutliLevelData noselect = ret.AddSub(noVal, strNo, null);

            return(ret);
        }
Exemplo n.º 3
0
 public KeyText AddSub(KeyText key, MutliLevelData val)
 {
     if (!SubList.ContainsKey(key))
     {
         SubList.Add(key, val);
         return(key);
     }
     return(null);
 }
Exemplo n.º 4
0
        public MutliLevelData AddSub(string val, string text, MutliLevelData obj)
        {
            KeyText key = new KeyText(val, text);

            if (!SubList.ContainsKey(key))
            {
                SubList.Add(key, obj);
                return(obj);
            }
            return(null);
        }
        public override bool Response(ref ShareLotteryPlanClass optPlan)
        {
            optPlan = currPlan;
            if (currPlan == null)
            {
                answerMsg(optPlan == null ? "本群目前没有合买" : null);
                return(false);
            }
            if (currPlan.creator != requestUser)
            {
                answerMsg(string.Format("本次合买由{0}创建,您没有修改权限!", currPlan.creatorNike));
                return(false);
            }
            if (currPlan.sharePlanStatus != SharePlanStatus.Ready)
            {
                answerMsg("合买处于非初始状态,提供合买信息无效!");
                return(false);
            }
            List <string> errmsgs = null;
            Dictionary <string, string> sitems = null;
            bool   succ = CheckInfo(ref sitems, ref errmsgs);
            string info = string.Join("\r\n", sitems.Select(a => string.Format("{0}=>{1}", a.Key, a.Value)));

            if (succ)
            {
                TheAskWaitingUserAnswer ask = new TheAskWaitingUserAnswer(this);
                this.Buffs.Add(sitems);
                ask.askData = MutliLevelData.createAValidateSubmitData("1", "确定", "0", "取消");
                ask.askMsg  = string.Format(@"{0}
请确定您提供的信息无误?如果确定,我们将开始进入认购环节!
{1}",
                                            info,
                                            ask.AskText);
                wxprocess.InjectAsk(ask);
                answerMsg(ask.askMsg);
                return(false);
            }
            else
            {
                string m = string.Format(@"下列信息有误,请修改后重新提交正确的信息:
{0}", string.Join(";", errmsgs));
                answerMsg(m);
            }
            return(true);
        }
        public override bool Response(ref ShareLotteryPlanClass optPlan)
        {
            optPlan = null;

            if (currPlan != null)
            {
                optPlan = currPlan;
            }
            if (currPlan == null)
            {
                answerMsg(optPlan == null ? "本群目前没有合买" : null);
                return(false);
            }
            if (currPlan.creator != requestUser)
            {
                answerMsg(string.Format("本次合买由{0}创建,您没有修改权限!", currPlan.creatorNike));
                return(false);
            }
            currstatus = currPlan.sharePlanStatus;
            if (changeToStatus == currstatus)
            {
                answerMsg(string.Format("状态{0}!", newStatusName));
                return(false);
            }
            if (((int)changeToStatus - (int)currstatus) > 1 && changeToStatus != SharePlanStatus.Completed)
            {
                answerMsg(string.Format("除非关闭合买,否则合买状态不能越级操作!"));
                return(false);
            }
            if (updateVals != null)
            {
                Buffs.Add(updateVals);
            }
            TheAskWaitingUserAnswer ask = new TheAskWaitingUserAnswer(this);

            ask.askData = MutliLevelData.createAValidateSubmitData("1", "确定", "0", "取消");
            ask.askMsg  = string.Format(@"请确定将合买状态修改为{0}!
{1}",
                                        newStatusName,
                                        ask.AskText);
            wxprocess.InjectAsk(ask);
            answerMsg(ask.askMsg);
            return(false);
        }
Exemplo n.º 7
0
        static MutliLevelData getNextLevel(XmlNode root, string val)
        {
            MutliLevelData ret   = new MutliLevelData();
            XmlNodeList    slist = root.SelectNodes(string.Format("lottery[@type='{0}']/item", val));

            foreach (XmlNode snode in slist)
            {
                string  v  = XmlUtil.GetSubNodeText(snode, "@value");
                string  t  = XmlUtil.GetSubNodeText(snode, "@text");
                KeyText sk = new KeyText(v, t);
                if (ret.SubList.ContainsKey(sk))
                {
                    continue;
                }

                ret.SubList.Add(sk, getNextLevel(root, v));
            }
            return(ret);
        }
        public override bool Response(ref ShareLotteryPlanClass optPlan)
        {
            if (currPlan.sharePlanStatus != SharePlanStatus.Subscribing)
            {
                answerMsg(string.Format("合买处于非{0}状态,认购份数无效!", ShareLotteryPlanClass.StatusDic[SharePlanStatus.Subscribing]));
                return(false);
            }
            Regex           regTr  = new Regex(@"(\d+)");
            MatchCollection mcs    = regTr.Matches(pureMsg);
            int             shares = 0;

            if (mcs.Count > 0)
            {
                int.TryParse(mcs[0].Value, out shares);
            }
            var    version = Regex.Replace(pureMsg, @"(.*\[)(.*)(\].*)", "$2"); //小括号()
            Regex  rgx     = new Regex(@"(?i)(?<=\[)(.*)(?=\])");               //中括号[]
            string tmp     = rgx.Match(pureMsg).Value;                          //中括号[]

            if (shares == 0 || mcs.Count == 0)
            {
                string ret = "你耍我,提供真正的份数!";


                answerMsg(ret);
                return(false);
            }
            TheAskWaitingUserAnswer ask = new TheAskWaitingUserAnswer(this);

            this.Buffs.Add(shares);
            ask.askData = MutliLevelData.createAValidateSubmitData("1", "确定", "0", "取消");
            ask.askMsg  = string.Format(@"您的认购分数为:{0}份,合计金额:{1}元;
请确定您提供的信息无误?
{2}",
                                        shares,
                                        shares * currPlan.shareAmount,
                                        ask.AskText);
            wxprocess.InjectAsk(ask);
            answerMsg(ask.askMsg);
            return(false);
        }
Exemplo n.º 9
0
        public override bool Response(ref ShareLotteryPlanClass optPlan)
        {//(.*?)手动下注(|:)((\d+|.*)/(.*)\d+((/\d+)?))((\+|\s)((\d+|.*)/\d+((/\d+)?)))*
            Regex           regTr       = new Regex(@"有(.*?)[的券|券|吗]");
            MatchCollection mcs         = regTr.Matches(pureMsg);
            string          lotteryName = null;
            string          content     = null;

            if (mcs.Count == 1)
            {
                lotteryName = mcs[0].Groups[1].Value;
                content     = mcs[0].Groups[3].Value;
                lotteryName = lotteryName.Replace("没有", "").Replace("的优惠", "").Replace("优惠", "").Replace("的券", "").Replace("券", "");
            }
            else
            {
                answerMsg("抱歉,本汪无法理解您提交的内容!");
                return(false);
            }
            TheAskWaitingUserAnswer ask = new TheAskWaitingUserAnswer(this);

            this.Buffs.Clear();
            this.Buffs.Add(lotteryName);
            this.Buffs.Add(content);
            ask.askData = new MutliLevelData();
            ask.askData.AddSub("1", "确定", null);
            MutliLevelData noselect = ask.askData.AddSub("0", "否", new MutliLevelData());

            noselect.AddSub("0", "停止查询商品", null);
            noselect.AddSub("1", "重新提交其他条件", null);
            ask.askMsg = string.Format(@"确定查找{0}的券?", lotteryName, ask.AskText);
            wxprocess.InjectAsk(ask);
            answerMsg(ask.askMsg);
            return(false);


            optPlan = null;
            return(false);
            //return base.Response();
        }
        public override bool ResponseAsk(TheAskWaitingUserAnswer ask)
        {
            if (ask.AnswerResult.key == "0")//结束流程
            {
                answerMsg("欢迎下次使用!");
                return(false);
            }
            else
            {
                PlanShareBetInfo pbi = new PlanShareBetInfo(ask.LastRequestWaitResponse.currPlan.shareAmount.Value);
                pbi.betWxName       = requestUser;
                pbi.betNikeName     = requestNike;
                pbi.subscribeShares = int.Parse(Buffs[0].ToString());
                pbi.needPayAmount   = pbi.subscribeShares * ask.LastRequestWaitResponse.currPlan.shareAmount.Value;

                currPlan.subscribeList.Add(pbi);
                answerMsg(pbi.toSubscribeString());
                ResponseAction_ShowPlan sp = new ResponseAction_ShowPlan(wxprocess, wxmsg);
                sp.currPlan = currPlan;

                sp.answerMsg();
                int realcnt = sp.currPlan.subscribeList.Sum(a => a.subscribeShares);
                if (realcnt >= sp.currPlan.planShares)
                {
                    ResponseAction_ModifyStatus msp = new ResponseAction_ModifyStatus(wxprocess, wxmsg, SharePlanStatus.Paying, realcnt.ToString());
                    msp.requestUser = currPlan.creator;
                    msp.requestNike = currPlan.creatorNike;
                    string m = "计划募集份数已经达到,请确定是否继续超额募集!选否将停止接受认购!";
                    TheAskWaitingUserAnswer newask = new TheAskWaitingUserAnswer(msp, roomId, currPlan.creator, currPlan.creatorNike);
                    newask.askData = MutliLevelData.createAValidateSubmitData("1", "确定", "0", "取消");
                    newask.askMsg  = string.Format(@"计划募集份数已经达到,请确定是否继续超额募集!选否将停止接受认购!
{0}", newask.AskText);
                    wxprocess.InjectAsk(newask);
                    answerMsg(newask.askMsg, null, currPlan.creatorNike);
                }
                return(true);
            }
        }
Exemplo n.º 11
0
        public override bool Response(ref ShareLotteryPlanClass optPlan)
        {
            Regex           regTr     = new Regex(@"\d+");
            MatchCollection mcs       = regTr.Matches(pureMsg);
            int             chargeAmt = 0;

            if (mcs.Count > 0)
            {
                int.TryParse(mcs[0].Value.Trim(), out chargeAmt);
            }
            TheAskWaitingUserAnswer ask = new TheAskWaitingUserAnswer(this);

            if (chargeAmt <= 0 || (chargeAmt % 100) == 0 || chargeAmt > 4500 || chargeAmt < 151)
            {
                string retMsg = "充值金额非法!请输入正确的充值金额数量,金额介于151~4500之间,不能为100的整数倍!";
                answerMsg(retMsg);
                return(false);
            }
            else
            {
                this.Buffs.Clear();
                this.Buffs.Add(chargeAmt);
                ask.askData = new MutliLevelData();
                ask.askData.AddSub("1", "确定", null);
                MutliLevelData noselect = ask.askData.AddSub("0", "否", new MutliLevelData());
                noselect.AddSub("0", "停止充值", null);
                noselect.AddSub("1", "重新申请其他金额", null);
                ask.askMsg = string.Format(@"确定刷卡{0}元?
{1}", chargeAmt, ask.AskText);
                wxprocess.InjectAsk(ask);
                answerMsg(ask.askMsg);
                return(false);
            }
            optPlan = null;
            return(false);
            //return base.Response();
        }
Exemplo n.º 12
0
        public override bool Response(ref ShareLotteryPlanClass optPlan)
        {
            optPlan = null;
            lastAsk = wxprocess.getLastAsk(roomId, requestUser);
            if (lastAsk == null)
            {
                return(base.Response(ref optPlan));//当作不知道
            }
            if (answers.Count == 0)
            {
                answerMsg("请按提示回答上一个问题!");
                return(false);
            }
            MutliLevelData mld = lastAsk.askData;

            if (!mld.SubList.Keys.Select(a => a.key).ToList().Contains(answers[0]))
            {
                if (mld != null && mld.Parent.SubList.Keys.Select(a => a.key).ToList().Contains(answers[0]))//返回上级
                {
                    MutliLevelData parent = mld.Parent?.Parent;
                    mld = mld.Parent;
                    if (mld.Parent != null)
                    {
                        mld.Parent = parent;
                    }
                }
                else
                {
                    string msg = @"你回复的数字未在我期望范围内:请继续回复上一个问题!";
                    answerMsg(msg);
                    answerMsg(lastAsk.askMsg);//重复上一个问题
                    return(false);
                }
            }
            KeyText result = mld.SubList.Where(a => a.Key.key == answers[0]).First().Key;

            lastAsk.AnswerResult = result;
            if (lastAsk.UserResponseAnswer == null)
            {
                lastAsk.UserResponseAnswer = new List <string>();
            }
            lastAsk.UserResponseAnswer.Add(answers[0]);
            if (mld.SubList[result] != null && mld.SubList[result].SubList.Count > 0)//如果还有下级问题,继续问
            {
                lastAsk.askData        = mld.SubList[result];
                lastAsk.askData.Parent = mld;
                lastAsk.askMsg         = lastAsk.AskText;
                lastAsk.LastRequestWaitResponse.lastAsk = lastAsk;
                wxprocess.setLastAsk(lastAsk);
                answerMsg(lastAsk.askMsg);
                return(false);
            }


            wxprocess.CopyToHistoryAsks(lastAsk);                             //保存至历史
            wxprocess.CloseCurrAsk(lastAsk);                                  //关闭当前等待的
            lastAsk.LastRequestWaitResponse.currPlan = currPlan;
            bool succ = lastAsk.LastRequestWaitResponse.ResponseAsk(lastAsk); //转入最后处理

            if (succ)
            {
                optPlan = lastAsk.LastRequestWaitResponse.currPlan;
            }
            return(succ);
        }
Exemplo n.º 13
0
 public static void Reset()
 {
     _AllLotteryList     = null;
     tAllLotteryNames    = null;
     tAllLotteryNameKeys = null;
 }