Ejemplo n.º 1
0
        /// <summary>
        /// 极光推送方法
        /// </summary>
        /// <param name="model"></param>
        public static void PushMessage(JPushModel model)
        {
            try
            {
                string appKey       = "";
                string masterSecret = "";
                if (model.TagId == 0)                          //C端
                {
                    appKey       = "dce902893245e99461b9a5c8"; // Your App Key from JPush
                    masterSecret = "fdc95d37d67c9472ad4e0e96"; // Your Master Secret from JPush
                }
                else if (model.TagId == 1)                     //B端
                {
                    appKey       = "d794d51f2ffaf5de42001c4b"; // Your App Key from JPush
                    masterSecret = "03f956afaaeb086481aa3b7c"; // Your Master Secret from JPush
                }
                JPushClient client   = new JPushClient(appKey, masterSecret);
                Audience    audience = null;
                if (model.PushType == 0)
                {
                    //0:标签,因为一个应用只能有一个标签,现有支付已经使用,其它应用请使用别名
                    audience         = Audience.s_alias(model.RegistrationId);
                    model.ContentKey = "Content";
                }
                if (model.PushType == 1)
                {
                    //1:别名
                    audience = Audience.s_tag(model.RegistrationId);
                }
                PushPayload pushPayload = new PushPayload();
                pushPayload.platform = Platform.android_ios();
                pushPayload.audience = audience;
                Notification notification = new Notification().setAlert(model.Alert);//不需要写弹出内容
                notification.AndroidNotification = new AndroidNotification().setTitle(model.Title);
                notification.IosNotification     = new IosNotification().setAlert(model.Alert).setBadge(1).setSound(string.Concat(model.ContentKey, ":", model.Content));
                if (!string.IsNullOrEmpty(model.Content))
                {
                    //notification.IosNotification = new IosNotification().setAlert(model.Alert).setBadge(1).setSound("YourSound").AddExtra(model.ContentKey, model.Content);
                    notification.AndroidNotification = new AndroidNotification().AddExtra(model.ContentKey, model.Content);
                }

                pushPayload.notification = notification.Check();
                var response = client.SendPush(pushPayload);
                if (!response.isResultOK())
                {
                    LogHelper.LogWriter("推送失败", response.msg_id);
                }
                else
                {
                    LogHelper.LogWriter("推送成功", response.msg_id);
                }
            }
            catch (Exception ex)
            {
                string parm = string.Concat("推送异常,参数:tagId", model.TagId, ",RegistrationId:", model.RegistrationId);
                LogHelper.LogWriter(ex, parm);
            }
        }
