Ejemplo n.º 1
0
        private async void ModifyTimes(int id)

        {
            var distances = StoredTimes.Select(e => e.Distance).Distinct();

            foreach (var distance in distances)

            {
                var reps = StoredTimes.Where(e => e.Distance == distance).Select(r => r.Repetitions).Max();
                ShowList.Add(new ListofRaces()
                {
                    DistanceName = distance, Reps = reps, EventId = id
                });
            }

            //borrar null EventId Times
            await TimeServices.DeleteNullEventIdTimes();

            //correr SetTimes por cada linea de Showlist.
            foreach (var race in ShowList)

            {
                ReSetTimes(race, race.Reps);
            }

            IsBusy = false;
        }
Ejemplo n.º 2
0
        private async void SetTimes(int obj)

        {
            var time = new Time();

            for (int j = 0; j < obj; j++)
            {
                for (int i = 0; i < SelectedRunners.Count; i++)
                {
                    time.Times       = new TimeSpan(0, 0, 0);
                    time.Distance    = listofraces.DistanceName;
                    time.Repetitions = j + 1;
                    await TimeServices.AddTime(time);

                    time.Runner = SelectedRunners[i];
                    time.Event  = NewEvent;
                    await TimeServices.AddEventToTime(time);
                }
            }
            ShowList.Add(new ListofRaces()
            {
                DistanceName = listofraces.DistanceName, Reps = listofraces.Reps, EventId = NewEvent.Id
            });
            listofraces.Reps         = 1;
            listofraces.DistanceName = null;
        }
Ejemplo n.º 3
0
        private void CompareUserListHDDDelete()
        {
            ShowList showList    = UserDataMgr.GetThe().ShowList;
            ShowList newShowList = new ShowList();

            bool fileExistFlag  = false;
            bool showDeleteFlag = false;

            foreach (Show show in showList)
            {
                if (DownloadStatus.Completed.Equals(show.DownloadStatus))
                {
                    try
                    {
                        fileExistFlag = DriveInfo.CheckFileExistOnHDD(show.DataFileName.ToString());
                    }
                    catch (Exception e)
                    {
                        Logger.LogError(this, "CompareUserListHDDDelete", e);
                    }

                    if (!fileExistFlag)
                    {
                        //Delete File from the user list and download list
                        Logger.LogInfo(this, "CompareUserListHDDDelete", "Delete File from the userlist and downloadlist");
                        Session.GetThe().ReleaseShow(show.RentedShowID);
                        showDeleteFlag = true;
                    }
                    else
                    {
                        newShowList.Add(show);
                    }
                }
                else
                {
                    newShowList.Add(show);
                }
            }

            //if any show is deleted from showlist then Write new User.XML
            if (showDeleteFlag)
            {
                UserDataMgr.GetThe().SaveShowList(newShowList);
            }
        }
Ejemplo n.º 4
0
        //Create Show from DownloadShow
        private void AddDownloadShowToList(ShowList showList, DownloadShow downloadShow)
        {
            Show show = Show.NewInstance(downloadShow.RentedShowID);

            show.ShowURL        = downloadShow.ShowURL;
            show.DataFileName   = new TString(determineNewShowName(showList, downloadShow));
            show.DownloadStatus = DownloadStatus.NotStarted;

            showList.Add(show);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mode"></param>
        public void Serach(int mode, string key)
        {
            ShowList.Clear();
            PageList.Clear();

            //启动动画
            myProgress.Visibility = Visibility.Visible;
            myProgress.Start();

            switch (Auth.Type)
            {
            case BTType.BT蚂蚁:
                new BTMY().Serach(mode, key, new Action <List <BT>, List <Models.Page>, string>((list, pagelist, info) =>
                {
                    if (list != null)
                    {
                        Dispatcher.Invoke(new Action(() =>
                        {
                            for (int i = 0; i < list.Count; i++)
                            {
                                ShowList.Add(list[i]);
                            }
                        }));
                        Dispatcher.Invoke(new Action(() =>
                        {
                            for (int i = 0; i < pagelist.Count; i++)
                            {
                                PageList.Add(new Models.Page()
                                {
                                    Name = pagelist[i].Name, Path = pagelist[i].Path, Type = BTType.BT蚂蚁
                                });
                            }
                        }));
                    }
                    Dispatcher.Invoke(new Action(() =>
                    {
                        myProgress.Stop();
                        myProgress.Visibility = Visibility.Collapsed;
                    }));
                }));
                break;

            default:
                break;
            }
        }
Ejemplo n.º 6
0
        private void CompareUserListDelete(DownloadShowList downloadShowList)
        {
            //Delete Show From UserList
            ShowList showList    = UserDataMgr.GetThe().ShowList;
            ShowList newShowList = new ShowList();

            bool bRentedShowIDFound_Flag = false;
            bool bShowDeleted            = false;

            foreach (Show show in showList)
            {
                bRentedShowIDFound_Flag = downloadShowList.ContainsByRentedShowID(show.RentedShowID);
                if (!bRentedShowIDFound_Flag)
                {
                    //Delete Show From User List
                    Logger.LogInfo(this, "CompareUserListDelete", "Delete Show From User List and HDD");
                    try
                    {
                        DriveInfo.DeleteShowFromHDD(show.DataFileName.ToString());
                        bShowDeleted = true;
                    }
                    catch (Exception e)
                    {
                        Logger.LogError(this, "CompareUserListDelete", e);
                    }
                }
                else
                {
                    newShowList.Add(show);
                }
            }

            // Write user XML if any show is deleted
            if (bShowDeleted)
            {
                UserDataMgr.GetThe().SaveShowList(newShowList);
            }
        }