예제 #1
0
        public void NotifyUser()
        {
            bool needNotify = false;

            JiShi.BLL.js_item Bll = new JiShi.BLL.js_item();
            //更新最低成交价
            var ds0 = DbHelperMySQL.Query(" SELECT itemname,itemprice*par as price  FROM `js_concernitem` ").Tables[0];

            for (int i = 0; i < ds0.Rows.Count; i++)
            {
                var name  = ds0.Rows[i]["itemname"];
                var price = ds0.Rows[i]["price"];

                //2.获取数据库中对应的价格并作比较
                var models1 = Bll.GetModelList("  itemName='{0}'   and status==NULL ".With(name, price));
                if (models1.Count > 0)
                {
                    // MailBll.SendOneEmail(_smtpClient, "*****@*****.**", "*****@*****.**", RandomManager.GetRandomName() + " " + name + price, RandomManager.GetRandomName(), "");
                    LogManager.WriteLog("更新最低价{0}={1}".With(name, price));
                }
            }

            //加入各个残卷的低价获取和通知
            //1.抓取指定表格中的物品名及其价格
            var ds1 = DbHelperMySQL.Query(" SELECT itemname,itemprice*par as price  FROM `js_concernitem` ").Tables[0];

            for (int i = 0; i < ds1.Rows.Count; i++)
            {
                var name  = ds1.Rows[i]["itemname"];
                var price = ds1.Rows[i]["price"];

                //2.获取数据库中对应的价格并作比较
                var models1 = Bll.GetModelList("  itemName='{0}' and rice/itemAmount < {1} and gameItemId<>NULL ".With(name, price));
                if (models1.Count > 0)
                {
                    MailBll.SendOneEmail(_smtpClient, "*****@*****.**", "*****@*****.**", RandomManager.GetRandomName() + " " + name + price, RandomManager.GetRandomName(), "");
                }
            }


            //

            //银子的通知
            var models = Bll.GetModelList("  itemName='银子' and 1000*price/(itemAmount/1000)<75 and gameItemId<>NULL ");

            if (models.Count > 0)
            {
                needNotify = true;
            }

            if (needNotify)
            {
                init_smtpclient();


                MailBll.SendOneEmail(_smtpClient, "*****@*****.**", "*****@*****.**", RandomManager.GetRandomName() + " 低于75银子", RandomManager.GetRandomName(), "");
            }
            //
        }
예제 #2
0
        /// <summary>
        /// 数据保存
        /// </summary>
        /// <returns></returns>
        public override string Save()
        {
            string result = string.Empty;

            try
            {
                #region 赋值

                //获取实体
                var model = new WebConfig(x => x.Id == id);
                model.WebName   = StringHelper.Left(txtWebName.Text, 50);
                model.WebDomain = StringHelper.Left(txtWebDomain.Text, 50, true, false);
                model.WebEmail  = StringHelper.Left(txtWebEmail.Text, 50, true, false);

                model.LoginLogReserveTime = ConvertHelper.Cint0(txtLoginLogReserveTime.Text);
                model.UseLogReserveTime   = ConvertHelper.Cint0(txtUseLogReserveTime.Text);

                model.EmailSmtp     = StringHelper.Left(txtEmailSmtp.Text, 50, true, false);
                model.EmailUserName = StringHelper.Left(txtEmailUserName.Text, 50);
                model.EmailPassWord = StringHelper.Left(txtEmailPassWord.Text, 50, true, false);

                #endregion

                //----------------------------------------------------------
                //存储到数据库
                WebConfigBll.GetInstence().Save(this, model);

                //------------------------------------
                //测试邮件发送服务
                if (chkSendTest.Checked && model.EmailSmtp.Length > 0 && model.EmailUserName.Length > 0)
                {
                    var    oMail = new MailBll();
                    string ss    = oMail.TestMail();

                    if (ss.Length > 0)
                    {
                        return("出错!" + ss);
                    }
                    else
                    {
                        return("发送成功!");
                    }
                }
                return("修改成功!");
            }
            catch (Exception e)
            {
                result = "保存失败!";

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }

            return(result);
        }