Torna al Thread

Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork Dim MyBackgroundWorker As System.ComponentModel.BackgroundWorker = CType(sender, System.ComponentModel.BackgroundWorker) AlbColl = Read_record.CaricaRecAll(ObjAlb, 1) For i As Integer = 0 To AlbColl.Count - 1 NomeAlb = AlbColl.Item(i).Descrizione Try Dim strcom, stralb, strmese, stranno As String Dim IndexAlbergostart As Integer = 0 ObjC59.CodAlbergo = AlbColl.Item(i).CodiceAlbergo ObjC59.CodiceComAlbergo = AlbColl.Item(i).CodiceComune ObjC59.DallaData = CDate(Me.MaskedTextBox1.Text) ObjC59.AllaData = CDate(Me.MaskedTextBox2.Text) C59Coll = Read_record.CaricaRecAllAlb(ObjC59) totrecordalb = C59Coll.Count For y As Integer = 0 To C59Coll.Count - 1 y += 1 If IndexAlbergostart = 0 Then strcom = String.Format("{0:D3}", CInt(C59Coll.Item(i).CodiceComAlbergo)).Substring(2, 3) stralb = String.Format("{0:D4}", CInt(C59Coll.Item(i).CodAlbergo)) strmese = Me.MaskedTextBox1.Text.Substring(3, 2) stranno = Convert.ToString(C59Coll.Item(i).Annogestionale) If Directory.Exists("C:\Istatc59\" & C59Coll.Item(i).NomeAlbergo) = False Then Directory.CreateDirectory("C:\Istatc59\" & C59Coll.Item(i).NomeAlbergo) End If '********************************************************************** FileOpen(1, "C:\Istatc59\" & C59Coll.Item(i).NomeAlbergo & "\" & strcom & stralb & strmese & stranno & ".Txt", OpenMode.Output) FileOpen(2, "C:\foglio\" & strcom & stralb & strmese & stranno & ".Txt", OpenMode.Output) nfile += 1 End If PrintLine(1, "'" & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodiceRegione), 3) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodiceProvincia), 3) & LSet(Convert.ToString(C59Coll.Item(i).CodiceComAlbergo).Substring(2, 3), 3) & LSet(String.Format("{0:D4}", C59Coll.Item(i).CodAlbergo), 4) & LSet(Convert.ToString(C59Coll.Item(i).CodiceCategoria), 2) & LSet(C59Coll.Item(i).DataArrivo, 10) & LSet(C59Coll.Item(i).DataPartenza, 10) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodStato_Res), 3) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodComune), 3) & "'") PrintLine(2, "'" & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodiceRegione), 3) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodiceProvincia), 3) & LSet(Convert.ToString(C59Coll.Item(i).CodiceComAlbergo).Substring(2, 3), 3) & LSet(String.Format("{0:D4}", C59Coll.Item(i).CodAlbergo), 4) & LSet(Convert.ToString(C59Coll.Item(i).CodiceCategoria), 2) & LSet(C59Coll.Item(i).DataArrivo, 10) & LSet(C59Coll.Item(i).DataPartenza, 10) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodStato_Res), 3) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodComune), 3) & "'") IndexAlbergostart = C59Coll.Item(i).CodAlbergo MyBackgroundWorker.ReportProgress(y) Next FileClose(1) : FileClose(2) Val = 0 Catch ex As Exception MyBackgroundWorker.CancelAsync() MyBackgroundWorker.Dispose() MessageBox.Show("Attenzione impossibile procedere con la creazione dei file C59." & Chr(10) & Err.Description, "Receive.Net", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Me.Label5.Text = "Attesa elaborazione..." Return End Try Next i End Sub
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5