コード例 #1
0
        /// <summary>
        /// 重载基类算法
        /// </summary>
        /// <returns></returns>
        internal override string GenerateData()
        {
            var start    = DateTime.Parse($"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day}"); //统计当天时间
            var end      = DateTime.Parse($"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day + 1}").AddSeconds(-1);
            var startStr = DateTime.Now.ToString("yyyyMMdd000000");                                        //统计当天时间
            var endStr   = end.ToString("yyyyMMddHHmmss");
            var week     = DateTime.Now.DayOfWeek;

            if (week == DayOfWeek.Saturday || week == DayOfWeek.Sunday)//周末跳过
            {
                return(string.Empty);
            }
            //获取当前登录状态
            List <BsonDocument> loginList = dataOp.FindAllByQuery("SysBehaviorLog", Query.And(Query.GTE("timeSort", startStr), Query.LTE("timeSort", endStr))).ToList();

            //2015.4.13 新增错误日志发送到125.77.255.2:8023端口进行存储,后续迁移
            JobLogger.Info($"登陆统计个数:{loginList.Count()}");
            if (loginList.Any())
            {
                return(string.Empty);
            }
            var errorMessage =
                $"截止{start.ToString()}至{end.ToString()} {DateTime.Now:ddd} 系统目前无任何用户登录进行操作请注意";

            var messageInfo = new PushMessageInfo()
            {
                content        = "系统登录预警",
                approvalUserId = this.JobParamsDoc.Text("approvalUserId"),
                errorMessage   = errorMessage,
                customerCode   = SysAppConfig.CustomerCode,
                logType        = "1"
            };

            return(messageInfo.ToJson());
        }
コード例 #2
0
        /// <summary>
        /// 重载基类算法,查看队列服务是否正常
        /// </summary>
        /// <returns></returns>
        internal override string GenerateData()
        {
            var mqAddress  = JobParamsDoc.Text("MQAddress");
            var mqPassWord = JobParamsDoc.Text("MQAuthorization");

            //http://192.168.185.173:15672/api/queues
            Core.HttpHelper http = new Core.HttpHelper();
            HttpItem        item = new HttpItem()
            {
                URL       = mqAddress,
                Accept    = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
                UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
            };

            item.Header.Add("Authorization", "Basic YW50YXBvczphbnRhcG9z");
            var result = http.GetHtml(item);

            if (result.StatusCode != System.Net.HttpStatusCode.OK)
            {
                var messageInfo = new PushMessageInfo()
                {
                    content        = "RabbitMQ服务停止预警",
                    approvalUserId = this.JobParamsDoc.Text("approvalUserId"),
                    errorMessage   = $"{mqAddress}rabbitMQ队列服务出错",
                    customerCode   = SysAppConfig.CustomerCode,
                    logType        = "1"
                };
                return(messageInfo.ToJson());
            }
            return(string.Empty);
        }
コード例 #3
0
        public void TimingPush()
        {
            //获取数据库中所有等待推送的数据
            string Msg = string.Empty;
            List <PushMessageInfo> pushMessageInfoList = MobilePushBLL.Instance.MobilePush_GetList(ref Msg, 30);

            if (pushMessageInfoList == null || pushMessageInfoList.Count <= 0)
            {
                PushLog(string.Format("暂时没有需要推送信息:{0}", Msg));
                return;
            }
            PushLog(string.Format("推送信息总条数:{0}", pushMessageInfoList.Count));
            for (int i = 0; i < pushMessageInfoList.Count; i++)
            {
                PushMessageInfo pushMessageInfo = pushMessageInfoList[i];
                try
                {
                    if (pushMessageInfo.PushCount >= 5 && pushMessageInfo.Status == 2)
                    {
                        pushMessageInfo.Status = 3;//设置为拒绝推送状态
                        PushLog(string.Format("推送数据已失败5次 推送ID:{0}", pushMessageInfo.PushID));
                    }
                    else
                    {
                        if (pushMessageInfo.PushType == "app" || string.IsNullOrEmpty(pushMessageInfo.PushType) == true)
                        {
                            //推送所有用户(app下)
                            pushMessageToApp(pushMessageInfo);
                        }
                        else
                        {
                            //推送1-n个用户
                            PushMessageToList(pushMessageInfo);
                        }
                        pushMessageInfo.Status     = 1;
                        pushMessageInfo.PushCount += 1;
                    }
                }
                catch (Exception e)
                {
                    //推送异常,数据推pushCount计数
                    PushLog(string.Format("推送异常:{0}", e.Message));
                    PushLog(string.Format("异常数据:{0}", pushMessageInfo.PushID));
                    pushMessageInfo.Status     = 2;
                    pushMessageInfo.PushCount += 1;
                }

                //1.修改推送后数据库数据 Status 为 1 表示已推送 0表示未推送
                //2.推送次数超过5此将不再推送 Status=3
                MobilePushBLL.Instance.UpdateMobilePush(pushMessageInfo);
            }
        }
