Ciao,
E' il mio primo post su Mr.Webmaster (grandioso!).
Non so nulla di programmazione web e spero mi possiate aiutare.
Ho un'applicazione di gestione di tornei di scacchi che genera iscrizione dei giocatori, accoppiamenti, inserimento risultati partite, classifiche ecc. e vorrei pubblicare, via ftp (che so fare), i file htm creati dai report vari che posso ottenere in formato txt.
Una prima pagina l'ho ottenuta generarndo in una sub il codice htm con aggiunta di variabili-dati. E' il modo più stupido, ma efficiente, per fare un lavoro del genere, ma penso che esistano metodi migliori.
Ecco il codice delle mia sub elementare, ma per ogni pagina, dovrei creare una sub specifica, il che mi sembra davvero poco elegante.
All'interno dello stesso modulo, ho anche creato una sub per generare la lista dei giocatori in formato XML, ma non penso sia visualizzabile in forma leggibile direttamente sul web.
Grazie mille,
Emiliano
E' il mio primo post su Mr.Webmaster (grandioso!).
Non so nulla di programmazione web e spero mi possiate aiutare.
Ho un'applicazione di gestione di tornei di scacchi che genera iscrizione dei giocatori, accoppiamenti, inserimento risultati partite, classifiche ecc. e vorrei pubblicare, via ftp (che so fare), i file htm creati dai report vari che posso ottenere in formato txt.
Una prima pagina l'ho ottenuta generarndo in una sub il codice htm con aggiunta di variabili-dati. E' il modo più stupido, ma efficiente, per fare un lavoro del genere, ma penso che esistano metodi migliori.
Ecco il codice delle mia sub elementare, ma per ogni pagina, dovrei creare una sub specifica, il che mi sembra davvero poco elegante.
Codice:
Imports System.Xml
Imports System.IO
Imports System.Text
Module HTMLModule
Sub CreaHomeHTML()
Dim strHTML As String, filename As String
' Crea index.htm
Dim wwwdir = glob.DirTorneo & "\www"
CreaDir(wwwdir)
filename = wwwdir & "\index.html"
Dim objWriter As New System.IO.StreamWriter(filename)
'
Dim sb As New StringBuilder
sb.Append("<p style=""text-align: center;""><img src=""http://www.astrofantasy.it/sfideCSP/www_myProgram/logo.gif"" border=""0"" width=""150"" /></p>")
'sb.Append("<br /><img style=display: block; margin-left: auto; margin-right: auto; src=""http://www.astrofantasy.it/sfideCSP/www_myProgram/logo.gif"" alt="" width=""150"" />" & vbLf)
sb.Append("<h1 style=""text-align: center;""><span style=""color: #008000;"">Gestione sfide</span></h1>""" & vbLf)
sb.Append("<table style=""height: 50px; width: 400px; border: 1px solid #02000a; background-color: #ffffcc;"" border=""1"" align=""center"">" & vbLf)
sb.Append("<tbody>" & vbLf)
sb.Append("<tr style=""background-color: #ffffff; height: 30px;"">" & vbLf)
sb.Append("<td style=""text-align: center; width: 300px;"" colspan=""2"">" & vbLf)
sb.Append("<h2><strong><a href=""indirizzo_pagina_web""><br />Partecipanti ordinati per nome</a></strong></h2>" & vbLf)
sb.Append("</td>" & vbLf)
sb.Append("</tr>" & vbLf)
sb.Append("<tr style=""background-color: #ffffff; height: 30px;"">" & vbLf)
sb.Append("<td style=""text-align: center; width: 300px;"" colspan=""2"">" & vbLf)
sb.Append("<h2><strong><a href=""indirizzo_pagina_web""><br />Partecipanti ordinati per Elo</a></strong></h2>" & vbLf)
sb.Append("</td>" & vbLf)
sb.Append("</tr>" & vbLf)
sb.Append("<tr style=""background-color: #ffffff; height: 30px;"">" & vbLf)
sb.Append("<td style=""text-align: center; width: 300px;"" colspan=""2"">" & vbLf)
sb.Append("<h2><strong><a href=""indirizzo_pagina_web""><br />Turni e risultati</a></strong></h2>" & vbLf)
sb.Append("</td>" & vbLf)
sb.Append("</tr>" & vbLf)
sb.Append("<tr style=""background-color: #ffffff; height: 30px;"">" & vbLf)
sb.Append("<td style=""text-align: center; width: 300px;"" colspan=""2"">" & vbLf)
sb.Append("<h2><strong><a href=""indirizzo_pagina_web""><br />Classifica</a></strong></h2>" & vbLf)
sb.Append("</td>" & vbLf)
sb.Append("</tr>" & vbLf)
sb.Append("<tr style=""background-color: #ffffff; height: 30px;"">" & vbLf)
sb.Append("<td style=""text-align: center; width: 300px;"" colspan=""2"">" & vbLf)
sb.Append("<h2><strong><a href=""indirizzo_pagina_web""><br />Storico</a></strong></h2>" & vbLf)
sb.Append("</td>" & vbLf)
sb.Append("</tr>" & vbLf)
sb.Append("</tbody>" & vbLf)
sb.Append("</table>" & vbLf)
sb.Append("<h3 style=""text-align: center;"">by Eggpap 2014</h3>" & vbLf)
sb.Append("</head>")
strHTML = sb.ToString()
objWriter.Write(strHTML)
objWriter.Close()
End Sub
All'interno dello stesso modulo, ho anche creato una sub per generare la lista dei giocatori in formato XML, ma non penso sia visualizzabile in forma leggibile direttamente sul web.
Codice:
Sub CreaPlayersXML(players As List(Of player))
' Crea XmlWriterSettings.
Dim settings As XmlWriterSettings = New XmlWriterSettings()
settings.Indent = True
Dim wwwdir = glob.DirTorneo & "\www"
CreaDir(wwwdir)
' Crea XmlWriter.
Using writer As XmlWriter = XmlWriter.Create(wwwdir & "\players.xml", settings)
' Inizio scrittura giocatori iscritti
writer.WriteStartDocument()
writer.WriteStartElement("Iscritti") ' Root.
' ciclo di ricerca in players.
Dim ndx As Integer
For Each item In players
ndx += 1
writer.WriteStartElement("Giocatore")
writer.WriteElementString("ID", ndx)
writer.WriteElementString("Nome", item.FN)
writer.WriteElementString("Elo", item.ER)
writer.WriteEndElement()
Next
' End document.
writer.WriteEndElement()
writer.WriteEndDocument()
End Using
End Sub
Grazie mille,
Emiliano
Ultima modifica: