示例#1
0
 public void LoadFromWWW()
 {
     try
     {
         string content = "";
         LOADING = true;
         try
         {
             string today_file = string.Format(Internal.WORKPATH + Internal.BAR + "xml" + Internal.BAR + "{0}.nteam", RMHTML.GetDate());
             string last_file = string.Format(Internal.WORKPATH + Internal.BAR + "xml" + Internal.BAR + "last.nteam", RMHTML.GetDate());
             content = Internal.Main.DownloadNazionale(!System.IO.File.Exists(last_file));
             content = RMHTML.GetBody(content);
             if (content == "") if (System.IO.File.Exists(last_file))
                     content = System.IO.File.ReadAllText(last_file);
             if (content != "")
             {
                 if (System.IO.File.Exists(last_file))
                 {
                     string last = System.IO.File.ReadAllText(last_file);
                     if (content != last)
                     {
                         System.IO.File.WriteAllText(today_file, content, Encoding.UTF8);
                         System.IO.File.WriteAllText(last_file, content, Encoding.UTF8);
                     }
                 }
                 else
                 {
                     System.IO.File.WriteAllText(today_file, content, Encoding.UTF8);
                     System.IO.File.WriteAllText(last_file, content, Encoding.UTF8);
                 }
                 string[] players = content.Split(new string[1] { @"href='player.php?" }, StringSplitOptions.RemoveEmptyEntries);
                 System.Collections.ArrayList Giocatori = new System.Collections.ArrayList();
                 int totale_eta = 0;
                 foreach (string g in players)
                 {
                     if (g.Contains("id_player=") && g.Contains("class='squadskill'"))
                     {
                         RMO.Class.Player p = new RMO.Class.Player();
                         p.ID = (int)RMO.RMHTML.GetNumero(g, @"id_player=", @"'>");
                         string nome = RMO.RMHTML.U(RMO.RMHTML.GetStringa(g, @"id_player=" + p.ID.ToString() + "'>", @"</a>"));
                         string[] nome1 = nome.Split(' ');
                         p.NOME = nome1[0];
                         p.COGNOME = nome.Replace(nome1[0] + " ", "");
                         p.STATO = "Nazionale";
                         //p.club_id = (int)RMO.RMHTML.GetNumero(g, @"club.php?id_club=", "'>");
                         //p.club_name = RMO.RMHTML.U(RMO.RMHTML.GetStringa(g, @"id_club=" + p.club_id + "'>", @"</a>"));
                         p.ALTEZZA = (int)RMO.RMHTML.GetNumero(g, @"altezza :", @"<br>");
                         p.ETA = (int)RMO.RMHTML.GetNumero(g, @"</a>)&nbsp;&nbsp;", @"anni");
                         if (p.ETA == 0) p.ETA = (int)RMO.RMHTML.GetNumero(g, @"</a></b><br>", @"anni");
                         p.SALARIO = 0;
                         p.PESO = RMO.RMHTML.GetNumero(g, @"peso :", @"<");
                         p.ESPERIENZA = (int)RMO.RMHTML.GetNumero(g, @"esperienza : <img src = '" + skillurl, @".gif");
                         p.RESISTENZA = (int)RMO.RMHTML.GetNumero(g, @"resistenza : <img src = '" + skillurl, @".gif");
                         p.FORZA = (int)RMO.RMHTML.GetNumero(g, @"forza : <img src = '" + skillurl, @".gif");
                         p.PLACCAGGI = (int)RMO.RMHTML.GetNumero(g, @"placcaggi : <img src = '" + skillurl, @".gif");
                         p.VELOCITA = (int)RMO.RMHTML.GetNumero(g, @"velocità : <img src = '" + skillurl, @".gif");
                         p.PASSAGGI = (int)RMO.RMHTML.GetNumero(g, @"passaggi : <img src = '" + skillurl, @".gif");
                         p.RICEZIONE = (int)RMO.RMHTML.GetNumero(g, @"ricezione : <img src = '" + skillurl, @".gif");
                         p.CALCI = (int)RMO.RMHTML.GetNumero(g, @"calci : <img src = '" + skillurl, @".gif");
                         Giocatori.Add(p);
                         totale_eta += p.ETA;
                     }
                 }
                 Internal.Main.StatusBar.Value = 0;
                 Internal.Main.StatusBar.Maximum = Giocatori.Count;
                 Control.Player.MAXRESET();
                 panelPlayers.SuspendLayout();
                 panelPlayers.Controls.Clear();
                 int y = 0; int k = 0;
                 foreach (RMO.Class.Player pl in Giocatori)
                 {
                     Control.Player c = new RMO.Control.Player();
                     c.LoadData(pl);
                     c.ShowFACVT();
                     panelPlayers.Controls.Add(c);
                     if (Properties.Settings.Default.GrayLines)
                     {
                         if ((k++ % 2) == 0) c.BackColor = Properties.Settings.Default.LinesColor1;
                         else c.BackColor = Properties.Settings.Default.LinesColor2;
                     }
                     Internal.Main.StatusBar.Value++;
                 }
                 foreach (Control.Player p in panelPlayers.Controls)
                 {
                     p.SetSize();
                     p.Location = new Point(0, y);
                     y += p.Height;
                 }
                 InitHeader();
                 panelPlayers.ResumeLayout();
                 decimal media = Math.Truncate((decimal)(totale_eta * 10 / Giocatori.Count)) / 10;
                 lEta.Text = string.Format(T("Età media {0} anni"), media.ToString());
                 lTOTALE.Text = string.Format(T("{0} Giocatori"), Giocatori.Count.ToString());
             }
             else { labelLoading.Text = T("Sei sicuro di essere manager di una nazionale?"); }
         }
         catch (Exception ex) { My.Box.Errore("TabTeam::LoadFromDB()\r\n"+ex.Message); }
         Internal.Main.StatusBar.Value = 0;
         LOADING = (content == "");
     }
     catch (Exception ex) { My.Box.Errore("TabTeam::LoadFromDB()\r\n"+ex.Message); }
 }
