Hola!
Estoy confundida... estoy intentando crear una tarea en el scheduled task, con un componente (dll) llamado TaskScheduler.
En desarrollo todo funciona bien y al momento de lanzar la tarea, en la página muestro un mensaje que dice: "="La copia se hará en un minuto, por favor verifique"
El problema es que al pasar a produccion todo el proyecto, y al dar click en el boton de Copiar (que es el que lanza: Copiar_al_web()), no me muestra el mensaje, pero si está creando la tarea....
le doy click y es como si hiciera solo un refresh a la página, no entiendo por que si en desarrollo todo funciona bien, y pase todo a produccion tal cual, solo cambiando IP de máquinas y nombres de usuarios, pero en si el concepto es tal cual...
Aquí les paso el código con el que estoy creando la tarea:
Código:
private void Copiar_al_web()
{
try
{
String parametros = ciudad.SelectedValue.ToString() + " " + Convert.ToString((fecha.SelectedDate).ToString("yyyy-MM-dd"));
//Get a ScheduledTasks object for the local computer.
ScheduledTasks st = new ScheduledTasks();
// Create a task
Task t;
try
{
t = st.CreateTask("CopiarWeb");
}
catch (ArgumentException)
{
//Console.WriteLine("Task name already exists");
st.DeleteTask("CopiarWeb");
t = st.CreateTask("CopiarWeb");
}
// Fill in the program info
string PathArchivosBat=System.Configuration.ConfigurationSettings.AppSettings["SrvArchivosBat"];
t.ApplicationName = PathArchivosBat + "Crea_Programacion.bat";
t.Parameters = parametros;
t.Comment = "Copia programacion del día actual para la ciudad seleccionada";
// Set the account under which the task should run.
string User=System.Configuration.ConfigurationSettings.AppSettings["Usr"];
string Pass=System.Configuration.ConfigurationSettings.AppSettings["Pwd"];
t.SetAccountInformation(User, Pass);
// Declare that the system must have been idle for ten minutes before
// the task will start
//t.IdleWaitMinutes = 1;
// Allow the task to run for no more than 2 hours, 30 minutes.
t.MaxRunTime = new TimeSpan(2, 30, 0);
// Set priority to only run when system is idle.
t.Priority = System.Diagnostics.ProcessPriorityClass.Idle;
t.Triggers.Add(new RunOnceTrigger(DateTime.Now + TimeSpan.FromMinutes(1.0)));
// Save the changes that have been made.
t.Save();
// Close the task to release its COM resources.
t.Close();
// Dispose the ScheduledTasks to release its COM resources.
st.Dispose();
mensajeExito.ForeColor=Color.Green;
mensajeExito.Text="La copia se hará en un minuto, por favor verifique";
mensajeExito.Visible=true;
ImageExito.Visible=true;
}
catch (Exception ee)
{
Console.WriteLine("Exception: " + ee.Message);
}