public LineApiController() { func = new Functional(); richMenu = new LineMessageTemplate.RichMenuResponse(); ChannelAccessToken = "q281ubFyT1L3Z1gAyrcLdLY4mHv2hXJFqAb/MEUO2OncgbgXdSsR6BDCXsrTZh0I3haZwDDaz1lrKF694gC0fTnp/CnbLma8WkiHW3UXwSf6gHxU5lNJP/IYeb1+KQRFeun9E5jJT8qx9lpQpY1S9AdB04t89/1O/w1cDnyilFU="; AccessTokenForSupport = "4bw1smnE8oLXGQg09XJRhq9H4xHh9w1207hwUxq5q1l"; clsPushMultiCast = new PushLineResponseMultiCastModel(); clsdupBubbleMultiCast = new dupBubbleMulticast(); clsdupBubbleMultiCastNoFooter = new dupBubbleMulticastNoFooter(); dataEvent = new EventLogModel(); }
public LineApiController(string ChannelName) { func = new Functional(); richMenu = new LineMessageTemplate.RichMenuResponse(); ChannelAccessToken = "q281ubFyT1L3Z1gAyrcLdLY4mHv2hXJFqAb/MEUO2OncgbgXdSsR6BDCXsrTZh0I3haZwDDaz1lrKF694gC0fTnp/CnbLma8WkiHW3UXwSf6gHxU5lNJP/IYeb1+KQRFeun9E5jJT8qx9lpQpY1S9AdB04t89/1O/w1cDnyilFU="; // ChannelAccessToken = "Pq+kySWPUtbt1YvcDtMHXkbUIrN7CDqzx18DAPS4Ij153mb+1id7NNKp7m3c74Fg5h54zPR1kFraEGm8JC31540oCiUPSwgK3SiKsYd9+nftcztMkFRg2u0PXGReejmHfKccPvNmTSwEIB63yyOvFAdB04t89/1O/w1cDnyilFU="; AccessTokenForSupport = "4bw1smnE8oLXGQg09XJRhq9H4xHh9w1207hwUxq5q1l"; clsPushMultiCast = new PushLineResponseMultiCastModel(); clsdupBubbleMultiCast = new dupBubbleMulticast(); clsdupBubbleMultiCastNoFooter = new dupBubbleMulticastNoFooter(); dataEvent = new EventLogModel(); }
public async Task CallApiMultiCast(object data) { clsPushMultiCast = new PushLineResponseMultiCastModel(); clsdupBubbleMultiCast = new dupBubbleMulticast(); clsdupBubbleMultiCastNoFooter = new dupBubbleMulticastNoFooter(); StringContent content = new StringContent(func.JsonSerialize(data), System.Text.Encoding.UTF8, "application/json"); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ChannelAccessToken); var response = await client.PostAsync("https://api.line.me/v2/bot/message/multicast", content); try { var contents = await response.Content.ReadAsStringAsync(); // Sqlstr = "EXEC REST_KeepEventTransaction '{0}', '{1}', '{2}', '{3}' "; if (data.GetType() == Type.GetType("APICore.Models.dupBubbleMulticast")) { clsdupBubbleMultiCast = (dupBubbleMulticast)data; Sqlstr = "EXEC REST_KeepEventTransaction 'API : multicast[153]', 'CallApiMultiCast', '" + func.JsonSerialize(clsdupBubbleMultiCast.to) + "', '" + contents + "' "; // Sqlstr = string.Format(Sqlstr, "API : multicast[153]", "CallApiMultiCast", func.JsonSerialize(clsdupBubbleMultiCast.to), contents); } else if (data.GetType() == Type.GetType("APICore.Models.dupBubbleMulticastNoFooter")) { clsdupBubbleMultiCastNoFooter = (dupBubbleMulticastNoFooter)data; Sqlstr = "EXEC REST_KeepEventTransaction 'API : multicast[168]', 'CallApiMultiCast', '" + func.JsonSerialize(clsdupBubbleMultiCastNoFooter.to) + "', '" + contents + "' "; // Sqlstr = string.Format(Sqlstr, "API : multicast[168]", "CallApiMultiCast", func.JsonSerialize(clsdupBubbleMultiCastNoFooter.to), contents); } else if (data.GetType() == Type.GetType("APICore.Models.PushLineResponseMultiCastModel")) { clsPushMultiCast = (PushLineResponseMultiCastModel)data; Sqlstr = "EXEC REST_KeepEventTransaction 'API : multicast[173]', 'CallApiMultiCast', '" + func.JsonSerialize(clsPushMultiCast.to) + "', '" + contents + "' "; // Sqlstr = string.Format(Sqlstr, "API : multicast[173]", "CallApiMultiCast", func.JsonSerialize(clsPushMultiCast.to), contents); } } catch (Exception e) { // Write Log Exception ExecuteSQL("EXEC REST_KeepEventTransaction 'API : multicast[179]', 'CallApiMultiCast', '" + func.JsonSerialize(data) + "', '" + e.StackTrace + "'"); } finally { // Write Log Response ExecuteSQL(Sqlstr); } }
public async Task <IActionResult> TestNotice(ExternalRequest request) { dupBubbleMulticast bubble = new dupBubbleMulticast(); dupBubbleMulticastNoFooter nofooter = new dupBubbleMulticastNoFooter(); string strmessage = template.MessageAlertTaskList(); // Get Data for string format dt = new DataTable(); dt = DAC.REST_GetApplicationInformation(request.AppNo); if (dt.Rows.Count > 0) { DateTime date = Convert.ToDateTime(dt.Rows[0]["Application_CreateDate"].ToString()); strmessage = string.Format( strmessage, dt.Rows[0]["Application_DealerName"].ToString(), dt.Rows[0]["Application_No"].ToString(), date.ToString("dd/MM/yyyy HH:mm"), dt.Rows[0]["Application_CustomerName"].ToString(), dt.Rows[0]["Area"].ToString(), dt.Rows[0]["Application_PhoneNumber"].ToString(), dt.Rows[0]["Application_DealerCode"].ToString(), dt.Rows[0]["Dealer_BranchCode"].ToString(), dt.Rows[0]["PhoneNumber"].ToString() ); dt = new DataTable(); dt = DAC.REST_GetCheckerList(request.AppNo); for (int i = 0; i < dt.Rows.Count; i++) { bubble = new dupBubbleMulticast(); nofooter = new dupBubbleMulticastNoFooter(); if (dt.Rows[i]["action"].ToString() == "NoFooter") { nofooter = api.SetBubbleMessageMultiCastNoFooter(strmessage, request.AppNo); nofooter.to.Add(dt.Rows[i]["User_LineUserId"].ToString()); // await api.CallApiMultiCast(nofooter); } else { bubble = api.SetBubbleMessageMultiCast(strmessage, request.AppNo); bubble.to.Add(dt.Rows[i]["User_LineUserId"].ToString()); // await api.CallApiMultiCast(bubble); } } } return(Ok()); }
public async Task <IActionResult> PushMessageOnTaskOverTime(List <ExternalRequest> requests) { dupBubbleMulticast bubble = new dupBubbleMulticast(); dupBubbleMulticastNoFooter nofooter = new dupBubbleMulticastNoFooter(); DataTable dtAppInfo; DAC.REST_KeepEventTransaction("PushMessageOnTaskOverTime", func.JsonSerialize(requests), "PushMessageOnTaskOverTime", "[545]"); if (requests.Count > 0) { foreach (ExternalRequest ex in requests) { dt = new DataTable(); dtAppInfo = new DataTable(); dt = DAC.REST_SelectPendingTaskByAppNo(ex.AppNo); if (dt.Rows.Count > 0) { string strmessage = template.MessageAlertTaskList(); dtAppInfo = DAC.REST_GetApplicationInformation(ex.AppNo); if (dtAppInfo.Rows.Count > 0) { DateTime date = Convert.ToDateTime(dtAppInfo.Rows[0]["Application_CreateDate"].ToString()); strmessage = string.Format( strmessage, dtAppInfo.Rows[0]["Application_DealerName"].ToString(), dtAppInfo.Rows[0]["Application_No"].ToString(), date.ToString("dd/MM/yyyy HH:mm"), dtAppInfo.Rows[0]["Application_CustomerName"].ToString(), dtAppInfo.Rows[0]["Area"].ToString(), dtAppInfo.Rows[0]["Application_PhoneNumber"].ToString() ); } else { DAC.REST_KeepEventTransaction("PushMessageOnTaskOverTime", ex.AppNo, "DealerController -> REST_GetApplicationInformation is Empty", "REST_GetApplicationInformation " + ex.AppNo); } foreach (DataRow row in dt.Rows) { try { if (row["action"].ToString() == "NoFooter") { nofooter = api.SetBubbleMessageMultiCastNoFooter(strmessage, ex.AppNo, "แจ้งเตือนไม่มีผู้รับงาน", "#fdb813"); nofooter.to.Add(row["User_LineUserId"].ToString()); await api.CallApiMultiCast(nofooter); DAC.REST_KeepEventTransaction("PushMessageOnTaskOverTime : State is " + row["action"].ToString(), func.JsonSerialize(nofooter), "DealerController -> CallApiMultiCast", "[578]"); } else { bubble = api.SetBubbleMessageMultiCast(strmessage, ex.AppNo, "แจ้งเตือนไม่มีผู้รับงาน", "#fdb813"); bubble.to.Add(row["User_LineUserId"].ToString()); await api.CallApiMultiCast(bubble); DAC.REST_KeepEventTransaction("PushMessageOnTaskOverTime : State is " + row["action"].ToString(), func.JsonSerialize(bubble), "DealerController -> CallApiMultiCast", "[585]"); } } catch (Exception e) { if (row["action"].ToString() == "NoFooter") { DAC.REST_KeepEventTransaction("PushMessageOnTaskOverTime", func.JsonSerialize(nofooter), "DealerController -> CallApiMultiCast", e.StackTrace); } else { DAC.REST_KeepEventTransaction("PushMessageOnTaskOverTime", func.JsonSerialize(bubble), "DealerController -> CallApiMultiCast", e.StackTrace); } } } } else { DAC.REST_KeepEventTransaction("PushMessageOnTaskOverTime", ex.AppNo, "DealerController -> REST_SelectPendingTaskByAppNo is Empty", "REST_SelectPendingTaskByAppNo " + ex.AppNo); } } } else { DAC.REST_KeepEventTransaction("PushMessageOnTaskOverTime", requests.Count.ToString(), "DealerController -> ExternalRequest is Empty", "PushMessageOnTaskOverTime"); } return(Ok()); }
public async Task <IActionResult> Push(ExternalRequest request) { dupBubbleMulticast bubble = new dupBubbleMulticast(); dupBubbleMulticastNoFooter nofooter = new dupBubbleMulticastNoFooter(); DAC.REST_KeepEventTransaction("PushMessage", func.JsonSerialize(request), "Push", "[364]"); string strmessage = template.MessageAlertTaskList(); // Get Data for string format dt = new DataTable(); dt = DAC.REST_GetApplicationInformation(request.AppNo); if (dt.Rows.Count > 0) { DateTime date = Convert.ToDateTime(dt.Rows[0]["Application_CreateDate"].ToString()); strmessage = string.Format( strmessage, dt.Rows[0]["Application_DealerName"].ToString(), dt.Rows[0]["Application_No"].ToString(), date.ToString("dd/MM/yyyy HH:mm"), dt.Rows[0]["Application_CustomerName"].ToString(), dt.Rows[0]["Area"].ToString(), dt.Rows[0]["Application_PhoneNumber"].ToString(), dt.Rows[0]["Application_DealerCode"].ToString(), dt.Rows[0]["Dealer_BranchCode"].ToString(), dt.Rows[0]["PhoneNumber"].ToString() ); dt = new DataTable(); dt = DAC.REST_GetCheckerList(request.AppNo); for (int i = 0; i < dt.Rows.Count; i++) { bubble = new dupBubbleMulticast(); nofooter = new dupBubbleMulticastNoFooter(); if (dt.Rows[i]["action"].ToString() == "NoFooter") { try { nofooter = api.SetBubbleMessageMultiCastNoFooter(strmessage, request.AppNo); nofooter.to.Add(dt.Rows[i]["User_LineUserId"].ToString()); await api.CallApiMultiCast(nofooter); DAC.REST_KeepEventTransaction("PushMessage : NoFooter", func.JsonSerialize(nofooter.to), "Push", "[395]"); } catch (Exception e) { DAC.REST_KeepEventTransaction("PushMessage : NoFooter", func.JsonSerialize(nofooter.to), "Push", e.StackTrace); } } else { try { bubble = api.SetBubbleMessageMultiCast(strmessage, request.AppNo); bubble.to.Add(dt.Rows[i]["User_LineUserId"].ToString()); await api.CallApiMultiCast(bubble); DAC.REST_KeepEventTransaction("PushMessage : haveFooter", func.JsonSerialize(bubble.to), "Push", "[409]"); } catch (Exception e) { DAC.REST_KeepEventTransaction("PushMessage : haveFooter", func.JsonSerialize(bubble.to), "Push", e.StackTrace); } } } } return(Ok()); }
public dupBubbleMulticast SetBubbleMessageMultiCast(string strMessage, string appNo, string headerDefault = "แจ้งเตือนงานใหม่!", string textcolor = "#FFFFFFFF") { dupBubbleMulticast main = new dupBubbleMulticast(); dupBubbleSubMain subMain = new dupBubbleSubMain(); dupBubbleTemplate template = new dupBubbleTemplate(); dupBubbleHeader header = new dupBubbleHeader(); dupBubbleHeaderContents headerContents = new dupBubbleHeaderContents(); dupBubbleHero hero = new dupBubbleHero(); dupBubbleBody body = new dupBubbleBody(); dupBubbleContents contents = new dupBubbleContents(); dupBubbleFooter footer = new dupBubbleFooter(); dupBubbleFooterContents footerContents = new dupBubbleFooterContents(); subMain.type = "flex"; subMain.altText = headerDefault; template.type = "bubble"; header.type = "box"; header.layout = "horizontal"; header.position = "relative"; header.backgroundColor = "#20409A"; headerContents.type = "text"; headerContents.text = headerDefault; headerContents.weight = "bold"; headerContents.size = "lg"; headerContents.color = textcolor; headerContents.contents = new List <object>(); header.contents.Add(headerContents); hero.type = "image"; hero.url = "https://www.nextcapital.co.th/uploads/06F1/files/b0b78757ee3181d6ce333da2a31128ec.png"; hero.size = "full"; hero.aspectRatio = "16:8"; hero.aspectMode = "cover"; hero.action.type = "uri"; hero.action.label = "Action"; hero.action.uri = "https://www.nextcapital.co.th"; body.type = "box"; body.layout = "horizontal"; body.spacing = "md"; contents.type = "text"; contents.text = strMessage; contents.weight = "regular"; contents.wrap = true; contents.style = "normal"; contents.contents = new List <object>(); body.contents.Add(contents); footer.type = "box"; footer.layout = "horizontal"; footer.backgroundColor = "#FDB813"; footerContents.type = "button"; footerContents.action.type = "message"; footerContents.action.label = ">>> รับงานนี้ <<<"; footerContents.action.text = appNo; footerContents.color = "#20409A"; //footerContents.color = "#FDB813"; footerContents.style = "link"; footer.contents.Add(footerContents); template.header = header; template.hero = hero; template.body = body; template.footer = footer; subMain.contents = template; main.messages.Add(subMain); return(main); }