| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 
 | Imports Microsoft.SqlServer.Management
Imports System.Data.SqlTypes
Imports System.Data.SqlClient
 
Partial Class Private_gestionCube
    Inherits System.Web.UI.Page
 
 
 
    Protected Sub btnstartSSISJob_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnstartSSISJob.Click
        Dim timeout As Integer = 3600
        lblLogSSISJob.Text = "Début de la mise à jour des Cubes. Un moment S.V.P. ..."
        Dim jobname As String = "jobSSIS_GestionIntervention"
        Try
            Dim con As New Microsoft.SqlServer.Management.Common.ServerConnection("LESERVEUR", "usager", "motdepasse")
            'creation de l'objet serveur
            Dim egbi2k5 As New Microsoft.SqlServer.Management.Smo.Server(con)
            'execute le job si il existe.
            If egbi2k5.JobServer.Jobs.Contains(jobname) Then
                Dim oLastRunDate As DateTime = egbi2k5.JobServer.Jobs(jobname).LastRunDate
                egbi2k5.JobServer.Jobs(jobname).Start()
                Dim nb_sec As Integer = 0
                While oLastRunDate = egbi2k5.JobServer.Jobs(jobname).LastRunDate
                    Console.Write(".")
                    egbi2k5.JobServer.Jobs(jobname).Refresh()
                    If nb_sec < timeout Then
                        nb_sec += 1
                        System.Threading.Thread.Sleep(1000)
                    Else
                        'envoi d'email
                        lblLogSSISJob.Text = "time out : le process est trop lent"
                        Console.WriteLine("time out: le process est trop lent")
                    End If
                End While
                lblLogSSISJob.Text = "La mise à jour du cube s'est terminée avec succès !"
                Console.WriteLine("fin")
                Return
            Else
                Return
            End If
        Catch ex As Exception
            lblLogSSISJob.Text = "Il y a présentement déjà une mise à jour des cubes !"
        End Try
    End Sub
 
End Class | 
Partager