Commit c0c671c8 authored by 席世权's avatar 席世权

优化极光推送

parent 7161e91e
...@@ -29,6 +29,7 @@ namespace PushInfo.Core.BLL ...@@ -29,6 +29,7 @@ namespace PushInfo.Core.BLL
private PushDataBLL pDataBll = new PushDataBLL(); private PushDataBLL pDataBll = new PushDataBLL();
private string MqName = "PushTaskQueue"; private string MqName = "PushTaskQueue";
private string MqNameTwo = "PushTaskQueueTwo"; private string MqNameTwo = "PushTaskQueueTwo";
private string MqNameUrora = "PushTaskQueueUrora";
#region 推送执行任务 #region 推送执行任务
/// <summary> /// <summary>
/// 推送执行任务 /// 推送执行任务
...@@ -327,11 +328,15 @@ namespace PushInfo.Core.BLL ...@@ -327,11 +328,15 @@ namespace PushInfo.Core.BLL
AppPushConfig appCfgModel = JsonUtil.ConvertToObject<AppPushConfig>(appCfg.Config_Info); AppPushConfig appCfgModel = JsonUtil.ConvertToObject<AppPushConfig>(appCfg.Config_Info);
if (!string.IsNullOrEmpty(Data.clientID) && !string.IsNullOrEmpty(Data.clientType)) if (!string.IsNullOrEmpty(Data.clientID) && !string.IsNullOrEmpty(Data.clientType))
{ {
var taskResult = Task.Run(() => Task.Run(() =>
{ {
return Send_Push(appCfgModel, Data.clientID, Data.clientType, mapProPush.Push_Title, mapProPush.Push_Body, mapProPush.Push_AndLink, mapProPush.Push_IosLink); var resultTask = Send_Push(appCfgModel, Data.clientID, Data.clientType, mapProPush.Push_Title, mapProPush.Push_Body, mapProPush.Push_AndLink, mapProPush.Push_IosLink);
mapProPush.Return_Code = resultTask.Msg;
result = InsertPushMessage(mapProPush, Data, pushStype, result);
if (result.Result == 0)
{ LogHelper.Info(mapProPush.Name_Des + Data.realName + "-" + Data.loginName + "手机推送记录失败"); result.Result = 0; };
}); });
result = taskResult.Result; return result;
} }
else else
{ {
...@@ -546,7 +551,7 @@ namespace PushInfo.Core.BLL ...@@ -546,7 +551,7 @@ namespace PushInfo.Core.BLL
isProd = true; isProd = true;
return message.SendPush(new Jiguang.JPush.Model.Audience { RegistrationId = new List<string> { clientId } }, return message.SendPush(new Jiguang.JPush.Model.Audience { RegistrationId = new List<string> { clientId } },
pushTitle, pushBody, intent, pushTitle, pushBody, intent,
extras); extras, isProd);
} }
#endregion #endregion
...@@ -575,10 +580,12 @@ namespace PushInfo.Core.BLL ...@@ -575,10 +580,12 @@ namespace PushInfo.Core.BLL
{ {
try try
{ {
ConfirmSendTask(mapProPush, data); //ConfirmSendTask(mapProPush, data);
//if (mapProPush.Push_Style.IndexOf(((int)PushStyle.APP).ToString()) > -1) if (mapProPush.Push_Style.IndexOf(((int)PushStyle.APP).ToString()) > -1)
// MqNameTwo = MqName; MqNameTwo = MqName;
//ActiveMQHelper.CreateMQProducer(MqNameTwo, MQMode.Queue, new DataCenterMessage { ObjectID = "", MsgData = mapProPush.ToJson(), MsgSecondData = data.ToJson()}, sendDate); else if (mapProPush.Push_Style.IndexOf(((int)PushStyle.极光App).ToString()) > -1)
MqNameTwo = MqNameUrora;
ActiveMQHelper.CreateMQProducer(MqNameTwo, MQMode.Queue, new DataCenterMessage { ObjectID = "", MsgData = mapProPush.ToJson(), MsgSecondData = data.ToJson() }, sendDate);
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -595,6 +602,7 @@ namespace PushInfo.Core.BLL ...@@ -595,6 +602,7 @@ namespace PushInfo.Core.BLL
/// <returns></returns> /// <returns></returns>
public void ReleaseTaskMq() public void ReleaseTaskMq()
{ {
MqName = System.Configuration.ConfigurationManager.AppSettings["MqName"];
ActiveMQHelper.CreateMQConsumer(MqName, MQMode.Queue, msg => ActiveMQHelper.CreateMQConsumer(MqName, MQMode.Queue, msg =>
{ {
try try
...@@ -614,7 +622,7 @@ namespace PushInfo.Core.BLL ...@@ -614,7 +622,7 @@ namespace PushInfo.Core.BLL
} }
if (result.Result != 1 && result.code == 1) if (result.Result != 1 && result.code == 1)
TaskIntoMq(mapProPush, data, DateTime.Now.AddSeconds(10)); TaskIntoMq(mapProPush, data, DateTime.Now.AddSeconds(10));
Console.WriteLine(mapProPush.Push_Title + ":" + DateTime.Now.ToString("yyyy-MM-dd HHss")); Console.WriteLine(mapProPush.Push_Title + ":" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
} }
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<td>@pushConfig.Create_Time.ToString("yyyy-MM-dd")</td> <td>@pushConfig.Create_Time.ToString("yyyy-MM-dd")</td>
<td>@pushConfig.Name_Des</td> <td>@pushConfig.Name_Des</td>
<td>@((ExecuteStatus)pushConfig.Exec_Status)</td> <td>@((ExecuteStatus)pushConfig.Exec_Status)</td>
<td>@pushConfig.Exec_Time.ToString("yyyy-MM-dd")</td> <td>@pushConfig.Exec_Time.ToString("yyyy-MM-dd HH:mm:ss")</td>
<td> <td>
<div class="form-inline"> <div class="form-inline">
<div class="btn-group"> <div class="btn-group">
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<add key="ActiveMQ" value="tcp://47.100.208.49:61616/"/> <add key="ActiveMQ" value="tcp://47.100.208.49:61616/"/>
<add key="WechatTokenUrl" value="https://tools.ashermed.com/Wechat/Token/"/> <add key="WechatTokenUrl" value="https://tools.ashermed.com/Wechat/Token/"/>
<add key="IsProd" value="1"/> <add key="IsProd" value="0"/>
</appSettings> </appSettings>
<system.web> <system.web>
<compilation debug="true" targetFramework="4.5" /> <compilation debug="true" targetFramework="4.5" />
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
<add key="ActiveMQ" value="tcp://47.100.208.49:61616/" /> <add key="ActiveMQ" value="tcp://47.100.208.49:61616/" />
<add key="WechatTokenUrl" value="https://tools.ashermed.com/Wechat/Token/" /> <add key="WechatTokenUrl" value="https://tools.ashermed.com/Wechat/Token/" />
<add key="IsProd" value="0"/>
<add key="MqName" value="PushTaskQueue,PushTaskQueueUrora"/>
</appSettings> </appSettings>
<connectionStrings> <connectionStrings>
<!--<add name="WriteConnStr" connectionString="Server=192.168.0.39;Database=db_ashermed_push;Uid=user;Pwd=123456;"/> <!--<add name="WriteConnStr" connectionString="Server=192.168.0.39;Database=db_ashermed_push;Uid=user;Pwd=123456;"/>
......
...@@ -28,11 +28,11 @@ namespace PushTest ...@@ -28,11 +28,11 @@ namespace PushTest
static void Main(string[] args) static void Main(string[] args)
{ {
var message = new JiguangPushMessage("298ec6f7cdcdee87a3faf64b", "36dd48a9028eeb4471acec46"); var message = new JiguangPushMessage("298ec6f7cdcdee87a3faf64b", "36dd48a9028eeb4471acec46");
message.SendPush(new Jiguang.JPush.Model.Audience { RegistrationId = new List<string> { "1a0018970a578514295" } }, // android: 1a0018970a578514295, ios: 161a3797c8f24d790c1 var result = message.SendPush(new Jiguang.JPush.Model.Audience { RegistrationId = new List<string> { "171976fa8a74aa10a22" } }, // android: 1a0018970a578514295, ios: 161a3797c8f24d790c1
"上海保供物资管理意见1700", "备用手机号避免因注册1700", "我的头痛日记", "您的头痛时间已持续72小时,请确认是否已结束?点击确认>>",
//"intent:#Intent;action=android.intent.action.MAIN;end", // 首页 "intent:#Intent;action=android.intent.action.MAIN;end", // 首页
"intent:#Intent;action=android.intent.action.MAIN;component=com.aisha.headache.ui.activity.SplashActivity;S.key1=\"哈哈\";i.key2=2;end", // 指定页面并传参 //"intent:#Intent;action=android.intent.action.MAIN;component=com.aisha.headache.ui.activity.SplashActivity;S.key1=\"哈哈\";i.key2=2;end", // 指定页面并传参
new Dictionary<string, object> { { "Data", "{\"ProjectId\":\"[projectId]\",\"PatientNumber\":\"[patientNumber]\"}" } }); new Dictionary<string, object> { { "Data", "{\"ProjectId\":\"[projectId]\",\"PatientNumber\":\"[patientNumber]\"}" } },true);
var field1 = "<field>501a4360-5648-45be-8aaa-935d5f6673c3</field>"; //体重 var field1 = "<field>501a4360-5648-45be-8aaa-935d5f6673c3</field>"; //体重
var field2 = "<field>c7142c7b-2372-4a79-8626-6ae218e9ae0b</field>"; //身高 var field2 = "<field>c7142c7b-2372-4a79-8626-6ae218e9ae0b</field>"; //身高
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment