/// <summary> /// Llamado cada vez que se detecta un nuevo fichero /// </summary> private static void Watcher_NewFile(object sender, FileSystemEventArgs e) { string TASFullPath = string.Empty; try { TASFullPath = e.FullPath; FileInfo _info = new FileInfo(TASFullPath); if (_info == null) { return; } int retryCount = 0; int MaxCount = 10; while (IsFileLocked(_info, retryCount == MaxCount) && retryCount <= MaxCount) { Globals.HardSleep(2); } Globals.SoftSleep(); string tasDestFileName = Path.Combine(Globals.GetDestinationDirectory, Path.GetFileNameWithoutExtension(TASFullPath) + Const.FinalTasFileExtension); try { TasProcess.ProcessIndividualTas(TASFullPath, tasDestFileName); } catch (PathTooLongException) { Log.LogServer.WriteLog("Fichero con ByPass por ruta demasiado larga: " + Path.GetFileName(tasDestFileName)); File.Copy(TASFullPath, tasDestFileName); } catch (ByPassException ex) { Log.LogServer.WriteLog("Fichero con ByPass por error: " + Path.GetFileName(tasDestFileName)); Log.LogServer.WriteLog(ex); File.Copy(TASFullPath, tasDestFileName); } TasProcess.ArchiveOrDeleteOriginalFile(TASFullPath); } catch (Exception ex) { Log.LogServer.WriteLog(string.Format("Error procesando la tasación {0}. Más información: ", TASFullPath)); Log.LogServer.WriteLog(ex); } }
public static string Resize(string sourceFilePath) { string DirPath = Path.GetDirectoryName(sourceFilePath); string FileName = Path.GetFileNameWithoutExtension(sourceFilePath); string tempDestPath = Path.Combine(DirPath, FileName); Unzip(sourceFilePath, tempDestPath); TasProcess.Resize(tempDestPath); string destinationFileName = System.IO.Path.Combine(Globals.GetTempPath, Guid.NewGuid() + System.IO.Path.GetExtension(sourceFilePath)); /* * if (File.Exists(destFilePath)) * { * File.Delete(destFilePath); * } */ Zip(tempDestPath, destinationFileName); Directory.Delete(tempDestPath, true); return(destinationFileName); }