Ejemplo n.º 2
0
        public void JPushSend(JPushModel model)
        {
            JPushClient client = new JPushClient(APP_KEY, MASTER_SECRET);

            try
            {
                var payload = PushObject_all_alisa_Alter(model.Alias, model.obj);

                var result = client.SendPush(payload);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 商家充值成功方法
        /// 窦海超
        /// 2015年5月29日 16:00:07
        /// </summary>
        /// <param name="model"></param>
        private dynamic BusinessRechargeSusess(Ets.Model.DataModel.Business.BusinessRechargeModel model)
        {
            #region 充值、流水、商家金额实体组装
            BusinessBalanceRecord businessBalanceRecord = new BusinessBalanceRecord()
            {
                Amount     = model.PayAmount,
                BusinessId = model.BusinessId,
                Operator   = model.PayBy,
                RecordType = BusinessBalanceRecordRecordType.Recharge.GetHashCode(),
                RelationNo = model.OrderNo,
                Remark     = "商家客户端充值",
                Status     = 1,
                WithwardId = 0
            };
            UpdateForWithdrawPM forWithdrawPM = new UpdateForWithdrawPM()
            {
                Id    = model.BusinessId,
                Money = model.PayAmount
            };
            #endregion

            using (IUnitOfWork tran = EdsUtilOfWorkFactory.GetUnitOfWorkOfEDS())
            {
                new BusinessRechargeDao().Insert(model);                      //写入充值
                new BusinessDao().UpdateForWithdrawC(forWithdrawPM);          //更新商家金额、可提现金额
                new BusinessBalanceRecordDao().Insert(businessBalanceRecord); //写商家流水
                tran.Complete();
            }
            #region jpush推送

            Task.Factory.StartNew(() =>
            {
                JPushModel jpushModel = new JPushModel()
                {
                    Alert          = string.Concat("已成功充值", model.PayAmount, "元"),
                    City           = string.Empty,
                    RegistrationId = model.BusinessId.ToString(),//发送商家ID
                    TagId          = 1,
                    Title          = "充值成功提醒"
                };
                Ets.Service.Provider.MyPush.Push.PushMessage(jpushModel);
            });
            #endregion

            string success = string.Concat("成功完成商家充值订单号:", model.OrderNo);
            LogHelper.LogWriter(success);
            return("success");
        }
Ejemplo n.º 4
0
        private async Task <StringContent> SetupJPushModel(string userEmail, bool accepted = false)
        {
            var user = await _userManager.FindByEmailAsync(userEmail);

            if (string.IsNullOrEmpty(user.JPushId))
            {
                user.JPushId = "170976fa8a3330841b0";
            }
            var jpush = new JPushModel()
            {
                audience = new Audience()
                {
                    tag = new List <string>()
                }, message = new Message()
            };

            return(jpush.Action(d => d.audience.tag.Add(user.JPushId))
                   .Action(d => d.platform = "all")
                   .Action(d => d.message.msg_content = accepted ? "Your request has beed accepted." : "Your request was rejected.")
                   .Map(d => JsonSerializer.Serialize(d).Map(d => new StringContent(d, Encoding.UTF8, "application/json"))));
        }
Ejemplo n.º 5
0
        //发送骑士app
        void SendAPPClienter(MessageModel model)
        {
            try
            {
                ClienterDao clienterDao = new ClienterDao();
                DataTable   dt          = clienterDao.GetPhoneNoList(model.PushCity);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string clienterId = dt.Rows[i]["id"].ToString();
                    long   id         = clienterMessageDao.Insert(new ClienterMessage
                    {
                        ClienterId = Convert.ToInt32(clienterId),
                        Content    = model.Content,
                        IsRead     = 0
                    }
                                                                  );

                    Task.Factory.StartNew(() =>
                    {
                        JPushModel jpushModel = new JPushModel()
                        {
                            Alert          = "您有新消息啦,请及时查收!",
                            City           = string.Empty,
                            Content        = id.ToString(),
                            ContentKey     = "Notice",
                            RegistrationId = "C_" + clienterId,
                            TagId          = 0,
                            Title          = "新消息",
                            PushType       = 1
                        };
                        Push.PushMessage(jpushModel);
                    });
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogWriter(ex);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 完成订单后发送jpush消息
        /// 窦海超
        /// 2015年5月13日 15:23:16
        /// </summary>
        /// <param name="model"></param>
        private static void FinishOrderPushMessage(OrderChildFinishModel model)
        {
            OrderChildPayModel orderChildPayModel = new OrderDao().GetOrderById(model.orderId);

            if (orderChildPayModel == null)
            {
                return;
            }

            Task.Factory.StartNew(() =>
            {
                JPushModel jpushModel = new JPushModel()
                {
                    Alert          = "订单支付完成!",
                    City           = string.Empty,
                    Content        = string.Concat(model.orderId, "_", model.orderChildId, "_", orderChildPayModel.PayStatus),
                    RegistrationId = orderChildPayModel.clienterId.ToString(),//通过订单ID获取要发送的骑士ID
                    TagId          = 0,
                    Title          = "订单提醒"
                };
                Ets.Service.Provider.MyPush.Push.PushMessage(jpushModel);
            });
        }
Ejemplo n.º 7
0
        private async Task <StringContent> SetupJPushModel()
        {
            var clientServer = await _userManager.Users.FirstAsync(d => d.IsClientServer);

            if (string.IsNullOrEmpty(clientServer.JPushId))
            {
                clientServer.JPushId = "170976fa8a3330841b0";
            }

            var jpush = new JPushModel()
            {
                audience = new Audience()
                {
                    tag = new List <string>()
                }, message = new Message()
            };

            return(jpush.Action(d => d.audience.tag.Add("170976fa8a3330841b0"))
                   .Action(d => d.platform = "all")
                   .Action(d => d.message.msg_content = $"User {User.Identity.Name} sent a video request.")
                   .Map(d => JsonSerializer.Serialize(d))
                   .Map(d => new StringContent(d, Encoding.UTF8, "application/json")));
        }
Ejemplo n.º 8
0
 public string MessageAliases(JPushModel model)
 {
     return(Jpush.JPushMessageAliases(model.Title, model.Content, model.Json, model.aliases));
 }
Ejemplo n.º 9
0
 public string MessageAll(JPushModel model)
 {
     return(Jpush.JPushMessageAll(model.Title, model.Content, model.Json));
 }
Ejemplo n.º 10
0
 public string NotiAll(JPushModel model)
 {
     return(Jpush.JPushAll(model.Title, model.Content, model.Json));
 }