コード例 #4
0
        /// <summary>
        /// 重载基类算法,注意如果重复读取可能发生数据重复发送邮件
        /// </summary>
        /// <returns></returns>
        internal override string GenerateData()
        {
            var rabbitQueueMessageType = JobParamsDoc.Text("MQMessageType");
            var rabbitMQVirtualHost    = JobParamsDoc.Text("MQVirtualHost");
            var RetryCount             = JobParamsDoc.Text("RetryCount");
            var tableName = $"{rabbitQueueMessageType}_{rabbitMQVirtualHost}_{DateTime.Now.ToString("yyyy-MM")}";

            var week           = DateTime.Now.DayOfWeek;
            var retryTimeQuery = Query.And(Query.NE("DeQueueStage", 1), Query.GTE("EnQueueStage", 3)); //重试入队多次
            var query          = Query.Or(retryTimeQuery, Query.Exists("errorMsgs", true));            //有错误消息
            var limit          = 20;
            //获取当前登录状态
            var recordCount    = dataOp.FindCount(tableName, query);
            var topRecoredList = dataOp.FindLimitFieldsByQuery(tableName, query, new MongoDB.Driver.SortByDocument()
            {
            }, 0, limit, new string[] { "messageID", "errorMsgs", "MessageRouter", "MessageBody", "EnQueueStage" }).ToList();

            //2015.4.13 新增错误日志发送到125.77.255.2:8023端口进行存储,后续迁移
            if (!topRecoredList.Any())
            {
                return(string.Empty);
            }
            JobLogger.Info($"队列执行错误个数:{recordCount}");
            var errorMessage = new StringBuilder();

            errorMessage.AppendLine($"{DateTime.Now.ToString("yyyy-MM")}捕获到队列执行异常数据${recordCount}条.前{limit}内容如下:\n\r");
            topRecoredList.ForEach(doc =>
            {
                errorMessage.AppendLine($"{doc.ToJson()}");
            });
            var approvalUserId = this.JobParamsDoc.Text("approvalUserId");

            var messageInfo = new PushMessageInfo()
            {
                content        = $"小票上传重试错误预警,失败条数:{recordCount}",
                approvalUserId = approvalUserId,
                errorMessage   = errorMessage.ToString(),
                customerCode   = SysAppConfig.CustomerCode,
                logType        = "1"
            };

            return(messageInfo.ToJson());
        }
コード例 #5
0
        public PushMessageInfo RecoverModel(IDataReader dataReader)
        {
            PushMessageInfo pushMessageInfo = new PushMessageInfo();

            pushMessageInfo.PushID     = dataReader["PushID"].ToInt();
            pushMessageInfo.ChannelID  = dataReader["ChannelID"].ToInt();
            pushMessageInfo.TypeID     = dataReader["TypeID"].ToInt();
            pushMessageInfo.Section    = dataReader["Section"].ToInt();
            pushMessageInfo.Contents   = dataReader["Contents"].ToString();
            pushMessageInfo.Creator    = dataReader["Creator"].ToString();
            pushMessageInfo.Updater    = dataReader["Updater"].ToString();
            pushMessageInfo.Status     = dataReader["Status"].ToInt();
            pushMessageInfo.PushType   = dataReader["PushType"].ToString();
            pushMessageInfo.Template   = dataReader["Template"].ToInt();
            pushMessageInfo.TargetList = dataReader["TargetList"].ToString();
            pushMessageInfo.DataID     = dataReader["DataID"].ToString();
            pushMessageInfo.Url        = dataReader["Url"].ToString();
            pushMessageInfo.PushCount  = dataReader["PushCount"].ToInt();
            pushMessageInfo.CreateTime = dataReader["CreateTime"].ToDateTime();
            pushMessageInfo.UpdateTime = dataReader["UpdateTime"].ToDateTime();
            return(pushMessageInfo);
        }
