public void setEmgEvent(List <Event> EventList)
        {
            pso2Event.Clear();

            foreach (Event evn in EventList)
            {
                Event tmp;

                if (evn is emgQuest)
                {
                    emgQuest emgTmp = evn as emgQuest;
                    tmp = new emgQuest(emgTmp.eventTime, emgTmp.eventName, emgTmp.live, emgTmp.liveEnable);
                    pso2Event.Add(tmp);
                }
                else
                {
                    if (evn is casino)
                    {
                        //casino cas = evn as casino;
                        tmp = new casino(evn.eventTime);
                        pso2Event.Add(tmp);
                    }
                    else
                    {
                        //エラー
                        System.Console.WriteLine("なにかがおかしい");
                    }
                }
            }

            //pso2Event.Sort((a, b) => (a.eventTime - b.eventTime).Seconds);
            setNextEmg();
            calcNextNofity();
        }
        public List <Event> getTodayEmg()    //今日の緊急クエスト一覧を取得
        {
            DateTime dt     = DateTime.Now;
            TimeSpan OneDay = new TimeSpan(24, 0, 0);

            DateTime toDay00 = new DateTime(dt.Year, dt.Month, dt.Day, 0, 0, 0);
            DateTime toDay01 = new DateTime(dt.Year, dt.Month, dt.Day, 0, 0, 0) + OneDay;

            List <Event> output = new List <Event>();

            foreach (Event ev in pso2Event)
            {
                if (DateTime.Compare(ev.eventTime, toDay00) >= 0 && DateTime.Compare(ev.eventTime, toDay01) < 0)
                {
                    if (ev is emgQuest)
                    {
                        emgQuest tmp = (emgQuest)ev;
                        output.Add(new emgQuest(tmp.eventTime, tmp.eventName, tmp.live, tmp.liveEnable));
                    }

                    if (ev is casino)
                    {
                        casino tmp = (casino)ev;
                        output.Add(new casino(tmp.eventTime));
                    }
                }
            }

            return(output);
        }
Esempio n. 3
0
        public override void reloadPSO2Event()
        {
            //取得する緊急クエストの日数を計算
            DateTime dt = DateTime.Now;

            int getDays = 7 - ((int)dt.DayOfWeek + 4) % 7;                            //この先の緊急を取得する日数

            if (getDays == 7)                                                         //水曜日の時
            {
                DateTime dt1630 = new DateTime(dt.Year, dt.Month, dt.Day, 17, 00, 0); //今日の17:00
                if (DateTime.Compare(dt, dt1630) <= 0)
                {
                    getDays = 0;
                }
            }

            //バッファの初期化など
            if (base.pso2EventBuffer.Count != 0)
            {
                base.pso2EventBuffer.Clear();
            }

            //緊急クエスト取得成功・失敗の結果
            bool getOK = true;

            //緊急クエストの取得
            for (int i = 0; i <= getDays; i++)
            {
                DateTime getEmgTime = dt + new TimeSpan(i, 0, 0, 0);

                //JSONを生成
                sendjson_eventgetter jsonData = new sendjson_eventgetter();
                jsonData.EventDate = getEmgTime.ToString("yyyyMMdd");
                string data = JsonConvert.SerializeObject(jsonData, Formatting.Indented);

                //HTTPによる取得
                StringContent sc = new StringContent(data, encode, "application/json");

                Task <string> resultHTTP;
                try
                {
                    resultHTTP = AsyncHttpPOST(sc);
                    resultHTTP.Wait();
                }
                catch (System.NullReferenceException)
                {
                    break;
                }

                //結果をstringにする

                /*
                 * Task<string> resultStrTask;
                 * try
                 * {
                 *  resultStrTask = resultHTTP.Result.Content.ReadAsStringAsync();
                 * }
                 * catch(System.NullReferenceException)    //緊急クエストの取得に失敗
                 * {
                 *  break;
                 * }
                 * resultStrTask.Wait();
                 */
                string result = resultHTTP.Result;

                //Jsonをパース
                List <JsonPSO2Event> Jsonresult = new List <JsonPSO2Event>();
                Jsonresult = JsonConvert.DeserializeObject <List <JsonPSO2Event> >(result);

                //バッファに格納
                bool   live     = false;
                string livename = "";

                foreach (JsonPSO2Event ev in Jsonresult)
                {
                    DateTime emgDT = new DateTime(DateTime.Now.Year, ev.Month, ev.Date, ev.Hour, ev.Minute, 0);

                    if (ev.EventType == "緊急")
                    {
                        emgQuest emg;
                        if (live == true)
                        {
                            emg      = new emgQuest(emgDT, ev.EventName, livename);
                            live     = false;
                            livename = "";
                        }
                        else
                        {
                            emg = new emgQuest(emgDT, ev.EventName);
                        }
                        base.pso2EventBuffer.Add(emg);
                    }

                    if (ev.EventType == "ライブ")
                    {
                        live     = true;
                        livename = ev.EventName;
                    }

                    if (ev.EventType == "カジノイベント")
                    {
                        casino cas = new casino(emgDT);
                        base.pso2EventBuffer.Add(cas);
                    }
                }
            }

            if (getOK == true)
            {
                logOutput.writeLog("緊急クエストの情報を取得しました。緊急クエストは以下の通りです。\n" + outputBufferEmg());
            }
        }