Torna al Thread

Private Sub BackgroundWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker.DoWork Dim worker As System.ComponentModel.BackgroundWorker = (CType(sender, System.ComponentModel.BackgroundWorker)) Try AlbColl = Read_record.CaricaRecAll(ObjAlb, 1) For y As Integer = 0 To AlbColl.Count - 1 NomeAlb = AlbColl.Item(y).Descrizione codalb = AlbColl.Item(y).CodiceAlbergo indexalb = y Try Dim strcom, stralb, strmese, stranno As String ObjC59.CodAlbergo = AlbColl.Item(y).CodiceAlbergo ObjC59.CodiceComAlbergo = AlbColl.Item(y).CodiceComune ObjC59.DallaData = CDate(Me.MaskedTextBox1.Text) ObjC59.AllaData = CDate(Me.MaskedTextBox2.Text) C59Coll = Read_record.CaricaRecAllAlb(ObjC59) totrecordalb = C59Coll.Count For i As Integer = 0 To C59Coll.Count - 1 If Me.BackgroundWorker.CancellationPending Then e.Cancel = True FileClose(1) : FileClose(2) Exit Sub End If 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) & "'") val += 1 If val = 1 Then worker.ReportProgress(totrecordalb, True) Else worker.ReportProgress(val) End If IndexAlbergostart = C59Coll.Item(i).CodAlbergo Threading.Thread.Sleep(50) Next If C59Coll.Count = 0 Then MovNull = True worker.ReportProgress(0) End If FileClose(1) : FileClose(2) val = 0 IndexAlbergostart = 0 Catch ex As Exception e.Cancel = True MessageBox.Show("Attenzione impossibile procedere con la creazione dei file C59." & Chr(10) & Err.Description, "Receive.Net", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Return End Try Next Catch ex As Exception e.Cancel = True MessageBox.Show(Err.Description, "Receive.Net", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End Try End Sub
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5