コード例 #6
0
        public bool InsertMobilePush(PushMessageInfo pushMessageInfo)
        {
            string parmsKey       = string.Empty;
            string strPlaceholder = string.Empty;

            parmsKey       = "ChannelID,Section,DataID,Contents,Creator,CreateTime,Status,Updater,UpdateTime,PushType,Template,TargetList,PushCount,TypeID,Url ";
            strPlaceholder = "@ChannelID,@Section,@DataID,@Contents,@Creator,@CreateTime,@Status,@Updater,@UpdateTime,@PushType,@Template,@TargetList,@PushCount,@TypeID,@Url";
            var sql = " INSERT INTO MobilePush ";

            sql += " ( " + parmsKey + ") ";
            sql += " VALUES ";
            sql += string.Format(" (" + strPlaceholder + ") ");
            var cmd = dbw.GetSqlStringCommand(sql);

            dbw.AddInParameter(cmd, "ChannelID", DbType.Int16, pushMessageInfo.ChannelID);
            dbw.AddInParameter(cmd, "Section", DbType.String, pushMessageInfo.Section);
            dbw.AddInParameter(cmd, "DataID", DbType.String, pushMessageInfo.DataID);
            dbw.AddInParameter(cmd, "Contents", DbType.String, pushMessageInfo.Contents);
            dbw.AddInParameter(cmd, "Creator", DbType.String, pushMessageInfo.Creator);
            dbw.AddInParameter(cmd, "CreateTime", DbType.DateTime, pushMessageInfo.CreateTime);
            dbw.AddInParameter(cmd, "Status", DbType.Int16, pushMessageInfo.Status);
            dbw.AddInParameter(cmd, "Updater", DbType.String, pushMessageInfo.Updater);
            dbw.AddInParameter(cmd, "UpdateTime", DbType.DateTime, pushMessageInfo.UpdateTime);
            dbw.AddInParameter(cmd, "PushType", DbType.String, pushMessageInfo.PushType);
            dbw.AddInParameter(cmd, "Template", DbType.Int16, pushMessageInfo.Template);
            dbw.AddInParameter(cmd, "TargetList", DbType.String, pushMessageInfo.TargetList);
            dbw.AddInParameter(cmd, "PushCount", DbType.Int32, pushMessageInfo.PushCount);
            dbw.AddInParameter(cmd, "TypeID", DbType.Int32, pushMessageInfo.TypeID);
            dbw.AddInParameter(cmd, "Url", DbType.String, pushMessageInfo.Url);
            try
            {
                var result = dbw.ExecuteNonQuery(cmd);
                return(result > 0);
            }
            catch
            {
                return(false);
            }
        }
