shakun
11 months ago
5 changed files with 109 additions and 55 deletions
-
63SendMail/API/NotifierV2.cs
-
4SendMail/App.config
-
66SendMail/Business/TxnPush.cs
-
30SendMail/DAO/TxnPushDAO.cs
-
1SendMail/JMETxnPushScheduler.csproj
@ -0,0 +1,63 @@ |
|||
using JMETxnPushScheduler.Common; |
|||
using Newtonsoft.Json; |
|||
using Swift.API.Common.Enum; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net.Http; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace JMETxnPushScheduler.API |
|||
{ |
|||
public static class NotifierV2 |
|||
{ |
|||
// private static readonly ILog Log = LogManager.GetLogger(typeof(NotifierV2));
|
|||
public static JsonResponse SendNotification(SendNotificationRequestMobile request, NOTIFICATION_TYPE nOTIFICATION_TYPE = NOTIFICATION_TYPE.PUSH_NOTIFICATION) |
|||
{ |
|||
using (var client = RestApiClient.CallJMEThirdParty()) |
|||
{ |
|||
JsonResponse jsonResponse = new JsonResponse(); |
|||
var obj = JsonConvert.SerializeObject(request); |
|||
var jbdContent = new StringContent(obj.ToString(), Encoding.UTF8, "application/json"); |
|||
try |
|||
{ |
|||
var URL = "api/v1/TP/NotificationAPI"; |
|||
|
|||
HttpResponseMessage resp = client.PostAsync(URL, jbdContent).Result; |
|||
string resultData = resp.Content.ReadAsStringAsync().Result; |
|||
if (resp.IsSuccessStatusCode) |
|||
{ |
|||
jsonResponse = JsonConvert.DeserializeObject<JsonResponse>(resultData); |
|||
var a = (jsonResponse.Data != null ? JsonConvert.DeserializeObject<JsonResponse>(jsonResponse.Data.ToString()) : null); |
|||
jsonResponse.Data = a; |
|||
|
|||
return jsonResponse; |
|||
} |
|||
else |
|||
{ |
|||
var errorJson = JsonConvert.DeserializeObject<ErrorJosn>(resultData); |
|||
var jsonResponseData = JsonConvert.DeserializeObject<JsonResponse>(errorJson.Message); |
|||
var data = JsonConvert.DeserializeObject<List<Data>>(jsonResponseData.Data.ToString()); |
|||
jsonResponse.Id = jsonResponseData.Id; |
|||
jsonResponse.ResponseCode = jsonResponseData.ResponseCode; |
|||
jsonResponse.Msg = jsonResponseData.Msg; |
|||
jsonResponse.Data = data; |
|||
jsonResponse.Extra = jsonResponseData.Extra; |
|||
jsonResponse.Extra1 = jsonResponseData.Extra1; |
|||
return jsonResponse; |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
return new JsonResponse() |
|||
{ |
|||
ResponseCode = "1", |
|||
Msg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message) |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue