public JsonResult fntAzureSearch(clsDocumentPdfSearch parameters, int?page) { IndexFiles indexFiles = new IndexFiles(); List <Enlace> lstTempEnlaces = new List <Enlace>(); ClsContainer cntContenedores = new ClsContainer(); try { var lstResult = indexFiles.SearchDocuments(parameters, usrUser); foreach (var item in lstResult) { lstTempEnlaces.Add(new Enlace { alterName = item.AlterName, referencialMonth = item.ReferencialMonth, referencialYear = item.ReferencialYear, container = item.Container, application = item.Application, module = item.Module, documentUploadAt = item.DocumentUploadAt, page = item.Page, uri = fntReturnUri(item.Container, item.FullName, item.Page) }); } } catch (Exception) { } finally { cntContenedores.lstEnlaces = lstTempEnlaces; } return(Json(cntContenedores.lstEnlaces)); }
static int Main(string[] args) { var finishedProcessing = new AutoResetEvent(false); int returnCode = 0; var index = new IndexFiles(); index.Out_Statistics += stats => { System.Console.WriteLine("Successfully indexed {0} words.", stats.WordCount); returnCode = 0; finishedProcessing.Set(); }; index.Out_ValidationError += err => { System.Console.WriteLine("*** Aborted indexing! Validation error: {0}", err); returnCode = 1; finishedProcessing.Set(); }; index.Out_UnhandledException += ex => { System.Console.WriteLine("*** Aborted indexing! Unexpected exception: {0}. See log for details.", ex.Message); returnCode = 99; finishedProcessing.Set(); }; System.Console.WriteLine("Indexing files in {0} [Thread {1}]", args[0], Thread.CurrentThread.GetHashCode()); index.Index(args[0], args[1]); finishedProcessing.WaitOne(); return returnCode; }
/// <summary> /// Returns true if OrgApacheSlingServletsGetDefaultGetServletProperties instances are equal /// </summary> /// <param name="other">Instance of OrgApacheSlingServletsGetDefaultGetServletProperties to be compared</param> /// <returns>Boolean</returns> public bool Equals(OrgApacheSlingServletsGetDefaultGetServletProperties other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Aliases == other.Aliases || Aliases != null && Aliases.Equals(other.Aliases) ) && ( Index == other.Index || Index != null && Index.Equals(other.Index) ) && ( IndexFiles == other.IndexFiles || IndexFiles != null && IndexFiles.Equals(other.IndexFiles) ) && ( EnableHtml == other.EnableHtml || EnableHtml != null && EnableHtml.Equals(other.EnableHtml) ) && ( EnableJson == other.EnableJson || EnableJson != null && EnableJson.Equals(other.EnableJson) ) && ( EnableTxt == other.EnableTxt || EnableTxt != null && EnableTxt.Equals(other.EnableTxt) ) && ( EnableXml == other.EnableXml || EnableXml != null && EnableXml.Equals(other.EnableXml) ) && ( JsonMaximumresults == other.JsonMaximumresults || JsonMaximumresults != null && JsonMaximumresults.Equals(other.JsonMaximumresults) ) && ( EcmaSuport == other.EcmaSuport || EcmaSuport != null && EcmaSuport.Equals(other.EcmaSuport) )); }
public override bool Handle(string route, HttpListenerContext context) { var range = context.Request.Headers["Range"]; var rangeSet = false; int rangeStart = 0, rangeEnd = 0; if (!string.IsNullOrEmpty(range)) { range = range.Replace("bytes=", ""); GetRange(range, out rangeStart, out rangeEnd); rangeSet = true; } var publicFile = Path.Combine(_pdir, route); // Verify that the file is indeed supposed to be public if (!Path.GetFullPath(publicFile).Contains(_pdir)) { return(false); } if (File.Exists(publicFile)) { if (!rangeSet) { new RResponse(context.Response).SendFile(publicFile); } else { new RResponse(context.Response).SendFile(publicFile, rangeStart, rangeEnd); } return(true); } var pfiles = IndexFiles.Select(x => Path.Combine(publicFile, x)); if (string.IsNullOrEmpty(publicFile = pfiles.FirstOrDefault(File.Exists))) { return(false); } if (!rangeSet) { new RResponse(context.Response).SendFile(publicFile); } else { new RResponse(context.Response).SendFile(publicFile, rangeStart, rangeEnd); } return(true); }
private void ScanForIndexFiles() { IndexFiles.Clear(); try { DirectoryInfo di = new DirectoryInfo(ActiveProfile.PlateSolveSettings.CygwinLocation + @"\usr\share\astrometry\data"); if (di.Exists) { foreach (FileInfo f in di.GetFiles("*.fits")) { IndexFiles.Add(f.Name); } } } catch (Exception ex) { Logger.Error(ex); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var dlg = new WinIndex(); var indexer = new IndexFiles(); dlg.Out_Index += indexer.In_Process; indexer.Out_FileFoundToIndex += SwitchBackToSyncContext<string>.Wrap(dlg.In_FileFound); indexer.Out_Statistics += SwitchBackToSyncContext<IndexStats>.Wrap(dlg.In_IndexStats); indexer.Out_ValidationError += SwitchBackToSyncContext<string>.Wrap(dlg.In_ValidationError); indexer.Out_UnhandledException += SwitchBackToSyncContext<Exception>.Wrap(dlg.In_Exception); Application.Run(dlg); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Aliases != null) { hashCode = hashCode * 59 + Aliases.GetHashCode(); } if (Index != null) { hashCode = hashCode * 59 + Index.GetHashCode(); } if (IndexFiles != null) { hashCode = hashCode * 59 + IndexFiles.GetHashCode(); } if (EnableHtml != null) { hashCode = hashCode * 59 + EnableHtml.GetHashCode(); } if (EnableJson != null) { hashCode = hashCode * 59 + EnableJson.GetHashCode(); } if (EnableTxt != null) { hashCode = hashCode * 59 + EnableTxt.GetHashCode(); } if (EnableXml != null) { hashCode = hashCode * 59 + EnableXml.GetHashCode(); } if (JsonMaximumresults != null) { hashCode = hashCode * 59 + JsonMaximumresults.GetHashCode(); } if (EcmaSuport != null) { hashCode = hashCode * 59 + EcmaSuport.GetHashCode(); } return(hashCode); } }
public Configuration(CommandLineOptions options) { this.Main = (args) => IndexFiles.Main(args); this.Name = "index-files"; this.Description = FromResource("Description"); this.ExtendedHelpText = FromResource("ExtendedHelpText"); this.IndexDirectoryArgument = new IndexDirectoryArgument(required: true); this.Arguments.Add(IndexDirectoryArgument); this.SourceDirectoryArgument = this.Argument( "<SOURCE_DIRECTORY>", FromResource("SourceDirectoryDescription")); this.UpdateOption = this.Option( "-u|--update", FromResource("UpdateDescription"), CommandOptionType.NoValue); this.OnExecute(() => new DemoIndexFilesCommand().Run(this)); }
public void fntValidarExcel() { string strvalue = ConfigurationManager.AppSettings["Direccion"]; string strconnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + strvalue + ";Extended Properties='Excel 12.0 Macro;HDR=YES'"; OleDbConnection OleDbconn = new OleDbConnection(strconnectionString); OleDbCommand OleDbcmd = new OleDbCommand(); OleDbDataAdapter dataAdapter = new OleDbDataAdapter(); System.Data.DataTable dttDataTable = new System.Data.DataTable(); OleDbcmd.Connection = OleDbconn; try { OleDbconn.Open(); OleDbcmd.CommandText = "SELECT * From [Hoja1$]"; dataAdapter.SelectCommand = OleDbcmd; dataAdapter.Fill(dttDataTable); OleDbconn.Close(); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Para poder abrir el archivo excel se deben instalar los drivers necesarios"); } var excel = dttDataTable; Application myExcelApp = new Application(); Workbook myExcelWorkbook; Worksheet myExcelSheet; myExcelWorkbook = myExcelApp.Workbooks.Open(strvalue, 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", true, false, 0, true, 1, 0); myExcelSheet = (Worksheet)myExcelWorkbook.Sheets.get_Item(1); myExcelWorkbook.Close(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("[{0}] Procesando...", DateTime.Now); foreach (DataRow row in excel.Rows) { var index = new IndexFiles(); var error = new clsErrores(); if (row.Field <object>(0) is null) { continue; } //asignacion de celdas a variables double dblIndice = row.Field <double>(0); string strrutaArchivo = row.Field <string>(1); string strnombreArchivo = row.Field <string>(2); string strnombreAlternoArchivo = row.Field <string>(3); string strExtension = Path.GetExtension(strrutaArchivo); string strextensionArchivo = "." + row.Field <string>(4); string strDescripcionArchivo = row.Field <string>(5); string strCompaniaArchivo = row.Field <string>(6); string strAplicativoArchivo = row.Field <string>(7); string strModuloArchivo = row.Field <string>(8); string strAnioReferencialArchivo = row.Field <string>(9); string strMesReferencialArchivo = row.Field <string>(10); string strNombreContainerArchivo = row.Field <string>(11); string strCarga = row.Field <string>(12); string strIndexo = row.Field <string>(13); string strMensajeError = row.Field <string>(14); strnombreArchivo = strNomralizarString(strnombreArchivo); strnombreAlternoArchivo = strNomralizarString(strnombreAlternoArchivo); strDescripcionArchivo = strNomralizarString(strDescripcionArchivo); strCompaniaArchivo = strNomralizarString(strCompaniaArchivo); strAplicativoArchivo = strNomralizarString(strAplicativoArchivo); strNombreContainerArchivo = strNomralizarString(strNombreContainerArchivo); strModuloArchivo = strNomralizarString(strModuloArchivo); if (strCarga == null) { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("[{0}] Procesando Documento " + dblIndice, DateTime.Now); error.dblIndice = dblIndice; User usr = new User(); BlobStorage blb = new BlobStorage(); //validacion de campos de excel //path if (!File.Exists(strrutaArchivo)) { error.lstErrores.Add("Error: No existe la ruta para el archivo"); } //nombre archivo if (String.IsNullOrEmpty(strnombreArchivo)) { error.lstErrores.Add("Error: No se ha ingrsado un nombre el archivo"); } else { if (strnombreArchivo != Path.GetFileNameWithoutExtension(strrutaArchivo)) { error.lstErrores.Add("Error: No se ha ingresado correctamente el nombre del archivo"); } } //nombre alterno archivo if (String.IsNullOrEmpty(strnombreAlternoArchivo)) { error.lstErrores.Add("Error: nombre alterno del archivo se encuentra vacio "); } //extension if (strExtension != strextensionArchivo) { error.lstErrores.Add("Extensiones no coinciden"); } //Modulo if (String.IsNullOrEmpty(strModuloArchivo)) { error.lstErrores.Add("Error: No se ha ingresado modulo"); } //Año referncial if (String.IsNullOrEmpty(strAnioReferencialArchivo)) { error.lstErrores.Add("Error: No se ha ingresado año referencial"); } else { if (strAnioReferencialArchivo.Length > 4 || strAnioReferencialArchivo.Length < 4) { error.lstErrores.Add("Error: Se debe ingresar el año en formato aaaa"); } } //Mes referencial if (String.IsNullOrEmpty(strMesReferencialArchivo)) { error.lstErrores.Add("Error: No se ha ingresado mes referencial"); } else { if (strMesReferencialArchivo.Length > 2) { error.lstErrores.Add("Error: Se debe ingresar el mes en formato mm "); } } //Empresa if (String.IsNullOrEmpty(strCompaniaArchivo)) { error.lstErrores.Add("Error: El nombre de la empresa se encuentra vacío"); } else { if (usr.fntCompanyStr != strCompaniaArchivo) { error.lstErrores.Add("Error: El nombre de la empresa mencionanda no existe"); } } //aplicativo if (String.IsNullOrEmpty(strAplicativoArchivo)) { error.lstErrores.Add("Error:Se debe ingresar un nombre para el aplicativo"); } else { int valor = usr.fntAplicationsLst.Count; for (int i = 0; i < usr.fntAplicationsLst.Count; i++) { if (usr.fntAplicationsLst[i] != strAplicativoArchivo) { valor = valor - 1; } } if (valor == 0) { error.lstErrores.Add("Error: El nombre ingresado para el aplicativo no existe"); } } //container var lstContainer = blb.fntListBlobContainerLst(usr); Container containerRow = null; if (String.IsNullOrEmpty(strNombreContainerArchivo)) { error.lstErrores.Add("Error:Se debe ingresar un nombre para el container"); } else { try { containerRow = lstContainer.First(x => x.fntFullNameStr == strNombreContainerArchivo); } catch (Exception ex) { error.lstErrores.Add("Error: El nombre ingresado para el container no existe"); } } List <clsErrores> lstListaErroresExcel = new List <clsErrores>(); lstListaErroresExcel.Add(error); try { if (error.lstErrores.Count > 0) { //insercion de mensajes de error using (var cn = new OleDbConnection(strconnectionString)) { cn.Open(); OleDbCommand cmd1 = new OleDbCommand(); cmd1.Connection = cn; var str = new StringBuilder(); foreach (var item in error.lstErrores) { str.Append("- " + item + "\n"); } string sql = "Update [Hoja1$] set Validaciones='" + str + "\n" + "' where ORD=" + error.dblIndice; cmd1.CommandText = sql; cmd1.ExecuteNonQuery(); cn.Close(); } using (var cn = new OleDbConnection(strconnectionString)) { cn.Open(); OleDbCommand cmd1 = new OleDbCommand(); cmd1.Connection = cn; string sql = "Update [Hoja1$] set cargo='No' where ORD=" + error.dblIndice; cmd1.CommandText = sql; cmd1.ExecuteNonQuery(); cn.Close(); } using (var cn = new OleDbConnection(strconnectionString)) { cn.Open(); OleDbCommand cmd1 = new OleDbCommand(); cmd1.Connection = cn; string sql = "Update [Hoja1$] set indexo='No' where ORD=" + error.dblIndice; cmd1.CommandText = sql; cmd1.ExecuteNonQuery(); cn.Close(); } } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Error al momento de escribir en el documento excel"); } try { if (error.lstErrores.Count == 0) { FileUpload flSubirArchivos = new FileUpload() { fntNameFileStr = strnombreAlternoArchivo, fntLocalPathStr = strrutaArchivo, fntCompanyStr = strCompaniaArchivo, fntApplicationStr = strAplicativoArchivo, }; Dictionary <string, object> diccionario = new Dictionary <string, object>(); strextensionArchivo = strextensionArchivo.Replace(".", ""); int sstrAnioReferencialArchivo = int.Parse(strAnioReferencialArchivo); int sstrMesReferencialArchivo = int.Parse(strMesReferencialArchivo); diccionario.Add("Id", dblIndice.ToString()); diccionario.Add("FileName", strnombreArchivo); diccionario.Add("AlterName", strnombreAlternoArchivo); diccionario.Add("Extension", strextensionArchivo); diccionario.Add("Company", strCompaniaArchivo); diccionario.Add("Container", strNombreContainerArchivo); diccionario.Add("Application", strAplicativoArchivo); diccionario.Add("Module", strModuloArchivo); diccionario.Add("DocumentUploadAt", DateTimeOffset.Now); diccionario.Add("ReferencialYear", sstrAnioReferencialArchivo); diccionario.Add("ReferencialMonth", sstrMesReferencialArchivo); diccionario.Add("Path", strrutaArchivo); diccionario.Add("Description", strDescripcionArchivo); diccionario.Add("Tags", null); flSubirArchivos.fntMetadataDct = diccionario; IEnumerable <FileUpload> lstArchivos = new List <FileUpload>() { flSubirArchivos }; var documentosCargar = blb.fntUploadBlobs(containerRow, lstArchivos, usr); var documentosIndexar = index.AddDocumentsToIndex(documentosCargar, usr); if (documentosCargar.First().IsUploaded) { using (var cn = new OleDbConnection(strconnectionString)) { cn.Open(); OleDbCommand cmd1 = new OleDbCommand(); cmd1.Connection = cn; string sql = "Update [Hoja1$] set cargo='Si' where ORD=" + error.dblIndice; cmd1.CommandText = sql; cmd1.ExecuteNonQuery(); cn.Close(); } } else { using (var cn = new OleDbConnection(strconnectionString)) { cn.Open(); OleDbCommand cmd1 = new OleDbCommand(); cmd1.Connection = cn; string sql = "Update [Hoja1$] set cargo='No' where ORD=" + error.dblIndice; cmd1.CommandText = sql; cmd1.ExecuteNonQuery(); cn.Close(); } } if (documentosIndexar.First().IsIndexed) { using (var cn = new OleDbConnection(strconnectionString)) { cn.Open(); OleDbCommand cmd1 = new OleDbCommand(); cmd1.Connection = cn; string sql = "Update [Hoja1$] set indexo='Si' where ORD=" + error.dblIndice; cmd1.CommandText = sql; cmd1.ExecuteNonQuery(); cn.Close(); } } else { using (var cn = new OleDbConnection(strconnectionString)) { cn.Open(); OleDbCommand cmd1 = new OleDbCommand(); cmd1.Connection = cn; string sql = "Update [Hoja1$] set indexo='No' where ORD=" + error.dblIndice; cmd1.CommandText = sql; cmd1.ExecuteNonQuery(); cn.Close(); } } } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Error al momento de escribir en el documento excel"); } } } Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("[{0}] Proceso Terminado ", DateTime.Now); }
/// <summary> /// Generates of a list of all the files inside the .idx .dat files from the Hellgate path. /// </summary> /// <returns>Result of the initialization. Occurance of an error will return false.</returns> private bool _LoadFileTable() { if (!Directory.Exists(HellgateDataPath)) { Console.WriteLine(@"Critical Error: HellgateDataPath data\ does not exist!"); return(false); } List <String> idxPaths = new List <String>(); string[] query = IsVersionTestCenter ? Common.MPFiles : Common.SPFiles; foreach (String fileQuery in query) { idxPaths.AddRange(Directory.GetFiles(HellgateDataPath, fileQuery).Where(p => p.EndsWith(IndexFile.Extension) || p.EndsWith(HellgatePackFile.Extension))); } if (idxPaths.Count == 0) { Console.WriteLine("Error: No index files found at path: " + HellgateDataPath); return(false); } foreach (String idxPath in idxPaths) { HellgateFile hellgateFile; String datFullPath; if (idxPath.EndsWith(IndexFile.Extension)) { hellgateFile = new IndexFile(idxPath); datFullPath = idxPath.Replace(IndexFile.Extension, ((IndexFile)hellgateFile).DatExtension); } else { hellgateFile = new HellgatePackFile(idxPath); datFullPath = idxPath.Replace(HellgatePackFile.Extension, ((HellgatePackFile)hellgateFile).DatExtension); } // if there is no accompanying .dat at all, then ignore .idx if (!File.Exists(datFullPath)) { continue; } // read in and parse index Debug.Write(String.Format("Loading pack file: {0}... ", Path.GetFileName(idxPath))); PackFile packFile = (PackFile)hellgateFile; try { byte[] fileBytes = File.ReadAllBytes(idxPath); hellgateFile.ParseFileBytes(fileBytes); #if DEBUG IndexFile indexFile = hellgateFile as IndexFile; if (indexFile != null) { Debug.WriteLine("{0} files loaded.", indexFile.Files.Count); } HellgatePackFile hgPackFile = hellgateFile as HellgatePackFile; if (hgPackFile != null) { Debug.WriteLine("{0} files loaded.", hgPackFile.Files.Count); } #endif } catch (Exception ex) { Console.WriteLine("Warning: Failed to read in index file: " + idxPath); Debug.WriteLine(ex); continue; } if (packFile.Count == 0) { continue; } IndexFiles.Add(packFile); _LoadIndexFile(packFile); } return(FileEntries.Count != 0); }
private string GetFileName(IndexFiles file) { switch(file) { case IndexFiles.Articles: return "artikelen.csv"; case IndexFiles.Photos: return "fotos.csv"; case IndexFiles.Recordings: return "audio.csv"; case IndexFiles.Users: return "index.csv"; } return ""; }
public FileInfo GetFile(DataFolders folder, IndexFiles file) { return new FileInfo(Path.Combine(GetDirectory(folder).FullName, GetFileName(file))); }