コード例 #7
0
        /// <summary>
        /// 从数据库中调用EUR_DEADLOCK_DETAIL
        /// TimePoint  statement_parameter_k statement_k statement_parameter [statement] waitresource_k waitresource
        /// isolationlevel_k isolationlevel waittime_k waittime
        ///clientapp_k clientapp hostname_k hostname
        /// </summary>
        /// <returns></returns>
        internal override string GenerateData()
        {
            //获取异常数据的接口地址通过pos站点数据
            var posUrl = JobParamsDoc.Text("PosUrl");
            var result = GetHtml(posUrl);

            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                try
                {
                    var resultDoc = MongoDB.Bson.Serialization.BsonSerializer.Deserialize <BsonDocument>(result.Html);
                    if (!resultDoc.ContainsColumn("data") || string.IsNullOrEmpty(resultDoc.Text("data")))
                    {
                        return(string.Empty);
                    }
                    var detailDetailInfo = string.Empty;
                    var deadLockList     = MongoDB.Bson.Serialization.BsonSerializer.Deserialize <List <BsonDocument> >(resultDoc.Text("data"));
                    if (deadLockList.Count() > 0)
                    {
                        //返回解析后的内容字符串
                        detailDetailInfo  = GetDetailFromJson(deadLockList);
                        detailDetailInfo += "详情请通过exec EUR_DEADLOCK_DETAIL 进行查询";
                        var messageInfo = new PushMessageInfo()
                        {
                            content        = "数据库死锁预警",
                            approvalUserId = this.JobParamsDoc.Text("approvalUserId"),
                            errorMessage   = detailDetailInfo,
                            customerCode   = SysAppConfig.CustomerCode,
                            logType        = "1"
                        };
                        return(messageInfo.ToJson());
                    }
                } catch (Exception ex)
                {
                }
            }
            return(string.Empty);
        }
コード例 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pushMessageInfo">pushId,pushCount,Status</param>
        /// <returns></returns>
        public bool UpdateMobilePush(PushMessageInfo pushMessageInfo)
        {
            string parmsKey       = string.Empty;
            string strPlaceholder = string.Empty;

            var sql = " UPDATE  MobilePush SET ";

            sql += " Status=@Status,PushCount=@PushCount ";
            sql += " WHERE  PushID=@PushID";
            var cmd = dbw.GetSqlStringCommand(sql);

            dbw.AddInParameter(cmd, "Status", DbType.Int16, pushMessageInfo.Status);
            dbw.AddInParameter(cmd, "PushCount", DbType.Int32, pushMessageInfo.PushCount);
            dbw.AddInParameter(cmd, "PushID", DbType.Int32, pushMessageInfo.PushID);
            try
            {
                var result = dbw.ExecuteNonQuery(cmd);
                return(result > 0);
            }
            catch
            {
                return(false);
            }
        }
コード例 #9
0
        /// <summary>
        /// 处理站点健康检查信息,一般为需要发送邮件的内容,后续定期从数据库中读取数据进行邮件发送
        /// </summary>
        /// <param name="jobLog"></param>
        /// <returns></returns>
        public InvokeResult ProcessPushMessageInfo(PushMessageInfo messageInfo)
        {
            var result = new InvokeResult()
            {
                Status = Status.Successful
            };

            if (!string.IsNullOrEmpty(messageInfo.errorMessage))
            {
                //messageInfo.errorMessage = HttpUtility.UrlEncode(messageInfo.errorMessage);
                //messageInfo.content = HttpUtility.UrlDecode(messageInfo.content);
                if (!string.IsNullOrEmpty(messageInfo.errorMessage))
                {
                    var bsonDoc = new BsonDocument
                    {
                        { "title", messageInfo.content },
                        { "content", messageInfo.errorMessage },
                        { "arrivedUserIds", messageInfo.approvalUserId },
                        { "sendUserId", messageInfo.approvalUserId },
                        { "sendType", "0" },
                        { "registerDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") },
                        { "sendDate", DateTime.Now.AddMinutes(5).ToString("yyyy-MM-dd HH:mm:ss") },
                        { "isMessagePack", 1 },//加密模式
                    };
                    result = CommonDbChangeHelper.SubmitChange(new StorageData()
                    {
                        Document = bsonDoc,
                        Name     = "SystemMessagePushQueue",
                        Type     = StorageType.Insert
                    });
                }
            }


            return(result);
        }
