viernes, 25 de agosto de 2017

Parámetros de entrada

Dim dialog As New FolderBrowserDialog()
dialog.ShowNewFolderButton = False ' No aparece la opción crear carpeta
 If dialog.ShowDialog() = Windows.Forms.DialogResult.OK Then tbcarpeta.Text = dialog.SelectedPath()
End If

 NumericUpDown

 StartPosition: CenterScreen

Autosize: False

TextImageRelation: ImageAboveText

My.Application.CommandLineArgs(0) ' conex
My.Application.CommandLineArgs(1) ' estación
My.Application.CommandLineArgs(2) ' usuario

jueves, 24 de agosto de 2017

Contar la cantidad de líneas de un archivo

Dim n As Integer = File.ReadAllLines("C:\file.txt").Lenght fuente: https://stackoverflow.com/questions/119559/determine-the-number-of-lines-within-a-text-file

lunes, 14 de agosto de 2017

Webservice Registro Reclamo DTE

http://www.sii.cl/factura_electronica/Webservice_Registro_Reclamo_DTE_V1.1.pdf
http://www.sii.cl/factura_electronica/GUIA_aceptacion_reclamo_dte.pdf
https://www4.sii.cl/registrorechazodteInternet/

ingresarAceptacionReclamoDoc: Acepta Contenido del Documento (ACD)

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ws="http://ws.registroreclamodte.diii.sdi.sii.cl">
    <soapenv:Header/>
    <soapenv:Body>
        <ws:ingresarAceptacionReclamoDoc>
            <rutEmisor>123</rutEmisor>
            <dvEmisor>4</dvEmisor>
            <tipoDoc>33</tipoDoc>
            <folio>98765</folio>
            <accionDoc>ACD</accionDoc>
        </ws:ingresarAceptacionReclamoDoc>
    </soapenv:Body>
</soapenv:Envelope>

ingresarAceptacionReclamoDoc: Reclamo al Contenido del Documento (RCD)

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ws="http://ws.registroreclamodte.diii.sdi.sii.cl">
    <soapenv:Header/>
    <soapenv:Body>
        <ws:ingresarAceptacionReclamoDoc>
            <rutEmisor>123</rutEmisor>
            <dvEmisor>4</dvEmisor>
            <tipoDoc>33</tipoDoc>
            <folio>98765</folio>
            <accionDoc>RCD</accionDoc>
        </ws:ingresarAceptacionReclamoDoc>
    </soapenv:Body>
</soapenv:Envelope>

ingresarAceptacionReclamoDoc: Otorga Recibo de Mercaderías o Servicios (ERM)

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ws="http://ws.registroreclamodte.diii.sdi.sii.cl">
    <soapenv:Header/>
    <soapenv:Body>
        <ws:ingresarAceptacionReclamoDoc>
            <rutEmisor>123</rutEmisor>
            <dvEmisor>4</dvEmisor>
            <tipoDoc>33</tipoDoc>
            <folio>98765</folio>
            <accionDoc>ERM</accionDoc>
        </ws:ingresarAceptacionReclamoDoc>
    </soapenv:Body>
</soapenv:Envelope>


ingresarAceptacionReclamoDoc: Reclamo por Falta Parcial de Mercaderías (RFP)

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ws="http://ws.registroreclamodte.diii.sdi.sii.cl">
    <soapenv:Header/>
    <soapenv:Body>
        <ws:ingresarAceptacionReclamoDoc>
            <rutEmisor>123</rutEmisor>
            <dvEmisor>4</dvEmisor>
            <tipoDoc>34</tipoDoc>
            <folio>98765</folio>
            <accionDoc>RFP</accionDoc>
        </ws:ingresarAceptacionReclamoDoc>
    </soapenv:Body>
</soapenv:Envelope>

ingresarAceptacionReclamoDoc: Reclamo por Falta Total de Mercaderías (RFT)

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ws="http://ws.registroreclamodte.diii.sdi.sii.cl">
    <soapenv:Header/>
    <soapenv:Body>
        <ws:ingresarAceptacionReclamoDoc>
            <rutEmisor>123</rutEmisor>
            <dvEmisor>4</dvEmisor>
            <tipoDoc>33</tipoDoc>
            <folio>98765</folio>
            <accionDoc>RFT</accionDoc>
        </ws:ingresarAceptacionReclamoDoc>
    </soapenv:Body>
</soapenv:Envelope>


