1 2 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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Web.Security;
using System.Data;
using System.Configuration;
using System.Diagnostics;
namespace PortailRMN
{
public partial class ExecuteJobRaymark : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (_Default.Membership1.EtreConsultant(Context.User.Identity.Name) == true)
{
Response.Redirect("Accueil.aspx");
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Execute")
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DWHConnectionString11"].ConnectionString))
{
con.Open();
int index = Convert.ToInt32(e.CommandArgument);
SqlCommand select = con.CreateCommand();
GridViewRow selectedRow = GridView1.Rows[index];
TableCell Job_PK = selectedRow.Cells[0];
string ID = Job_PK.Text;
SqlDataReader lire_select;
select.CommandText = "SELECT [JBI_JobFolder] FROM [msdb].[dbo].[D_JobRaymark] WHERE JBI_PK = '" + ID + "'";
lire_select = select.ExecuteReader();
//Condition qui vérifie si la requête retourne quelque chose (ligne/valeur)
if (lire_select.HasRows)
{
lire_select.Read();
string fichier = lire_select.GetValue(0).ToString();
string fichierBat = fichier + ".bat";
//Label1.Text = fichier;
//Label2.Text = fichierBat;
ProcessStartInfo fichierRun = new ProcessStartInfo(@"\\BDRAYMARKPREP2\d$\Interface\bat\" + fichierBat);
Process proRaymark = new Process();
fichierRun.UseShellExecute = true;
fichierRun.WorkingDirectory = @"\\BDRAYMARKPREP2\d$\Interface\bat\";
proRaymark = Process.Start(fichierRun);
lire_select.Close();
}
}
}
}
}
} |
Partager