コード例 #10
0
        /// <summary>
        /// 商品到货
        /// </summary>
        public void ProductArrival()
        {
            int level1 = 0;
            int level2 = 0;

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

            if (isUse)
            {
                IList <ProductOutBookMySqlInfo> productOutBookInfoList = null;
                try
                {
                    productOutBookInfoList = productStockMysqlBLL.ProductOutBookMySql_GetAll();
                    PushLog("product商品到货数据已获取,共" + productOutBookInfoList.Count + "条(未匹配推送表)!");
                }
                catch (Exception e)
                {
                    PushLog("product商品到货信息获取异常:" + e.Message);
                }
                if (productOutBookInfoList != null)
                {
                    for (int j = 0; j < productOutBookInfoList.Count; j++)
                    {
                        ProductOutBookMySqlInfo productInfo = productOutBookInfoList[j];
                        //验证是否已推送
                        bool state = mobilePushBLL.MobilePush_IsExist(productInfo.UID, level1, level2, productInfo.ProductID.ToString());
                        if (state)//已推送
                        {
                            continue;
                        }
                        else//if(state==false)
                        {
                            try
                            {
                                PushMessageInfo pushMessageInfo = new PushMessageInfo();
                                pushMessageInfo.ChannelID  = 0;
                                pushMessageInfo.Contents   = GetContentsByLevel2(level2, productInfo.ProductName.ToString(), null);
                                pushMessageInfo.CreateTime = DateTime.Now;
                                pushMessageInfo.DataID     = productInfo.ProductID.ToString();
                                pushMessageInfo.TypeID     = level1;
                                pushMessageInfo.Section    = level2;
                                pushMessageInfo.PushType   = "single";
                                pushMessageInfo.Status     = 0;
                                pushMessageInfo.TargetList = productInfo.UID.ToString();
                                pushMessageInfo.Creator    = "后台推送程序";
                                pushMessageInfo.PushCount  = 0;
                                pushMessageInfo.Template   = 1;
                                pushMessageInfo.Updater    = "后台推送程序";
                                pushMessageInfo.UpdateTime = DateTime.Now;

                                //修改mysql中的推送状态
                                productStockMysqlBLL.ProductOutBookMySql_UpIsPush(productInfo.OutID, 1);

                                //写入推送表
                                mobilePushBLL.InsertMobilePush(pushMessageInfo);
                            }
                            catch (Exception e)
                            {
                                PushLog("ProductOutBook商品到货数据写入异常:" + e.Message);
                            }
                        }
                    }
                }
            }
        }
コード例 #11
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);
                            }
                        }
                    }
                }
            }
        }
コード例 #12
0
 public bool InsertMobilePush(PushMessageInfo pushMessageInfo)
 {
     return(dal.InsertMobilePush(pushMessageInfo));
 }
コード例 #13
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);
                            }
                        }
                    }
                }
            }
        }
コード例 #14
0
 public bool UpdateMobilePush(PushMessageInfo pushMessageInfo)
 {
     return(dal.UpdateMobilePush(pushMessageInfo));
 }
コード例 #15
0
        /// <summary>
        /// 推送所有用户(向app应用内发送)
        /// </summary>
        /// <param name="pushMessageInfo"></param>
        public void pushMessageToApp(PushMessageInfo pushMessageInfo)
        {
            IGtPush push    = new IGtPush(HOST, APPKEY, MASTERSECRET);
            string  content = pushMessageInfo.Contents;
            string  title   = string.Empty;
            //为接收者组织数据
            var transmissionContent =
                new
            {
                Template = pushMessageInfo.Template,
                Content  = pushMessageInfo.Contents,
                Url      = pushMessageInfo.Url,
                Section  = pushMessageInfo.TypeID + "/" + pushMessageInfo.Section,
                NodeId   = pushMessageInfo.DataID
            };
            string jsonContent = JsonHelper.ConvertToJson(transmissionContent);

            PushLog("- - - - - - - - - - - - - ");
            PushLog(string.Format("推送类型:{0}", pushMessageInfo.PushType));
            PushLog(string.Format("推送内容:{0}", pushMessageInfo.Contents));
            PushLog(string.Format("推送目标:{0}", "应用内的所有用户"));
            if (pushMessageInfo.TypeID != 0)
            {
                title = Enum.GetName(typeof(SectionSecondType), pushMessageInfo.Section);
            }
            //透传模板
            TransmissionTemplate template = TransmissionTemplateDemo(content, title, jsonContent, 0);

            template.TransmissionType    = "2";
            template.TransmissionContent = jsonContent; //透传内容
            AppMessage message = new AppMessage();

            message.IsOffline         = true;
            message.OfflineExpireTime = 1000 * 3600 * 12;
            message.Data = template;

            //账号APPID
            List <string> appIdList = new List <string>();

            appIdList.Add(APPID);

            //推送手机的类型
            List <string> phoneTypeList = new List <string>();

            if (pushMessageInfo.ChannelID == 0)
            {
                phoneTypeList.Add("IOS");
                phoneTypeList.Add("ANDROID");
            }
            else if (pushMessageInfo.ChannelID == 1)
            {
                phoneTypeList.Add("IOS");
            }
            else
            {
                phoneTypeList.Add("ANDROID");
            }
            message.AppIdList     = appIdList;
            message.PhoneTypeList = phoneTypeList;
            string pushResult = push.pushMessageToApp(message);

            try
            {
                var result = JsonHelper.ConvertToObj <PushResult>(pushResult);
                PushLog("推送结果:" + result.result);
            }
            catch
            {
                PushLog("推送结果转换异常");
            }
        }
