コード例 #1
0
        private String fnDiasNoHabiles(DateTime?fechaCierre, DateTime oPrimerDiaDelMes, DateTime oUltimoDiaDelMes)
        {
            string DiaHabil = "S";

            CargarDatosSvc.clsResultado        resultado      = new CargarDatosSvc.clsResultado();
            CargarDatosSvc.clsFiltro           filtro1        = new CargarDatosSvc.clsFiltro();
            CargarDatosSvc.CargaDatosSvcClient svcDiasHabiles = new CargarDatosSvc.CargaDatosSvcClient();

            //List<CargarDatosSvc.clsDiasFeriados> diasHabiles = new List<CargarDatosSvc.clsDiasFeriados>();
            filtro1.Modo   = 1;
            filtro1.Filtro = "df_fecha>='" + Convert.ToDateTime(oPrimerDiaDelMes.ToString()).ToString("MM/dd/yyyy") + "' and df_fecha <='" + Convert.ToDateTime(oUltimoDiaDelMes.ToString()).ToString("MM/dd/yyyy") + "' and df_ciudad = 1706";
            var diasHabiles = svcDiasHabiles.CargarDataFechas(filtro1, out resultado);

            for (int i = 0; i < diasHabiles.Length; i++)
            {
                if (fechaCierre == diasHabiles[i].Fecha)
                {
                    DiaHabil = "N";
                    break;
                }
            }

            return(DiaHabil);
        }
