public EXCEPTION Skip(EXCEPTION exception, string prepCode = null) { var fieldsToUpdate = new List <string> { "ERR_RESPONSE", "OUT", "PREPCODE", "CLEARED_DATE" }; exception.ERR_RESPONSE = "S"; exception.OUT = "T"; if (!string.IsNullOrEmpty(prepCode)) { exception.PREPCODE = prepCode; } exception.CLEARED_DATE = DateTime.Now; var mgr = new ExceptionsManager(); mgr.UpdateException(exception, fieldsToUpdate); return(exception); }
/// <summary>Creates an entry from a file in the archive.</summary> /// <param name="archive">The archive.</param> /// <param name="sourceFileName">The source File Name.</param> /// <param name="entryName">The entry name.</param> /// <param name="compressionLevel">The compression level.</param> /// <param name="overwrite">The overwrite toggle.</param> public static void CreateEntryFromFile(Archive archive, string sourceFileName, string entryName, CompressionLevel compressionLevel = CompressionLevel.Optimal, bool overwrite = true) { ExceptionsManager.IsNull(archive); ExceptionsManager.IsNullOrEmpty(entryName); ExceptionsManager.IsNullOrEmpty(sourceFileName); ExceptionsManager.FileExists(sourceFileName); ExceptionsManager.IsNull(compressionLevel); Overwrite(archive, entryName, overwrite); try { using (FileStream _zipFile = new FileStream(archive.GetFullPath, FileMode.Open)) { using (ZipArchive _archive = new ZipArchive(_zipFile, ZipArchiveMode.Update)) { _archive.CreateEntryFromFile(sourceFileName, entryName, compressionLevel); } } } catch (IOException e) { throw new IOException(nameof(GetFullPath), e); } catch (Exception e) { Console.WriteLine(e); } }
/// <summary>Reads the archive entries.</summary> /// <param name="archivePath">The archive path.</param> /// <returns> /// <see cref="ZipArchiveEntry" /> /// </returns> public static ZipArchiveEntry[] ReadEntries(string archivePath) { ExceptionsManager.IsNullOrEmpty(archivePath); ExceptionsManager.FileExists(archivePath); var _entries = new ZipArchiveEntry[GetCount(archivePath)]; try { using (ZipArchive _archive = ZipFile.OpenRead(archivePath)) { for (var i = 0; i < _archive.Entries.Count; i++) { ZipArchiveEntry _archiveEntry = _archive.Entries[i]; _entries[i] = _archiveEntry; } return(_entries); } } catch (Exception e) { throw new Exception(e.Message, e); } }
/// <summary>Check if the archive contains the file name.</summary> /// <param name="archive">The archive.</param> /// <param name="fileName">The file name.</param> /// <returns> /// <see cref="bool" /> /// </returns> public static bool FileExists(Archive archive, string fileName) { ExceptionsManager.IsNull(archive); ExceptionsManager.FileExists(archive.GetFullPath); try { using (FileStream _fileStream = new FileStream(archive.GetFullPath, FileMode.Open)) { using (ZipArchive _archive = new ZipArchive(_fileStream, ZipArchiveMode.Read)) { foreach (ZipArchiveEntry _entry in _archive.Entries) { if (_entry.FullName == fileName) { return(true); } } } } } catch (Exception e) { Console.WriteLine(e); } return(false); }
/// <summary>Displays details about the working package file.</summary> /// <returns>The <see cref="string" />.</returns> public static string Info() { if ((PackageManager.WorkingPackage == null) || string.IsNullOrWhiteSpace(PackageManager.WorkingPath)) { ConsoleManager.WriteOutput(Descriptions.CommandDescriptions[7]); ConsoleManager.WriteOutput("Usage: Info"); Console.WriteLine(); ConsoleManager.WriteOutput("No package has been loaded."); Console.WriteLine(); } else { try { string _file = Path.GetFileName(PackageManager.WorkingPath); string _path = Path.GetFullPath(PackageManager.WorkingPath); string _directory = Path.GetDirectoryName(_path); ConsoleManager.WriteOutput("Package Information:"); ConsoleManager.WriteOutput("File: " + _file); ConsoleManager.WriteOutput("Path: " + _directory); Console.WriteLine(); } catch (Exception e) { ExceptionsManager.WriteException(e.Message); } } return(string.Empty); }
/// <summary>Open a package file.</summary> /// <param name="path">The file path.</param> /// <returns>The <see cref="string" />.</returns> public static string Open(string path = "") { if (string.IsNullOrEmpty(path)) { ConsoleManager.WriteOutput(Descriptions.CommandDescriptions[11]); ConsoleManager.WriteOutput("Usage: Open [path]"); Console.WriteLine(); return(string.Empty); } else { try { PackageManager.WorkingPath = path; PackageManager.WorkingPackage = new Package(path); if (!PackageManager.WorkingPackage.IsEmpty) { StringManager.DrawPackageTable(PackageManager.WorkingPackage); } Console.WriteLine(); } catch (Exception e) { ExceptionsManager.WriteException(e.Message); } return(string.Empty); } }
/// <summary>Deletes an entry from the archive.</summary> /// <param name="archive">The archive.</param> /// <param name="entryName">The entry to delete.</param> public static void DeleteEntry(Archive archive, string entryName) { ExceptionsManager.IsNull(archive); ExceptionsManager.IsNullOrEmpty(entryName); if (!FileExists(archive, entryName)) { throw new FileNotFoundException("The " + nameof(entryName) + " was not found in the " + nameof(archive)); } try { using (FileStream _zipFile = new FileStream(archive.GetFullPath, FileMode.Open)) { using (ZipArchive _archive = new ZipArchive(_zipFile, ZipArchiveMode.Update)) { foreach (ZipArchiveEntry _entry in _archive.Entries) { if (_entry.FullName == entryName) { _entry.Delete(); } } } } } catch (IOException e) { throw new IOException(nameof(GetFullPath), e); } catch (Exception e) { Console.WriteLine(e); } }
/// <summary>Saves the working package to file.</summary> /// <param name="path">The file path.</param> /// <returns>The <see cref="string" />.</returns> public static string Save(string path = "") { if (string.IsNullOrEmpty(path) || (PackageManager.WorkingPackage == null)) { ConsoleManager.WriteOutput(Descriptions.CommandDescriptions[13]); ConsoleManager.WriteOutput("Usage: Save [path]"); Console.WriteLine(); } else { try { PackageManager.WorkingPath = path; PackageManager.WorkingPackage.Save(path, SaveOptions.None); ConsoleManager.WriteOutput("The package was saved to the file."); ConsoleManager.WriteOutput("Path: " + path); Console.WriteLine(); } catch (NullReferenceException e) { ExceptionsManager.WriteException(e.Message); } catch (Exception e) { ExceptionsManager.WriteException(e.Message); } } return(string.Empty); }
/// <summary>Unload the working package.</summary> /// <returns>The <see cref="string" />.</returns> public static string Unload() { if (PackageManager.WorkingPackage == null) { ConsoleManager.WriteOutput(Descriptions.CommandDescriptions[14]); ConsoleManager.WriteOutput("Usage: Unload"); Console.WriteLine(); } else { try { PackageManager.WorkingPath = string.Empty; PackageManager.WorkingPackage = new Package(); ConsoleManager.WriteOutput("Unloaded package."); Console.WriteLine(); } catch (Exception e) { ExceptionsManager.WriteException(e.Message); } } return(string.Empty); }
/// <summary>Download a file.</summary> /// <param name="url">The url.</param> /// <param name="fileName">The file Name.</param> /// <returns>The <see cref="string" />.</returns> public static string Download(string url = "", string fileName = "") { if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(fileName)) { ConsoleManager.WriteOutput("Downloads a file."); ConsoleManager.WriteOutput("Usage: Download [url] [filename]"); Console.Write(Environment.NewLine); return(string.Empty); } else { if (NetworkManager.IsURLFormatted(url)) { Thread _downloadThread = new Thread(() => { ConsoleManager.WriteOutput("Download link: " + url); ConsoleManager.WriteOutput("Download output: " + fileName); Console.WriteLine(); NetworkManager.Download(new Uri(url), fileName); }); _downloadThread.Start(); } else { ExceptionsManager.WriteException("The url is not well formatted."); Console.WriteLine(); } } return(string.Empty); }
/// <summary>Creates a empty archive file.</summary> /// <param name="archiveOutput">The output file.</param> public static void CreateEmptyArchive(string archiveOutput) { ExceptionsManager.IsNullOrEmpty(archiveOutput); const string EmptyEntry = "Empty"; try { using (FileStream _fileStream = new FileStream(archiveOutput, FileMode.CreateNew)) { using (ZipArchive _archive = new ZipArchive(_fileStream, ZipArchiveMode.Create)) { _archive.CreateEntry(EmptyEntry, CompressionLevel.Optimal); } } DeleteEntry(new Archive(archiveOutput), EmptyEntry); } catch (IOException e) { throw new IOException(nameof(GetFullPath), e); } catch (Exception e) { Console.WriteLine(e); } }
/// <summary>Creates an archive from the file.</summary> /// <param name="filePath">The file path.</param> /// <param name="archiveOutput">The archive output.</param> /// <param name="compressionLevel">The compression level.</param> public static void CompressFile(string filePath, string archiveOutput, CompressionLevel compressionLevel = CompressionLevel.Optimal) { ExceptionsManager.IsNullOrEmpty(filePath); ExceptionsManager.FileExists(filePath); ExceptionsManager.IsNullOrEmpty(archiveOutput); ExceptionsManager.IsNull(compressionLevel); try { using (FileStream _zipFile = new FileStream(archiveOutput, FileMode.CreateNew)) { using (ZipArchive _archive = new ZipArchive(_zipFile, ZipArchiveMode.Create)) { _archive.CreateEntryFromFile(filePath, Path.GetFileName(filePath), compressionLevel); } } } catch (IOException e) { throw new IOException(nameof(archiveOutput), e); } catch (Exception e) { Console.WriteLine(e); } }
public ActionResult ContactRecords([DataSourceRequest] DataSourceRequest request, ContactViewModel search) { var manager = new ContactManager(); List <ContactViewModel> data = null; if (!string.IsNullOrEmpty(search.ErrorCode)) { var exceptionManager = new ExceptionsManager(); var exception = exceptionManager.GetExceptionByExId(search.ExceptionId); TempData["exception"] = exception; data = manager.GetByException(search.ExceptionId, search.ErrorCode, search); } else { search.FtsOrgCodeList = FetchFtsOrgCodeList(); search.PbsOrgCodeList = FetchPbsOrgCodeList(); search.AssignedService = AssignSrv; data = manager.Get(search); } var result = data.AsQueryable().ToDataSourceResult(request); return(Json(result, JsonRequestBehavior.AllowGet)); }
private List <ExceptionPreparerCode> GetExceptionPrepCode(string strClearDate, string strSearchIn, string strPrepCode, string strSortBy) { var mgr = new ExceptionsManager(); List <ExceptionPreparerCode> model = new List <ExceptionPreparerCode>(); model = mgr.GetExceptPrepCode(strClearDate, strSearchIn, strPrepCode, strSortBy); return(model); }
private List <ExceptionCleared> GetExceptionCleared(string strExtrasel, string strFrom, string strTo, string strCheck, string assignedService) { var mgr = new ExceptionsManager(); List <ExceptionCleared> model = new List <ExceptionCleared>(); model = mgr.SearchExceptClearedRpt(assignedService, strExtrasel, strFrom, strTo, strCheck); return(model); }
private List <PreparerCodeProductivity> GetPCProductivity(string strClearDate, string strPrepCode) { var mgr = new ExceptionsManager(); List <PreparerCodeProductivity> model = new List <PreparerCodeProductivity>(); model = mgr.GetPrepCodeProductivity(AssignSrv, strClearDate, strPrepCode); return(model); }
private List <AssociateProductivity> GetAssociateProductivity(string strClearDate, string assignedService) { var mgr = new ExceptionsManager(); List <AssociateProductivity> model = new List <AssociateProductivity>(); model = mgr.GetAssoProd(assignedService, strClearDate); return(model); }
/// <summary>Read the archive file filling the entries array.</summary> public void Read() { ExceptionsManager.IsNullOrEmpty(GetFullPath); ExceptionsManager.FileExists(GetFullPath); _zipEntries = new ZipArchiveEntry[GetCount(GetFullPath)]; _zipEntries = ReadEntries(GetFullPath); _isNewArchive = Count <= 0; }
/// <summary>Gets the entry count from the archive.</summary> /// <param name="archivePath">The archive path.</param> /// <returns> /// <see cref="int" /> /// </returns> public static int GetCount(string archivePath) { ExceptionsManager.IsNullOrEmpty(archivePath); ExceptionsManager.FileExists(archivePath); using (ZipArchive _archive = ZipFile.OpenRead(archivePath)) { return(_archive.Entries.Count); } }
public void FinishCode() { NewNotes(); var faxNotes = notes.returnVal7; var responseNotes = exception.RESPONSENOTES + "\r\n" + NewNote + " - Next Day.', "; ExceptionsManager manager = new ExceptionsManager(); manager.NextDayUpdate(exception.EX_ID, PrepCode, faxNotes, responseNotes); }
/// <summary>Load a package from filename.</summary> /// <param name="path">The file path</param> /// <param name="encoding">The encoding.</param> public void Load(string path, Encoding encoding) { try { XDocument _packageFile = XDocument.Parse(File.ReadAllText(path, encoding)); Deserialize(_packageFile); } catch (FileNotFoundException) { ExceptionsManager.ShowFileNotFoundException(path); } catch (Exception e) { ExceptionsManager.WriteException(e.Message); } }
/// <summary>Initializes a new instance of the <see cref="Archive" /> class.</summary> /// <param name="archivePath">Read an archive.</param> public Archive(string archivePath) : this() { ExceptionsManager.IsNull(archivePath); ExceptionsManager.FileExists(archivePath); OpenArchiveStream(new FileStream(archivePath, FileMode.Open)); try { Read(); } catch (Exception e) { DisposeInternal(true); throw new Exception(e.Message); } }
/// <summary>Initializes a new instance of the <see cref="Archive" /> class.</summary> /// <param name="fileStream">The file stream.</param> public Archive(FileStream fileStream) : this() { ExceptionsManager.IsNull(fileStream); ExceptionsManager.CanSeek(fileStream); OpenArchiveStream(fileStream); try { Read(); } catch (Exception e) { DisposeInternal(true); throw new Exception(e.Message); } }
/// <summary>Check for an update.</summary> /// <param name="executablePath">The path to the executable.</param> /// <param name="packagePath">The path to the package source.</param> /// <returns>The <see cref="string" />.</returns> public static string Check(string executablePath = "", string packagePath = "") { if (string.IsNullOrEmpty(packagePath) || !NetworkManager.SourceExists(packagePath) || string.IsNullOrEmpty(executablePath)) { ConsoleManager.WriteOutput(Descriptions.CommandDescriptions[0]); ConsoleManager.WriteOutput("Usage: Check [executablePath] [packagePath]"); Console.WriteLine(); } else { try { PackageManager.WorkingPath = packagePath; PackageManager.WorkingPackage = new Package(packagePath); Version _currentVersion = ApplicationManager.GetFileVersion(executablePath); ConsoleManager.WriteOutput("Current version: " + _currentVersion); ConsoleManager.WriteOutput("Latest version: " + PackageManager.WorkingPackage.Version); bool _updateRequired = ApplicationManager.CompareVersion(_currentVersion, PackageManager.WorkingPackage.Version); string _updateMessage; if (_updateRequired) { _updateMessage = "You don't have the latest version."; } else { _updateMessage = "You have the latest version."; } ConsoleManager.WriteOutput(_updateMessage); Console.WriteLine(); } catch (Exception e) { ExceptionsManager.WriteException(e.Message); } return(string.Empty); } return(string.Empty); }
/// <summary>Saves the archive to file.</summary> /// <param name="output">The file path output.</param> public void Save(string output) { ExceptionsManager.IsNullOrEmpty(output); ExceptionsManager.IsNullOrEmpty(_directory); ExceptionsManager.IsNullOrEmpty(_name); ExceptionsManager.IsNullOrEmpty(_extension); string _archiveOutputPath = _directory + _name + _extension; if (_isNewArchive) { CreateEmptyArchive(_archiveOutputPath); _isNewArchive = false; } else { SaveArchiveContents(_archiveOutputPath); } }
/// <summary>Extract file from the archive.</summary> /// <param name="archive">The archive.</param> /// <param name="fileName">The file name.</param> /// <param name="output">The output.</param> /// <param name="overwrite">The overwrite toggle.</param> public static void ExtractToFile(Archive archive, string fileName, string output, bool overwrite = true) { ExceptionsManager.IsNullOrEmpty(archive.GetFullPath); ExceptionsManager.FileExists(archive.GetFullPath); ExceptionsManager.IsNullOrEmpty(fileName); ExceptionsManager.IsNullOrEmpty(output); if (!overwrite) { ExceptionsManager.FileExists(output); } if (!FileExists(archive, fileName)) { throw new FileNotFoundException(nameof(fileName) + " was not found in the archive."); } try { using (FileStream _fileStream = new FileStream(archive.GetFullPath, FileMode.Open)) { using (ZipArchive _archive = new ZipArchive(_fileStream, ZipArchiveMode.Read)) { foreach (ZipArchiveEntry _entry in _archive.Entries) { if (_entry.FullName == fileName) { _entry.ExtractToFile(output, overwrite); } } } } } catch (IOException e) { throw new IOException(nameof(output), e); } catch (Exception e) { Console.WriteLine(e); } }
/// <summary>Compress the directory.</summary> /// <param name="directoryPath">The directory path.</param> /// <param name="output">The output file.</param> /// <returns>The <see cref="string" />.</returns> public static string Compress(string directoryPath = "", string output = "") { if (string.IsNullOrEmpty(directoryPath) && string.IsNullOrEmpty(output)) { ConsoleManager.WriteOutput(Descriptions.CommandDescriptions[16]); ConsoleManager.WriteOutput("Usage: Compress [directoryPath] [output]"); Console.WriteLine(); } else { if (string.IsNullOrEmpty(directoryPath)) { ExceptionsManager.ShowNullOrEmpty("The directory path is null or empty."); } if (!Directory.Exists(directoryPath)) { ExceptionsManager.WriteException("The directory was not found."); } if (string.IsNullOrEmpty(output)) { ExceptionsManager.ShowNullOrEmpty("The output is null or empty"); } try { Archive.CompressDirectory(directoryPath, output, CompressionLevel.Optimal); ConsoleManager.WriteOutput("The directory has been compressed."); ConsoleManager.WriteOutput("Output: " + output); Console.WriteLine(); } catch (Exception e) { ExceptionsManager.WriteException(e.Message); } } return(string.Empty); }
/// <summary>Extract the archive to directory.</summary> /// <param name="archivePath">The archive path.</param> /// <param name="output">The output file.</param> /// <returns>The <see cref="string" />.</returns> public static string Extract(string archivePath = "", string output = "") { if (string.IsNullOrEmpty(archivePath) && string.IsNullOrEmpty(output)) { ConsoleManager.WriteOutput(Descriptions.CommandDescriptions[15]); ConsoleManager.WriteOutput("Usage: Extract [archivePath] [output]"); Console.WriteLine(); } else { if (string.IsNullOrEmpty(archivePath)) { ExceptionsManager.ShowNullOrEmpty("The archive path is null or empty."); } if (!File.Exists(archivePath)) { ExceptionsManager.WriteException("The archive was not found."); } if (string.IsNullOrEmpty(output)) { ExceptionsManager.ShowNullOrEmpty("The output is null or empty"); } try { Archive.ExtractToDirectory(new Archive(archivePath), output); ConsoleManager.WriteOutput("The directory has been extracted."); ConsoleManager.WriteOutput("Output: " + output); Console.WriteLine(); } catch (Exception e) { ExceptionsManager.WriteException(e.Message); } } return(string.Empty); }
/// <summary>Load a package from a url.</summary> /// <param name="url">The url.</param> public void Load(string url) { try { // TODO: Tests not done using async method // Load using async with WebClient. // WebClient _webClient = new WebClient(); // string _packageString = await _webClient.DownloadStringTaskAsync(url); // Load from url XDocument _xPackage = XDocument.Load(url); Deserialize(_xPackage); } catch (WebException) { ExceptionsManager.ShowSourceNotFoundException(url); } catch (Exception e) { ExceptionsManager.WriteException(e.Message); } }
/// <summary>Reads the working package file.</summary> /// <returns>The <see cref="string" />.</returns> public static string Read() { if (PackageManager.WorkingPackage == null) { ConsoleManager.WriteOutput(Descriptions.CommandDescriptions[12]); ConsoleManager.WriteOutput("Usage: Read"); Console.WriteLine(); } else { try { StringManager.DrawPackageTable(PackageManager.WorkingPackage); Console.WriteLine(); } catch (Exception e) { ExceptionsManager.WriteException(e.Message); } } return(string.Empty); }