public ViewResult HighlightedFileDetails() { int count = 1; var uploads = System.IO.Path.Combine(_environment.WebRootPath); List <FileDetailsModel> DetList = new List <FileDetailsModel>(); if (Directory.Exists(uploads)) { string supportedExtensions = "*.pdf"; foreach (string file in Directory.GetFiles(uploads, supportedExtensions, SearchOption.AllDirectories).Where(s => supportedExtensions.Contains(System.IO.Path.GetExtension(s).ToLower()))) { if (!string.IsNullOrEmpty(file)) { if (file.ToLower().Contains("highlighted")) { FileDetailsModel obj = new FileDetailsModel(); obj.Id = count; obj.FileName = System.IO.Path.GetFileNameWithoutExtension(file); //obj.FileTextContent = "../../books/pdf/FoxitPdfSdk.pdf"; obj.FileTextContent = string.Format("../../Highlighted/{0}", System.IO.Path.GetFileName(file)); DetList.Add(obj); count++; } } } } return(View("HighlightedFileDetails", DetList)); }
private void StoreFileDetails(IDictionary <string, FileData> files) { if (files == null) { return; } foreach (var file in files) { Uri key; var isValid = Uri.TryCreate(file.Key, UriKind.RelativeOrAbsolute, out key); if (!isValid) { continue; } var contents = file.Value.Contents; if (contents != null) { EnsureHashExists(file.Value); var fileDetails = new FileDetailsModel(file.Value); CodeAnalysisResultManager.Instance.FileDetails.Add(key.ToPath(), fileDetails); } } }
public ViewResult ListFiles() { var uploads = System.IO.Path.Combine(_environment.WebRootPath); List <FileDetailsModel> DetList = new List <FileDetailsModel>(); if (Directory.Exists(uploads)) { string supportedExtensions = "*.pdf"; var files = Directory.GetFiles(uploads, supportedExtensions, SearchOption.AllDirectories). Where(s => supportedExtensions.Contains(System.IO.Path.GetExtension(s).ToLower())); foreach (string file in files) { if (!string.IsNullOrEmpty(file)) { if (!file.ToLower().Contains("merged pdfs")) { FileDetailsModel obj = new FileDetailsModel(); obj.FileName = System.IO.Path.GetFileName(file); obj.FileTextContent = file; DetList.Add(obj); } } } } return(View("ListFiles", DetList)); }
/// <summary> /// Create instance of FilesInfo object for a file to be moved and /// and add it to the _filesToMove list. /// </summary> /// <param name="filePath">File's location path.</param> /// <param name="fileType">File's filetype.</param> /// <param name="totalFileSize">Value used to calculate total size /// of all files, this value is then used to calculate progress of /// organistion and state of progress bar passed from GUI.</param> void CreateFileObject(string filePath, string fileType, ref long totalFileSize) { string fileName = Path.GetFileName(filePath); /// Create destination directory. Directory path is contigent upon the /// file's file-type and whether or not a preset has been chosen. string destDir = (_presetName == String.Empty) ? _rootDirectory.Path + "\\ordoFiled\\" + fileType + "\\" : _rootDirectory.Path + "\\ordoFiled\\" + _presetName + "\\" + fileType + "\\"; /// If file's name currently exists in _fileNames call rename method /// to create a new, unique name for the file. if (_fileNames.Contains(fileName) || (new FileInfo(destDir + fileName).Exists)) { fileName = Rename(destDir, fileName, fileType); } _fileNames.Add(fileName); /// Get file's size and add it to totalFileSize variable which is used /// to calculate size of all files long fileSize = new FileInfo(filePath).Length; totalFileSize += fileSize; FileDetailsModel fileInfo = new FileDetailsModel(filePath, destDir + fileName, fileName, fileType, destDir, fileSize); _filesToMove.Add(fileInfo); }
public ViewResult ExtractedImages() { var uploads = System.IO.Path.Combine(_environment.WebRootPath); List <FileDetailsModel> DetList = new List <FileDetailsModel>(); if (Directory.Exists(uploads)) { string supportedExtensions = "*.jpg"; foreach (string file in Directory.GetFiles(uploads, supportedExtensions, SearchOption.AllDirectories).Where(s => supportedExtensions.Contains(System.IO.Path.GetExtension(s).ToLower())).OrderByDescending(d => new FileInfo(d).CreationTime)) { if (!string.IsNullOrEmpty(file)) { if (file.ToLower().Contains("extractedimages")) { FileDetailsModel obj = new FileDetailsModel(); obj.FileName = ConvertImageURLToBase64(file); obj.FileTextContent = file; DetList.Add(obj); } } } } return(View("ExtractedImages", DetList)); }
private void SaveFileDetails(FileDetailsModel objDet) { object[] parameters = { new SqlParameter("FileName", objDet.FileName), new SqlParameter("FileContent", objDet.FileContent), }; cn.Database.ExecuteSqlCommand("AddFileDetails @FileName,@FileContent", parameters); }
public static (PdfPKCS7, FileDetailsModel) VerifySignature(FileDetailsModel model, SignatureUtil signUtil, String name) { PdfPKCS7 pkcs7 = signUtil.ReadSignatureData(name); logger.Error("Signature covers whole document: " + signUtil.SignatureCoversWholeDocument(name)); logger.Error("Document revision: " + signUtil.GetRevision(name) + " of " + signUtil.GetTotalRevisions()); logger.Error("Integrity check OK? " + pkcs7.VerifySignatureIntegrityAndAuthenticity()); model.Integrity = pkcs7.VerifySignatureIntegrityAndAuthenticity() == true?"OK":"NOT OK"; return(pkcs7, model); }
/// <summary> /// Converts from. /// </summary> /// <param name="model">The model.</param> /// <returns></returns> public FileDetailsViewModel ConvertFrom(FileDetailsModel model) { if (model == null) { return(null); } FileDetailsViewModel viewModel = new FileDetailsViewModel { ProcessingSummary = new FileProcessingSummaryViewModel { TotalLines = model.ProcessingSummary.TotalLines, IgnoredLines = model.ProcessingSummary.IgnoredLines, SuccessfullyProcessedLines = model.ProcessingSummary.SuccessfullyProcessedLines, FailedLines = model.ProcessingSummary.FailedLines, NotProcessedLines = model.ProcessingSummary.NotProcessedLines, RejectedLines = model.ProcessingSummary.RejectedLines }, ProcessingCompleted = model.ProcessingCompleted, EstateId = model.EstateId, FileId = model.FileId, FileImportLogId = model.FileImportLogId, FileLines = new List <FileLineViewModel>(), FileLocation = model.FileLocation, FileProfileId = model.FileProfileId, MerchantId = model.MerchantId, UserId = model.UserId }; if (model.FileLines.Any()) { foreach (FileLineModel modelFileLine in model.FileLines) { FileLineViewModel fileLineViewModel = new FileLineViewModel { LineData = modelFileLine.LineData, LineNumber = modelFileLine.LineNumber, TransactionId = modelFileLine.TransactionId, RejectionReason = modelFileLine.RejectionReason }; // Translate the processing result (FileLineProcessingResult result, String stringResult)processingResult = this.ConvertFrom(modelFileLine.ProcessingResult); fileLineViewModel.ProcessingResult = processingResult.result; fileLineViewModel.ProcessingResultString = processingResult.stringResult; viewModel.FileLines.Add(fileLineViewModel); } } return(viewModel); }
private void SaveFileDetails(FileDetailsModel objDet) { DynamicParameters Parm = new DynamicParameters(); Parm.Add("@FileName", objDet.FileName); Parm.Add("@FileContent", objDet.FileContent); DbConnection(); con.Open(); con.Execute("AddFileDetails", Parm, commandType: System.Data.CommandType.StoredProcedure); con.Close(); }
private void EditFileDetails(FileDetailsModel objDet) { DynamicParameters Parm = new DynamicParameters(); Parm.Add("@Id", objDet.Id); Parm.Add("@FileName", objDet.FileName); Parm.Add("@pdf", objDet.pdf); DbConnection(); con.Open(); con.Execute("EditFileDetails", Parm, commandType: System.Data.CommandType.StoredProcedure); con.Close(); }
public static (SignaturePermissions, FileDetailsModel) InspectSignature(FileDetailsModel model, PdfDocument pdfDoc, SignatureUtil signUtil, PdfAcroForm form, String name, SignaturePermissions perms) { IList <PdfWidgetAnnotation> widgets = form.GetField(name).GetWidgets(); PdfPKCS7 pkcs7 = null; (pkcs7, model) = VerifySignature(model, signUtil, name); logger.Error("Digest algorithm: " + pkcs7.GetHashAlgorithm()); logger.Error("Encryption algorithm: " + pkcs7.GetEncryptionAlgorithm()); logger.Error("Filter subtype: " + pkcs7.GetFilterSubtype()); X509Certificate cert = (X509Certificate)pkcs7.GetSigningCertificate(); logger.Error("Name of the signer: " + iText.Signatures.CertificateInfo.GetSubjectFields(cert).GetField("CN")); model.SignerName = iText.Signatures.CertificateInfo.GetSubjectFields(cert).GetField("CN"); if (pkcs7.GetSignName() != null) { logger.Error("Alternative name of the signer: " + pkcs7.GetSignName()); } logger.Error("Signed on: " + pkcs7.GetSignDate().ToUniversalTime().ToString("yyyy-MM-dd")); model.SignatureDate = pkcs7.GetSignDate().ToUniversalTime().ToString("yyyy-MM-dd"); logger.Error("Location: " + pkcs7.GetLocation()); logger.Error("Reason: " + pkcs7.GetReason()); PdfDictionary sigDict = signUtil.GetSignatureDictionary(name); PdfString contact = sigDict.GetAsString(PdfName.ContactInfo); if (contact != null) { logger.Error("Contact info: " + contact); } return(perms, model); }
public async Task <IActionResult> GetFileDetails([FromQuery] Guid fileId, CancellationToken cancellationToken) { try { String accessToken = await this.HttpContext.GetTokenAsync("access_token"); FileDetailsModel fileDetailsModel = await this.ApiClient.GetFileDetails(accessToken, this.User.Identity as ClaimsIdentity, fileId, cancellationToken); return(this.View("FileDetails", this.ViewModelFactory.ConvertFrom(fileDetailsModel))); } catch (Exception e) { Logger.LogError(e); return(this.View("FileDetails").WithWarning("File Details", Helpers.BuildUserErrorMessage("Failed to get File Details Record"))); } }
public async Task <IActionResult> GetFileLineListAsJson([FromQuery] Guid fileId, CancellationToken cancellationToken) { try { String accessToken = await this.HttpContext.GetTokenAsync("access_token"); FileDetailsModel fileDetailsModel = await this.ApiClient.GetFileDetails(accessToken, this.User.Identity as ClaimsIdentity, fileId, cancellationToken); FileDetailsViewModel viewModel = this.ViewModelFactory.ConvertFrom(fileDetailsModel); return(this.Json(Helpers.GetDataForDataTable(this.Request.Form, viewModel.FileLines))); } catch (Exception e) { Logger.LogError(e); return(this.Json(Helpers.GetErrorDataForDataTable <String>("Failed to get File Details Record"))); } }
public FilesPageModel(FileDetailsModel file, bool exists) { if (file == null) { return; } Id = file.Id; Name = file.Name; IsDownloaded = exists; FileName = file.FileName; PathName = file.PathName; var size = (double)file.Size / 100000; if (size > 0) { Size = size.ToString("0.00"); Size = $"{Size} {CrossLocalization.Translate("files_megabytes")}"; } }
public static List <FileDetailsModel> InspectSignatures(String path) { List <FileDetailsModel> fileModelList = new List <FileDetailsModel>(); PdfDocument pdfDoc = new PdfDocument(new PdfReader(path)); PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, false); SignaturePermissions perms = null; SignatureUtil signUtil = new SignatureUtil(pdfDoc); IList <String> names = signUtil.GetSignatureNames(); foreach (String name in names) { FileDetailsModel fileModel = new FileDetailsModel(); logger.Error("===== " + name + " ====="); fileModel.Signature = name; (perms, fileModel) = InspectSignature(fileModel, pdfDoc, signUtil, form, name, perms); fileModelList.Add(fileModel); } return(fileModelList); }
public ActionResult FileUpload(HttpPostedFileBase files) { String FileExt = Path.GetExtension(files.FileName).ToUpper(); if (FileExt == ".PDF") { Stream str = files.InputStream; BinaryReader Br = new BinaryReader(str); Byte[] FileDet = Br.ReadBytes((Int32)str.Length); FileDetailsModel Fd = new FileDetailsModel(); Fd.FileName = files.FileName; Fd.FileContent = FileDet; SaveFileDetails(Fd); return(RedirectToAction("FileUpload")); } else { ViewBag.FileStatus = "Invalid file format."; return(View()); } }
private void WriteRunToErrorList(Run run, string logFilePath, Solution solution) { List <SarifErrorListItem> sarifErrors = new List <SarifErrorListItem>(); var projectNameCache = new ProjectNameCache(solution); if (run.Files != null) { foreach (var file in run.Files) { var hasSha256Hash = file.Value.Hashes?.Any(x => x.Algorithm == AlgorithmKind.Sha256); var contents = file.Value.Contents; var key = new Uri(file.Key); if ((hasSha256Hash ?? false) && contents != null) { var fileDetails = new FileDetailsModel(file.Value); CodeAnalysisResultManager.Instance.FileDetails.Add( key.IsAbsoluteUri ? key.LocalPath : key.OriginalString, fileDetails); } } } if (run.Results != null) { foreach (Result result in run.Results) { var sarifError = new SarifErrorListItem(run, result, logFilePath, projectNameCache); sarifErrors.Add(sarifError); } } foreach (var error in sarifErrors) { CodeAnalysisResultManager.Instance.SarifErrors.Add(error); } SarifTableDataSource.Instance.AddErrors(sarifErrors); }
public FileDetailsModel PutFileDetails(int id, FileDetailsModel fileDetails) { _context.Entry(fileDetails).State = EntityState.Modified; _context.SaveChanges(); return(GetFileDetails(fileDetails.FileId)); }
public FileDetailsModel PostFileDetails(FileDetailsModel fileDetails) { _context.FileDetails.Add(fileDetails); _context.SaveChanges(); return(GetFileDetails(fileDetails.FileId)); }