El Symphony no es un CMS ?
Alguien que pueda comentar sobre ella ??
Alguien que pueda comentar sobre ella ??
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
Imports System.Text
Public Class MainForm
' Declare necessary class variables.
Private CommPort As New RS232()
Private IsModemFound As Boolean = False
Private ModemPort As Integer = 0
' This subroutine clears the TextBox.
Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
Me.StatusTextbox.Clear()
End Sub
' This subroutine sends a user specified command to the modem, and records its
' response. It depends on the timer to do the reading of the response.
Private Sub SendUserCommandButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendUserCommandButton.Click
' Always wrap up working with Comm Ports in exception handlers.
Try
' Enable the timer.
'If Not Me.tmrReadCommPort.Enabled Then
Me.tmrReadCommPort.Enabled = True
'End If
'If Not CommPort.IsOpen Then
' Attempt to open the port.
CommPort.Open(8, 115200, 8, RS232.DataParity.Parity_None, RS232.DataStopBit.StopBit_1, 4096)
'End If
'Write an user specified Command to the Port.
CommPort.Write(Encoding.ASCII.GetBytes(Me.UserCommandTextbox.Text & Chr(13)))
' Sleep long enough for the modem to respond and the timer to fire.
System.Threading.Thread.Sleep(200)
Application.DoEvents()
CommPort.Close()
Catch ex As Exception
' Warn the user.
MessageBox.Show("Unable to communicate with Modem")
Finally
' Disable the timer.
Me.tmrReadCommPort.Enabled = False
End Try
End Sub
' This subroutine is fired when the timer event is raised. It writes whatever
' is in the Comm Port buffer to the output window.
Private Sub tmrReadCommPort_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrReadCommPort.Tick
Try
' As long as there is information, read one byte at a time and
' output it.
While (CommPort.Read(1) <> -1)
' Write the output to the screen.
WriteMessage(Chr(CommPort.InputStream(0)), False)
End While
Catch exc As Exception
' An exception is raised when there is no information to read.
' Don't do anything here, just let the exception go.
End Try
End Sub
' This subroutine writes a message to the txtStatus TextBox.
Private Sub WriteMessage(ByVal message As String)
Me.StatusTextbox.Text += message + vbCrLf
End Sub
' This subroutine writes a message to the txtStatus TextBox and allows
' the line feed to be suppressed.
Private Sub WriteMessage(ByVal message As String, ByVal linefeed As Boolean)
Me.StatusTextbox.Text += message
If linefeed Then
Me.StatusTextbox.Text += vbCrLf
End If
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
CommPort.Close()
End
End Sub
Private Sub MainForm_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
CommPort.Close()
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'UploadLocalFile()
Dim CookieJar As New CookieContainer
Dim Url As String = "http://lok.myvnc.com/insertar-anuncio.html?isDBMode=1"
Dim parametros As New NameValueCollection()
' Create the data we want to send
parametros.Add("var1", "1235")
parametros.Add("var2", "524")
parametros.Add("var3", "Mas información para mandar")
parametros.Add("var4", "Mas informacion para mandar")
parametros.Add("var5", "jdueybd@gjhf.com")
parametros.Add("var6", "123456")
parametros.Add("var7", "654321")
parametros.Add("var8", "Pepin")
Uploaddata(CookieJar, Url, "C:\corazon.jpeg", "ad_picture_a", "image,jpeg", parametros)
End Sub
'Funcion que manda la información
Public Function Uploaddata(ByVal containa As CookieContainer, ByVal uri As String, ByVal filePath As String, ByVal fileParameterName As String, ByVal contentType As String, ByVal otherParameters As Specialized.NameValueCollection) As String
Dim boundary As String = "---------------------------" & DateTime.Now.Ticks.ToString("x")
Dim newLine As String = System.Environment.NewLine
Dim boundaryBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(newLine & "--" & boundary & newLine)
Dim request As Net.HttpWebRequest = Net.WebRequest.Create(Uri)
request.ContentType = "multipart/form-data; boundary=" & boundary
request.Method = "POST"
request.Referer = "http://lok.myvnc.com/vivienda/casa-en-la-playa/insertar-anuncio.html"
request.Headers.Add("Accept-Encoding", "gzip, deflate")
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
request.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20100101 Firefox/16.0"
request.CookieContainer = containa
request.AllowAutoRedirect = True
request.Timeout = -1
request.KeepAlive = True
request.AllowWriteStreamBuffering = False
Dim ms As New MemoryStream()
Dim formDataTemplate As String = "Content-Disposition: form-data; name=""{0}""{1}{1}{2}"
For Each key As String In otherParameters.Keys
ms.Write(boundaryBytes, 0, boundaryBytes.Length)
Dim formItem As String = String.Format(formDataTemplate, key, newLine, otherParameters(key))
Dim formItemBytes As Byte() = System.Text.Encoding.UTF8.GetBytes(formItem)
ms.Write(formItemBytes, 0, formItemBytes.Length)
Next key
ms.Write(boundaryBytes, 0, boundaryBytes.Length)
Dim headerTemplate As String = "Content-Disposition: form-data; name=""{0}""; filename=""{1}""{2}Content-Type: {3}{2}{2}"
Dim header As String = String.Format(headerTemplate, fileParameterName, filePath, newLine, contentType)
Dim headerBytes As Byte() = System.Text.Encoding.UTF8.GetBytes(header)
ms.Write(headerBytes, 0, headerBytes.Length)
Dim length As Long = ms.Length
length += New FileInfo(filePath).Length
request.ContentLength = length
Using requestStream As IO.Stream = request.GetRequestStream()
Dim bheader() As Byte = ms.ToArray()
requestStream.Write(bheader, 0, bheader.Length)
Using fileStream As New IO.FileStream(filePath, IO.FileMode.Open, IO.FileAccess.Read)
Dim buffer(4096) As Byte
Dim bytesRead As Int32 = fileStream.Read(buffer, 0, buffer.Length)
Do While (bytesRead > 0)
requestStream.Write(buffer, 0, bytesRead)
bytesRead = fileStream.Read(buffer, 0, buffer.Length)
Loop
End Using
requestStream.Close()
End Using
Dim response As Net.WebResponse = Nothing
Dim responseText = ""
Try
response = request.GetResponse()
Using responseStream As IO.Stream = response.GetResponseStream()
Using responseReader As New IO.StreamReader(responseStream)
responseText = responseReader.ReadToEnd()
End Using
End Using
Catch exception As Net.WebException
MsgBox(exception.Message)
Finally
response.Close()
response = Nothing
request = Nothing
End Try
Return responseText
End Function
End Class