Exemplo n.º 1
0
        private bool myInfoSet;         // 나의 정보가 설정되어있는지 확인
        #endregion

        #region 생성자
        public TabbedHomePage()
        {
            #region 변수 초기화
            instance = this;

            task = false;
            view = "notice";
            hanyangLogoRotate = false;
            myInfoSet         = false;
            #endregion

            InitializeComponent();

            MyInfoUpdate();
        }
Exemplo n.º 2
0
        public async Task GetArticle(bool refresh = false)
        {
            try
            {
                if (Connectivity.NetworkAccess == NetworkAccess.Internet)
                {
                    try
                    {
                        if (dataInfo != null && !refresh)
                        {
                            var serverDataInfo = GetDataInfo();

                            if (serverDataInfo != null)
                            {
                                serverDataInfo.Remove("Timetable-" + App.GetClassName());
                                serverDataInfo.Remove("LunchMenu");
                                serverDataInfo.Remove("SchoolSchedule");
                                serverDataInfo.Add("Timetable-" + App.GetClassName(), dataInfo["Timetable-" + App.GetClassName()]);
                                serverDataInfo.Add("LunchMenu", dataInfo["LunchMenu"]);
                                serverDataInfo.Add("SchoolSchedule", dataInfo["SchoolSchedule"]);

                                var schoolNoticeChange     = false;
                                var schoolNewsletterChange = false;
                                var appNoticeChange        = false;

                                if (dataInfo["SchoolNotice"].ContainsKey("Size") && serverDataInfo["SchoolNotice"].ContainsKey("Size") &&
                                    dataInfo["SchoolNotice"]["Size"] != serverDataInfo["SchoolNotice"]["Size"])
                                {
                                    schoolNoticeChange = true;
                                }

                                if (dataInfo["SchoolNewsletter"].ContainsKey("Size") && serverDataInfo["SchoolNewsletter"].ContainsKey("Size") &&
                                    dataInfo["SchoolNewsletter"]["Size"] != serverDataInfo["SchoolNewsletter"]["Size"])
                                {
                                    schoolNewsletterChange = true;
                                }

                                if (dataInfo["AppNotice"].ContainsKey("Size") && serverDataInfo["AppNotice"].ContainsKey("Size") &&
                                    dataInfo["AppNotice"]["Size"] != serverDataInfo["AppNotice"]["Size"])
                                {
                                    appNoticeChange = true;
                                }

                                if (schoolNoticeChange || schoolNewsletterChange || appNoticeChange)
                                {
                                    var result = await DisplayAlert("최신 게시글 발견",
                                                                    "최신 게시글을 발견하였습니다.\n" +
                                                                    (schoolNoticeChange ? "\n- 공지사항 : " + serverDataInfo["SchoolNotice"]["Size"] : "") +
                                                                    (schoolNewsletterChange ? "\n- 가정통신문 : " + serverDataInfo["SchoolNewsletter"]["Size"] : "") +
                                                                    (appNoticeChange ? "\n- 앱 공지사항 : " + serverDataInfo["AppNotice"]["Size"] : ""), "다운로드", "취소");

                                    if (!result)
                                    {
                                        return;
                                    }

                                    var schoolNoticeT     = "";
                                    var schoolNewsletterT = "";
                                    var appNoticeT        = "";

                                    if (schoolNoticeChange)
                                    {
                                        schoolNoticeT = GetSchoolNotice();
                                    }

                                    if (schoolNewsletterChange)
                                    {
                                        schoolNewsletterT = GetSchoolNewsletter();
                                    }

                                    if (appNoticeChange)
                                    {
                                        appNoticeT = GetAppNotice();
                                    }

                                    if (schoolNoticeT != "" || schoolNewsletterT != "" || appNoticeT != "")
                                    {
                                        // 파일로 저장
                                        var controller = new JsonController("data_info");
                                        dataInfo = serverDataInfo;
                                        await controller.Write(JObject.Parse(JsonConvert.SerializeObject(serverDataInfo)));
                                    }

                                    #region 공지사항 초기화
                                    if (schoolNoticeT != "")
                                    {
                                        TabbedHomePage.GetInstance().InitSchoolNotice();

                                        // 파일로 저장
                                        var controller = new JsonController("school_notice");
                                        await controller.Write(JObject.Parse(schoolNoticeT));
                                    }
                                    #endregion

                                    #region 가정통신문 초기화
                                    if (schoolNewsletterT != "")
                                    {
                                        TabbedHomePage.GetInstance().InitSchoolNewsletter();

                                        // 파일로 저장
                                        var controller = new JsonController("school_newsletter");
                                        await controller.Write(JObject.Parse(schoolNewsletterT));
                                    }
                                    #endregion

                                    #region 앱 공지사항 초기화
                                    if (appNoticeT != "")
                                    {
                                        TabbedHomePage.GetInstance().InitAppNotice();

                                        // 파일로 저장
                                        var controller = new JsonController("app_notice");
                                        await controller.Write(JObject.Parse(appNoticeT));
                                    }
                                    #endregion
                                }
                            }

                            return;
                        }

                        var dataInfoT        = GetDataInfo();
                        var schoolNotice     = "";
                        var schoolNewsletter = "";
                        var appNotice        = "";

                        if (refresh || App.SchoolNotice == null)
                        {
                            schoolNotice = GetSchoolNotice();
                        }

                        if (refresh || App.SchoolNewsletter == null)
                        {
                            schoolNewsletter = GetSchoolNewsletter();
                        }

                        if (refresh || App.AppNotice == null)
                        {
                            appNotice = GetAppNotice();
                        }

                        if (dataInfoT != null)
                        {
                            var controller = new JsonController("data_info");
                            await controller.Write(JObject.Parse(JsonConvert.SerializeObject(dataInfoT)));
                        }

                        if (schoolNotice != "")
                        {
                            // 공지사항 초기화
                            TabbedHomePage.GetInstance().InitSchoolNotice();

                            // 파일로 저장
                            var controller = new JsonController("school_notice");
                            await controller.Write(JObject.Parse(schoolNotice));
                        }

                        if (schoolNewsletter != "")
                        {
                            // 가정통신문 초기화
                            TabbedHomePage.GetInstance().InitSchoolNewsletter();

                            // 파일로 저장
                            var controller = new JsonController("school_newsletter");
                            await controller.Write(JObject.Parse(schoolNewsletter));
                        }

                        if (appNotice != "")
                        {
                            // 앱 공지사항 초기화
                            TabbedHomePage.GetInstance().InitAppNotice();

                            // 파일로 저장
                            var controller = new JsonController("app_notice");
                            await controller.Write(JObject.Parse(appNotice));
                        }
                    }
                    catch (Exception e)
                    {
                        await ErrorAlert("게시글 가져오기", "게시글을 가져오는 도중 오류가 발생했습니다.\n" + e.Message);
                    }
                }
                else
                {
                    DependencyService.Get <IToastMessage>().Longtime("인터넷에 연결되어 있지 않아 최신 정보를 확인할 수 없습니다.");
                }
            }
            catch (Exception e)
            {
                await ErrorAlert("게시글 가져오기 (인터넷 상태)", "게시글을 가져오는 도중 오류가 발생했습니다.\n" + e.Message);
            }
        }
