示例#1
0
        /// <summary>
        /// QRCode 생성을 위한 URL 요청
        /// </summary>
        /// <param name="aRfid"></param>
        /// <param name="aPurchaseHistoryOnetimeURL"></param>
        /// <returns></returns>
        public static DTOPurchaseHistoryOnetimeURLResponse API_PostPurchaseHistoryOnetimeURL(string aRfid, long aBeforeTimestamp, long aAfterTimestamp)
        {
            //----------------------------------------
            DTOPurchaseHistoryOnetimeURLRequest req = new DTOPurchaseHistoryOnetimeURLRequest();

            {
                req.rfid            = aRfid;
                req.purchase_before = aBeforeTimestamp;
                req.purchase_after  = aAfterTimestamp;
            }

            //----------------------------------------
            RestSharp.RestClient  client  = new RestSharp.RestClient(URL_DCCAFFE);
            RestSharp.RestRequest request = new RestSharp.RestRequest();
            request.AddHeader("Content-Type", "application/json;charset=UTF-8");

            request.Method        = RestSharp.Method.POST;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource      = URI_POST_PURCHASE_HISTORY_TEMPORARY_URL;
            request.AddJsonBody(req);

            //----------------------------------------
            var t1 = client.ExecuteTaskAsync(request);

            t1.Wait();

            //----------------------------------------
            // error handling
            if (t1.Result.ErrorException != null)
            {
                System.Diagnostics.Debug.WriteLine("[RESPONSE] " + t1.Result.Content);
                return(null);
            }

            string json = t1.Result.Content;

            //----------------------------------------
            // debug output
            json = JsonFormatting(json);
            System.Diagnostics.Debug.WriteLine("[RESPONSE] " + json);

            //----------------------------------------
            // desirialized json data
            DTOPurchaseHistoryOnetimeURLResponse dto = new DTOPurchaseHistoryOnetimeURLResponse();

            try
            {
                dto      = JsonConvert.DeserializeObject <DTOPurchaseHistoryOnetimeURLResponse>(json);
                dto.code = (int)t1.Result.StatusCode;
            }
            catch (Exception ex)
            {
                dto = null;
                System.Diagnostics.Debug.WriteLine("[ERROR] " + ex.Message);
            }

            return(dto);
        }
