public void RunEventRules(string eventName, Item pageItem = null, params string[] values)
        {
            Assert.IsNotNullOrEmpty(eventName, $"{nameof(RulesService)}.{nameof(RunEventRules)} parameter {nameof(eventName)} is required");

            var ruleContext = new EventRuleContext()
            {
                EventName = eventName,
                Item      = pageItem,
                Value1    = ParamUtil.GetValue(1, values),
                Value2    = ParamUtil.GetValue(2, values),
                Value3    = ParamUtil.GetValue(3, values)
            };

            // Run Global Rules
            using (new SecurityDisabler())
            {
                var root = Utils.ItemUtil.GetItemById(ItemIds.GlobalRules.EventRules);
                if (root == null)
                {
                    return; // no root, exit
                }
                RuleList <EventRuleContext> rules = RuleFactory.GetRules <EventRuleContext>(root, "Rule");
                if (rules != null)
                {
                    rules.Run(ruleContext);
                }
            }
        }
Exemple #2
0
        public FileContentResult getQRImage()
        {
            Hashtable aHT = Authorizes.GetAuthorizeCache(Request);

            if (aHT != null)
            {
                string channel = Request.QueryString["c"];
                string payId   = Request.QueryString["p"];
                if (channel == "qrway" && double.TryParse(Request["a"], out double amount) && amount > 0)
                {
                    // 得到接口数据并解析其对应的支付接口逻辑。
                    Hashtable htPayment = PaymentUtil.GetPaymethod2Hashtable(channel, payId);
                    if (htPayment != null)
                    {
                        UriUtil uriUtil = null;
                        try
                        {
                            uriUtil = new UriUtil(PickParam(htPayment).GetValueAsString("PAYLINK"));
                        }
                        catch (Exception)
                        {
                        }

                        if (uriUtil != null)
                        {
                            ParamUtil paramUtil = PickParam(Request.QueryString).Merge(htPayment).SetCmd(uriUtil.GetQueryItem(ActionUtil.Cmd)).ExecuteCmd(uriUtil.GetActionInstance(GetControl()));
                            if (paramUtil.IsOK())
                            {
                                return(File(paramUtil.GetValue <byte[]>(), paramUtil.GetValueAsString("content-type")));
                            }
                        }
                    }
                }
            }

            // 返回默认二维码图片
            using (Image image = Image.FromFile(Server.MapPath("~/content/images/noimage.png")))
            {
                using (MemoryStream ms1 = new MemoryStream())
                {
                    image.Save(ms1, System.Drawing.Imaging.ImageFormat.Png);

                    return(File(ms1.ToArray(), "image/png"));
                }
            }
        }
Exemple #3
0
        public void Trigger(string makerKey, string eventName, params string[] values)
        {
            //Assert.IsNotNullOrEmpty(makerKey, $"{nameof(IftttService)}.{nameof(Trigger)} parameter {nameof(makerKey)} is required");
            //Assert.IsNotNullOrEmpty(eventName, $"{nameof(IftttService)}.{nameof(Trigger)} parameter {nameof(eventName)} is required");

            // TODO: Add proper queue for scaling
            // TODO: Add governance? - block too many requests?

            using (var client = new HttpClient())
            {
                // Handle optional ifttt data values
                var value1 = ParamUtil.GetValue(1, values);
                var value2 = ParamUtil.GetValue(2, values);
                var value3 = ParamUtil.GetValue(3, values);

                var url = $"https://maker.ifttt.com/trigger/{eventName}/with/key/{makerKey}?value1={value1}&value2={value2}&value3={value3}";

                // Log.Info($"IFTTT Trigger service: {url}", this);
                var response = Task.Run(() => client.GetAsync(url)).Result;
                // Log.Info($"IFTTT Trigger response: {response?.StatusCode} - {response?.ReasonPhrase}", this);
            }
        }
