Beispiel #1
0
        public IEnumerable <WTicketResp> Post(WTicket ticket)
        {
            var response = new HttpResponseMessage(HttpStatusCode.Created);

            if (ticket.Block == 1)
            {
                return(wticResp);
            }
            else
            {
                return(wticResp2);
            }
        }
Beispiel #2
0
        private async void CreateProductAsync()
        {
            string  beginT    = string.Format("{0:yyyy/MM/dd HH:00:00}", DateTime.Now);
            string  endT      = string.Format("{0:yyyy/MM/dd HH:00:00}", DateTime.Now.AddHours(1));
            string  Pro_code  = (string)checkBox1.Text.ToString();
            string  Pro_code2 = (string)checkBox2.Text.ToString();
            WTicket ticket    = new WTicket
            {
                Products_Code = "B01LITNY",
                Orders_STIME  = beginT,
                Orders_ETIME  = endT,
                Block         = Block
            };

            Block++;
            HttpClient          client   = new HttpClient();
            HttpResponseMessage response = await client.PostAsync("http://210.61.47.134/QWARE_TICKET_ADMIN/WebServices/ibonTicket.asmx/GetTicketData", new StringContent(
                                                                      new JavaScriptSerializer().Serialize(ticket), Encoding.UTF8, "application/json"));

            response.EnsureSuccessStatusCode();
            string myConnStr = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;

            if (response.IsSuccessStatusCode)
            {
                // Get the response
                var customerJsonString = await response.Content.ReadAsStringAsync();

                // Deserialise the data (include the Newtonsoft JSON Nuget package if you don't already have it)
                var deserialized = JsonConvert.DeserializeObject <IEnumerable <WTicketResp> >(customerJsonString);
                // Do something with it
                getdataFapi g   = new getdataFapi();
                string      sql = "";
                try
                {
                    using (SqlConnection _con = new SqlConnection(myConnStr))
                    {
                        _con.Open();

                        foreach (WTicketResp wTicketResp in deserialized)
                        {
                            g.TK_QRCODE       = wTicketResp.QR_Code;
                            g.TK_ORDERNO      = wTicketResp.Orders_No;
                            g.TK_PRICETYPES   = wTicketResp.PriceTypes;
                            g.TK_PRICE        = Convert.ToInt32(wTicketResp.Price);
                            g.TK_ORDERDT      = wTicketResp.Order_datetime;
                            g.TK_PLACE        = "ibon";
                            g.TK_STATUS       = wTicketResp.Order_Type; //B:購票  R:退票
                            g.TK_USED_DT      = "";
                            g.TK_END_DT       = "";
                            g.TK_FEEDBACK     = "";
                            g.TK_FEEDBACKMEMO = "";
                            g.CREATEDT        = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);;
                            g.CREATEID        = "admin";
                            g.MODIFYDT        = null;
                            g.MODIFYID        = null;

                            if (!GetDataDB(g.TK_QRCODE))
                            {
                                if (g.TK_STATUS == "R")
                                {
                                    sql = string.Format(@"insert into cTicketWhitelist
                                                    (TK_QRCODE
                                                    ,TK_ORDERNO
                                                    ,TK_PRICETYPES
                                                    ,TK_PRICE
                                                    ,TK_ORDERDT
                                                    ,TK_PLACE
                                                    ,TK_STATUS
                                                    ,TK_USED_DT
                                                    ,TK_END_DT
                                                    ,TK_FEEDBACK
                                                    ,TK_FEEDBACKMEMO
                                                    ,CREATEDT
                                                    ,CREATEID
                                                    ,MODIFYDT
                                                    ,MODIFYID
                                                        ) 
                                                     values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}')"
                                                        , g.TK_QRCODE
                                                        , g.TK_ORDERNO
                                                        , g.TK_PRICETYPES
                                                        , g.TK_PRICE
                                                        , g.TK_ORDERDT
                                                        , g.TK_PLACE
                                                        , "X"
                                                        , g.TK_USED_DT
                                                        , g.TK_END_DT
                                                        , g.TK_FEEDBACK
                                                        , g.TK_FEEDBACKMEMO
                                                        , g.CREATEDT
                                                        , g.CREATEID
                                                        , g.MODIFYDT
                                                        , g.MODIFYID
                                                        );                            //1:售出  2:已使用  X:作廢
                                    SqlCommand cmd = new SqlCommand(sql, _con);
                                    cmd.ExecuteNonQuery();
                                }
                                else
                                {
                                    sql = string.Format(@"insert into cTicketWhitelist
                                                    (TK_QRCODE
                                                    ,TK_ORDERNO
                                                    ,TK_PRICETYPES
                                                    ,TK_PRICE
                                                    ,TK_ORDERDT
                                                    ,TK_PLACE
                                                    ,TK_STATUS
                                                    ,TK_USED_DT
                                                    ,TK_END_DT
                                                    ,TK_FEEDBACK
                                                    ,TK_FEEDBACKMEMO
                                                    ,CREATEDT
                                                    ,CREATEID
                                                    ,MODIFYDT
                                                    ,MODIFYID
                                                        ) 
                                                     values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}')"
                                                        , g.TK_QRCODE
                                                        , g.TK_ORDERNO
                                                        , g.TK_PRICETYPES
                                                        , g.TK_PRICE
                                                        , g.TK_ORDERDT
                                                        , g.TK_PLACE
                                                        , "1"
                                                        , g.TK_USED_DT
                                                        , g.TK_END_DT
                                                        , g.TK_FEEDBACK
                                                        , g.TK_FEEDBACKMEMO
                                                        , g.CREATEDT
                                                        , g.CREATEID
                                                        , g.MODIFYDT
                                                        , g.MODIFYID
                                                        );
                                    SqlCommand cmd = new SqlCommand(sql, _con);
                                    cmd.ExecuteNonQuery();
                                }
                            }
                        }
                        _con.Close();
                    }
                }
                catch (Exception e)
                {
                }
            }
            // return URI of the created resource.
            //return response.Headers.Location;
        }