Esempio n. 1
0
                                                      public async Task <IHttpActionResult> GetDatos(long id)
                                                      {
                                                          try{ log.Info(new MDCSet(this.ControllerContext.RouteData), new InfoException(id));
                                                               Adjunto fil = await adjuntoRepo.GetAsync(id);

                                                               var mime = UtilMime.GetMimeMapping(fil.nombre);
                                                               var obj  = new {
                                                                   nombre = fil.nombre,
                                                                   mime   = mime
                                                               };
                                                               return(Ok(obj)); }
                                                          catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);

                                                                                return(InternalServerError(e)); }
                                                      }
Esempio n. 2
0
                                                          public async Task <HashSet <string> > adjuntoToText(HashSet <string> exts, long id) //id del Adjunto
                                                          {
                                                              StringBuilder result = null;

                                                              try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                    var     extension = "";
                                                                    Adjunto fil       = await adjuntoRepo.GetAsync(id);

                                                                    var localFilePath = fil.RutaCompleta;



                                                                    HashSet <string> hash = null;
                                                                    if (!File.Exists(localFilePath))
                                                                    {
                                                                        return(null);
                                                                    }
                                                                    else
                                                                    {
                                                                        extension = Path.GetExtension(localFilePath);
                                                                        if (!exts.Contains(extension))
                                                                        {
                                                                            throw new Exception("documento no soportado, se esperaba alguna de las siguientes extensiones: " + string.Join(",", exts.ToArray()));
                                                                        }
                                                                    }
                                                                    //extension = Path.GetExtension(localFilePath);
                                                                    ToPlainText toText = new ToPlainText();
                                                                    try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                          result = toText.GetText(localFilePath, extension);
                                                                          result = Texts.DeleteSpecialCharacteres(result);
                                                                          string[] items = Regex.Split(result.ToString(), @"\s+");
                                                                          hash = new HashSet <string>(items);
                                                                          hash = Texts.getDiferencia(hash, Texts.getStopWords());
                                                                          await this.setVocabulario(hash, dbVoca, fil);//guardar nuevo vocabulario en la BD
                                                                    }
                                                                    catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                                                                                          return(null); }
                                                                    return(hash); }
                                                              catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                                                                                    throw new Exception(e.Message); }

                                                              //UtileriasArchivo util = new UtileriasArchivo();
                                                          }