Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("id,motivo,tipo,estaResuelto")] Asunto asunto)
        {
            if (id != asunto.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(asunto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AsuntoExists(asunto.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(asunto));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parametros relacionados con el comando
        /// Operador : nombre de usuario del operador que recibira el asunto
        /// Numero : Correspondiente al asunto a generar sobre la UI del operador
        /// Descripcion : Contenido de descripcion breve del asunto
        /// </summary>
        /// <param name="parameters"></param>
        internal override void loadAndCheckparameters(string[] parameters)
        {
            // Si los parametros pasados por consola son menores a 3, se rechaza la generación del comando.
            if (parameters.Length < 3)
            {
                throw new Exception("usage : gestion [operator] [asunto_number] [short_description]");
            }
            // Subdividimos los parametros
            string        strOperator   = parameters[0];
            string        strNumero     = parameters[1];
            StringBuilder sbDescription = new StringBuilder();

            // Almacenamos los valores desde la posicion 3 hacia adelante para la descripción breve
            foreach (var strWordShortDescription in parameters.Skip(2).ToArray())
            {
                // Agregamos cada palabra a la descripción breve
                sbDescription.Append(strWordShortDescription + " ");
            }
            // Generamos un nuevo asunto y almacenamos la información guardada
            Asunto = new Asunto()
            {
                Numero = strNumero, Oper = new Operador()
                {
                    UserName = strOperator
                }, DescripcionBreve = sbDescription.ToString()
            };
        }
Ejemplo n.º 3
0
    public Asunto[] asuntos()
    {
        SQLiteCommand cmd = new SQLiteCommand(G.conexion_principal);

        cmd.CommandText = "SELECT texto, id FROM Asunto WHERE usuario_id = ? order by cant_veces_usado desc, fecha_creacion desc";
        SQLiteParameter param = new SQLiteParameter();

        cmd.Parameters.Add(param);
        param.Value = this.ID;
        SQLiteDataReader dr = cmd.ExecuteReader();

        List <Asunto> lista_asuntos = new List <Asunto>();

        while (dr.Read())
        {
            Asunto asunto = new Asunto();
            asunto.__texto = dr.GetString(0);
            asunto.__id    = dr.GetInt32(1);
            lista_asuntos.Add(asunto);
        }

        dr.Close();
        dr.Dispose();
        cmd.Dispose();

        return(lista_asuntos.ToArray());
    }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (txtTexto.Text.Length == 0)
            {
                lblAsuntoVacio.Visible = true;
                panel1.BackColor       = Color.Red;
                return;
            }
            lblAsuntoVacio.Visible = false;
            panel1.BackColor       = Color.White;

            Asunto asunto = new Asunto();

            asunto.__texto = txtTexto.Text;

            if (ID == 0) //agregue
            {
                G.user.agregar_asunto(asunto);
            }
            else //modifique
            {
                asunto.__id = ID;
                G.user.modificar_asunto(asunto);
            }

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
Ejemplo n.º 5
0
 public void AsuntoReceiptCompleted(Asunto asuntoToConfirm)
 {
     // Update Callback from client
     CheckAndUpdateCallbackOperator(getClientByOperator(asuntoToConfirm.Oper), CurrentCallback);
     // Confirm asunto receipt
     ConfirmAsuntoReceipt(asuntoToConfirm);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Process a request from the service for new asunto
 /// </summary>
 /// <param name="a"></param>
 private void newAsuntoFromService(Asunto a)
 {
     try {
         // Generamos un objeto de logica para procesar el agregado de los asuntos
         Logica.Asunto logAsunto = new Logica.Asunto();
         // Gestionamos una variable operador disponible para el método
         Operador operLogged = App.Current.Properties["user"] as Operador;
         // Si el operador al que era destino de este asunto no es el logueado, se lanza una excepción
         if (a.Oper.UserName != operLogged.UserName)
         {
             throw new Exception("Se ha recibido un asunto de un operador erroneo. Informar al administrador. Asunto: " + a.Numero + ". Operador: " + a.Oper.UserName);
         }
         // TODO : A modo de prueba inicial, el primer estado lo generamos en la capa de presentación. Esto debería ser generado en el servicio, para mantener fidelidad con el horario de entrada del asunto en bandeja
         generateInitialStatusOfAsunto(a);
         // Consultamos si el asunto en cuestion existe en la base de datos del operador
         if (!logAsunto.Exist(a))
         {
             // Si no existe, se agrega a la base de datos
             logAsunto.Add(a);
             // Actualizamos la capa de presentación y los casos diarios
             NotifyUIOfNewAsunto(a.Numero, false);
         }
     }
     catch (Exception ex) {
         Except.Throw(ex);
     }
 }
Ejemplo n.º 7
0
    public Asunto getAsunto(int id)
    {
        SQLiteCommand cmd = new SQLiteCommand(G.conexion_principal);

        cmd.CommandText = "SELECT usuario_id, texto, cant_veces_usado FROM Asunto WHERE id = ?";
        SQLiteParameter param = new SQLiteParameter();

        cmd.Parameters.Add(param);
        param.Value = id;
        SQLiteDataReader dr = cmd.ExecuteReader();

        Asunto asunto = new Asunto();

        try
        {
            if (!dr.Read())
            {
                throw new Exception("...");
            }

            asunto.__id               = dr.GetInt32(0);
            asunto.__texto            = dr.GetString(1);
            asunto.__cant_veces_usado = dr.GetInt32(2);
            asunto.__id               = id;
        }
        finally
        {
            dr.Close();
            dr.Dispose();
            cmd.Dispose();
        }

        return(asunto);
    }
        public async Task <IActionResult> Create(
            [Bind("fecha,correlativo,duracion")] Actividad actividad,
            [Bind("id,motivo,tipo,estaResuelto")] Asunto asunto)
        {
            ModelState.Remove("usuarioAppId");
            //TryValidateModel(actividad);
            if (ModelState.IsValid)
            {
                var transaction = _context.Database.BeginTransaction();
                try {
                    var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
                    actividad.usuarioAppId = userId;
                    //ha proporcionado asuntoId por tanto simplemente registrar
                    if (asunto.id > 0)
                    {
                        actividad.asuntoId = asunto.id;
                        Asunto asuntoLocal = await _context.Asuntos.Where(asu => asu.id == asunto.id)
                                             .FirstOrDefaultAsync();

                        if (asuntoLocal == null)
                        {
                            throw new Exception("Asunto no encontrado");
                        }
                        //solo puede cambiar el motivo y puede marcarlo como resuelto
                        asuntoLocal.motivo       = asunto.motivo;
                        asuntoLocal.estaResuelto = asunto.estaResuelto;
                        actividad.estaResuelto   = asunto.estaResuelto;
                        _context.Update(asuntoLocal);
                        _context.Add(actividad);
                    }
                    else
                    {
                        _context.Add(asunto);
                        await _context.SaveChangesAsync();

                        actividad.estaResuelto = asunto.estaResuelto;
                        actividad.asuntoId     = asunto.id;
                        _context.Add(actividad);
                    }
                    await _context.SaveChangesAsync();

                    transaction.Commit();
                    return(RedirectToAction(nameof(Index)));
                }catch (Exception e) {
                    transaction.Rollback();
                    ViewData["Error"] = e.Message;
                    return(View());
                }
            }
            var errors = ModelState.Values.SelectMany(v => v.Errors);

            ViewData["asuntoId"]     = new SelectList(_context.Asuntos, "id", "id", actividad.asuntoId);
            ViewData["usuarioAppId"] = new SelectList(_context.UsuariosApp, "Id", "Id", actividad.usuarioAppId);
            return(View(actividad));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Create([Bind("id,motivo,tipo,estaResuelto")] Asunto asunto)
        {
            if (ModelState.IsValid)
            {
                _context.Add(asunto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(asunto));
        }
        public asunto_new_update(int id, RichForm form_padre_actual)
        {
            InitializeComponent();
            form_padre = form_padre_actual;

            if (id > 0)
            {
                Asunto asunto = G.user.getAsunto(id);
                txtTexto.Text = asunto.Texto;

                this.Text = "Modificar asunto";
            }
            ID = id;
        }
Ejemplo n.º 11
0
        public Tarea(string plantilla, string creadoPor, DateTime fechaCreacion, params string[][] parametros)
        {
            try
            {
                var xmlConfiguration = new XmlDocument();

                var configFileInfo = new FileInfo(plantilla);

                //if (!configFileInfo.Exists)
                //    throw new Exception($"El archivo no existe {plantilla}");

                if (configFileInfo.Exists)
                {
                    xmlConfiguration.Load(configFileInfo.FullName);

                    // subject
                    var xpath    = @"task/subject";
                    var nSubject = xmlConfiguration.SelectSingleNode(xpath);

                    if (nSubject == null)
                    {
                        throw new Exception($"Seccion {xpath} no existe");
                    }
                    xpath = @"task/description";

                    var nDescription = xmlConfiguration.SelectSingleNode(xpath);

                    Asunto        = nSubject.InnerText;
                    Descripcion   = nDescription.InnerText;
                    CreadoPor     = creadoPor;
                    FechaCreacion = fechaCreacion;

                    if (parametros == null)
                    {
                        return;
                    }

                    foreach (var paramKey in parametros)
                    {
                        var paramValue = paramKey[1];
                        Asunto      = Asunto.Replace(paramKey[0], paramValue);
                        Descripcion = Descripcion.Replace(paramKey[0], paramValue);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// On asunto process completed sent a refresh to balance list
 /// </summary>
 /// <param name="a"></param>
 public async void AsuntoProcessCompleted(Asunto a)
 {
     try {
         balanceOfOperators.Increment(a);
         balanceOfOperators.UpdateAverage();
     }
     catch (Exception ex) {
         Except.Throw(ex);
     }
     await Dispatcher.BeginInvoke((Action)(() =>
     {
         getAsuntosWithoutAssignation();
         LoadReportInformation();
     }));
 }
Ejemplo n.º 13
0
    public void modificar_asunto(Asunto asunto)
    {
        SQLiteCommand cmd = new SQLiteCommand(G.conexion_principal);

        cmd.CommandText = "update Asunto set texto= ? where id = ?";

        SQLiteParameter paramNombre = new SQLiteParameter();

        cmd.Parameters.Add(paramNombre);
        paramNombre.Value = asunto.Texto;

        SQLiteParameter paramId = new SQLiteParameter();

        cmd.Parameters.Add(paramId);
        paramId.Value = asunto.ID;

        cmd.ExecuteNonQuery();

        cmd.Dispose();
    }
Ejemplo n.º 14
0
    public void agregar_asunto(Asunto asunto)
    {
        SQLiteCommand cmd = new SQLiteCommand(G.conexion_principal);

        cmd.CommandText = "insert into Asunto(usuario_id, texto, cant_veces_usado, fecha_creacion) values(?, ? , 0, date('now'))";

        SQLiteParameter paramId = new SQLiteParameter();

        cmd.Parameters.Add(paramId);
        paramId.Value = this.ID;

        SQLiteParameter paramNombre = new SQLiteParameter();

        cmd.Parameters.Add(paramNombre);
        paramNombre.Value = asunto.Texto;

        cmd.ExecuteNonQuery();

        cmd.Dispose();
    }
Ejemplo n.º 15
0
 /// <summary>
 /// Process a request from Backoffice and put delivery of them in a qeue
 /// </summary>
 /// <param name="prmAsunto"></param>
 public void SentAsuntoToOperator(Operador prmOperatorBackoffice, Asunto prmAsunto)
 {
     try {
         // Check if the operator who sents the asunto is a backoffice operator logged
         if (!CheckCallingBackofficeIsAlreadyLogged(prmOperatorBackoffice))
         {
             throw new Exception(Error.BACKOFFICE_SENDER_IS_NOT_CORRECTLY_LOGGED);
         }
         // Validates asunto if correct loaded
         if (SQL.Asunto.Validate(prmAsunto))
         {
             // Adds a asunto to deliver
             AddPending(prmAsunto);
         }
         else
         {
             // Sent a reject sent message
             CurrentCallback.Mensaje(string.Format("El asunto {0} para el operador {1} no puede ser agregada a la lista de distribución. Es posible que el operador no sea valido o probablemente el asunto ya esta cargado."));
         }
     }
     catch (Exception ex) {
         Log.Error("SentAsuntoToOperator", ex.Message);
     }
 }
Ejemplo n.º 16
0
    public bool DownloadFromExchange(string PathDownload, string Subject, string Filter, string Sender)
    {
        //cargar credenciales
        string       Asunto;
        string       _stage = "";
        bool         _isRead;
        bool         _attachmentFound = false;
        EmailMessage _message;


        if (pExchange != null)
        {
            //El filtro de búsqueda para obtener correos electrónicos no leídos
            SearchFilter sf   = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
            ItemView     view = new ItemView(50);
            // Se Activa la consulta de los elementos no leídos
            // Este método obtiene el resultado de la llamada FindItem a EWS. Con los correos sin leer
            FindItemsResults <Item> findResults = pExchange.FindItems(WellKnownFolderName.Inbox, sf, view);

            // Recorremos los correos no leídos
            foreach (Item item in findResults)
            {
                try
                {
                    // Recorrer los mensajes
                    _stage   = "Find in messages";
                    _message = EmailMessage.Bind(pExchange, item.Id);        // se carga el "message" busca por Id
                    Asunto   = _message.Subject.ToString();                  // sacamos el Subject
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"[{_stage}]: {ex.Message}");
                    continue;
                }

                try
                {
                    if (Regex.IsMatch(_message.From.ToString(), Sender) || Sender == "")
                    {
                        Console.WriteLine($"-> Checking sender: {_message.From}");
                        if (Asunto.Contains(Subject) || Subject == "")    // se comprueba en los correos no leídos el asunto
                        {
                            Console.WriteLine($"  -> Checking subject: {Asunto}");
                            _isRead = false;

                            //
                            foreach (Attachment att in _message.Attachments)
                            {
                                // Recorrer los adjuntos
                                _stage = "Find in messages";
                                if (att is FileAttachment)
                                {
                                    FileAttachment fileAttachment = att as FileAttachment;
                                    // Carga el archivo adjunto en un archivo
                                    //if (Filter == fileAttachment.Name.Substring((fileAttachment.Name.ToString().Length - 3), 3))
                                    if (Regex.IsMatch(fileAttachment.Name.ToString(), Filter) || Filter == "")
                                    {
                                        Console.Write($"    -> Checking attachment: {fileAttachment.Name} ...");

                                        // Que guarda en la dirección indicada
                                        _stage = "Save File";
                                        fileAttachment.Load(PathDownload + fileAttachment.Name);
                                        Console.WriteLine($" Downloaded OK!!");
                                        _attachmentFound = true;

                                        pBody += $"- File {fileAttachment.Name.ToString()} found and stored.<br>";

                                        if (!_isRead)
                                        {
                                            _stage          = "Message update is read";
                                            _message.IsRead = true;                              // lo marcamos como leído
                                            _message.Update(ConflictResolutionMode.AutoResolve); // Se envía al servidor el cambio realizado
                                            _isRead = true;
                                            Console.WriteLine($"  -> Marked as read.");
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("-> No matches");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"[{_stage}]: {ex.Message}");
                    continue;
                }
            }
        }
        return(_attachmentFound);
    }
Ejemplo n.º 17
0
 public void ConfigurarAsunto(String item, String valor)
 {
     this.Asunto = Asunto.Replace("{" + item + "}", valor);
 }
Ejemplo n.º 18
0
 public void AsuntoProcessCompleted(Asunto a)
 {
 }
Ejemplo n.º 19
0
 public void EnviarAsunto(Asunto a)
 {
 }