Ejemplo n.º 1
0
        /// <summary>
        /// downloads the logo of the team if its not already on users computer
        /// </summary>
        /// <param name="urlOfLogo"></param>
        /// <returns></returns>
        public static string getLogoOfTeam(TeamLogo logo, Guid teamId)
        {
            try
            {
                DirectoryInfo dir = new DirectoryInfo(ScoreboardConfig.SAVE_LOGOS_FOLDER);
                if (!dir.Exists)
                    dir.Create();

                string fileLocation = logo.ImageUrl;
                string fileName = Path.GetFileName(fileLocation);

                FileInfo file = new FileInfo(ScoreboardConfig.SAVE_LOGOS_FOLDER + fileName);
                if (!file.Exists)
                {
                    WebClient client = new WebClient();
                    client.DownloadFile(logo.ImageUrl, ScoreboardConfig.SAVE_LOGOS_FOLDER + fileName);
                    waitOnDownload(client);
                }

                return ScoreboardConfig.SAVE_LOGOS_FOLDER + fileName;
            }
            catch (Exception exception)
            {
                ErrorViewModel.Save(exception, exception.GetType(), null, null, null, Logger.Instance.getLoggedMessages());
            }
            return string.Empty;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// gets all the logos in the DB.
        /// </summary>
        /// <returns></returns>
        public List<RDN.Portable.Classes.Team.TeamLogo> GetAllLogos(TeamDisplay team)
        {
            try
            {
                if (team.LeagueLogos == null || team.LeagueLogos.Count == 0)
                {
                    var dc = new ManagementContext();
                    if (team.ScoreboardLogos == null || team.ScoreboardLogos.Count == 0)
                        team.ScoreboardLogos = GetAllScoreboardLogos(team);

                    var leagues = dc.Leagues.Where(x => x.Logo != null).AsParallel().ToList();
                    foreach (var league in leagues)
                    {
                        RDN.Portable.Classes.Team.TeamLogo logo = new RDN.Portable.Classes.Team.TeamLogo();
                        logo.ImageUrl = league.Logo.ImageUrl;
                        logo.TeamName = league.Name;
                        logo.TeamLogoId = league.Logo.LeaguePhotoId;
                        team.LeagueLogos.Add(logo);
                    }
                    team.LeagueLogos = team.LeagueLogos.OrderBy(x => x.TeamName).ToList();
                }
                return team.LeagueLogos;
            }
            catch (Exception e)
            {
                Library.Classes.Error.ErrorDatabaseManager.AddException(e, e.GetType(), ErrorGroupEnum.Database);
            }
            return null;
        }
Ejemplo n.º 3
0
 private void GetLogosFromDirectory()
 {try{
     instance.DirectoryLogos.Clear();
     DirectoryInfo dir = new DirectoryInfo(ScoreboardConfig.SAVE_LOGOS_FOLDER);
     if (dir.Exists)
     {
         var files = dir.GetFiles();
         int fileCount = files.Count();
         for (int i = 0; i < fileCount; i++)
         {
             try
             {
                 if (files[i].ToString().Contains(".jpg") || files[i].ToString().Contains(".png"))
                 {
                     TeamLogo logo = new TeamLogo();
                     logo.SaveLocation = ScoreboardConfig.SAVE_LOGOS_FOLDER + files[i].ToString();
                     logo.ImageUrl = ScoreboardConfig.SAVE_LOGOS_FOLDER + files[i].ToString();
                     instance.DirectoryLogos.Add(logo);
                 }
             }
             catch (Exception exception)
             {
                 ErrorViewModel.Save(exception, exception.GetType());
             }
         }
     }
 }
 catch (Exception exception)
 {
     ErrorViewModel.Save(exception, exception.GetType());
 }
 }
        private void uploadFileUpload_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string filename = uploadFileTextBox.Text;

                if (!String.IsNullOrEmpty(filename))
                {

                    string destinationFilename = System.IO.Path.Combine(ScoreboardConfig.SAVE_LOGOS_FOLDER, Guid.NewGuid().ToString().Replace("-", "") + System.IO.Path.GetExtension(filename));

                    DirectoryInfo dir = new DirectoryInfo(ScoreboardConfig.SAVE_LOGOS_FOLDER);
                    if (!dir.Exists)
                        dir.Create();

                    File.Copy(filename, destinationFilename, true);
                    TeamLogo logo = new TeamLogo();
                    logo.ImageUrl = destinationFilename;
                    logo.SaveLocation = destinationFilename;
                    logo.NewlyUploaded = true;
                    LogoViewModel.Instance.DirectoryLogos.Insert(0, logo);
                    Logos.Insert(0, logo);
                    uploadFileTextBox.Text = "";
                }
                //TODO:upload logo to RDNation if team name is entered..
            }
            catch (Exception exception)
            {
                ErrorViewModel.Save(exception, exception.GetType());
            }
        }