コード例 #2
0
        private void fnEjecutarProcesos()
        {
            DateTime fechaCalendario = new DateTime();

            fechaCalendario = DateTime.Now;
            //DateTime fechaSd = new DateTime();

            System.DateTime.Now.DayOfWeek.ToString();
            CargarDatosSvc.clsCargaDatos param     = new CargarDatosSvc.clsCargaDatos();
            CargarDatosSvc.clsResultado  resultado = new CargarDatosSvc.clsResultado();
            CargarDatosSvc.clsFiltro     filtro    = new CargarDatosSvc.clsFiltro();

            CargarDatosSvc.CargaDatosSvcClient svc = new CargarDatosSvc.CargaDatosSvcClient();
            //Consulta de las fechas saldo diario y fecha de cierre o corte
            filtro.Modo   = 0;
            filtro.Filtro = "";
            svc.CargarDataFechas(filtro, out resultado);

            if (resultado.Resultado != 0)
            {
                using (EventLog eventLog = new System.Diagnostics.EventLog("Application", Environment.MachineName, strSource))
                {
                    eventLog.WriteEntry("ERROR CONSULTA DE FECHAS DE CIERRE Y SALDOS DIARIOS: " + "   " + resultado.Mensaje, EventLogEntryType.Error, 0);
                    errores.Add(resultado.Mensaje);
                    System.IO.File.WriteAllLines(pathLog, errores);
                    fnEnviarCorreo();
                    return;
                }
            }
            param.FechaSd     = resultado.FechaSd;
            param.FechaCierre = resultado.FechaCierre;

            var date = fechaCalendario;//resultado.FechaSd;// fecha.Value.DayOfWeek.ToString();
            ///Valida si es Fin de mes
            //se obtiene primer dia del mes
            DateTime oPrimerDiaDelMes = new DateTime(date.Year, date.Month, 1);
            //Y de la siguiente forma obtenemos el ultimo dia del mes
            //agregamos 1 mes al objeto anterior y restamos 1 día.
            DateTime oUltimoDiaDelMes = oPrimerDiaDelMes.AddMonths(1).AddDays(-1);

            ///comparamos la fecha obtenida con el ultimo dia del mes
            if (fechaCalendario.Day == oUltimoDiaDelMes.Day)
            //if (resultado.FechaCierre.Value.Day == oUltimoDiaDelMes.Day)
            {
                //validar si es feriado o dia no habil
                //var diaHabil = fnDiasNoHabiles(resultado.FechaCierre, oPrimerDiaDelMes, oUltimoDiaDelMes);
                param.Finmes     = "S";
                param.Fechadesde = oPrimerDiaDelMes;
                param.FechaHasta = oUltimoDiaDelMes;
                //var diaHabil = fnDiasNoHabiles(fechaCalendario, oPrimerDiaDelMes, oUltimoDiaDelMes);
                //if (diaHabil == "N")
                //{
                //    param.FechaHasta = resultado.FechaCierre;
                //}
                //else {
                //    param.FechaHasta = oUltimoDiaDelMes;
                //}
            }
            else
            {
                var diaHabil = fnDiasNoHabiles(Convert.ToDateTime(fechaCalendario.ToShortDateString()), oPrimerDiaDelMes, oUltimoDiaDelMes);
                if (diaHabil == "S")
                {
                    param.Finmes     = "N";
                    param.Fechadesde = param.FechaHasta = resultado.FechaCierre;
                }
                else
                {
                    eventLog.WriteEntry("Dia no Habil." + DateTime.Now.ToLocalTime().ToString());
                    return;
                }
            }

            //CONSULTA 2105 PF
            param.DiasIni = 0;
            eventLog.WriteEntry("Inicia Carga 2105 PF." + DateTime.Now.ToLocalTime().ToString());
            svc.CargarData2105PF(param, out resultado);

            if (resultado.Resultado != 0)
            {
                using (EventLog eventLog = new System.Diagnostics.EventLog("Application", Environment.MachineName, strSource))
                {
                    string errorRecibido = "ERROR EN EL PROCESO DE CARGA 2105 PF: " + "   " + resultado.Mensaje;
                    eventLog.WriteEntry(errorRecibido, EventLogEntryType.Error, 0);
                    errores.Add(errorRecibido);
                }
            }
            eventLog.WriteEntry("Fin Carga 2105 PF." + DateTime.Now.ToLocalTime().ToString());
            //CONSULTA 2103
            eventLog.WriteEntry("Inicia Carga 2103 PF." + DateTime.Now.ToLocalTime().ToString());
            param.DiasIni = 0;
            svc.CargarData2103(param, out resultado);

            if (resultado.Resultado != 0)
            {
                using (EventLog eventLog = new System.Diagnostics.EventLog("Application", Environment.MachineName, strSource))
                {
                    string errorRecibido = "ERROR EN EL PROCESO DE CARGA 2103: " + "   " + resultado.Mensaje;
                    eventLog.WriteEntry(errorRecibido, EventLogEntryType.Error, 0);
                    errores.Add(errorRecibido);
                }
            }
            eventLog.WriteEntry("Fin Carga 2103 PF." + DateTime.Now.ToLocalTime().ToString());

            //CONSULTA 2105
            eventLog.WriteEntry("Inicia Carga 2105 AHORRO." + DateTime.Now.ToLocalTime().ToString());
            param.Encaje = "S";
            svc.CargarData2105(param, out resultado);

            if (resultado.Resultado != 0)
            {
                using (EventLog eventLog = new System.Diagnostics.EventLog("Application", Environment.MachineName, strSource))
                {
                    string errorRecibido = "ERROR EN EL PROCESO DE CARGA 2105: " + "   " + resultado.Mensaje;
                    eventLog.WriteEntry(errorRecibido, EventLogEntryType.Error, 0);
                    errores.Add(errorRecibido);
                }
            }
            eventLog.WriteEntry("Fin Carga 2105 ahorro." + DateTime.Now.ToLocalTime().ToString());
            ////CONSULTA 2101

            eventLog.WriteEntry("Inicia Carga 2101 AHORRO." + DateTime.Now.ToLocalTime().ToString());
            svc.CargarData2101(param, out resultado);

            if (resultado.Resultado != 0)
            {
                using (EventLog eventLog = new System.Diagnostics.EventLog("Application", Environment.MachineName, strSource))
                {
                    string errorRecibido = "ERROR EN EL PROCESO DE CARGA 2101: " + "   " + resultado.Mensaje;
                    eventLog.WriteEntry(errorRecibido, EventLogEntryType.Error, 0);
                    errores.Add(errorRecibido);
                }
            }
            eventLog.WriteEntry("FIN Carga 2101 AHORRO." + DateTime.Now.ToLocalTime().ToString());

            //CONSULTA 210150
            eventLog.WriteEntry("Inicia Carga 210150 AHORRO." + DateTime.Now.ToLocalTime().ToString());
            svc.CargarData210105(param, out resultado);

            if (resultado.Resultado != 0)
            {
                using (EventLog eventLog = new System.Diagnostics.EventLog("Application", Environment.MachineName, strSource))
                {
                    string errorRecibido = "ERROR EN EL PROCESO DE CARGA 210150: " + "   " + resultado.Mensaje;
                    eventLog.WriteEntry(errorRecibido, EventLogEntryType.Error, 0);
                    errores.Add(errorRecibido);
                }
            }

            eventLog.WriteEntry("FIN Carga 210150 AHORRO." + DateTime.Now.ToLocalTime().ToString());

            //GENERAR LOG SI LA LISTA NO ESTA VACÍA
            if (errores.Count > 0)
            {
                System.IO.File.WriteAllLines(pathLog, errores);
                fnEnviarCorreo();
            }
        }