示例#2
0
        /// <summary>
        /// 개별 페이지들의 성공 이벤트
        /// 다음 페이지 이동 처리
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        ///
        ///================================================================================
        /// 월말 공제 프로세스 시작
        /// FormPayType -> FormRFReader -> FormMenuBoard -> FormResultOrder -> FormPayType
        ///
        /// 손님 결제 프로세스 시작
        /// FormPayType -> FormRFReader -> FormMenuBoard -> FormResultOrder -> FormPayType
        ///
        /// 주문 취소
        /// FormPayType -> FormRFReader -> FormKeyPad -> FormResultCancle -> FormPayType
        ///
        /// 사용자 이용 내역 조회
        /// FormPayType -> FormRFReader -> FormResultInquery -> FormPayType
        ///================================================================================
        private void OnPageSuccess(object sender, EventArgs e)
        {
            //------------------
            // from FormRFReader
            //------------------
            if ((sender.GetType()).Name.CompareTo(PAGES.FormRFRead.ToString()) == 0)
            {
                // 현재 사용자 인증 정보 임시 저장
                {
                    this.mRFID      = mFormRFRead.XstrHashedRFid;
                    this.mName      = mFormRFRead.XApiResponse.name;
                    this.mCompany   = mFormRFRead.XApiResponse.company;
                    this.mReceiptId = mFormRFRead.XApiResponse.receipt_id; // new receipt id
                }

                // 다음 페이지 화면 보이기
                string nextPageName = NextPage(this.mCurrentPayType, PAGES.FormRFRead);
                {
                    if (nextPageName == PAGES.FormMenuBoard.ToString())
                    {
                        mFormMenuBoard.XCompany   = mCompany;
                        mFormMenuBoard.XName      = mName;
                        mFormMenuBoard.XPayType   = mCurrentPayType;
                        mFormMenuBoard.XReceiptId = mReceiptId;
                        mFormMenuBoard.ResetForm();
                    }
                    else if (nextPageName == PAGES.FormKeyPad.ToString())
                    {
                        mFormKeyPad.XCompany = mCompany;
                        mFormKeyPad.XName    = mName;
                        mFormKeyPad.XRfid    = mRFID;
                        mFormKeyPad.ResetForm();
                    }
                    else if (nextPageName == PAGES.FormResultInquery.ToString())
                    {
                        mFormResultInquery.XCompany   = mCompany;
                        mFormResultInquery.XName      = mName;
                        mFormResultInquery.XReceiptId = mReceiptId;

                        //----------------------------------------------
                        // 사용자 사용내역 URI 가져와서 QRCod Image 만들기
                        //----------------------------------------------
                        DateTime afterDt  = DateTime.Now;
                        DateTime beforeDt = new DateTime(afterDt.Year, afterDt.Month, 1);

                        long beforeTimestamp = Utilities.TimeStamp.getUnixTimeStamp(beforeDt);
                        long afterTimestamp  = Utilities.TimeStamp.getUnixTimeStamp(afterDt);

                        //-------------------------------------------------
                        DTOPurchaseHistoryOnetimeURLResponse _rsp =
                            APIController.API_PostPurchaseHistoryOnetimeURL(mRFID, beforeTimestamp, afterTimestamp);

                        if (_rsp.code == 200)
                        {
                            mFormResultInquery.XBitmapQRCode = Utilities.QRCode.GetQRCodeBitmap(_rsp.uri);
                        }
                        else
                        {
                            mFormResultInquery.XBitmapQRCode = null;
                        }
                        //-------------------------------------------------

                        mFormResultInquery.ResetForm();
                    }
                }
                DisplayPage(nextPageName);
            }

            //--------------------
            // from FormMenuBoard
            //--------------------
            if ((sender.GetType()).Name.CompareTo(PAGES.FormMenuBoard.ToString()) == 0)
            {
                string nextPageName = NextPage(this.mCurrentPayType, PAGES.FormMenuBoard);
                {
                    mFormResultOrder.XCompany = mCompany;
                    mFormResultOrder.XName    = mName;
                    mFormResultOrder.XPayType = mCurrentPayType;
                    mFormResultOrder.ResetForm();
                }
                DisplayPage(nextPageName);
            }

            //---------------------
            // from FormResultOrder
            //---------------------
            if ((sender.GetType()).Name.CompareTo(PAGES.FormResultOrder.ToString()) == 0)
            {
                string nextPageName = NextPage(this.mCurrentPayType, PAGES.FormResultOrder);
                DisplayPage(nextPageName);
            }

            //------------------
            // from FormKeyPad
            //------------------
            if ((sender.GetType()).Name.CompareTo(PAGES.FormKeyPad.ToString()) == 0)
            {
                string nextPageName = NextPage(this.mCurrentPayType, PAGES.FormKeyPad);
                {
                    mFormResultCancel.XCompany       = mCompany;
                    mFormResultCancel.XName          = mName;
                    mFormResultCancel.XReceiptId     = mFormKeyPad.XApiResponse.receipt_id;
                    mFormResultCancel.XPurchasedDate = mFormKeyPad.XApiResponse.purchased_date;
                    mFormResultCancel.ResetForm();
                }
                DisplayPage(nextPageName);
            }

            //-----------------------
            // from FormResultCancel
            //-----------------------
            if ((sender.GetType()).Name.CompareTo(PAGES.FormResultCancel.ToString()) == 0)
            {
                // nothing ...
            }

            //------------------------
            // from FormResultInquery
            //------------------------
            if ((sender.GetType()).Name.CompareTo(PAGES.FormResultInquery.ToString()) == 0)
            {
                // nothing ...
            }
        }