Exemplo n.º 3
0
        public async void InitUI()
        {
            try
            {
                string timetableJson = null;

                if (App.Class != 0)
                {
                    var timetableCtrl = new JsonController("timetable-" + App.GetClassName());
                    timetableJson = timetableCtrl.ReadString();
                }

                var lunchMenuCtrl = new JsonController("lunch_menu");
                var lunchMenuJson = lunchMenuCtrl.ReadString();

                var schoolScheduleCtrl = new JsonController("school_schedule");
                var schoolScheduleJson = schoolScheduleCtrl.ReadString();

                var schoolNoticeCtrl = new JsonController("school_notice");
                var schoolNoticeJson = schoolNoticeCtrl.ReadString();

                var schoolNewsletterCtrl = new JsonController("school_newsletter");
                var schoolNewsletterJson = schoolNewsletterCtrl.ReadString();

                var appNoticeCtrl = new JsonController("app_notice");
                var appNoticeJson = appNoticeCtrl.ReadString();

                #region 시간표 파일 읽기
                if (timetableJson != null)
                {
                    App.Timetable = JsonConvert.DeserializeObject <Timetable>(timetableJson);

                    TabbedSchedulePage.GetInstance().task = true;
                    _ = TabbedSchedulePage.GetInstance().ViewScheduleAnimation();
                }
                #endregion

                #region  식 메뉴 파일 읽기
                if (lunchMenuJson != null)
                {
                    App.LunchMenu = JsonConvert.DeserializeObject <LunchMenu>(lunchMenuJson);

                    TabbedSchedulePage.GetInstance().InitLunchMenu();
                }
                #endregion

                #region 학사 일정 파일 읽기
                if (schoolScheduleJson != null)
                {
                    App.SchoolSchedule = JsonConvert.DeserializeObject <Dictionary <string, SchoolSchedule> >(schoolScheduleJson);

                    TabbedSchedulePage.GetInstance().InitSchoolSchedule();
                }
                #endregion

                #region 학교 공지사항 파일 읽기
                if (schoolNoticeJson != null)
                {
                    App.SchoolNotice = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, string> > >(schoolNoticeJson);

                    TabbedHomePage.GetInstance().InitSchoolNotice();
                }
                #endregion

                #region 가정통신문 파일 읽기
                if (schoolNewsletterJson != null)
                {
                    App.SchoolNewsletter = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, string> > >(schoolNewsletterJson);

                    TabbedHomePage.GetInstance().InitSchoolNewsletter();
                }
                #endregion

                #region 앱 공지사항 파일 읽기
                if (appNoticeJson != null)
                {
                    App.AppNotice = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, string> > >(appNoticeJson);

                    TabbedHomePage.GetInstance().InitAppNotice();
                }
                #endregion
            }
            catch (Exception e)
            {
                await ErrorAlert("UI 초기화", "UI를 초기화하는 도중 오류가 발생했습니다.\n" + e.Message);
            }
        }