Exemple #1
0
 private void btnEjecutar_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var ProcesoConsumo = new Thread(delegate(object ctx)
         {
             Dispatcher.BeginInvoke((Action) delegate
             {
                 btnEjecutar.IsEnabled = false;
                 imgloading.Visibility = Visibility.Visible;
             },
                                    DispatcherPriority.Background, null);
             try
             {
                 var context           = ctx as AplicacionConsumoModel;
                 var consumoAlimentoPL = new ConsumoAlimentoPL();
                 consumoAlimentoPL.GenerarConsumoAlimento(
                     context.Organizacion.OrganizacionID, context.FechaConsumo);
                 Dispatcher.BeginInvoke((Action) delegate
                 {
                     SkMessageBox.Show(
                         Application.Current.Windows[ConstantesVista.WindowPrincipal],
                         Properties.Resources.AplicacionConsumoAlimento_EjecutadoExito,
                         MessageBoxButton.OK,
                         MessageImage.Correct);
                     Limpiar();
                 },
                                        DispatcherPriority.Background, null);
             }
             catch (Exception ex)
             {
                 Logger.Error(ex);
                 Dispatcher.BeginInvoke((Action) delegate
                 {
                     SkMessageBox.Show(
                         Application.Current.Windows[ConstantesVista.WindowPrincipal],
                         Properties.Resources.AplicacionConsumoAlimento_ErrorEjecutarConsumos,
                         MessageBoxButton.OK, MessageImage.Error);
                     btnEjecutar.IsEnabled = true;
                     imgloading.Visibility = Visibility.Hidden;
                 },
                                        DispatcherPriority.Background, null);
             }
         });
         ProcesoConsumo.IsBackground = true;
         ProcesoConsumo.Start(Contexto);
     }
     catch (Exception ex)
     {
         btnEjecutar.IsEnabled = true;
         imgloading.Visibility = Visibility.Hidden;
         Logger.Error(ex);
         SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.AplicacionConsumoAlimento_ErrorEjecutarConsumos, MessageBoxButton.OK, MessageImage.Error);
     }
 }
            public void RunApp()
            {
                if (app.Codigo == AccionesSIAPEnum.SerConsAli.ToString())
                {
                    eventLog1.WriteEntry("ServiciosSiapSK RunApp Consumo de Alimento Inicio.");
                    try
                    {
                        var consumoAlimentoPL = new ConsumoAlimentoPL();

                        consumoAlimentoPL.GenerarConsumoAlimento(0, DateTime.Now.AddDays(-1));
                    }
                    catch (Exception ex)
                    {
                        eventLog1.WriteEntry("ServiciosSiapSK RunApp Consumo Alimento Exception: " + ex);
                    }
                    finally
                    {
                        eventLog1.WriteEntry("ServiciosSiapSK RunApp Consumo de Alimento Fin.");
                    }
                }
                else if (app.Codigo == AccionesSIAPEnum.SerCostGan.ToString())
                {
                    eventLog1.WriteEntry("ServiciosSiapSK RunApp Costeo de Ganado Inicio.");
                    try
                    {
                        var costeoGanadoPL = new CosteoGanadoPL();
                        costeoGanadoPL.GenerarCosteoGanado();
                    }
                    catch (Exception ex)
                    {
                        eventLog1.WriteEntry("ServiciosSiapSK RunApp Costeo de Ganado Exception: " + ex);
                    }
                    finally
                    {
                        eventLog1.WriteEntry("ServiciosSiapSK RunApp Costeo de Ganado Fin.");
                    }
                }
                else if (app.Codigo == AccionesSIAPEnum.SerAlerta.ToString())
                {
                    eventLog1.WriteEntry("ServiciosSiapSK RunApp Alertas SIAP.");
                    try
                    {
                        var incidenciaPL = new IncidenciasPL();
                        incidenciaPL.GenerarIncidenciasSIAP();
                    }
                    catch (Exception ex)
                    {
                        eventLog1.WriteEntry("ServiciosSiapSK RunApp Alertas SIAP Exception: " + ex);
                    }
                    finally
                    {
                        eventLog1.WriteEntry("ServiciosSiapSK RunApp Alertas SIAP Fin.");
                    }
                }
            }