Exemplo n.º 1
0
        public ActionResult CreateMenu(LunchMenu menuObj)
        {
            LunchMenuModel model = null;

            if (ModelState.IsValid)
            {
                try
                {
                    if (menuObj.ImagePath != null)
                    {
                        string fileName = Saveimage(menuObj);
                        model = new LunchMenuModel
                        {
                            DishName  = menuObj.DishName,
                            Price     = menuObj.Price,
                            ServedAt  = menuObj.ServedAt,
                            ImagePath = fileName
                        };
                    }
                    using (MongoContext <LunchMenuModel> db = new MongoContext <LunchMenuModel>("LunchMenu"))
                    {
                        db.context.Insert(model);
                        return(RedirectToAction("Index"));
                    }
                }
                catch (Exception e)
                {
                    ViewBag.Error = e.Message;
                    return(View());
                }
            }
            return(View());
        }
Exemplo n.º 2
0
        public LunchMenu NotKey()
        {
            var clientInfo = Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4() + ":" + Request.HttpContext.Connection.RemotePort;

            try
            {
                var error = new LunchMenu
                {
                    ResultCode = "001",
                    ResultMsg  = "API 키 값을 입력해주세요.",
                    Data       = null
                };

                Program.Logger.LogInformation("<" + clientInfo + "> 급식 메뉴 요청: 결과 - " + error.ResultCode + " (" + error.ResultMsg + ")");
                return(error);
            }
            catch (Exception e)
            {
                var error = new LunchMenu
                {
                    ResultCode = "999",
                    ResultMsg  = "알 수 없는 오류:\n" + e.Message,
                    Data       = null
                };
                Program.Logger.LogError("<" + clientInfo + "> 급식 메뉴 요청: 결과 - 999 (" + e.Message + ")");
                return(error);
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            LunchMenu lunchMenu = new LunchMenu();

            Waitress waitress = new Waitress(lunchMenu);

            waitress.PrintMenu();
        }
 private async Task ViewLunchMenuAnimation()
 {
     LunchMenu.IsVisible = true;
     if (App.Animation)
     {
         LunchMenu.Opacity = 0;
         await LunchMenu.FadeTo(1, 750, Easing.SpringIn);
     }
 }
Exemplo n.º 5
0
 private string Saveimage(LunchMenu menuObj)
 {
     try
     {
         var fileName = Guid.NewGuid().ToString() + Path.GetFileName(menuObj.ImagePath.FileName);
         var path     = Path.Combine(Server.MapPath("~/images"), fileName);
         menuObj.ImagePath.SaveAs(path);
         return(fileName);
     }
     catch (Exception e)
     {
         return(string.Empty);
     }
 }
Exemplo n.º 6
0
        public async Task StartAsync(IDialogContext context)
        {
            // TODO: Asynchronous menu
            // 1. Make menu fetch asnyc
            // 2. Update MenuManager with a HasLatest prop
            // 3. if (!menuManager.HasLatest)
            //      push message("Lemme go grab the menu");
            MenuManager = new MenuManager()
            {
                DirectoryPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PDFParser\"
            };

            LunchMenu = MenuManager.LunchMenu;

            context.Wait(this.MessageReceivedAsync);
        }
Exemplo n.º 7
0
        public LunchMenu Get(string apiKey)
        {
            var clientInfo = Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4() + ":" + Request.HttpContext.Connection.RemotePort;

            try
            {
                if (apiKey != Program.API_KEY)
                {
                    var error = new LunchMenu
                    {
                        ResultCode = "002",
                        ResultMsg  = "유효하지 않은 API 키 값입니다.",
                        Data       = null
                    };

                    Program.Logger.LogInformation("<" + clientInfo + "> 급식 메뉴 요청: 결과 - " + error.ResultCode + " (" + error.ResultMsg + ")");
                    return(error);
                }

                if (Program.LunchMenu == null)
                {
                    var error = new LunchMenu
                    {
                        ResultCode = "003",
                        ResultMsg  = "데이터가 로드되지 않았습니다.\n잠시 후 다시 시도해 주시기 바랍니다.",
                        Data       = null
                    };

                    Program.Logger.LogInformation("<" + clientInfo + "> 급식 메뉴 요청: 결과 - " + error.ResultCode + " (" + error.ResultMsg + ")");
                    return(error);
                }

                Program.Logger.LogInformation("<" + clientInfo + "> 급식 메뉴 요청: 결과 - 000 (정상적으로 요청되었습니다.)");
                return(Program.LunchMenu);
            }
            catch (Exception e)
            {
                var error = new LunchMenu
                {
                    ResultCode = "999",
                    ResultMsg  = "알 수 없는 오류:\n" + e.Message,
                    Data       = null
                };
                Program.Logger.LogError("<" + clientInfo + "> 급식 메뉴 요청: 결과 - 999 (" + e.Message + ")");
                return(error);
            }
        }
        public void ReadAllData(string strSearchValue)
        {
            try
            {
                List <LunchOrder> items = new List <LunchOrder>();

                string url   = string.Format(@"https://saibugasinformations-dev.outsystemsenterprise.com/LunchOrder_Core/rest/LunchOrder/GetLunchOrders");
                string param = "?PersonName=" + strSearchValue;

                HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(url + param);

                WebReq.Method = "GET";

                HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();

                Console.WriteLine(WebResp.StatusCode);
                Console.WriteLine(WebResp.Server);

                string jsonString;
                using (Stream stream = WebResp.GetResponseStream())   //modified from your code since the using statement disposes the stream automatically when done
                {
                    StreamReader reader = new StreamReader(stream, System.Text.Encoding.UTF8);
                    jsonString = reader.ReadToEnd();
                }

                items = JsonConvert.DeserializeObject <List <LunchOrder> >(jsonString);

                List <LunchMenu> lunchMenu = GetLunchMenu();

                foreach (LunchOrder item in items)
                {
                    LunchMenu menu = lunchMenu.Find(x => x.Id == item.LunchMenuId);
                    item.LunchMenuName = menu.MenuName;
                }

                DataCount.Text = "Data Count : " + items.Count;

                OrderDataGrid.ItemsSource = items;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 9
0
        public static void Main(string[] args)
        {
            // 점심 메뉴 생성
            LunchMenu lunch = new LunchMenu();

            lunch.AddItem(0, new MenuItem(6000, "제육볶음"));
            lunch.AddItem(5, new MenuItem(7000, "불고기"));
            lunch.AddItem(3, new MenuItem(6500, "순두부 찌개"));

            // 저녁 메뉴 생성
            DinnerMenu dinner = new DinnerMenu();

            dinner.AddItem(new MenuItem(15000, "닭발"));
            dinner.AddItem(new MenuItem(7000, "황도"));
            dinner.AddItem(new MenuItem(12000, "오뎅탕"));

            PartTimer.AllPrintMenu(lunch.CreateIterator());

            PartTimer.AllPrintMenu(dinner.CreateIterator());
        }
Exemplo n.º 10
0
        private void CalculateAmount()
        {
            int lunchMenuId = 0;
            int quantity;

            if (ddlLunchMenu.SelectedValue != null && int.TryParse(ddlLunchMenu.SelectedValue.ToString(), out lunchMenuId))
            {
                lunchMenuId = int.Parse(ddlLunchMenu.SelectedValue.ToString());
            }

            if (ddlLunchMenu.SelectedValue != null && txtQuantity.Text != "" && int.TryParse(txtQuantity.Text, out quantity))
            {
                LunchMenu menu = listLunchMenu.Find(x => x.Id == lunchMenuId);
                quantity          = int.Parse(txtQuantity.Text);
                lblAmount.Content = "¥" + Math.Round(quantity * menu.Price, 2);
            }
            else
            {
                lblAmount.Content = "";
            }
        }
Exemplo n.º 11
0
        public LunchOrderDetail(LunchOrderManagement wndOrderMng, int passId)
        {
            InitializeComponent();

            this.wndOrderManagement = wndOrderMng;

            listLunchMenu                  = GetLunchMenu();
            ddlLunchMenu.ItemsSource       = listLunchMenu;
            ddlLunchMenu.DisplayMemberPath = "MenuName";
            ddlLunchMenu.SelectedValuePath = "Id";

            if (passId > 0)
            {
                Console.WriteLine(passId);

                lunchOrder = GetLunchOrderById(passId);

                if (lunchOrder != null)
                {
                    txtOrderId.Text            = lunchOrder.OrderId;
                    txtOrderPerson.Text        = lunchOrder.OrderPerson;
                    dtOrderDate.SelectedDate   = lunchOrder.OrderDate;
                    ddlLunchMenu.SelectedValue = lunchOrder.LunchMenuId;
                    txtQuantity.Text           = lunchOrder.Quantity.ToString();

                    LunchMenu menu = listLunchMenu.Find(x => x.Id == lunchOrder.LunchMenuId);
                    lblAmount.Content = "¥" + Math.Round(lunchOrder.Quantity * menu.Price, 2);

                    isNewOrder = false;
                }
                else
                {
                    this.Close();

                    MessageBox.Show("Lunch Order is not existed. Please check again.", "Read Data Failed");
                }
            }
        }
        public void ReadAllData(string strSearchValue)
        {
            try
            {
                HttpClient client = new HttpClient();

                client.BaseAddress = new Uri("https://saibugasinformations-dev.outsystemsenterprise.com/LunchOrder_Core/rest/LunchOrder/");

                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = client.GetAsync("GetLunchOrders?PersonName=" + strSearchValue).Result;

                if (response.IsSuccessStatusCode)
                {
                    var orders = response.Content.ReadAsAsync <IEnumerable <LunchOrder> >().Result;
                    OrderDataGrid.ItemsSource = orders;

                    List <LunchMenu> lunchMenu = GetLunchMenu();

                    foreach (LunchOrder order in orders)
                    {
                        LunchMenu menu = lunchMenu.Find(x => x.Id == order.LunchMenuId);
                        order.LunchMenuName = menu.MenuName;
                    }

                    DataCount.Text = "Data Count : " + orders.Count <LunchOrder>();
                }
                else
                {
                    MessageBox.Show("Error Code" + response.StatusCode + " : Message - " + response.ReasonPhrase);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 13
0
        private static LunchMenu GetLunchMenu()
        {
            try
            {
                string MLSV_YMD = "MLSV_YMD=" + DateTime.Now.ToString("yyyyMM") + "&"; // 급식 일자

                var json = new WebClient().DownloadString(
                    LUNCH_MENU_URL +
                    NEIS_API_KEY +
                    TYPE +
                    P_INDEX +
                    P_SIZE +
                    ATPT_OFCDC_SC_CODE +
                    SD_SCHUL_CODE +
                    MLSV_YMD);

                var lunchMenu = JObject.Parse(json)["mealServiceDietInfo"];

                var head = lunchMenu.First["head"];
                var row  = lunchMenu.Last["row"];

                var dataSize   = Convert.ToInt32(head.First["list_total_count"]);
                var resultCode = head.Last["RESULT"]["CODE"].ToString();
                var resultMsg  = head.Last["RESULT"]["MESSAGE"].ToString();

                if (resultCode == "INFO-000")
                {
                    var lunchMenuData = new LunchMenu
                    {
                        Data = new Dictionary <string, List <string> >()
                    };

                    for (int i = 0; i < dataSize; i++)
                    {
                        var data     = row[i];
                        var date     = data["MLSV_YMD"].ToString();                                   // 날짜 문자열 형식
                        var tmpMenus = new List <string>(data["DDISH_NM"].ToString().Split("<br/>")); // <br/>을 기준으로 잘라 임시 리스트에 저장
                        var menus    = new List <string>();                                           // 급식 메뉴 리스트 생성

                        // 메뉴에 있는 숫자(알레르기 표시) 제거
                        foreach (var tmp in tmpMenus)
                        {
                            var regex = new Regex(@"[0-9]"); // 정규식: 숫자 포함
                            var menu  = tmp;

                            for (var j = 0; j < tmp.Length; j++)
                            {
                                // 메뉴에 숫자가 포함되어 있을 때
                                if (regex.IsMatch(tmp[j].ToString()))
                                {
                                    // 그 뒤에 문자 모두 제거
                                    menu = tmp.Substring(0, tmp.IndexOf(tmp[j]));
                                    break;
                                }
                            }
                            menus.Add(menu); // 리스트에 추가
                        }

                        lunchMenuData.Data.Add(date, menus); // 급식 메뉴 데이터에 추가
                    }

                    Logger.LogInformation("<Server> 급식 메뉴 가져오기: 성공");
                    return(lunchMenuData);
                }
                else
                {
                    Logger.LogInformation("<Server> 급식 메뉴 가져오기: 실패 - " + resultCode + " (" + resultMsg + ")");
                }
            }
            catch (Exception e)
            {
                Logger.LogError("<Server> 급식 메뉴 가져오기: 오류 (" + e.Message + ")");
            }
            return(null);
        }
Exemplo n.º 14
0
 public MenuItemDTO LunchMenu_get(string key) => LunchMenu.FirstOrDefault(i => i.Id.ToString() == key);