示例#2
0
        public void LoadFromDB()
        {
            try
            {
                LOADING         = true;
                comboDa.Enabled = false;
                comboA.Enabled  = false;
                try
                {
                    if (RELOADDATA)
                    {
                        comboDa.Items.Clear();
                        comboA.Items.Clear();
                        comboDa.Items.AddRange(Internal.DB.GetDates());
                        comboA.Items.AddRange(Internal.DB.GetDates());
                        if (comboDa.Items.Count > 1)
                        {
                            comboDa.SelectedIndex = 1;
                        }
                        else if (comboDa.Items.Count == 1)
                        {
                            comboDa.SelectedIndex = 0;
                        }
                        if (comboA.Items.Count > 0)
                        {
                            comboA.SelectedIndex = 0;
                        }
                    }
                    if (comboDa.SelectedIndex < 0)
                    {
                        return;
                    }
                    if (comboA.SelectedIndex < 0)
                    {
                        return;
                    }
                    DataTable DT_NEW = Internal.DB.GetPlayers(comboA.Items[comboA.SelectedIndex].ToString());
                    string    da = comboDa.Items[comboDa.SelectedIndex].ToString();
                    int       y = 0; int j = 0;
                    Internal.Main.StatusBar.Value   = 0;
                    Internal.Main.StatusBar.Maximum = DT_NEW.Rows.Count * 2;
                    Control.Player[] list = new RMO.Control.Player[DT_NEW.Rows.Count];
                    foreach (DataRow dr in DT_NEW.Rows)
                    {
                        Control.Player p = new RMO.Control.Player();
                        p.LoadData(dr, da);
                        list[j] = p; j++;
                        switch (comboVT.SelectedIndex)
                        {
                        case 1: p.ShowFACVT(); break;

                        case 2: p.ShowFCDVT(); break;
                        }
                        Internal.Main.StatusBar.Value++;
                    }
                    int totale_stipendi = 0;
                    int totale_eta      = 0;
                    Array.Sort(list);
                    panelPlayers.SuspendLayout();
                    panelPlayers.Controls.Clear();
                    int k = 0;
                    foreach (Control.Player pl in list)
                    {
                        pl.SetSize();
                        totale_stipendi += pl.SALARIO;
                        totale_eta      += pl.ETA;
                        pl.Location      = new Point(0, y);
                        y += pl.Height;
                        panelPlayers.Controls.Add(pl);
                        if (Properties.Settings.Default.GrayLines)
                        {
                            if ((k++ % 2) == 0)
                            {
                                pl.BackColor = Properties.Settings.Default.LinesColor1;
                            }
                            else
                            {
                                pl.BackColor = Properties.Settings.Default.LinesColor2;
                            }
                        }
                        Internal.Main.StatusBar.Value++;
                    }
                    lStipendi.Text = string.Format(T("Totale stipendi: {0} €"), totale_stipendi.ToString());
                    decimal media = Math.Truncate((decimal)(totale_eta * 10 / list.Length)) / 10;
                    lEta.Text    = string.Format(T("Età media {0} anni"), media.ToString());
                    lTOTALE.Text = string.Format(T("{0} Giocatori"), list.Length.ToString());
                    InitHeader();
                    panelPlayers.ResumeLayout();
                }
                catch (Exception ex) { My.Box.Errore("TabTeam::LoadFromDB()\r\n" + ex.Message); }
                Internal.Main.StatusBar.Value = 0;
                comboDa.Enabled = true;
                comboA.Enabled  = true;
                LOADING         = false;
                CheckBlockedMarket();
            }
            catch (Exception ex) { My.Box.Errore("TabTeam::LoadFromDB()\r\n" + ex.Message); }
        }
