private async void SendConnectOrder()
        {
            try
            {
                // Generamos un objeto de logica operador
                Logica.Operador logOper = new Logica.Operador();
                // Disponemos de una entidad operador
                Entidades.Operador entOper = new Entidades.Operador()
                {
                    UserName = txtUsername.Text,
                    Password = txtPassword.Password
                };
                // Consultamos a las capas de negocio para validar el ingreso
                Entidades.Operador operResponse = await logOper.ConnectBackoffice(entOper, App.Current.MainWindow as Entidades.Service.Interface.IServicioCallback);

                if (operResponse != null)
                {
                    Operador     = operResponse;
                    DialogResult = true;
                }
                else
                {
                    Util.MsgBox.Error("El usuario o la clave es incorrecta.");
                    logInPetition = false;
                }
            }
            catch (Exception ex)
            {
                Util.MsgBox.Error(ex.Message);
                logInPetition = false;
            }
        }
Exemple #2
0
 public frmAddAsunto(Entidades.Operador prmOperatorToSent)
 {
     InitializeComponent();
     ConfigurarCustomWindow();
     operatorToSent   = prmOperatorToSent;
     txtOperator.Text = operatorToSent.Nombre + " " + operatorToSent.Apellido;
 }
Exemple #3
0
 private void btnLoguear_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         // Generamos un objeto de logica operador
         Logica.Operador logOper = new Logica.Operador();
         // Disponemos de una entidad operador
         Entidades.Operador entOper = new Entidades.Operador()
         {
             UserName = txtUsername.Text,
             Password = txtPassword.Password
         };
         // Consultamos a las capas de negocio para validar el ingreso
         entOper = logOper.Ingresar(entOper);
         if (entOper != null)
         {
             Operador     = entOper;
             DialogResult = true;
         }
         else
         {
             Util.MsgBox.Error("El usuario o la clave es incorrecta.");
         }
     }
     catch (Exception ex)
     {
         Util.MsgBox.Error(ex.Message);
     }
 }