Exemple #4
0
        private void VerifyPasswrod(Hashtable Params)
        {
            string account = PickParam(Params).GetValueAsString();
            string pwd     = PickParam(Params).GetValueAsString("pwd");
            string type    = PickParam(Params).GetValueAsString("type");

            try
            {
                if (type == "pay")
                {
                    DataSet dsMember = new ParamUtil()
                                       .SQLCmdLoadData()
                                       .SQLWithOutSchema()
                                       .SQLEntityScript("CAIKA_MEMBER", string.Format("SELECT * FROM CAIKA_MEMBER WHERE SSOPST='{0}@caika.com'", account))
                                       .ExecuteCmd(ADataLoader.DataLoader())
                                       .GetValueAsDataSet();

                    DataRow rowMember = dsMember.Tables[0].Rows[0];
                    string  signature = new DictSetUtil(null).DoSignature(pwd);
                    if (signature == rowMember.Field <string>("WITHDRAWALS").Trim())
                    {
                        PickParam(Params).Clear().SetParam(true);
                    }
                    else
                    {
                        PickParam(Params).Clear().SetError("密码输入不正确");
                        PickParam(Params).SetParam(false);
                    }
                }
                else
                {
                    // 得到通行证数据
                    DataSet dsPassport = new ParamUtil()
                                         .SQLCmdLoadData()
                                         .SQLEntityScript("SSODOMAINREF", string.Format("SELECT * FROM SSODOMAINREF WHERE DOMAINNAME='caika.com' AND DOMAINUSER='******'", account))
                                         .SQLEntityScript("SSOPASSPORT", string.Format("SELECT * FROM SSOPASSPORT WHERE SSOPST = '{0}@caika.com'", account))
                                         .ExecuteCmd(ADataLoader.DataLoader())
                                         .GetValueAsDataSet();

                    if (dsPassport.Tables["SSODOMAINREF"].Rows.Count == 0 || dsPassport.Tables["SSOPASSPORT"].Rows.Count == 0)
                    {
                        PickParam(Params).Clear().SetError("用户名或密码错误");
                        PickParam(Params).SetParam(false);
                    }
                    else
                    {
                        ParamUtil aPU = new ParamUtil().SetCmd(CVerifyPasswrod).SetParam(dsPassport).SetParam("PSTPWD", pwd).ExecuteCmd(new APassport());
                        if (aPU.IsOK())
                        {
                            PickParam(Params).Clear();
                            PickParam(Params).SetParam(aPU.GetValue());
                        }
                        else
                        {
                            PickParam(Params).Clear().SetError(aPU.GetError());
                            PickParam(Params).SetParam(false);
                        }
                    }
                }
            }
            catch (Exception)
            {
                PickParam(Params).Clear().SetError("校验密码出错");
                PickParam(Params).SetParam(false);
            }
        }
