public List <FileTableInfo> GetDataFromStoreProcedure(string procedureName) { string ConnectionStr = this.GetConnectionString(); SqlConnection connection = new SqlConnection(ConnectionStr); SqlCommand command = new SqlCommand(procedureName, connection); command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); SqlDataReader reader = command.ExecuteReader(); List <FileTableInfo> fileTableList = new List <FileTableInfo>(); FileTableInfo fileTableInfo = null; while (reader.Read()) { fileTableInfo = new FileTableInfo(); fileTableInfo.FileId = Convert.ToInt32(reader["FileId"].ToString()); fileTableInfo.ReceviedDate = Convert.ToDateTime(reader["ReceviedDate"]); fileTableInfo.FileLocation = reader["FileLocation"].ToString(); fileTableInfo.IsProcessed = Convert.ToBoolean(reader["IsProcessed"]); fileTableInfo.SettingId = Convert.ToInt32(reader["SettingId"].ToString()); fileTableList.Add(fileTableInfo); } return(fileTableList); }
public PdfProcessor(FileTableInfo file) { ReaderRepo = new Repository.FileReaderRepo(); FileTable = new FileTableInfo(); Mappings = new List <Mappings>(); OutputData = new List <Output>(); FileTable = file; }
public PdfFactory(FileTableInfo file) { FileTable = new FileTableInfo(); MappingData = new List <Mappings>(); OutputTableData = new List <OutputData>(); FileTable = file; FileReaderDataAccess = new FileReaderDataAccess(); LoadData(); }
public ActionResult VideoInfo() { FileTableInfo fi = new FileTableInfo(); list.Clear(); var fileInfoList = fi.GetListofFileInfo(); list.AddRange(fileInfoList); return(View(list)); }
private static IProcessor GetFileProcesser(FileTableInfo file) { string fileExtension = Path.GetExtension(file.FileLocation); if (fileExtension == ".pdf" || fileExtension == ".PDF") { return(new PdfProcessor(file)); } throw new NotImplementedException(); }
private static IProcessor GetFileTypeProcesser(FileTableInfo file) { string fileExtension = Path.GetExtension(file.FileLocation); if (fileExtension.ToLower() == ".pdf") { return(new Factory.PDF.PdfFactory(file)); } throw new NotImplementedException(); }
public ActionResult PlayVideoSync(int Id) { FileTableInfo fi = new FileTableInfo(); fi = list.Where(m => m.Id == Id).FirstOrDefault(); string name = fi.FileName; string contentType = fi.FileType; long fSize = fi.FileSize; long startbyte = 0; long endbyte = fSize - 1; int statusCode = 200; if ((Request.Headers["Range"] != null)) { //Get the actual byte range from the range header string, and set the starting byte. string[] range = Request.Headers["Range"].Split(new char[] { '=', '-' }); startbyte = Convert.ToInt64(range[1]); if (range.Length > 2 && range[2] != "") { endbyte = Convert.ToInt64(range[2]); } else { endbyte = startbyte + size - 1; //5M 字节 if (endbyte >= fSize - 1) { endbyte = fSize - 1; } } //If the start byte is not equal to zero, that means the user is requesting partial content. if (startbyte != 0 || endbyte != fSize - 1 || range.Length > 2 && range[2] == "") { statusCode = 206; } //Set the status code of the response to 206 (Partial Content) and add a content range header. } long desSize = endbyte - startbyte + 1; var data = fi.GetFileBlock(fi.FilePath, startbyte, desSize); desSize = data.Count(); //Headers Response.StatusCode = statusCode; Response.ContentType = contentType; Response.AddHeader("Content-Accept", Response.ContentType); Response.AddHeader("Content-Length", desSize.ToString()); Response.AddHeader("Content-Range", string.Format("bytes {0}-{1}/{2}", startbyte, endbyte, fSize)); return(File(data, Response.ContentType)); }
public ActionResult PlayVideo(int Id) { FileTableInfo fi = new FileTableInfo(); fi = list.Where(m => m.Id == Id).FirstOrDefault(); string name = fi.FileName; string contentType = fi.FileType; //var stream = fi.FileStream; //Byte[] video = (Byte[])row["data"]; //string mimeType; //switch (contentType.ToUpper()) //{ // case "MOV": // mimeType = "video/quicktime"; // break; // case "MP4": // mimeType = "video/mp4"; // break; // case "FLV": // mimeType = "video/x-flv"; // break; // case "AVI": // mimeType = "video/x-msvideo"; // break; // case "WMV": // mimeType = "video/x-ms-wmv"; // break; // case "MJPG": // mimeType = "video/x-motion-jpeg"; // break; // case "TS": // mimeType = "video/MP2T"; // break; // default: // mimeType = "video/mp4"; // break; //} //return File(stream, contentType); var data = fi.GetFileByte(fi.FilePath); Response.ContentType = contentType; Response.AddHeader("Content-Accept", Response.ContentType); return(File(data, Response.ContentType)); }
public static List <OutputData> ProcessData(List <Mappings> mappings, FileTableInfo fileTableInfo) { //Add key BitMiracle.Docotic.LicenseManager.AddLicenseData(""); var outputData = new List <OutputData>(); using (var pdf = new BitMiracle.Docotic.Pdf.PdfDocument(fileTableInfo.FileLocation)) { var pageGroups = mappings.GroupBy(pg => pg.PageNumber); foreach (var pageGroup in pageGroups) { var pageNumber = pageGroup.Key; var pageMappings = pageGroup.ToList(); var currentpage = pdf.GetPage(pageNumber); string formattedText = currentpage.GetTextWithFormatting(); string modifiedText = Regex.Replace(formattedText, @"['$]", string.Empty); var strArray = System.Text.RegularExpressions.Regex.Split(modifiedText, @"\s{2,}"); foreach (var map in pageMappings) { var amount = PdfFactory.GetNextPositionValue(strArray, map.MapName, map.Position); amount = Regex.Replace(amount, @"[,]", string.Empty); if (amount[0] == '(' && amount[amount.Length - 1] == ')') { amount = "-" + Regex.Replace(amount, @"[)(]", string.Empty); } outputData.Add(new OutputData { FileId = fileTableInfo.FileId, DataType = map.MapType, Value = amount, PageNumber = map.PageNumber }); } } } return(outputData); }