private CjCRDictionary<Int32, CjCRUnidadNegocio> GetUnidadesNegocioExecute(CjCRCredential credential)
        {
            Autenticate(credential);

            return AdoTemplate.Execute<CjCRDictionary<Int32, CjCRUnidadNegocio>>(delegate(DbCommand command)
            {
                CjCRDictionary<Int32, CjCRUnidadNegocio> unidadesNegocio = new CjCRDictionary<Int32, CjCRUnidadNegocio>();
                CjCRUnidadNegocio unidadNegocio;
                DbDataReader reader;

                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "PACJCCLSTRUnidadesNegocio";

                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    unidadNegocio = UnidadNegocioMapper.Get(reader,
                        CjCRUnidadNegocioMapper.BASIC_MODEL);

                    unidadesNegocio.Put(unidadNegocio.IdUnidadNegocio, unidadNegocio);
                }

                return unidadesNegocio;
            });
        }
        public CjCRCajaConfig GetCajaConfig(int folio, CjCRCredential credential)
        {
            CjCRCajaConfig cajaConfig = new CjCRCajaConfig(
                CjCRTurnadorStatus.MODULO_PROYECTO, folio);

            return CajaConfigDao.GetConfiguracion(cajaConfig, credential);
        }
        public CjCRSummary ConsultaCapacidad(String noEmpleado, CjCRCredential credential)
        {
            CjCREmpleadoPool empleado = PoolDao.GetPoolByEmpleado(noEmpleado, credential);
            int status = CjCRTurnadorStatus.UNIDAD_NEGOCIO_INACTIVA;
                CjCREmpleadoPool empleadoPool = new CjCREmpleadoPool();
                CjCRCualidadList cualidad = new CjCRCualidadList();
                CjCRSummary estado = new CjCRSummary();
                empleadoPool.NoEmpleado = noEmpleado;
                int unidadNegocioEmpleado = PoolDao.UnidadEmpleado(noEmpleado, credential);
                if (unidadNegocioEmpleado == CjCRTurnadorStatus.OPERATION_FAIL) {
                    status =  CjCRTurnadorStatus.OPERATION_FAIL;
                    return TurnadorSummaryFactory.Get(status);
                }
                CjCRDictionary<Int32, CjCRUnidadNegocio> unidadesNegocio = NegocioDao.GetUnidadesNegocio(credential);
                List<CjCRUnidadNegocio> unidadesNegocioList = unidadesNegocio.Values.ToList();

                foreach (CjCRUnidadNegocio i in unidadesNegocioList)
                {
                    if (i.IdUnidadNegocio == unidadNegocioEmpleado)
                    {
                        if (i.Estatus == 1)
                        {
                            status = CjCRTurnadorStatus.OPERATION_COMPLETE;
                        }
                        else
                        {
                            status = CjCRTurnadorStatus.UNIDAD_NEGOCIO_INACTIVA;
                        }
                    }

                }
                return TurnadorSummaryFactory.Get(status);
        }
        public int PuntoAtencion(String noEmpleado, String puntoatencion,String origen, CjCRCredential credential)
        {
            Autenticate(credential);
            return AdoTemplate.Execute<Int32>(delegate(DbCommand command)
            {
                int resultCode = CjCRTurnadorStatus.OPERATION_COMPLETE;
                DbDataReader reader;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "PACJCCLUTRPuntoAtencion";

                CjCRDaoUtils.AddParamNotNull(command, "@pcEmpNo", noEmpleado);
                CjCRDaoUtils.AddParamNotNull(command, "@pcPuntoAtencion", puntoatencion);
                CjCRDaoUtils.AddParamNotNull(command, "@pcOrigen", origen);

                try
                {
                    reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        resultCode = Convert.ToInt32(reader.GetByte(0));
                    }

                    return resultCode;
                }catch(Exception)
                {
                    return CjCRTurnadorStatus.EMPLEADO_INEXISTENTE ;
                }

            });
        }
        public List<CjCRUnidadNegocio> GetUnidadesNegocio(CjCRCredential credential)
        {
            CjCRDictionary<Int32, CjCRUnidadNegocio> unidadesNegocio =
                NegocioDao.GetUnidadesNegocio(credential);

            return new List<CjCRUnidadNegocio>(unidadesNegocio.Values);
        }
 public CjCRSummary CambiaPuntoAtencion(String noEmpleado, String puntoatencion, CjCRCredential credential)
 {
     string origen = "PuntoAtencion";
     int status = CjCRTurnadorStatus.EMPLEADO_INEXISTENTE;
     status = PoolDao.PuntoAtencion(noEmpleado, puntoatencion,origen, credential);
     return TurnadorSummaryFactory.Get(status);
 }
        public CjCRCajaConfig GetContingencia(CjCRCredential credential)
        {
            CjCRCajaConfig cajaConfig = GetPlanContingenciaConfig();

            cajaConfig = CajaConfigDao.GetConfiguracion(cajaConfig, credential);

            return cajaConfig;
        }
        public static void ClassInit(TestContext testContext)
        {
            CjCRSpringContext.Init(
                "assembly://Baz.Caja.Turnador/Baz.Caja.Turnador.resource.config/application-context.xml");

            DefaultCredential = CjCRSpringContext.Get<CjCRCredential>("DefaultCredential");
            NegocioService = CjCRSpringContext.Get<CjCRNegocioService>();
        }
        //public CjCRCredential GetCredential(Empleado empleado)
        //{
        //    CjCRCredential credential = new CjCRCredential();
        //    credential.User = empleado.Numero;
        //    credential.Password = empleado.Password;
        //    return credential;
        //}
        public CjCRCredential GetCredential(CjCRServiceToken serviceToken)
        {
            CjCRCredential credential = new CjCRCredential();

            credential.User = serviceToken.NumeroEmpleado;
            credential.Password = serviceToken.PasswordEmpleado;

            return credential;
        }
        private CjCRSummary ActualizarPlanContingencia(int action, CjCRCredential credential)
        {
            CjCRCajaConfig cajaConfig = GetPlanContingenciaConfig();
            int status;

            cajaConfig.Valor = action.ToString();
            status = CajaConfigDao.UpdateConfiguracion(cajaConfig, credential);

            return TurnadorSummaryFactory.Get(status);
        }