コード例 #16
0
        public JsonResultObject PushMessage()
        {
            var result = new JsonResultObject();

            Environment.SetEnvironmentVariable("needDetails", "true");
            PushMessageInfo pushMessageInfo = new PushMessageInfo();

            pushMessageInfo.PushType   = HttpContext.Current.Request["pushType"];
            pushMessageInfo.TargetList = HttpContext.Current.Request["targetList"];
            pushMessageInfo.Contents   = HttpContext.Current.Request["content"];
            pushMessageInfo.Creator    = HttpContext.Current.Request["creator"];
            pushMessageInfo.DataID     = HttpContext.Current.Request["dataID"];
            pushMessageInfo.Url        = HttpContext.Current.Request["url"];

            string template  = HttpContext.Current.Request["template"];
            string channelID = HttpContext.Current.Request["channelID"];
            string typeID    = HttpContext.Current.Request["typeID"];

            #region 验证
            if (pushMessageInfo.PushType == null || pushMessageInfo.PushType == string.Empty)
            {
                result.msg = "推送失败,缺少必要的参数: pushType !";
                return(result);
            }
            if (pushMessageInfo.PushType != "app")
            {
                if (pushMessageInfo.TargetList == null || pushMessageInfo.TargetList == "")
                {
                    result.msg = "推送失败,推送类型pushType:" + pushMessageInfo.PushType + "时,targetList 不能为空!";
                    return(result);
                }
            }
            #endregion

            #region 处理
            if (template != null && template != string.Empty)
            {
                pushMessageInfo.Template = int.Parse(template);
            }
            if (channelID != null && channelID != string.Empty)
            {
                pushMessageInfo.ChannelID = int.Parse(channelID);
            }
            else
            {
                pushMessageInfo.ChannelID = 0;
            }
            //拆分 TypeID 1/102
            if (typeID.IndexOf('/') != -1)
            {
                string[] splitTypeID = typeID.Split('/');
                pushMessageInfo.TypeID  = int.Parse(splitTypeID[0]);
                pushMessageInfo.Section = int.Parse(splitTypeID[1]);
            }
            #endregion

            //写入数据库
            DateTime dt = DateTime.Now;
            pushMessageInfo.CreateTime = dt;
            pushMessageInfo.UpdateTime = dt;
            result.status = MobilePushBLL.Instance.InsertMobilePush(pushMessageInfo);
            result.msg    = "队列数据库无法打开!";
            if (result.status)
            {
                result.msg = "已加入发送队列!";
            }
            return(result);
        }