示例#3
0
 public void LoadFromWWW()
 {
     try
     {
         string content = "";
         LOADING = true;
         try
         {
             string today_file = string.Format(Internal.WORKPATH + Internal.BAR + "xml" + Internal.BAR + "{0}.nteam", RMHTML.GetDate());
             string last_file  = string.Format(Internal.WORKPATH + Internal.BAR + "xml" + Internal.BAR + "last.nteam", RMHTML.GetDate());
             content = Internal.Main.DownloadNazionale(!System.IO.File.Exists(last_file));
             content = RMHTML.GetBody(content);
             if (content == "")
             {
                 if (System.IO.File.Exists(last_file))
                 {
                     content = System.IO.File.ReadAllText(last_file);
                 }
             }
             if (content != "")
             {
                 if (System.IO.File.Exists(last_file))
                 {
                     string last = System.IO.File.ReadAllText(last_file);
                     if (content != last)
                     {
                         System.IO.File.WriteAllText(today_file, content, Encoding.UTF8);
                         System.IO.File.WriteAllText(last_file, content, Encoding.UTF8);
                     }
                 }
                 else
                 {
                     System.IO.File.WriteAllText(today_file, content, Encoding.UTF8);
                     System.IO.File.WriteAllText(last_file, content, Encoding.UTF8);
                 }
                 string[] players = content.Split(new string[1] {
                     @"href='player.php?"
                 }, StringSplitOptions.RemoveEmptyEntries);
                 System.Collections.ArrayList Giocatori = new System.Collections.ArrayList();
                 int totale_eta = 0;
                 foreach (string g in players)
                 {
                     if (g.Contains("id_player=") && g.Contains("class='squadskill'"))
                     {
                         RMO.Class.Player p = new RMO.Class.Player();
                         p.ID = (int)RMO.RMHTML.GetNumero(g, @"id_player=", @"'>");
                         string   nome  = RMO.RMHTML.U(RMO.RMHTML.GetStringa(g, @"id_player=" + p.ID.ToString() + "'>", @"</a>"));
                         string[] nome1 = nome.Split(' ');
                         p.NOME    = nome1[0];
                         p.COGNOME = nome.Replace(nome1[0] + " ", "");
                         p.STATO   = "Nazionale";
                         //p.club_id = (int)RMO.RMHTML.GetNumero(g, @"club.php?id_club=", "'>");
                         //p.club_name = RMO.RMHTML.U(RMO.RMHTML.GetStringa(g, @"id_club=" + p.club_id + "'>", @"</a>"));
                         p.ALTEZZA = (int)RMO.RMHTML.GetNumero(g, @"altezza :", @"<br>");
                         p.ETA     = (int)RMO.RMHTML.GetNumero(g, @"</a>)&nbsp;&nbsp;", @"anni");
                         if (p.ETA == 0)
                         {
                             p.ETA = (int)RMO.RMHTML.GetNumero(g, @"</a></b><br>", @"anni");
                         }
                         p.SALARIO    = 0;
                         p.PESO       = RMO.RMHTML.GetNumero(g, @"peso :", @"<");
                         p.ESPERIENZA = (int)RMO.RMHTML.GetNumero(g, @"esperienza : <img src = '" + skillurl, @".gif");
                         p.RESISTENZA = (int)RMO.RMHTML.GetNumero(g, @"resistenza : <img src = '" + skillurl, @".gif");
                         p.FORZA      = (int)RMO.RMHTML.GetNumero(g, @"forza : <img src = '" + skillurl, @".gif");
                         p.PLACCAGGI  = (int)RMO.RMHTML.GetNumero(g, @"placcaggi : <img src = '" + skillurl, @".gif");
                         p.VELOCITA   = (int)RMO.RMHTML.GetNumero(g, @"velocità : <img src = '" + skillurl, @".gif");
                         p.PASSAGGI   = (int)RMO.RMHTML.GetNumero(g, @"passaggi : <img src = '" + skillurl, @".gif");
                         p.RICEZIONE  = (int)RMO.RMHTML.GetNumero(g, @"ricezione : <img src = '" + skillurl, @".gif");
                         p.CALCI      = (int)RMO.RMHTML.GetNumero(g, @"calci : <img src = '" + skillurl, @".gif");
                         Giocatori.Add(p);
                         totale_eta += p.ETA;
                     }
                 }
                 Internal.Main.StatusBar.Value   = 0;
                 Internal.Main.StatusBar.Maximum = Giocatori.Count;
                 Control.Player.MAXRESET();
                 panelPlayers.SuspendLayout();
                 panelPlayers.Controls.Clear();
                 int y = 0; int k = 0;
                 foreach (RMO.Class.Player pl in Giocatori)
                 {
                     Control.Player c = new RMO.Control.Player();
                     c.LoadData(pl);
                     c.ShowFACVT();
                     panelPlayers.Controls.Add(c);
                     if (Properties.Settings.Default.GrayLines)
                     {
                         if ((k++ % 2) == 0)
                         {
                             c.BackColor = Properties.Settings.Default.LinesColor1;
                         }
                         else
                         {
                             c.BackColor = Properties.Settings.Default.LinesColor2;
                         }
                     }
                     Internal.Main.StatusBar.Value++;
                 }
                 foreach (Control.Player p in panelPlayers.Controls)
                 {
                     p.SetSize();
                     p.Location = new Point(0, y);
                     y         += p.Height;
                 }
                 InitHeader();
                 panelPlayers.ResumeLayout();
                 decimal media = Math.Truncate((decimal)(totale_eta * 10 / Giocatori.Count)) / 10;
                 lEta.Text    = string.Format(T("Età media {0} anni"), media.ToString());
                 lTOTALE.Text = string.Format(T("{0} Giocatori"), Giocatori.Count.ToString());
             }
             else
             {
                 labelLoading.Text = T("Sei sicuro di essere manager di una nazionale?");
             }
         }
         catch (Exception ex) { My.Box.Errore("TabTeam::LoadFromDB()\r\n" + ex.Message); }
         Internal.Main.StatusBar.Value = 0;
         LOADING = (content == "");
     }
     catch (Exception ex) { My.Box.Errore("TabTeam::LoadFromDB()\r\n" + ex.Message); }
 }