Exemple #4
0
 /// <summary>
 /// Valida con base de datos si el ingreso es correcto
 /// </summary>
 /// <param name="opIngresante"></param>
 /// <returns></returns>
 public static bool ValidarIngreso(Entidades.Operador opIngresante)
 {
     using (SQLiteConnection c = new SQLiteConnection(Conexion.Cadena))
     {
         c.Open();
         string sConsultaValidacion = "SELECT 1 FROM operadores WHERE username=@User COLLATE NOCASE and password=@Password";
         using (SQLiteCommand commValidacion = new SQLiteCommand(sConsultaValidacion, c))
         {
             commValidacion.Parameters.Agregar("@User", opIngresante.UserName);
             commValidacion.Parameters.Agregar("@Password", opIngresante.Password);
             // Ejecutamos el lector de validacion
             using (SQLiteDataReader rdrValidacion = commValidacion.ExecuteReader())
             {
                 if (rdrValidacion.Read())
                 {
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }
         }
     }
 }
Exemple #5
0
 /// <summary>
 /// Valida si el operador informado cuenta con permisos de backoffice
 /// </summary>
 /// <param name="pOperator"></param>
 /// <returns>Operador con datos completos, nulo si no es encontrado o no tiene permisos</returns>
 public static Entidades.Operador ValidateBackofficeOperator(Entidades.Operador pOperator)
 {
     // El operador de backoffice es inicializado como nulo
     Entidades.Operador backofficeOperator = null;
     using (SQLiteConnection c = new SQLiteConnection(Conexion.Cadena))
     {
         c.Open();
         string strFillBackofficUserData = "SELECT nombre, apellido, dni from operadores where username=@Username and password=@Password and backoffice=1";
         using (SQLiteCommand cmdFillBackofficeUserData = new SQLiteCommand(strFillBackofficUserData, c))
         {
             // Agregamos el parametro de usuario y contraseña
             cmdFillBackofficeUserData.Parameters.Agregar("@Username", pOperator.UserName);
             cmdFillBackofficeUserData.Parameters.Agregar("@Password", pOperator.Password);
             using (SQLiteDataReader rdrBackofficeData = cmdFillBackofficeUserData.ExecuteReader())
             {
                 // Read the possible results of query
                 if (rdrBackofficeData.Read())
                 {
                     // Load all properties related to operator
                     backofficeOperator = new Entidades.Operador()
                     {
                         UserName = pOperator.UserName,
                         Password = pOperator.Password,
                         Nombre   = rdrBackofficeData["nombre"].ToString(),
                         Apellido = rdrBackofficeData["apellido"].ToString(),
                         DNI      = rdrBackofficeData["dni"].ToString()
                     };
                 }
             }
         }
     }
     // Return the operator value
     return(backofficeOperator);
 }
        private async void btnLoadBatchAsuntos_Click(object sender, RoutedEventArgs e)
        {
            try {
                List <Entidades.Asunto> lstToDistribute;
                if (!bllSelectedOnly)
                {
                    CheckLoadedUsersInAsunto();
                    lstToDistribute = lstAsuntoToAssign.ToList();
                }
                else
                {
                    isOneOperatorLoaded();
                    lstToDistribute = lstAsuntoToAssign.Where(asunto => asunto.Oper != null).ToList();
                }
                // Set sending time to current
                DateTime dtSendingTime = DateTime.Now;
                // On all filtered asuntos save sending date
                lstToDistribute.ForEach(asunto => asunto.SendingDate = dtSendingTime);
                // Generate a new logic asunto object
                Logica.Asunto      logAsunto      = new Logica.Asunto();
                Entidades.Operador currBackOffice = App.Current.Properties["user"] as Entidades.Operador;
                // Call for asunto distribution in batch
                await logAsunto.SentBatchAsuntoToOperators(currBackOffice, lstToDistribute);

                // Update balance with asuntos sented
                lstToDistribute.ForEach(asuntoToDeliver => currentBalanceFromOperators.Increment(asuntoToDeliver));
                currentBalanceFromOperators.UpdateAverage();
                // Refresh report of caller method
                (Owner as frmBackoffice).RefreshReportBalanceCurrentDay();
                Util.MsgBox.Error("Completado correctamente");
            }
            catch (Exception ex) {
                Except.Throw(ex);
            }
        }
Exemple #7
0
        /// <summary>
        /// Consulta la base de datos filtrando según número de asunto
        /// Fecha de creación : 05/07/2018
        /// Autor : Maximiliano Leiva
        /// </summary>
        /// <param name="pOper"></param>
        /// <param name="pTextoFiltro"></param>
        /// <returns></returns>
        public DataTable GetFilteredByNumber(Entidades.Operador pOper, string pTextoFiltro)
        {
            // Generamos la DataTable a procesar
            DataTable dtResultado = new DataTable();

            try
            {
                // Establecemos el valor del condicional de la vista
                _condicionalVistaEstadoAsunto = "num_asunto LIKE '3000" + pTextoFiltro + "%' and oper=@Oper";
                // Generamos el adaptador de datos para filtrar el asunto
                using (SQLiteDataAdapter adtListadoAsuntoFiltrado = new SQLiteDataAdapter(_consultaVistaEstadoAsunto, Conexion.Cadena))
                {
                    // Parametrizamos la consulta
                    adtListadoAsuntoFiltrado.SelectCommand.Parameters.Agregar("@Oper", pOper.UserName);
                    // Llenamos el DataTable con los datos indicados
                    adtListadoAsuntoFiltrado.Fill(dtResultado);
                }
            }
            catch (Exception)
            {
                throw new Exception("Error al procesar la consulta filtrada de asuntos.");
            }
            // Devolvemos la tabla procesada
            return(dtResultado);
        }
Exemple #8
0
 /// <summary>
 /// Sent asunto in batch to a cliente
 ///
 /// </summary>
 /// <param name="lstAsuntoToSent"></param>
 private async void SentAsuntoToOperator(List <Entidades.Asunto> lstAsuntoToSent)
 {
     try {
         await Task.Run(() =>
         {
             try {
                 if (lstAsuntoToSent.Count == 1)
                 {
                     // Get asunto to sent
                     Entidades.Asunto asuntoToSent = lstAsuntoToSent[0];
                     // Sent callback to operator
                     getCallback(asuntoToSent.Oper).EnviarAsunto(asuntoToSent);
                 }
                 else if (lstAsuntoToSent.Count > 1)
                 {
                     // Get operator from list
                     Entidades.Operador operToSent = lstAsuntoToSent[0].Oper;
                     // Sent a batch with the list of asuntos
                     getCallback(operToSent).SentAsuntosBatch(lstAsuntoToSent);
                 }
             } catch (Exception ex) {
                 Log.Error("AsuntosPendingDelivery-SentAsunto", ex.Message);
             }
         }).TimeoutAfter(2000);
     }
     catch (TimeoutException) { }
     catch (Exception ex) {
         Log.Error("AsuntosPendingDelivery-SentAsunto", ex.Message);
     }
 }
Exemple #9
0
 private void btnConfirm_Click(object sender, RoutedEventArgs e)
 {
     try {
         // Prepares new entity to travel to service
         Entidades.Asunto newAsunto = new Entidades.Asunto()
         {
             Numero                = txtAsuntoNumber.Text,
             DescripcionBreve      = txtShortDescription.Text,
             Oper                  = operatorToSent,
             isCreatedByBackoffice = true
         };
         // Generates a new logic asunto object
         Logica.Asunto logAsunto = new Logica.Asunto();
         // Gets operator logged on application
         Entidades.Operador backofficeOperator = App.Current.Properties["user"] as Entidades.Operador;
         // Calls a sent method
         logAsunto.SentAsuntoToOperator(backofficeOperator, newAsunto);
         // Set property on public property
         confirmedNewAsunto = newAsunto;
         // Sets result to true
         DialogResult = true;
     }
     catch (Exception ex) {
         Except.Throw(ex);
     }
 }
Exemple #10
0
 /// <summary>
 /// Validates if the operator is connected
 /// </summary>
 /// <param name="pOper"></param>
 private bool isOperatorLoggedIn(Entidades.Operador pOper)
 {
     // TODO : new implementation required.
     // 1 - Check if in some moment the operator has been logged
     // 2 - Check if the operator connection is live
     // 3 - Return result
     return(true);
 }
Exemple #11
0
 /// <summary>
 /// Sent to client service object a request for distribute a batch of asuntos
 /// </summary>
 /// <param name="prmBackofficeSender"></param>
 /// <param name="prmListOfAsunto"></param>
 public async Task SentBatchAsuntoToOperators(Entidades.Operador prmBackofficeSender, List <Entidades.Asunto> prmListOfAsunto)
 {
     try {
         await Client.Instance.SentBatchAsuntoToOperators(prmBackofficeSender, prmListOfAsunto);
     } catch (Exception ex) {
         throw ex;
     }
 }
Exemple #12
0
        /// <summary>
        /// Procesa una solicitud al servicio para poder obtener las credenciales completas
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        public async Task <Entidades.Operador> LogOnServiceBackoffice(Entidades.Operador operatorToLog, Entidades.Service.Interface.IServicioCallback paramCallback)
        {
            // Generamos un operador para procesar
            Entidades.Operador operatorProcess = await Client.Instance.ConnectBackoffice(operatorToLog, paramCallback);

            // Devolvemos el valor procesado
            return(operatorProcess);
        }
Exemple #13
0
 /// <summary>
 /// Process a request to sent asunto to the service for distribution
 /// </summary>
 /// <param name="prmBackofficeSender">Backoffice who calls sent</param>
 /// <param name="prmAsuntoToSent">Asunto to sent</param>
 public async void SentAsuntoToOperator(Entidades.Operador prmBackofficeSender, Entidades.Asunto prmAsuntoToSent)
 {
     try {
         await datAsunto.SentAsuntoToOperator(prmBackofficeSender, prmAsuntoToSent);
     }
     catch (Exception ex) {
         Except.Throw(ex);
     }
 }
Exemple #14
0
 /// <summary>
 /// Sent a client of the service a petition to add in queue al asunto
 /// </summary>
 /// <param name="prmBackofficeSender"></param>
 /// <param name="prmAsuntoToSent"></param>
 public async Task SentAsuntoToOperator(Entidades.Operador prmBackofficeSender, Entidades.Asunto prmAsuntoToSent)
 {
     try {
         await Client.Instance.SentAsuntoToOperator(prmBackofficeSender, prmAsuntoToSent);
     }
     catch (Exception ex) {
         Except.Throw(ex);
     }
 }
 /// <summary>
 /// Sent a signal for service disconnection
 /// </summary>
 /// <param name="pOperator">Operator to disconnect</param>
 /// <returns></returns>
 public async Task DisconnectFromService(Entidades.Operador pOperator)
 {
     try {
         // Sent to data information of disconnected operator
         await datOper.DisconnectFromService(pOperator);
     }
     catch (Exception ex) {
         throw ex;
     }
 }
Exemple #16
0
 /// <summary>
 /// Sent a request to service for changing current status on the service
 /// </summary>
 /// <param name="pOperator"></param>
 /// <param name="newStatus"></param>
 /// <returns></returns>
 public async Task ChangeCurrentStatus(Entidades.Operador prmOper, Entidades.AvailabiltyStatus newStatus)
 {
     try {
         // Sent to proxy interface to change status
         await Client.Instance.ChangeCurrentStatus(prmOper, newStatus);
     }
     catch (Exception ex) {
         throw ex;
     }
 }
Exemple #17
0
 /// <summary>
 /// Sent petition for desconnection from service
 /// </summary>
 /// <param name="pOperator">Operator to disconnect</param>
 public async Task DisconnectFromService(Entidades.Operador pOperator)
 {
     try {
         // Calls to disconnect from the service
         await Client.Instance.DisconnectOperator(pOperator);
     }
     catch (Exception ex) {
         throw ex;
     }
 }
 /// <summary>
 /// Sent a request to service for changing current status on the service
 /// </summary>
 /// <param name="pOperator"></param>
 /// <param name="newStatus"></param>
 /// <returns></returns>
 public async Task ChangeCurrentStatus(Entidades.Operador prmOper, Entidades.AvailabiltyStatus newStatus)
 {
     try {
         // Sents to data the request to change status
         await datOper.ChangeCurrentStatus(prmOper, newStatus);
     }
     catch (Exception ex) {
         throw ex;
     }
 }
Exemple #19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="paramOperator"></param>
 /// <returns></returns>
 internal IServicioCallback getCallback(Entidades.Operador paramOperator)
 {
     try {
         return(lstConnectedClients.First((client) => client.Operator.UserName == paramOperator.UserName).Callback);
         // TODO : Need to check if the operator is already connected with short timeout
     }
     catch (Exception) {
         throw new Exception(string.Format(Error.CALLBACK_RELATED_WITH_OPERATOR_NOTFOUND, paramOperator.UserName));
     }
 }
 /// <summary>
 /// Valida los datos pasados por parametros sobre la base de datos
 /// </summary>
 /// <param name="pUser"></param>
 /// <param name="pPass"></param>
 /// <returns></returns>
 public Entidades.Operador Ingresar(Entidades.Operador pOperador)
 {
     try
     {
         return(datOper.Ingresar(pOperador));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #21
0
 /// <summary>
 /// Trae un listado de asuntos filtrado segun el texto que haya sido pasado por parametro
 /// Fecha de creación : 05/07/2018
 /// Autor : Maximiliano Leiva
 /// </summary>
 /// <param name="pOper"></param>
 /// <param name="pTextoFiltro"></param>
 /// <returns></returns>
 public DataTable getFilteredByNumber(Entidades.Operador pOper, string pTextoFiltro)
 {
     try
     {
         return(datAsunto.GetFilteredByNumber(pOper, pTextoFiltro));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 /// <summary>
 /// Procesa una solicitud de conexión. Si el proceso es correcto la entidad operador viene completa
 /// </summary>
 /// <param name="pOperator"></param>
 /// <returns></returns>
 public async Task <Entidades.Operador> ConnectBackoffice(Entidades.Operador pOperator, Entidades.Service.Interface.IServicioCallback paramCallback)
 {
     try
     {
         return(await datOper.LogOnServiceBackoffice(pOperator, paramCallback));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #23
0
 /// <summary>
 /// Sent a request to service for connection to the service
 /// </summary>
 /// <param name="paramOperator"></param>
 /// <param name="paramCallback"></param>
 /// <returns>True if the connections succeds. False when connection is rejected</returns>
 public async Task <bool> ConnectOperatorToService(Entidades.Operador paramOperator, Entidades.Service.Interface.IServicioCallback paramCallback)
 {
     try
     {
         // Returns the getted value from service
         return(await Client.Instance.ConnectOperator(paramOperator, paramCallback));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #24
0
 /// <summary>
 /// Trae asuntos por periodo
 /// </summary>
 /// <param name="iMes"></param>
 /// <param name="iAno"></param>
 /// <param name="pOper"></param>
 /// <returns></returns>
 public DataTable GetByPeriod(int iMes, int iAno, Entidades.Operador pOper)
 {
     try
     {
         // Regresamos el valro obtenido
         return(datAsunto.GetByPeriod(iMes, iAno, pOper));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 /// <summary>
 /// Sent a connection request to service.
 /// </summary>
 /// <param name="pOperator"></param>
 /// <param name="paramCallback"></param>
 /// <returns>true if the connection is established, false if rejected</returns>
 public async Task <bool> ConnectOperatorToService(Entidades.Operador pOperator, Entidades.Service.Interface.IServicioCallback paramCallback)
 {
     try
     {
         // Calls Datos Project for get the results from service
         return(await datOper.ConnectOperatorToService(pOperator, paramCallback));
     }
     catch (Exception ex)
     {
         // Bubbles the exception to the next level
         throw ex;
     }
 }
Exemple #26
0
        /// <summary>
        /// Consulta a la base de datos por los asuntos que corresponden al dia de la fecha
        /// Fecha de creación : 07/06/2018
        /// Autor : Maximiliano Leiva
        /// </summary>
        /// <returns></returns>
        public List <Entidades.Asunto> GetCurrentDayList(Entidades.Operador pOper)
        {
            // Generamos la lista a devolver
            List <Entidades.Asunto> lstAsuntoDiario = new List <Entidades.Asunto>();

            // Generamos el objeto de conexión despachable
            using (SQLiteConnection c = new SQLiteConnection(Conexion.Cadena))
            {
                // Abrimos la conexión
                c.Open();
                // Creamos el comando despachable
                using (SQLiteCommand cmdConsultaAsuntosDia = new SQLiteCommand(_consultaAsuntosDiarios, c))
                {
                    // Cargamos el parametro de operador
                    cmdConsultaAsuntosDia.Parameters.Agregar("@Operador", pOper.UserName);
                    // Ejecutamos el lector de asuntos
                    using (SQLiteDataReader rdrLectorAsunto = cmdConsultaAsuntosDia.ExecuteReader())
                    {
                        // Leemos los resultados obtenidos del lector
                        while (rdrLectorAsunto.Read())
                        {
                            // Generamos una nueva entidad de asunto, donde almacenaremos los diferentes estados recolectados
                            Entidades.Asunto entAsuntoDiario = new Entidades.Asunto();
                            // Almacenamos el número y el operador sobre el asunto
                            entAsuntoDiario.Oper   = pOper;
                            entAsuntoDiario.Numero = rdrLectorAsunto["numero"].ToString();
                            // Traemos los estados del asunto recorrido
                            entAsuntoDiario.Estados = EstadoAsunto.TraerListaEstadosPorAsunto(entAsuntoDiario);
                            // Consultamos si el asunto es reportable
                            using (SQLiteCommand cmdAsuntoReportable = new SQLiteCommand(_consultaReportable, c))
                            {
                                cmdAsuntoReportable.Parameters.Agregar("@Numero", rdrLectorAsunto["numero"].ToString());
                                cmdAsuntoReportable.Parameters.Agregar("@Operador", pOper.UserName);
                                // Ejecutamos el lector y averiguamos si es verdadera la consulta
                                using (SQLiteDataReader rdrReportable = cmdAsuntoReportable.ExecuteReader())
                                {
                                    // Si devuelve respuesta se asigna verdadero a reportable
                                    if (rdrReportable.Read())
                                    {
                                        entAsuntoDiario.Reportable = true;
                                    }
                                }
                            }
                            lstAsuntoDiario.Add(entAsuntoDiario);
                        }
                    }
                }
            }
            // Devolvemos la lista procesada
            return(lstAsuntoDiario);
        }
Exemple #27
0
 /// <summary>
 /// Check if the operator is loaded in database
 /// </summary>
 /// <param name="prmOperatorToValidate"></param>
 /// <returns></returns>
 public static bool Exist(Entidades.Operador prmOperatorToValidate)
 {
     using (SQLiteConnection c = new SQLiteConnection(Conexion.Cadena)) {
         c.Open();
         string sQueryOperatorExistence = "SELECT 1 from operadores where UserName=@Operator";
         using (SQLiteCommand cmdQueryOperatorExistence = new SQLiteCommand(sQueryOperatorExistence, c)) {
             cmdQueryOperatorExistence.Parameters.Agregar("@Operator", prmOperatorToValidate.UserName);
             using (SQLiteDataReader rdrQueryOperatorExistence = cmdQueryOperatorExistence.ExecuteReader()) {
                 if (rdrQueryOperatorExistence.Read())
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Exemple #28
0
 /// <summary>
 /// Consulta a la base de datos con los datos brindados
 /// </summary>
 /// <param name="pUser"></param>
 /// <param name="pPass"></param>
 /// <returns>Nulo si los datos ingresados no concuerdan con los registros de la base de datos</returns>
 public Entidades.Operador Ingresar(Entidades.Operador pOperador)
 {
     // Generamos la entidad con valor nulo
     Entidades.Operador entOper = null;
     try
     {
         // Generamos el objeto de conexión
         using (SQLiteConnection c = new SQLiteConnection(Conexion.Cadena))
         {
             // Abrimos la conexión
             c.Open();
             // Generamos el string que se usará en la consulta
             string sConsultaUsuario = "SELECT nombre, apellido, DNI FROM operadores where username=@Operador and password=@Password";
             // Preparamos el comando a ejecutar
             using (SQLiteCommand cmdConsultaUsuario = new SQLiteCommand(sConsultaUsuario, c))
             {
                 // Parametrizamos el comando
                 cmdConsultaUsuario.Parameters.Agregar("@Operador", pOperador.UserName);
                 cmdConsultaUsuario.Parameters.Agregar("@Password", pOperador.Password);
                 // Ejecutamos el lector
                 using (SQLiteDataReader rdrLectorUsuario = cmdConsultaUsuario.ExecuteReader())
                 {
                     // Si hay resultado se carga el objeto operador
                     if (rdrLectorUsuario.Read())
                     {
                         // Generamos una nueva entidad operador
                         entOper = new Entidades.Operador()
                         {
                             UserName = pOperador.UserName,
                             Nombre   = rdrLectorUsuario["nombre"].ToString(),
                             Password = pOperador.Password,
                             Apellido = rdrLectorUsuario["apellido"].ToString(),
                             DNI      = rdrLectorUsuario["DNI"].ToString()
                         };
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Ha ocurrido un error al recolectar la información en la base de datos: " + ex.Message);
     }
     // Devolvemos el elemento procesado
     return(entOper);
 }
Exemple #29
0
        /// <summary>
        /// Por solicitud trae filtrado los registros cargados por mes y año
        /// </summary>
        /// <param name="iMonth">Mes de registro</param>
        /// <param name="iYear">Año de registro</param>
        /// <param name="pOper">Operador que ejecuta la consulta</param>
        public DataTable GetByPeriod(int iMonth, int iYear, Entidades.Operador pOper)
        {
            // Generamos una lista que devolveremos al final del recorrido
            DataTable dtResult = new DataTable();

            // Abrimos la consulta con control de errores
            try
            {
                _condicionalVistaEstadoAsunto = "ae.fechaHora BETWEEN @PeriodoInicio AND @PeriodoFin and a.operador = @Oper";
                // Modo con vistas, se deshabilita por ser mas performante el filtrado directo
                // String sConsultaEstados = "SELECT * FROM VistaEstadoAsuntosRecientes WHERE ultima_fecha BETWEEN @PeriodoInicio AND @PeriodoFin and oper = @Oper";
                using (SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(_consultaVistaEstadoAsunto, Conexion.Cadena))
                {
                    // Parametrizamos los datos a utilizar
                    DateTime dtPeriodoInicio = new DateTime(iYear, iMonth, 1).AddDays(-1);
                    DateTime dtPeriodoFinal  = new DateTime(iYear, iMonth, 1).AddMonths(1);
                    dataAdapter.SelectCommand.Parameters.Add(new SQLiteParameter()
                    {
                        ParameterName = "@PeriodoInicio",
                        Value         = Util.SQLite.FormatearFecha(dtPeriodoInicio),
                        DbType        = DbType.DateTime
                    });
                    dataAdapter.SelectCommand.Parameters.Add(new SQLiteParameter()
                    {
                        ParameterName = "@PeriodoFin",
                        Value         = Util.SQLite.FormatearFecha(dtPeriodoFinal),
                        DbType        = DbType.DateTime
                    });
                    dataAdapter.SelectCommand.Parameters.Add(new SQLiteParameter()
                    {
                        ParameterName = "@Oper",
                        Value         = pOper.UserName,
                        DbType        = DbType.String
                    });
                    dataAdapter.Fill(dtResult);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Ha ocurrido un error al intentar traer los estados: " + e.Message);
            }
            return(dtResult);
        }
Exemple #30
0
        /// <summary>
        /// Runs a Simulation of incrementing asuntos and automatic assign asuntos
        /// </summary>
        /// <param name="lstAsuntosToAssign"></param>
        /// <param name="lstOperatorsToAssignate"></param>
        public void GetAutomaticAsuntoAssignationByAverageHour(List <Entidades.Asunto> lstAsuntosToAssign, List <Entidades.Operador> lstOperatorsToAssignate)
        {
            // Get balance list based on parameter operators
            List <Entidades.Balance> lstBalanceFilteredByOperatorInParameter = List.Where(balance =>
                                                                                          lstOperatorsToAssignate.Exists(
                                                                                              oper => oper.Equals(balance.UserName)
                                                                                              )).ToList();

            // Start Simulation status over filtered balance
            lstBalanceFilteredByOperatorInParameter.ForEach(balance => balance.InitSimulation());
            // Iterates over all asuntos passed by parameter
            foreach (var asuntoToAssign in lstAsuntosToAssign)
            {
                // Get operator ordered by balance
                Entidades.Balance selectedBalance = lstBalanceFilteredByOperatorInParameter.OrderBy(balance => balance.SimulationAverageAsuntoByHour).First();
                // Get operator Related to balance
                Entidades.Operador selectedOperator = lstOperatorsToAssignate.Find(oper => oper.Equals(selectedBalance.UserName));
                // Assign operador to asunto
                asuntoToAssign.Oper = selectedOperator;
                // Increment simulation Balance
                selectedBalance.SimulateAverageIncrementingByOne();
            }
        }