コード例 #17
0
        /// <summary>
        /// 重载基类算法
        /// </summary>
        /// <returns></returns>
        internal override string GenerateData()
        {
            var now = DateTime.Now;                                                                        //统一记录当前运行时刻

            var start    = DateTime.Parse($"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day}"); //统计当天时间
            var end      = DateTime.Parse($"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day + 1}").AddSeconds(-1);
            var startStr = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");                                   //统计当天时间
            var endStr   = end.ToString("yyyy-MM-dd-HH HH:mm:ss");
            var extArray = SysAppConfig.needCutThumbExtArray;

            var limitCondition = this.JobParamsDoc.Double("limitCondition");

            if (limitCondition <= 0)
            {
                limitCondition = 0.05;
            }
            //2015.4.13 新增错误日志发送到125.77.255.2:8023端口进行存储,后续迁移
            var serverDiskAlertLimit = SysAppConfig.ServerDiskAlertLimit;

            System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
            var pushInfoStr    = new StringBuilder();
            var detaileContent = new StringBuilder();
            var needSend       = false;

            foreach (System.IO.DriveInfo drive in drives.Where(c => c.DriveType == DriveType.Fixed || c.DriveType == DriveType.Network))
            {
                try
                {
                    if (drive.IsReady)
                    {
                        long totalSize          = drive.TotalSize / 1024 / 1024 / 1024;          //MB//总大小
                        long availableFreeSpace = drive.AvailableFreeSpace / 1024 / 1024 / 1024; //MB//可用大小
                        var  usedSpace          = totalSize - availableFreeSpace;                //MB//
                        var  avaiablePercent    = double.Parse(availableFreeSpace.ToString()) / totalSize;

                        if (availableFreeSpace <= serverDiskAlertLimit || avaiablePercent <= limitCondition) //空间剩余5%报警
                        {
                            if (pushInfoStr.Length <= 0)
                            {
                                pushInfoStr.AppendFormat("磁盘空间提醒:", drive.Name);
                            }
                            pushInfoStr.AppendFormat("{0}空间不足 ", drive.Name);
                            detaileContent.AppendFormat("{0}总:{1}G 已用:{2}G 可用:{3}G\n\r", drive.Name, totalSize, usedSpace, availableFreeSpace);
                            needSend = true;
                        }
                    }
                }
                catch (System.IO.IOException ex)
                {
                    JobLogger.Info(ex.Message);
                }
                catch (Exception ex)
                {
                    JobLogger.Info(ex.Message);
                }
            }

            if (!needSend)
            {
                return(string.Empty);
            }
            JobLogger.Info("磁盘进入警告");
            var errorMessage = $"截止{start.ToString()}至{end.ToString()} {DateTime.Now:ddd} {pushInfoStr}";

            var messageInfo = new PushMessageInfo()
            {
                approvalUserId = this.JobParamsDoc.Text("approvalUserId"),
                errorMessage   = errorMessage,
                content        = detaileContent.ToString(),
                logType        = "4",
                customerCode   = SysAppConfig.CustomerCode,
                fileStatisDate = now.ToString("yyyy-MM-dd")
            };

            return(messageInfo.ToJson());
            //模拟发送post请求
        }