示例#4
0
 public void LoadFromDB()
 {
     try
     {
         LOADING = true;
         comboDa.Enabled = false;
         comboA.Enabled = false;
         try
         {
             if (RELOADDATA)
             {
                 comboDa.Items.Clear();
                 comboA.Items.Clear();
                 comboDa.Items.AddRange(Internal.DB.GetDates());
                 comboA.Items.AddRange(Internal.DB.GetDates());
                 if (comboDa.Items.Count > 1) comboDa.SelectedIndex = 1;
                 else if (comboDa.Items.Count == 1) comboDa.SelectedIndex = 0;
                 if (comboA.Items.Count > 0) comboA.SelectedIndex = 0;
             }
             if (comboDa.SelectedIndex < 0) return;
             if (comboA.SelectedIndex < 0) return;
             DataTable DT_NEW = Internal.DB.GetPlayers(comboA.Items[comboA.SelectedIndex].ToString());
             string da = comboDa.Items[comboDa.SelectedIndex].ToString();
             int y = 0; int j = 0;
             Internal.Main.StatusBar.Value = 0;
             Internal.Main.StatusBar.Maximum = DT_NEW.Rows.Count * 2;
             Control.Player[] list = new RMO.Control.Player[DT_NEW.Rows.Count];
             foreach (DataRow dr in DT_NEW.Rows)
             {
                 Control.Player p = new RMO.Control.Player();
                 p.LoadData(dr, da);
                 list[j] = p; j++;
                 switch (comboVT.SelectedIndex)
                 {
                     case 1: p.ShowFACVT(); break;
                     case 2: p.ShowFCDVT(); break;
                 }
                 Internal.Main.StatusBar.Value++;
             }
             int totale_stipendi = 0;
             int totale_eta = 0;
             Array.Sort(list);
             panelPlayers.SuspendLayout();
             panelPlayers.Controls.Clear();
             int k = 0;
             foreach (Control.Player pl in list)
             {
                 pl.SetSize();
                 totale_stipendi += pl.SALARIO;
                 totale_eta += pl.ETA;
                 pl.Location = new Point(0, y);
                 y += pl.Height;
                 panelPlayers.Controls.Add(pl);
                 if (Properties.Settings.Default.GrayLines)
                 {
                     if ((k++ % 2) == 0) pl.BackColor = Properties.Settings.Default.LinesColor1;
                     else pl.BackColor = Properties.Settings.Default.LinesColor2;
                 }
                 Internal.Main.StatusBar.Value++;
             }
             lStipendi.Text = string.Format(T("Totale stipendi: {0} €"), totale_stipendi.ToString());
             decimal media = Math.Truncate((decimal)(totale_eta * 10 / list.Length)) / 10;
             lEta.Text = string.Format(T("Età media {0} anni"), media.ToString());
             lTOTALE.Text = string.Format(T("{0} Giocatori"), list.Length.ToString());
             InitHeader();
             panelPlayers.ResumeLayout();
         }
         catch (Exception ex) { My.Box.Errore("TabTeam::LoadFromDB()\r\n"+ex.Message); }
         Internal.Main.StatusBar.Value = 0;
         comboDa.Enabled = true;
         comboA.Enabled = true;
         LOADING = false;
         CheckBlockedMarket();
     }
     catch (Exception ex) { My.Box.Errore("TabTeam::LoadFromDB()\r\n"+ex.Message); }
 }