Пример #1
0
        /// <summary>
        /// 메뉴 목록 가져오기
        /// </summary>
        /// <returns></returns>
        public static DTOGetMenusResponse API_GetMenus()
        {
            //============================================
            // GET http://10.1.203.12:8080/api/caffe/menus
            //============================================
            RestSharp.RestClient  client  = new RestSharp.RestClient(URL_DCCAFFE);
            RestSharp.RestRequest request = new RestSharp.RestRequest();
            request.AddHeader("Content-Type", "application/json");

            request.Method        = RestSharp.Method.GET;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource      = URI_GET_MENUS;
            request.Timeout       = 3000;

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

            t1.Wait();

            //----------------
            // error handling
            if (t1.Result.ErrorException != null)
            {
                return(null);
            }

            string json = t1.Result.Content;

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

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

            try
            {
                if (t1.Result.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    dto.dicCategoryMenus = JsonConvert.DeserializeObject <Dictionary <string, List <VOCategoryMenuList> > >(json);
                    dto.code             = (int)t1.Result.StatusCode;
                }
                else
                {
                    dto = JsonConvert.DeserializeObject <DTOGetMenusResponse>(json);
                }
            }
            catch (Exception ex)
            {
                dto = null;
                System.Diagnostics.Debug.WriteLine("[ERROR] " + ex.Message);
            }

            return(dto);
        }
Пример #2
0
        //========================================
        public FormMain()
        {
            InitializeComponent();
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            // 결제 방식 폼
            mFormPayType = new FormPayType();
            {
                mFormPayType.OnSelectedPayType += OnSelectedPayType;
            }

            // RFID 폼
            mFormRFRead = new FormRFRead();
            {
                mFormRFRead.PageSuccess += OnPageSuccess;
                mFormRFRead.PageCancel  += OnPageCancel;
            }

            // 메뉴 폼
            mFormMenuBoard = new FormMenuBoard();
            {
                mFormMenuBoard.PageSuccess += OnPageSuccess;
                mFormMenuBoard.PageCancel  += OnPageCancel;

                //-----------------------------------
                // 메뉴가 변경되면 프로그램 재시작 필요
                // 메뉴는 프로그램 시작될때 설정됨
                //-----------------------------------
                mCategoryMenus = APIController.API_GetMenus();

                if (mCategoryMenus != null)
                {
                    mFormMenuBoard.XCategoriesAndMenusDictionary = mCategoryMenus.dicCategoryMenus;
                    mFormMenuBoard.ResetForm();
                }
                else
                {
                    MessageBox.Show("DCCaffe 서버로 부터 메뉴 정보를 가져오지 못했습니다.\n\r인터넷 연결을 점검한 후 다시 실행해야 합니다.", "문제 보고", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Application.ExitThread();
                    Environment.Exit(0);
                    return;
                }
            }

            // 결제 완료 폼
            mFormResultOrder = new FormResultOrder();
            {
                mFormResultOrder.PageSuccess += OnPageSuccess;
                mFormResultOrder.PageCancel  += OnPageCancel;
            }

            // 취소 키패드 폼
            mFormKeyPad = new FormKeyPad();
            {
                mFormKeyPad.PageSuccess += OnPageSuccess;
                mFormKeyPad.PageCancel  += OnPageCancel;
            }

            // 취소 완료 폼
            mFormResultCancel = new FormResultCancel();
            {
                mFormResultCancel.PageSuccess += OnPageSuccess;
                mFormResultCancel.PageCancel  += OnPageCancel;
            }

            // 내역 조회 완료 폼
            mFormResultInquery = new FormResultInquery();
            {
                mFormResultInquery.PageSuccess += OnPageSuccess;
                mFormResultInquery.PageCancel  += OnPageCancel;
            }

            // 판넬에 페이지 추가
            AddForms2Panel(mFormPayType);
            AddForms2Panel(mFormRFRead);
            AddForms2Panel(mFormMenuBoard);
            AddForms2Panel(mFormResultOrder);
            AddForms2Panel(mFormKeyPad);
            AddForms2Panel(mFormResultCancel);
            AddForms2Panel(mFormResultInquery);

            // 시작 페이지 보이기
            DisplayPage(nameof(FormPayType));
        }