コード例 #18
0
        /// <summary>
        ///  推送1-n个用户(用户别名)
        /// </summary>
        /// <param name="pushMessageInfo">推送信息实体</param>
        private void PushMessageToList(PushMessageInfo pushMessageInfo)
        {
            int     isMute              = 0;//设定是否静音,只在于推送 客户等于1时可用
            IGtPush push                = new IGtPush(HOST, APPKEY, MASTERSECRET);
            string  content             = pushMessageInfo.Contents;
            string  title               = string.Empty;
            var     transmissionContent =
                new
            {
                Template = pushMessageInfo.Template,
                Content  = pushMessageInfo.Contents,
                Url      = pushMessageInfo.Url,
                Section  = pushMessageInfo.TypeID + "/" + pushMessageInfo.Section,
                NodeId   = pushMessageInfo.DataID
            };
            string jsonContent = JsonHelper.ConvertToJson(transmissionContent);

            PushLog("- - - - - - - - - - - - - ");
            PushLog(string.Format("推送类型:{0}", pushMessageInfo.PushType));
            PushLog(string.Format("推送内容:{0}", pushMessageInfo.Contents));
            PushLog(string.Format("推送目标:{0}", pushMessageInfo.TargetList));
            if (pushMessageInfo.TypeID != 0)
            {
                title = Enum.GetName(typeof(SectionSecondType), pushMessageInfo.Section);
            }
            //设置接收者
            List <com.igetui.api.openservice.igetui.Target> targetList = new List <com.igetui.api.openservice.igetui.Target>();

            if (pushMessageInfo.TargetList.IndexOf(",") == -1)
            {
                pushMessageInfo.TargetList += ",";
            }
            string[] targets = pushMessageInfo.TargetList.Split(',');

            for (int i = 0; i < targets.Length; i++)
            {
                if (targets[i] != null && targets[i] != string.Empty && targets[i] != "")
                {
                    com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target();
                    target.appId = APPID;
                    target.alias = targets[i];

                    #region 判定是否允许推送,并向java接口写入推送信息
                    MessagesAddBLL     pushBLL   = new MessagesAddBLL();
                    MessagesAddRequest maRequest = new MessagesAddRequest();
                    maRequest.creator = "推送程序";
                    maRequest.userID  = Convert.ToInt32(target.alias);
                    maRequest.status  = 0;
                    if (pushMessageInfo.Template == 1)
                    {
                        maRequest.contents = pushMessageInfo.Contents;
                    }
                    else
                    {
                        maRequest.contents = pushMessageInfo.Url;
                    }
                    if (pushMessageInfo.TypeID != 0)
                    {
                        maRequest.typeID = pushMessageInfo.TypeID;
                    }
                    if (pushMessageInfo.Section != 0)
                    {
                        maRequest.dataTypeID = pushMessageInfo.Section;
                    }
                    maRequest.dataID = pushMessageInfo.DataID;

                    //写入至未读消息列表
                    var respon = pushBLL.MessagesAdd(maRequest);
                    //IOS 数据判定开关
                    if (pushMessageInfo.ChannelID == 1 || pushMessageInfo.ChannelID == 0)
                    {
                        NotifyConfigGetBLL     notifyConfigGetBLL = new NotifyConfigGetBLL();
                        NotifyConfigGetRequest request            = new NotifyConfigGetRequest();
                        request.userID       = maRequest.userID;
                        request.userPlatform = 3;
                        NotifyConfigGetResponse ncgResponse = notifyConfigGetBLL.NotityConfigGet(request);
                        //转化为2进制字符串后换算出是否推送
                        //string allStatus = Convert.ToString(1, 2);
                        string allStatus = Convert.ToString(ncgResponse.notifyConfig.notifySwitch, 2);
                        int    t         = GetIntegerSomeBit(ncgResponse.notifyConfig.notifySwitch, maRequest.typeID - 1);
                        if (targets.Length == 2)
                        {
                            //静音的二进制返回位数
                            isMute = GetIntegerSomeBit(ncgResponse.notifyConfig.notifySwitch, 4);
                        }
                        //包含用户已有权限+不存在的用户
                        if (t == 0)
                        {
                            if (respon.code == 0)
                            {
                                targetList.Add(target);
                            }
                            else
                            {
                                PushLog(string.Format("消息写入失败,无法推送:{0}", maRequest.userID));
                            }
                        }
                        else
                        {
                            PushLog(string.Format("跳过推送ID:{0}", maRequest.userID));
                        }
                    }
                    else //Android
                    {
                        if (respon.code == 0)
                        {
                            targetList.Add(target);
                        }
                        else
                        {
                            PushLog(string.Format("消息写入失败,无法推送:{0}", maRequest.userID));
                        }
                    }

                    #endregion
                }
            }


            if (targetList == null || targetList.Count == 0)
            {
                return;
            }
            #region 因为IOS端需要静音,透传模板放置在方法底部
            ListMessage message = new ListMessage();

            //设置透传模板
            TransmissionTemplate template = TransmissionTemplateDemo(content, title, jsonContent, isMute);
            template.TransmissionType    = "2";          //应用启动类型,1:强制应用启动 2:等待应用启动
            template.TransmissionContent = jsonContent;  //透传内容
            message.IsOffline            = true;
            message.OfflineExpireTime    = 1000 * 3600 * 12;
            message.Data = template;
            #endregion
            string contentId  = push.getContentId(message);
            string pushResult = push.pushMessageToList(contentId, targetList);
            try
            {
                var result = JsonHelper.ConvertToObj <PushResult>(pushResult);
                PushLog("推送结果:" + result.result);
            }
            catch
            {
                PushLog("推送结果转换异常");
            }
        }