listarEventosHistDoc

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ws="http://ws.registroreclamodte.diii.sdi.sii.cl">
    <soapenv:Header/>
    <soapenv:Body>
        <ws:listarEventosHistDoc>
            <rutEmisor>123</rutEmisor>
            <dvEmisor>K</dvEmisor>
            <tipoDoc>34</tipoDoc>
            <folio>10293847</folio>
        </ws:listarEventosHistDoc>
    </soapenv:Body>
</soapenv:Envelope>


consultarDocDteCedible

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ws="http://ws.registroreclamodte.diii.sdi.sii.cl">
    <soapenv:Header/>
    <soapenv:Body>
        <ws:consultarDocDteCedible>
            <rutEmisor>123</rutEmisor>
            <dvEmisor>8</dvEmisor>
            <tipoDoc>34</tipoDoc>
            <folio>456</folio>
        </ws:consultarDocDteCedible>
    </soapenv:Body>
</soapenv:Envelope>


consultarFechaRecepcionSii

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ws="http://ws.registroreclamodte.diii.sdi.sii.cl">
    <soapenv:Header/>
    <soapenv:Body>
        <ws:consultarFechaRecepcionSii>
            <rutEmisor>1235</rutEmisor>
            <dvEmisor>7</dvEmisor>
            <tipoDoc>34</tipoDoc>
            <folio>9998</folio>
        </ws:consultarFechaRecepcionSii>
    </soapenv:Body>
</soapenv:Envelope>
Primero se hace el Recibo de mercaderías y después Acepta el contenido del documento

viernes, 11 de agosto de 2017

Mostrar un xml en un textbox multilinea

Dim doc As New XmlDocument()
doc.LoadXml(lineaxml)
 Dim sb As New StringBuilder()
 Dim settings As New XmlWriterSettings()
 settings.Indent = True
 Dim writer As XmlWriter = XmlWriter.Create(sb, settings)
 doc.WriteTo(writer)
 writer.Close()
tbrespsii.Text = sb.ToString()

Fuente: https://forums.asp.net/t/1302839.aspx?Displaying+xml+file+in+multiline+textbox

Limpiar combobox

ComboBox.SelectedIndex = -1

jueves, 10 de agosto de 2017

Reemplazar una cadena de caracteres

Dim mystr As String = New String("*"c, array.Length)

Fuente: https://stackoverflow.com/questions/14483500/how-do-i-generate-a-string-of-asterisks-with-specified-length

miércoles, 9 de agosto de 2017

BackgroundWorker

Imports System.Threading

Public Class Form1

    Private Sub btnaceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaceptar.Click
        If Not bgw1.IsBusy = True Then
            bgw1.RunWorkerAsync()
        End If
    End Sub

    Private Sub btncancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncancelar.Click
        If bgw1.WorkerSupportsCancellation = True Then
            bgw1.CancelAsync()
        End If
    End Sub

    Private Sub bgw1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgw1.DoWork

        While True
            If bgw1.CancellationPending = True Then
                e.Cancel = True
                Exit While
            Else
                MessageBox.Show("hola")
            End If
            Thread.Sleep(1000)
        End While
    End Sub

    Private Sub bgw1_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bgw1.RunWorkerCompleted
        If e.Cancelled = True Then
            MessageBox.Show("Cancelado!")
        ElseIf e.Error IsNot Nothing Then
            MessageBox.Show(e.Error.Message)
        Else
            MessageBox.Show("Fin!")
        End If
    End Sub
End Class

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Control.CheckForIllegalCrossThreadCalls = False
    End Sub



viernes, 4 de agosto de 2017

Agregar descripción en la cabecera WebService

<System.Web.Services.WebService(Namespace:="http://microsoft.com/webservices/", Description:="WebService para el respaldo de archivos xml")>

Agregar descripción a un método WebService

<WebMethod(Description:="Hola")>

fuente: https://msdn.microsoft.com/es-es/library/byxd99hx(v=vs.90).aspx

jueves, 3 de agosto de 2017

Insertar registro al inicio archivo txt

Public i As Integer = 0
Private Sub btnaceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaceptar.Click
        Dim filename As String = Directory.GetCurrentDirectory & "\log.txt"
        Dim tempfile As String = Path.GetTempFileName()
        i += 1
        Using writer = New StreamWriter(tempfile)
            Using reader = New StreamReader(filename)
                writer.WriteLine(Now.ToString("dd-MM-yyyy HH:mm:ss:ffff") & "|" & tbinsertar.Text.Trim & "|" & i)
                While Not reader.EndOfStream
                    writer.WriteLine(reader.ReadLine())
                End While
            End Using
        End Using
        File.Copy(tempfile, filename, True)
        File.Delete(tempfile)
    End Sub

fuente: https://stackoverflow.com/questions/2401523/how-to-insert-row-in-first-line-of-text-file