Exemple #5
0
        private void CreateNewAccount(Hashtable Params)
        {
            string account = PickParam(Params).GetValueAsString("DOMAINUSER");
            string domain  = PickParam(Params).GetValueAsString("DOMAINNAME");

            try
            {
                // 注册通行证
                ParamUtil register = PickParam(Params).SetCmd(APassport.CRegister).ExecuteCmd(new APassport());
                if (register.IsOK())
                {
                    ParamUtil aPU = new ParamUtil()
                                    .SQLCmdLoadData()
                                    .SQLEntityScript("CAIKA_MEMBER", string.Format("SELECT * FROM CAIKA_MEMBER WHERE SSOPST='{0}'", register.GetValue()))
                                    .SQLEntityScript("CAIKA_MEMBER_MESSAGE", string.Format("SELECT * FROM CAIKA_MEMBER_MESSAGE WHERE SSOPST='{0}'", register.GetValue()))
                                    .ExecuteCmd(ADataLoader.DataLoader());
                    if (aPU.IsOK())
                    {
                        DataSet dsPersistent = aPU.GetValueAsDataSet();
                        if (dsPersistent.Tables["CAIKA_MEMBER"].Rows.Count == 0)
                        {
                            DataRow rowNew = dsPersistent.Tables["CAIKA_MEMBER"].NewRow();
                            rowNew["SSOPST"]   = register.GetValue();
                            rowNew["NICKNAME"] = account;
                            rowNew["UPDFLAG"]  = "Y";
                            rowNew["STATE"]    = AosuApp.state.Enabled;
                            rowNew["CTIME"]    = DateTime.Now;
                            rowNew["ETIME"]    = DateTime.Now;
                            dsPersistent.Tables["CAIKA_MEMBER"].Rows.Add(rowNew);

                            // 添加提示信息 - 详细资料
                            DataRow row_message1 = AosuApp.Functions.FindRow(string.Format("MSGTYPE={0}", message_id.Account_KeyIn_DetailInfo), dsPersistent.Tables["CAIKA_MEMBER_MESSAGE"]);
                            if (row_message1 == null)
                            {
                                row_message1             = dsPersistent.Tables["CAIKA_MEMBER_MESSAGE"].NewRow();
                                row_message1["MSGID"]    = Guid.NewGuid();
                                row_message1["SSOPST"]   = register.GetValue();
                                row_message1["MSGTYPE"]  = message_id.Account_KeyIn_DetailInfo;
                                row_message1["MSGTITLE"] = "请完善用户基本资料";
                                row_message1["MSGBODY"]  = "<strong>完善用户基本资料提醒</strong><br/></br/>为了确保彩咖网更好的服务于您,请您完善<a href='/member/usercenter/grzl'><strong>个人资料信息</strong></a>。";
                                row_message1["STATE"]    = message_state.UnRead;
                                row_message1["CTIME"]    = DateTime.Now;
                                dsPersistent.Tables["CAIKA_MEMBER_MESSAGE"].Rows.Add(row_message1);
                            }

                            // 添加提示信息 - 设置提款密码
                            DataRow row_message2 = AosuApp.Functions.FindRow(string.Format("MSGTYPE={0}", message_id.Account_KeyIn_Withdrawals), dsPersistent.Tables["CAIKA_MEMBER_MESSAGE"]);
                            if (row_message2 == null)
                            {
                                row_message2             = dsPersistent.Tables["CAIKA_MEMBER_MESSAGE"].NewRow();
                                row_message2["MSGID"]    = Guid.NewGuid();
                                row_message2["SSOPST"]   = register.GetValue();
                                row_message2["MSGTYPE"]  = message_id.Account_KeyIn_Withdrawals;
                                row_message2["MSGTITLE"] = "请设置提款密码";
                                row_message2["MSGBODY"]  = "<strong>设置提款密码提醒</strong><br/></br/>提款密码用于提取彩咖网账户可用余额的安全密码,请您务必设置<a href='/member/usercenter/zhmm'><strong>提款密码</strong></a>。定期重新设置提款密码能提高您的账户安全性!";
                                row_message2["STATE"]    = message_state.UnRead;
                                row_message2["CTIME"]    = DateTime.Now;
                                dsPersistent.Tables["CAIKA_MEMBER_MESSAGE"].Rows.Add(row_message2);
                            }

                            // 添加提示信息 - 绑定银行卡
                            DataRow row_message3 = AosuApp.Functions.FindRow(string.Format("MSGTYPE={0}", message_id.Account_KeyIn_BankCard), dsPersistent.Tables["CAIKA_MEMBER_MESSAGE"]);
                            if (row_message3 == null)
                            {
                                row_message3             = dsPersistent.Tables["CAIKA_MEMBER_MESSAGE"].NewRow();
                                row_message3["MSGID"]    = Guid.NewGuid();
                                row_message3["SSOPST"]   = register.GetValue();
                                row_message3["MSGTYPE"]  = message_id.Account_KeyIn_BankCard;
                                row_message3["MSGTITLE"] = "请绑定银行卡";
                                row_message3["MSGBODY"]  = "<strong>绑定银行卡提醒</strong><br/></br/>当您购彩中奖后,彩咖网将会依据您提交的银行卡信息将彩金转入你的真实有效的银行卡账户中;所以请您务必<a href='/member/usercenter/bdyhk'><strong>绑定银行卡</strong></a>,并确保银行卡的真实有效。";
                                row_message3["STATE"]    = message_state.UnRead;
                                row_message3["CTIME"]    = DateTime.Now;
                                dsPersistent.Tables["CAIKA_MEMBER_MESSAGE"].Rows.Add(row_message3);
                            }

                            if (new ParamUtil().SQLCmdPersistent().SetParam(dsPersistent).ExecuteCmd(ADataLoader.DataLoader()).IsOK())
                            {
                                // 生成账户的摘要集
                                DictSetUtil ds_summary = new DictSetUtil(new DataSet());
                                ds_summary.SetValue("TOTALAMOUNT", "0.00"); // 账户总额
                                ds_summary.SetValue("AVAILABLE", "0.00");   // 可用余额
                                ds_summary.SetValue("FREEZED", "0.00");     // 冻结金额
                                ds_summary.SetValue("SCORE", "0");          // 积分
                                ds_summary.SetValue("DEPOSITED", "0.0");    // 充值金额
                                ds_summary.SetValue("BONUS", "0.0");        // 中奖金额
                                ds_summary.SetValue("EXCHANGED", "0.0");    // 积分兑换
                                ds_summary.SetValue("RETURNED", "0.0");     // 游戏返点
                                ds_summary.SetValue("CONSUME", "0.0");      // 投注金额
                                ds_summary.SetValue("WITHDRAW", "0.0");     // 提款金额

                                // 通行证+超级密码
                                string key = new DictSetUtil(null).PushSLItem(PickParam(Params).GetValueAsString()).PushSLItem("6B276432FFAF4FD4E086E739009256B3")
                                             .DoSignature();

                                AEntryDic.Pick(GetControl()).SetDic(ds_summary.MyDS, key);
                            }
                            else
                            {
                                PickParam(Params).Clear().SetError("注册失败");
                            }
                        }
                        else
                        {
                            PickParam(Params).Clear().SetError("账户名已存在");
                        }
                    }
                    else
                    {
                        PickParam(Params).Clear().SetError(aPU.GetError());
                    }
                }
                else
                {
                    PickParam(Params).Clear().SetError(register.GetError());
                }
            }
            catch
            {
                PickParam(Params).Clear().SetError("注册失败");
            }
        }