Пример #1
0
 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();
 }
Пример #2
0
        public async Task <IActionResult> NoticeTracking(ExternalNotice request)
        {
            PushLineResponseMultiCastModel response = new PushLineResponseMultiCastModel();
            MessageResponseModel           message  = new MessageResponseModel();
            LineMessageTemplate            template = new LineMessageTemplate();

            dt = new DataTable();

            DAC.REST_KeepEventTransaction("NoticeTracking", func.JsonSerialize(request), "NoticeTracking", "[436]");

            string msg = template.MessageNotice(request.State, request);
            string statecancel;

            message.type = "text";
            message.text = msg;

            response.messages.Add(message);

            if (request.State == "cancel" && string.IsNullOrEmpty(request.CheckerName))
            {
                // Dealer Cancel
                request.State = "dealerupdate";
            }
            else if (request.State == "cancel" && !string.IsNullOrEmpty(request.CheckerName))
            {
                // Checker Cancel
                request.State = "checkerupdate";
            }

            dt = DAC.REST_GetUserforNotice(request.ApplicationNo, request.State);
            try
            {
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        response.to.Add(dt.Rows[i]["Receiver"].ToString());
                    }
                    await api.CallApiMultiCast(response);

                    DAC.REST_KeepEventTransaction("NoticeTracking", func.JsonSerialize(response.to), "DealerController -> CallApiMultiCast", "[461]");
                }
                else
                {
                    DAC.REST_KeepEventTransaction("NoticeTracking", request.ApplicationNo, "DealerController -> REST_GetUserforNotice is Empty", "REST_UpdateStatusApp " + request.ApplicationNo + ", " + request.State);
                }
            }
            catch (Exception e)
            {
                DAC.REST_KeepEventTransaction("NoticeTracking", request.ApplicationNo, "DealerController", e.StackTrace);
            }
            return(Ok());
        }
Пример #3
0
 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();
 }
Пример #4
0
        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);
            }
        }