Esempio n. 1
0
 /// <summary>
 ///  获取WebConfig.images下的某个子节点
 /// </summary>
 /// <param name="configName">节点名</param>
 /// <returns></returns>
 public TimesConfigInfo GetImageConfigInfo(string configName = "coupon")
 {
     try
     {
         var             imagesSection   = ConfigurationManager.GetSection("times") as XmlNode;
         TimesConfigInfo timesConfigInfo = new TimesConfigInfo();
         XmlNode         gradesNode      = imagesSection.SelectSingleNode(configName + "time");
         for (int i = 0; i < gradesNode.Attributes.Count; i++)
         {
             string name  = gradesNode.Attributes[i].Name;
             string value = gradesNode.Attributes[name].Value;
             switch (name)
             {
             case "name":
                 timesConfigInfo.Name = value; break;
             }
         }
         XmlNodeList            childList           = gradesNode.ChildNodes;
         List <ChildConfigInfo> childConfigInfoList = new List <ChildConfigInfo>();
         for (int i = 0; i < childList.Count; i++)
         {
             ChildConfigInfo childConfigInfo = new ChildConfigInfo();
             childConfigInfo.Key        = childList[i].Attributes["key"].Value;
             childConfigInfo.NumberHour = int.Parse(childList[i].Attributes["numberHour"].Value);
             childConfigInfoList.Add(childConfigInfo);
         }
         timesConfigInfo.ChildConfigInfoList = childConfigInfoList;
         return(timesConfigInfo);
     }
     catch
     {
         return(null);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 清理推送数据 从配置文件中clean节点获取清理时间如果没有那么将不执行
        /// </summary>
        public void MobilePush_CleanExpired()
        {
            int             hour       = 0;                           //清理时间
            DateTime        nowTime    = DateTime.Now;                //当前时间
            TimesConfigInfo timeConfig = GetImageConfigInfo("clean"); //清理的配置文件

            if (nowTime.Hour != 7)
            {
                //每天只在早上7点执行一次
                return;
            }
            for (int i = 0; i < timeConfig.ChildConfigInfoList.Count; i++)
            {
                //找出需要清理数据时间配置
                if (timeConfig.ChildConfigInfoList[i].Key.Contains("expired"))
                {
                    hour = timeConfig.ChildConfigInfoList[i].NumberHour;
                    break;
                }
            }
            if (hour > 0)
            {
                //执行清理程序,如果出现清理后不正常推送数据时,请确认所有推送数据限制在当天
                mobilePushBLL.MobilePush_CleanExpired(hour);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///  优惠券快过期推送数据聚合
        /// </summary>
        public void CouponExpired()
        {
            //优惠券到期时间和收到优惠券通知 属于早8点以后才能发送
            int level1 = 0;
            int level2 = 0;

            GetLevel(SectionSecondType.优惠券将要到期通知, ref level1, ref level2);
            bool isUse = IsUseToTime(level2);

            if (isUse)//是否允许发送
            {
                TimesConfigInfo         timeConfig     = GetImageConfigInfo("coupon");
                IList <CouponMySqlInfo> couponInfoList = null;
                for (int i = 0; i < timeConfig.ChildConfigInfoList.Count; i++)
                {
                    //优惠券过期配置文件
                    if (timeConfig.ChildConfigInfoList[i].Key.Contains("expired"))
                    {
                        int hour = timeConfig.ChildConfigInfoList[i].NumberHour;
                        try
                        {
                            couponInfoList = couponMysqlBLL.CouponMySql_GetAll(hour);
                            PushLog("Coupon到期数据已获取,共" + couponInfoList.Count + "条(未匹配推送表)!");
                        }
                        catch (Exception e)
                        {
                            PushLog("Coupon到期数据获取异常:" + e.Message);
                        }
                    }
                }
                if (couponInfoList != null)
                {
                    for (int j = 0; j < couponInfoList.Count; j++)
                    {
                        CouponMySqlInfo couponInfo = couponInfoList[j];
                        //验证此优惠是否已推送过
                        bool state = mobilePushBLL.MobilePush_IsExist(couponInfo.UID, level1, level2, couponInfo.CouponCode);
                        if (state)//已推送过
                        {
                            continue;
                        }
                        else//if(state==false)
                        {
                            try
                            {
                                PushMessageInfo pushMessageInfo = new PushMessageInfo();
                                pushMessageInfo.ChannelID  = 0;
                                pushMessageInfo.Contents   = GetContentsByLevel2(level2, couponInfo.CouponCode, null);
                                pushMessageInfo.CreateTime = DateTime.Now;
                                pushMessageInfo.DataID     = couponInfo.CouponCode;
                                pushMessageInfo.TypeID     = level1;
                                pushMessageInfo.Section    = level2;
                                pushMessageInfo.PushType   = "single";
                                pushMessageInfo.Status     = 0;
                                pushMessageInfo.TargetList = couponInfo.UID.ToString();
                                pushMessageInfo.Creator    = "后台推送程序";
                                pushMessageInfo.PushCount  = 0;
                                pushMessageInfo.Template   = 1;
                                pushMessageInfo.Updater    = "后台推送程序";
                                pushMessageInfo.UpdateTime = DateTime.Now;
                                mobilePushBLL.InsertMobilePush(pushMessageInfo);
                            }
                            catch (Exception e)
                            {
                                PushLog("Coupon到期数据写入异常:" + e.Message);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 订单未支付
        /// </summary>
        public void OrdersTimeOut()
        {
            int level1 = 0;
            int level2 = 0;

            GetLevel(SectionSecondType.订单未支付提醒, ref level1, ref level2);
            bool isUse = IsUseToTime(level2);//是否属于8点以后发送的

            if (isUse)
            {
                TimesConfigInfo    timeConfig     = GetImageConfigInfo("orders");
                IList <OrdersInfo> ordersInfoList = null;
                for (int i = 0; i < timeConfig.ChildConfigInfoList.Count; i++)
                {
                    //优惠券过期配置文件
                    if (timeConfig.ChildConfigInfoList[i].Key.Contains("expired"))
                    {
                        int hour = timeConfig.ChildConfigInfoList[i].NumberHour;
                        try
                        {
                            ordersInfoList = ordersMysqlBLL.OrdersTimeOutMySql_GetAll(hour);
                            PushLog("Orders订单未支付数据已获取,共" + ordersInfoList.Count + "条(未匹配推送表)!");
                        }
                        catch (Exception e)
                        {
                            PushLog("Orders订单未支付数据获取异常:" + e.Message);
                        }
                    }
                }

                if (ordersInfoList != null)
                {
                    for (int j = 0; j < ordersInfoList.Count; j++)
                    {
                        OrdersInfo orderInfo = ordersInfoList[j];
                        //验证是否已推送
                        bool state = mobilePushBLL.MobilePush_IsExist(orderInfo.UID, level1, level2, orderInfo.OrderID);
                        if (state)//已推送
                        {
                            continue;
                        }
                        else//if(state==false)
                        {
                            try
                            {
                                PushMessageInfo pushMessageInfo = new PushMessageInfo();
                                pushMessageInfo.ChannelID  = 0;
                                pushMessageInfo.Contents   = GetContentsByLevel2(level2, orderInfo.OrderID, null);
                                pushMessageInfo.CreateTime = DateTime.Now;
                                pushMessageInfo.DataID     = orderInfo.OrderID;
                                pushMessageInfo.TypeID     = level1;
                                pushMessageInfo.Section    = level2;
                                pushMessageInfo.PushType   = "single";
                                pushMessageInfo.Status     = 0;
                                pushMessageInfo.TargetList = orderInfo.UID.ToString();
                                pushMessageInfo.Creator    = "后台推送程序";
                                pushMessageInfo.PushCount  = 0;
                                pushMessageInfo.Template   = 1;
                                pushMessageInfo.Updater    = "后台推送程序";
                                pushMessageInfo.UpdateTime = DateTime.Now;
                                mobilePushBLL.InsertMobilePush(pushMessageInfo);
                            }
                            catch (Exception e)
                            {
                                PushLog("Orders未支付数据写入异常:" + e.Message);
                            }
                        }
                    }
                }
            }
        }