示例#1
0
        private static async Task RequestTodayEventsAsync()
        {
            requestTodayData = new RequestData("true", "false", "true");
            await requestTodayData.CheckAuthToken();

            if (isFirstTodayData)
            {
                todayEventList = await requestTodayData.GetDataAsync();

                if (todayEventList == null)
                {
                    return;
                }

                await UploadData(requestTodayData, TODAY_URL);

                isFirstTodayData = false;
                return;
            }

            //new check diff
            List <Event> oldData = todayEventList.ToList();
            List <Event> newData = await requestTodayData.GetDataAsync();

            if (newData == null)
            {
                return;
            }

            todayEventList.Clear();
            todayEventList = newData.ToList();

            if (oldData.Count != newData.Count)
            {
                todayEventList = newData.ToList();
                await UploadData(requestTodayData, TODAY_URL);

                return;
            }

            for (int eventIdx = 0; eventIdx < newData.Count; eventIdx++)
            {
                if (oldData[eventIdx].Id == newData[eventIdx].Id)
                {
                    if (!oldData[eventIdx].StartTime.Equals(newData[eventIdx].StartTime))
                    {
                        todayEventList = newData.ToList();
                        await UploadData(requestTodayData, TODAY_URL);

                        break;
                    }
                }
            }
        }
示例#2
0
        public static async void StartAsync()
        {
            requestProgramData = new RequestData("true", "false", "false");
            await requestProgramData.GetDataAsync();

            await requestProgramData.CheckAuthToken();

            await UploadData(requestProgramData, PROGRAM_URL);

            while (true)
            {
                //WOW ! !! the comment to check commit
                await RequestLiveEventsAsync();
                await RequestTodayEventsAsync();

                await Task.Delay(3000);
            }
        }
示例#3
0
        private static async Task RequestLiveEventsAsync()
        {
            requestLiveData = new RequestData("false", "true", "false");
            await requestLiveData.CheckAuthToken();

            //Upload first data
            if (isFirstLiveData)
            {
                liveEventList = await requestLiveData.GetDataAsync();

                if (liveEventList == null)
                {
                    return;
                }

                await UploadData(requestLiveData, LIVE_URL);

                isFirstLiveData = false;
                return;
            }

            //new check diff
            List <Event> oldData = liveEventList.ToList();
            List <Event> newData = await requestLiveData.GetDataAsync();

            if (newData == null)
            {
                return;
            }

            liveEventList.Clear();
            liveEventList = newData.ToList();

            //check for finished events
            await CheckEventsResult(oldData, newData);

            if (oldData.Count != newData.Count)
            {
                liveEventList = newData.ToList();
                await UploadData(requestLiveData, LIVE_URL);

                return;
            }

            for (int eventIdx = 0; eventIdx < newData.Count; eventIdx++)
            {
                if (oldData[eventIdx].Id == newData[eventIdx].Id)
                {
                    if (!oldData[eventIdx].HomeGoals.Equals(newData[eventIdx].HomeGoals) ||
                        !oldData[eventIdx].AwayGoals.Equals(newData[eventIdx].AwayGoals) ||
                        !oldData[eventIdx].HomeCorners.Equals(newData[eventIdx].HomeCorners) ||
                        !oldData[eventIdx].AwayCorners.Equals(newData[eventIdx].AwayCorners)
                        )
                    {
                        liveEventList = newData.ToList();
                        await UploadData(requestLiveData, LIVE_URL);

                        break;
                    }
                }
            }
        }