Esempio n. 1
0
        public static async Task <IActionResult> OrderCancel(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log
            )
        {
            try
            {
                log.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}" + "\r\n" +
                                   "Host {req.Host.ToString()} 에서 Http trigger - OrderCancel 이(가) 시작되었습니다.");

                string  Body = await new StreamReader(req.Body).ReadToEndAsync();
                dynamic data = JsonConvert.DeserializeObject(Body);

                int OrgOrderNo = Convert.ToInt32(data?["OrgOrderNo"]);

                if (IsNullorWrongValue(OrgOrderNo, 0))
                {
                    throw new Exception("request body 에서 OrgOrderNo 값을 추출할 수 없습니다.");
                }

                NETX mNETX = new NETX();
                mNETX.Add("@OrgOrderNo", DataType.Int, 0, OrgOrderNo);
                mNETX.Add("@IsCancel", DataType.Bit, 0, true);
                //mNETX.Add("@Region", DataType.VarChar, 100, _Region);
                //mNETX.Add("@Host", DataType.VarChar, 100, req.Host);
                mNETX.Add("@APIPath", DataType.VarChar, 200, req.Path);

                mNETX.ExecuteNonQuery("DBO.USP_T_ORDERS");

                string responseMessage = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}" + "\r\n" +
                                         $"Region = {_Region}" + "\r\n" +
                                         $"Host = {req.Host.ToString()}" + "\r\n" +
                                         $"Path = {req.Path.ToString()}" + "\r\n" +
                                         $"Method = {req.Method}" + "\r\n" +
                                         $"Body = {Body}" + "\r\n" +
                                         $"Message = Orders 테이블에 데이터를 정상적으로 반영했습니다.";

                return(new OkObjectResult(responseMessage));
            }
            catch (Exception Ex)
            {
                log.LogError(Ex, $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")} : {Ex.Message}", null);

                return(new OkObjectResult(Ex.Message));
            }
            finally
            {
                log.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}" + "\r\n" +
                                   "Host {req.Host.ToString()} 에서 Http trigger - OrderCancel 이(가) 종료되었습니다.");
            }
        }
Esempio n. 2
0
        public static async Task <IActionResult> Order(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log
            )
        {
            //string resourceId = "subscriptions/f743325c-9857-4f13-bff9-bc1976f25693/resourceGroups/RG-JW-DotNetConf2021xSeoul/providers/Microsoft.Web/sites/func-DotNetConf2021xSeoul";
            //string ResourceInfo = GetResourceInfo(resourceId);

            try
            {
                log.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}" + "\r\n" +
                                   " Host {req.Host.ToString()} 에서 Http trigger - Order 이(가) 시작되었습니다.");

                string  Body = await new StreamReader(req.Body).ReadToEndAsync();
                dynamic data = JsonConvert.DeserializeObject(Body);

                int MemberNo  = Convert.ToInt32(data?["MemberNo"]);
                int ProductNo = Convert.ToInt32(data?["ProductNo"]);
                int OrderQty  = Convert.ToInt32(data?["OrderQty"]);

                if (IsNullorWrongValue(MemberNo, 0))
                {
                    throw new Exception("request body 에서 MemberNo 값을 추출할 수 없습니다.");
                }
                if (IsNullorWrongValue(ProductNo, 0))
                {
                    throw new Exception("request body 에서 ProductNo 값을 추출할 수 없습니다.");
                }
                if (IsNullorWrongValue(OrderQty, 0))
                {
                    throw new Exception("request body 에서 OrderQty 값을 추출할 수 없습니다.");
                }

                NETX mNETX = new NETX();
                mNETX.Add("@MemberNo", DataType.Int, 0, MemberNo);
                mNETX.Add("@ProductNo", DataType.Int, 0, ProductNo);
                mNETX.Add("@OrderQty", DataType.Int, 0, OrderQty);
                //mNETX.Add("@Region", DataType.VarChar, 100, _Region);
                //mNETX.Add("@Host", DataType.VarChar, 100, req.Host);
                mNETX.Add("@APIPath", DataType.VarChar, 200, req.Path);

                mNETX.ExecuteNonQuery("DBO.USP_T_ORDERS");

                string responseMessage = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}" + "\r\n" +
                                         $"Region = {_Region}" + "\r\n" +
                                         $"Host = {req.Host.ToString()}" + "\r\n" +
                                         $"Path = {req.Path.ToString()}" + "\r\n" +
                                         $"Method = {req.Method}" + "\r\n" +
                                         $"Body = {Body}" + "\r\n" +
                                         $"Message = Orders 테이블에 데이터를 정상적으로 반영했습니다.";

                return(new OkObjectResult(responseMessage));
            }
            catch (Exception Ex)
            {
                log.LogError(Ex, $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")} : {Ex.Message}", null);

                return(new OkObjectResult(Ex.Message));
            }
            finally
            {
                log.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}" + "\r\n" +
                                   "Host {req.Host.ToString()} 에서 Http trigger - Order 이(가) 종료되었습니다.");
            }
        }