示例#11
0
        public CjCREmpleadoPool GetPoolByEmpleado(String noEmpleado, CjCRCredential credential)
        {
            List<CjCREmpleadoPool> pool = GetPool(POOL_BY_EMPLEADO, noEmpleado, 0, credential);

            if (pool.Count > 0)
            {
                return pool.First();
            }

            return default(CjCREmpleadoPool);
        }
        public static void ClassInit(TestContext testContext)
        {
            CjCRSpringContext.Init(
                "assembly://Baz.Caja.Turnador/Baz.Caja.Turnador.resource.config/application-context.xml",
                "assembly://Baz.Caja.Turnador.Test/Baz.Caja.Turnador.Test.resource.config/application-context-test.xml");

            DefaultCredential = CjCRSpringContext.Get<CjCRCredential>("DefaultCredential");
            TTurnadorLogic = CjCRSpringContext.Get<CjCTTurnadorLogic>();
            PoolDao = CjCRSpringContext.Get<CjCRPoolDao>();
            TTurnoXmlMapper = CjCRSpringContext.Get<CjCTTurnoXmlMapper>();
            TEmpleadoPoolXmlMapper = CjCRSpringContext.Get<CjCTEmpleadoPoolXmlMapper>();
        }
        public CjCRSummary ApropiarTurno(String noEmpleado, CjCRTurno turno, CjCRCredential credential)
        {
            CjCRSummary summary = TurnoValidator.Validate(
                turno, CjCRTurnoValidator.ESTADO_VALIDATION);

            if (summary.Complete)
            {
                summary = TurnosLogic.ApropiarTurno(noEmpleado, turno, credential);
            }

            return summary;
        }
        public CjCRSummary AtenderTurno(String noEmpleado, CjCRTurno turno, CjCRCredential credential)
        {
            string fecha = util.ValidarFecha("0");
            turno.Fecha = Int32.Parse(fecha);
            CjCRSummary summary = TurnoValidator.Validate(
                turno, CjCRTurnoValidator.ESTADO_VALIDATION);

            if (summary.Complete)
            {
                summary = TurnosLogic.AtenderTurno(noEmpleado, turno, credential);
            }

            return summary;
        }
        public static void ClassInit(TestContext testContext)
        {
            CjCRSpringContext.Init(
                "assembly://Baz.Caja.Turnador/Baz.Caja.Turnador.resource.config/application-context.xml",
                "assembly://Baz.Caja.Turnador.Test/Baz.Caja.Turnador.Test.resource.config/application-context-test.xml");

            DefaultCredential = CjCRSpringContext.Get<CjCRCredential>("DefaultCredential");
            TurnosService = CjCRSpringContext.Get<CjCRTurnosService>();
            TurnadorService = CjCRSpringContext.Get<CjCRTurnadorService>();
            CajaConfigDao = CjCRSpringContext.Get<CjCRCajaConfigDao>();
            TTurnadorLogic = CjCRSpringContext.Get<CjCTTurnadorLogic>();
            TTurnoXmlMapper = CjCRSpringContext.Get<CjCTTurnoXmlMapper>();
            TTurnoApropiadoXmlMapper = CjCRSpringContext.Get<CjCTTurnoApropiadoXmlMapper>();
        }
        public int ApropiarTurno(String noEmpleado, CjCRTurno turno,String origen, CjCRCredential credential)
        {
            int resultCode = CjCRTurnadorStatus.OPERATION_FAIL;

            try
            {
                resultCode = ApropiarTurnoExecute(noEmpleado, turno, origen, credential);
            }
            catch (Exception ex)
            {
                Log.Error(CjCRPropertyUtils.GetFormat("sentence.execution.error", ex.Message));
            }

            return resultCode;
        }
        public CjCRTurno AtenderVirtual(int idUnidadNegocio, String noEmpleado, CjCRCredential credential)
        {
            CjCRTurno turnoVirtual = default(CjCRTurno);

            try
            {
                turnoVirtual = AtenderVirtualExecute(idUnidadNegocio, noEmpleado, credential);
            }
            catch (Exception ex)
            {
                Log.Error(CjCRPropertyUtils.GetFormat("sentence.execution.error", ex.Message));
            }

            return turnoVirtual;
        }
        public CjCRDictionary<Int32, CjCRUnidadNegocio> GetUnidadesNegocio(CjCRCredential credential)
        {
            CjCRDictionary<Int32, CjCRUnidadNegocio> unidadesNegocio = new CjCRDictionary<Int32, CjCRUnidadNegocio>();

            try
            {
                unidadesNegocio = GetUnidadesNegocioExecute(credential);
            }
            catch (Exception ex)
            {
                Log.Error(CjCRPropertyUtils.GetFormat("sentence.execution.error", ex.Message));
            }

            return unidadesNegocio;
        }
        public CjCRUnidadNegocio GetUnidadNegocio(int idUnidadNegocio, CjCRCredential credential)
        {
            CjCRUnidadNegocio unidadNegocio = default(CjCRUnidadNegocio);

            try
            {
                unidadNegocio = GetUnidadNegocioExecute(idUnidadNegocio, credential);
            }
            catch (Exception ex)
            {
                Log.Error(CjCRPropertyUtils.GetFormat("sentence.execution.error", ex.Message));
            }

            return unidadNegocio;
        }
        public int CaducarTurnos(int idUnidadNegocio, CjCRCredential credential)
        {
            int resultCode = CjCRTurnadorStatus.OPERATION_FAIL;

            try
            {
                resultCode = CaducarTurnosExecute(idUnidadNegocio, credential);
            }
            catch (Exception ex)
            {
                Log.Error(CjCRPropertyUtils.GetFormat("sentence.execution.error", ex.Message));
            }

            return resultCode;
        }
        public CjCRSummary ApropiarTurno(String noEmpleado, CjCRTurno turno, CjCRCredential credential)
        {
            String origen = "Apropiar Turno";
            CjCREmpleadoPool empleadoPool = PoolDao.GetPoolByEmpleado(noEmpleado, credential);
            CjCRUnidadNegocio unidadNegocio;
            CjCRSummary summary;
            int status;
            turno.Estado = TurnosDao.GetTurno(turno, credential).Estado;
            if (empleadoPool != null)
            {
                if (empleadoPool.Cualidades.GetIdUnidadNegocio() != turno.IdUnidadNegocio)
                {
                    summary = TurnadorSummaryFactory.Get(CjCRTurnadorStatus.EMPLEADO_DIFERENTE_NEGOCIO);
                    unidadNegocio = NegocioDao.GetUnidadNegocio(turno.IdUnidadNegocio, credential);

                    summary.Detail = String.Format(summary.Detail, noEmpleado,
                        (unidadNegocio != default(CjCRUnidadNegocio) ? unidadNegocio.Descripcion : ""));

                    return summary;
                }

                if (turno.Estado != CjCRTurnadorStatus.TURNO_ASIGNADO
                        && turno.Estado != CjCRTurnadorStatus.TURNO_POSPUESTO)
                {
                    return TurnadorSummaryFactory.Get(CjCRTurnadorStatus.TURNO_ESTADO_INCORRECTO);
                }

                if (empleadoPool != default(CjCREmpleadoPool)
                    && (empleadoPool.Estado == CjCRTurnadorStatus.ATENCION_DISPONIBLE
                        || empleadoPool.Estado == CjCRTurnadorStatus.ATENCION_NO_DISPONIBLE))
                {
                    status = TurnosDao.ApropiarTurno(noEmpleado, turno,origen, credential);
                    return TurnadorSummaryFactory.Get(status);
                }
                else
                {
                    return TurnadorSummaryFactory.Get(CjCRTurnadorStatus.EMPLEADO_NO_DISPONIBLE);
                }
            }
            else { return TurnadorSummaryFactory.Get(CjCRTurnadorStatus.EMPLEADO_INEXISTENTE); }
        }
        private int ApropiarTurnoExecute(String noEmpleado, CjCRTurno turno,String origen, CjCRCredential credential)
        {
            Autenticate(credential);

            return AdoTemplate.Execute<Int32>(delegate(DbCommand command)
            {
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "PACJCCLUTRApropiar";

                CjCRDaoUtils.AddParamNotNull(command, "@piFecha", turno.Fecha);
                CjCRDaoUtils.AddParamNotNull(command, "@piTurno", turno.IdTurno);
                CjCRDaoUtils.AddParamNotNull(command, "@piUnidadNegocio", turno.IdUnidadNegocio);
                CjCRDaoUtils.AddParamNotNull(command, "@pcOrigen", origen);
                CjCRDaoUtils.AddParamNotNull(command, "@pcEmpleado", noEmpleado);

                command.ExecuteNonQuery();

                return CjCRTurnadorStatus.OPERATION_COMPLETE;
            });
        }
        private int CaducarTurnosExecute(int idUnidadNegocio, CjCRCredential credential)
        {
            Autenticate(credential);

            return AdoTemplate.Execute<Int32>(delegate(DbCommand command)
            {
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "PACJCCLUTRCaduca";

                CjCRDaoUtils.AddNullParam(command, "@piUnidadNegocio", idUnidadNegocio, CjCRDaoUtils.INT_NULL);

                command.ExecuteNonQuery();

                return CjCRTurnadorStatus.OPERATION_COMPLETE;
            });
        }
        private CjCRTurno AtenderVirtualExecute(int idUnidadNegocio, String noEmpleado, CjCRCredential credential)
        {
            Autenticate(credential);

            return AdoTemplate.Execute<CjCRTurno>(delegate(DbCommand command)
            {
                CjCRTurno turno = new CjCRTurno();

                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "PACJCCLITRAsignaVirtual";

                CjCRDaoUtils.AddParamNotNull(command, "@pcEmpleado", noEmpleado);
                CjCRDaoUtils.AddParamNotNull(command, "@piUnidadNegocio", idUnidadNegocio);

                CjCRDaoUtils.AddOutputParam(command, "@piTurno", CjCRDaoUtils.INT_SIZE);
                CjCRDaoUtils.AddOutputParam(command, "@piFecha", CjCRDaoUtils.INT_SIZE);
                CjCRDaoUtils.AddOutputParam(command, "@piStatus", CjCRDaoUtils.INT_SIZE);

                command.ExecuteNonQuery();

                turno.IdUnidadNegocio = idUnidadNegocio;
                turno.IdTurno = CjCRDaoUtils.GetInt32(command, "@piTurno", -1);
                turno.Fecha = CjCRDaoUtils.GetInt32(command, "@piFecha", -1);
                turno.Estado = CjCRDaoUtils.GetInt32(command, "@piStatus", -1);

                return turno;
            });
        }
        private int SetEstadoExecute(CjCRTurno turno, CjCRCredential credential)
        {
            Autenticate(credential);

            return AdoTemplate.Execute<Int32>(delegate(DbCommand command)
            {
                int resultCode = CjCRTurnadorStatus.OPERATION_FAIL;
                DbDataReader reader;

                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "PACJCCLUTRHistorico";

                CjCRDaoUtils.AddParamNotNull(command, "@piFecha", turno.Fecha);
                CjCRDaoUtils.AddParamNotNull(command, "@piTurno", turno.IdTurno);
                CjCRDaoUtils.AddParamNotNull(command, "@piUnidadNegocio", turno.IdUnidadNegocio);
                CjCRDaoUtils.AddParamNotNull(command, "@piEstatusTurno", turno.Estado);
                CjCRDaoUtils.AddParamNotNull(command, "@pcUser", credential.User);

                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    resultCode = reader.GetInt32(0);
                }

                return resultCode;
            });
        }
        private List<CjCRTurno> GetTurnosExecute(int fecha, int idUnidadNegocio, int estadoTurno,
            CjCRCredential credential)
        {
            Autenticate(credential);

            return AdoTemplate.Execute<List<CjCRTurno>>(delegate(DbCommand command)
            {
                List<CjCRTurno> turnos = new List<CjCRTurno>();
                CjCRTurno turno;
                DbDataReader reader;

                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "PACJCCLSTRTurnos";

                CjCRDaoUtils.AddNullParam(command, "@piFecha", fecha, CjCRDaoUtils.INT_NULL);
                CjCRDaoUtils.AddNullParam(command, "@piUndNeg", idUnidadNegocio, CjCRDaoUtils.INT_NULL);
                CjCRDaoUtils.AddNullParam(command, "@piEstatusTurno", estadoTurno, CjCRDaoUtils.INT_NULL);

                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    turno = TurnoMapper.Get(reader, CjCRTurnoMapper.BASIC_MODEL);

                    turnos.Add(turno);
                }

                return turnos;
            });
        }
        private CjCRTurno GetTurnoExecute(CjCRTurno turno, CjCRCredential credential)
        {
            Autenticate(credential);

            return AdoTemplate.Execute<CjCRTurno>(delegate(DbCommand command)
            {
                CjCRTurno turnoGet = default(CjCRTurno);
                DbDataReader reader;

                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "PACJCCLSTRTurno";
                //-------------------------------------------------------------------->
                CjCRDaoUtils.AddParamNotNull(command, "@piFecha", turno.Fecha);
                CjCRDaoUtils.AddParamNotNull(command, "@piTurno", turno.IdTurno);
                CjCRDaoUtils.AddParamNotNull(command, "@piUndNegocio", turno.IdUnidadNegocio);

                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    turnoGet = TurnoMapper.Get(reader, CjCRTurnoMapper.BASIC_MODEL);
                }

                return turnoGet;
            });
        }
        private CjCRTurno GenerarTurnoExecute(CjCRTurno turno, CjCRCredential credential)
        {
            Autenticate(credential);

            return AdoTemplate.Execute<CjCRTurno>(delegate(DbCommand command)
            {
                CjCRTurno turnoGenerado = new CjCRTurno();

                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "PACJCCLITRTurno";

                CjCRDaoUtils.AddParamNotNull(command, "@piOrigenTurno", turno.IdOrigen);
                CjCRDaoUtils.AddParamNotNull(command, "@piUndNegocio", turno.IdUnidadNegocio);
                CjCRDaoUtils.AddParamNotNull(command, "@piFilaId", FILA_VIRTUAL);
                CjCRDaoUtils.AddParamNotNull(command, "@piSeguimiento", turno.TurnoSeguimiento);
                CjCRDaoUtils.AddParamNotNull(command, "@pcUser", credential.User);

                CjCRDaoUtils.AddOutputParam(command, "@piTurno", CjCRDaoUtils.INT_SIZE);
                CjCRDaoUtils.AddOutputParam(command, "@piFecha", CjCRDaoUtils.INT_SIZE);

                command.ExecuteNonQuery();

                turnoGenerado.IdTurno = CjCRDaoUtils.GetInt32(command, "@piTurno", -1);
                turnoGenerado.Fecha = CjCRDaoUtils.GetInt32(command, "@piFecha", -1);

                turnoGenerado.IdOrigen = turno.IdOrigen;
                turnoGenerado.IdUnidadNegocio = turno.IdUnidadNegocio;
                turnoGenerado.TurnoSeguimiento = turno.TurnoSeguimiento;

                return turnoGenerado;
            });
        }
 public List<CjCRUnidadNegocio> GetUnidadesNegocio(CjCRCredential credential)
 {
     return NegocioLogic.GetUnidadesNegocio(credential);
 }
        private int CompletarTurnosExecute(CjCRCredential credential)
        {
            Autenticate(credential);

            return AdoTemplate.Execute<Int32>(delegate(DbCommand command)
            {
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "PACJCCLUTRAsigna";

                command.ExecuteNonQuery();

                return CjCRTurnadorStatus.OPERATION_COMPLETE;
            });
        }