/// <summary> /// 获取所有文件 /// </summary> /// <param name="info"></param> public static void ListFiles(List <FileInfoModel> list, FileSystemInfo info) { if (!info.Exists) { return; } DirectoryInfo dir = info as DirectoryInfo; //不是目录 if (dir == null) { return; } FileSystemInfo[] files = dir.GetFileSystemInfos(); for (int i = 0; i < files.Length; i++) { FileInfo file = files[i] as FileInfo; //是文件 if (file != null) { FileInfoModel model = new FileInfoModel(); model.FileName = file.Name; model.FullPath = file.FullName; model.UploadTime = file.LastWriteTime; list.Add(model); } //对于子目录,进行递归调用 else { ListFiles(list, files[i]); } } }
private List <FileInfoModel> InfoFiles() { var result = new List <FileInfoModel>(); var files = Directory.GetFiles(path); foreach (var item in files) { var attributes = new FileInfo(item); var add = new FileInfoModel(); add.ModificationDate = attributes.LastWriteTime.ToLongDateString(); add.Names = attributes.Name; add.Size = Math.Round((double)attributes.Length / 1048576, 2); add.Path = $"{attributes.DirectoryName}\\{attributes.Name}"; add.TypeFiles = new GetTypeFiles(attributes.Extension).TypeFiles; if (add.TypeFiles == TypeFiles.Text) { add.Text = File.ReadAllText(add.Path); } if (add.TypeFiles == TypeFiles.Images) { var fB = File.ReadAllBytes(add.Path); add.Text = $"data:image/{attributes.Extension.Replace(".","")};charset=utf-8;base64, {Convert.ToBase64String(fB)}"; } result.Add(add); } return(result); }
public IActionResult ChangeFileInfo(long fileId) { HostingFile file = _hostingCore.GetFileById(fileId); if (file == null) { return(NotFound()); } User user = _hostingCore.GetUserById(file.AuthorId); if (User.Identity.Name == user.Email || User.HasClaim(ClaimsIdentity.DefaultRoleClaimType, Roles.Admin.ToString()) || User.HasClaim(ClaimsIdentity.DefaultRoleClaimType, Roles.Editor.ToString())) { var fileInfo = new FileInfoModel { Id = file.Id, Name = file.Name, Category = file.Category, Description = file.Description }; return(View(fileInfo)); } return(RedirectToAction("FilePage", new { fileId = file.Id })); }
public int Update(FileInfoModel model) { StringBuilder builder = new StringBuilder(); builder.Append("update F_FileInfo set "); builder.Append("FileName=@FileName,"); builder.Append("FileSize=@FileSize,"); builder.Append("FileOwner=@FileOwner,"); builder.Append("ParentId=@ParentId,"); builder.Append("FileType=@FileType,"); builder.Append("UserCodes=@UserCodes,"); builder.Append("CreateTime=@CreateTime,"); builder.Append("FileNewName=@FileNewName"); builder.Append(" where Id=@Id "); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@Id", SqlDbType.NVarChar, 0x40), new SqlParameter("@FileName", SqlDbType.NVarChar, -1), new SqlParameter("@FileSize", SqlDbType.NVarChar, 0x40), new SqlParameter("@FileOwner", SqlDbType.NVarChar, 0x40), new SqlParameter("@ParentId", SqlDbType.NVarChar, 0x40), new SqlParameter("@FileType", SqlDbType.NVarChar, 0x40), new SqlParameter("@UserCodes", SqlDbType.NVarChar, -1), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@FileNewName", SqlDbType.NVarChar) }; commandParameters[0].Value = model.Id; commandParameters[1].Value = model.FileName; commandParameters[2].Value = model.FileSize; commandParameters[3].Value = model.FileOwner; commandParameters[4].Value = model.ParentId; commandParameters[5].Value = model.FileType; commandParameters[6].Value = model.UserCodes; commandParameters[7].Value = model.CreateTime; commandParameters[8].Value = model.FileNewName; return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters)); }
public ActionResult GetFileInfo(string path, string fileNames) { if (!string.IsNullOrEmpty(fileNames)) { List <FileInfoModel> listFileInfo = new List <FileInfoModel>(); var fileNameSplip = fileNames.Split(','); foreach (var fileName in fileNameSplip) { if (!string.IsNullOrEmpty(fileName)) { FileInfoModel fileInfo = new FileInfoModel(); fileInfo.name = fileName; var urlFile = path + fileName; var fullPath = Common.GetPath(urlFile); if (System.IO.File.Exists(fullPath)) { fullPath = fullPath.Replace("/", "\\"); FileInfo info = new FileInfo(fullPath); long size = info.Length; fileInfo.size = size; } listFileInfo.Add(fileInfo); } } return(Json(listFileInfo, JsonRequestBehavior.AllowGet)); } // Return an empty string to signify success return(Content("")); }
public int Update(FileInfoModel fileInfoModel) { string sql = "UPDATE fileInfo " + "SET " + " classJson = @classJson" + ", fileUrl = @fileUrl" + ", createTime = @createTime" + ", memo = @memo" + ", status = @status" + " WHERE id = @id"; SQLiteParameter[] para = new SQLiteParameter[] { new SQLiteParameter("@id", fileInfoModel.Id) , new SQLiteParameter("@classJson", ToDBValue(fileInfoModel.ClassJson)) , new SQLiteParameter("@fileUrl", ToDBValue(fileInfoModel.FileUrl)) , new SQLiteParameter("@createTime", ToDBValue(fileInfoModel.CreateTime)) , new SQLiteParameter("@memo", ToDBValue(fileInfoModel.Memo)) , new SQLiteParameter("@status", ToDBValue(fileInfoModel.Status)) }; return(SqlHelper.ExecuteNonQuery(sql, para)); }
/// <summary> /// Initializes a new instance of the <see cref="MissingBarcodePage"/> class. /// </summary> /// <param name="barCodeLoading">The bar code loading.</param> /// <param name="fileInfo">The file information.</param> public MissingBarcodePage(NewLoadingModel barCodeLoading, FileInfoModel fileInfo) { InitializeComponent(); _loading = barCodeLoading; _fileInfo = fileInfo; BindingContext = new MissingBarcodeViewModel(new PageService(), _loading, _fileInfo); }
private async Task <FileInfoModel> DownloadFileAsync(string key, string path) { CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(accessKey); CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient(); string strContainerName = "savegames"; CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference(strContainerName); if (await cloudBlobContainer.CreateIfNotExistsAsync()) { await cloudBlobContainer.SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }); } CloudBlockBlob cloudBlockBlob = cloudBlobContainer.GetBlockBlobReference(key); if (await cloudBlockBlob.ExistsAsync()) { await cloudBlockBlob.DownloadToFileAsync(path, FileMode.Create); var fileModel = new FileInfoModel { Name = cloudBlockBlob.Name, Md5 = cloudBlockBlob.Properties.ContentMD5, LastModified = cloudBlockBlob.Properties.LastModified }; return(fileModel); } return(null); }
protected void btnSave_Click(object sender, System.EventArgs e) { string text = this.hfldFIleName.Value; FileInfoModel model = this.fileInfoBll.GetModel(this.hfldPurchaseChecked.Value); if (model.FileType == "0") { string text2 = model.FileName.Substring(model.FileName.LastIndexOf('.')); if (text.LastIndexOf('.') != -1) { if (text.Substring(text.LastIndexOf('.')) != text2) { text += text2; } } else { text += text2; } model.FileName = text; } this.fileInfoBll.Update(model); string arg_9B_0 = model.ParentId; this.BindGv(); }
/// <summary> /// Initializes a new instance of the <see cref="LoadMenu"/> class. /// </summary> /// <param name="barCodeLoading">The bar code loading.</param> /// <param name="fileInfo">The file information.</param> public LoadMenu(NewLoadingModel barCodeLoading, FileInfoModel fileInfo) { InitializeComponent(); _loading = barCodeLoading; _fileinfo = fileInfo; BindingContext = new LoadMenuViewModel(new PageService(), barCodeLoading, fileInfo); }
public static void InjectResponseModel(MiResponseModel responseModel, FileInfoModel fileInfoModel) { if (responseModel.VideoStreams.Count == 0) { return; } fileInfoModel.Codec = responseModel.VideoStreams[0].CodecID; fileInfoModel.Width = responseModel.VideoStreams[0].Width; fileInfoModel.Height = responseModel.VideoStreams[0].Height; fileInfoModel.AspectRatioPercent = responseModel.VideoStreams[0].DisplayAspectRatio.Replace(" ", string.Empty); fileInfoModel.AspectRatioDecimal = GenerateARDecimal(fileInfoModel.AspectRatioPercent); fileInfoModel.FPS = GenerateFPS(responseModel.VideoStreams[0].FrameRate); fileInfoModel.FPSRounded = GenerateFPSRounded(responseModel.VideoStreams[0].FrameRate); fileInfoModel.Ntsc = IsNtsc(fileInfoModel.FPS); fileInfoModel.Pal = IsPal(fileInfoModel.FPS); fileInfoModel.ProgressiveScan = responseModel.VideoStreams[0].ScanType == "Progressive"; fileInfoModel.InterlacedScan = responseModel.VideoStreams[0].ScanType == "Interlaced"; fileInfoModel.SubtitleStreams = responseModel.SubtitleStreams; fileInfoModel.AudioStreams = responseModel.AudioStreams; }
/// <summary> /// Initializes a new instance of the <see cref="LoadEndControl"/> class. /// </summary> /// <param name="loading">The loading.</param> /// <param name="fileInfo">The file information.</param> public LoadEndControl(NewLoadingModel loading, FileInfoModel fileInfo) { InitializeComponent(); _loading = loading; _fileInfo = fileInfo; BindingContext = new LoadEndControlViewModel(new PageService(), loading, fileInfo); }
public ActionResult SaveExcelFileInfos(FileInfoModel info) { TaskManager TaskManager = (TaskManager)Session["TaskManager"]; ExcelFileReaderInfo excelFileReaderInfo = new ExcelFileReaderInfo(); excelFileReaderInfo.Data = info.Data; excelFileReaderInfo.Dateformat = "";//info.Dateformat; excelFileReaderInfo.Decimal = info.Decimal; excelFileReaderInfo.Offset = info.Offset; excelFileReaderInfo.Orientation = info.Orientation; excelFileReaderInfo.Variables = info.Variables; TaskManager.AddToBus(TaskManager.FILE_READER_INFO, excelFileReaderInfo); GetFileInformationModel model = new GetFileInformationModel(); model.StepInfo = TaskManager.Current(); model.Extention = TaskManager.Bus[TaskManager.EXTENTION].ToString(); model.FileInfoModel = info; model.FileInfoModel.Extention = TaskManager.Bus[TaskManager.EXTENTION].ToString(); model.IsSaved = true; return(RedirectToAction("ReloadUploadWizard", new { restart = false })); }
public ActionResult SaveAsciiFileInfos(FileInfoModel info) { TaskManager TaskManager = (TaskManager)Session["TaskManager"]; AsciiFileReaderInfo asciiFileReaderInfo = new AsciiFileReaderInfo(); asciiFileReaderInfo.Data = info.Data; asciiFileReaderInfo.Dateformat = "";//info.Dateformat; asciiFileReaderInfo.Decimal = info.Decimal; asciiFileReaderInfo.Offset = info.Offset; asciiFileReaderInfo.Orientation = info.Orientation; asciiFileReaderInfo.Seperator = info.Separator; asciiFileReaderInfo.Variables = info.Variables; asciiFileReaderInfo.TextMarker = info.TextMarker; TaskManager.AddToBus(TaskManager.FILE_READER_INFO, asciiFileReaderInfo); GetFileInformationModel model = new GetFileInformationModel(); model.StepInfo = TaskManager.Current(); model.StepInfo.SetValid(true); model.Extention = TaskManager.Bus[TaskManager.EXTENTION].ToString(); model.FileInfoModel = info; model.FileInfoModel.Extention = TaskManager.Bus[TaskManager.EXTENTION].ToString(); model.IsSaved = true; return(RedirectToAction("ReloadUploadWizard", new { restart = false })); }
private static IEnumerable <FileInfoModel> GetRepositoryInfo() { new ApiConsumer().GetFile($"{_publicRepositoryUrlHttps}/{RepositoryFileNameZip}", $"{TmpDirectory}/{RepositoryFileNameZip}"); if (!File.Exists($"{TmpDirectory}/{RepositoryFileNameZip}")) { return(new List <FileInfoModel>()); } var tmpRepoListText = Bash.Execute($"xzcat {TmpDirectory}/{RepositoryFileNameZip}"); var list = tmpRepoListText.SplitToList(Environment.NewLine); var files = new List <FileInfoModel>(); foreach (var f in list) { var fileInfo = f.Split(new[] { ' ' }, 4); if (fileInfo.Length <= 3) { continue; } var fi = new FileInfoModel { FileHash = fileInfo[0], FileContext = fileInfo[1], FileDate = fileInfo[2], FileName = fileInfo[3] }; var date = GetVersionDateFromFile(fi.FileName); if (date != "00000000") { fi.FileDate = date; } files.Add(fi); } return(files); }
/// <summary> /// Gets the file information asynchronous. /// </summary> /// <returns></returns> public async Task <FileInfoModel> GetFileInfoAsync(string fileBarcode, string phoneNumber) { FileInfoModel fileInfo = new FileInfoModel(); try { using (var client = new RestClient(new Uri("https://api-tray.intragest.info/api/"))) { client.Authenticator = new HttpBasicAuthenticator("astek.tracker", "3B]U/2Z8w7fDce=("); var request = new RestRequest("PackingGetFileInfosLoading", Method.GET); request.AddQueryParameter("file_number", fileBarcode); request.AddQueryParameter("mobile_number", phoneNumber); var result = await client.Execute <FileInfoModel>(request).ConfigureAwait(false); fileInfo = result.Data; } } catch (Exception e) { var da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(System.Globalization.CultureInfo.CurrentCulture), MethodName = e.Source }); } return(fileInfo); }
public async Task <StorageFile> Handle(FileUploadCommand request, CancellationToken cancellationToken) { FileInfoModel fileInfo = await _fileRepository.GetFileInfo(request.FilePath); string fileName = Path.GetFileName(request.FilePath); string storageFilePath = $"{request.DestinationDirectoryPath}/{fileName}"; if (await _storageRepository.GetFileInfo(storageFilePath) != null) { throw new ArgumentException("A file with the same name already exists in the storage"); } if (!_storageRepository.IsFileSizeLessThanMaxSize(fileInfo.Size)) { throw new ArgumentException("The file exceeds the maximum size"); } if (!_storageRepository.IsEnoughStorageSpace(fileInfo.Size)) { throw new ArgumentException("Not enough space in the storage to upload the file"); } StorageFile storageFile = await _storageRepository.CreateFile(request.DestinationDirectoryPath, fileName, fileInfo.Size, fileInfo.Hash, fileInfo.CreationDate); string guidFileName = storageFile.Id.ToString(); await _fileRepository.UploadFileIntoStorage(request.FilePath, guidFileName); return(storageFile); }
public FileModel(FileInfoModel filemodel) { FileName = filemodel.FileName; FileSize = (filemodel.FileSize / 1024) + " KB"; FileExtension = filemodel.FileName.Substring(filemodel.FileName.IndexOf(".") + 1); FileUrl = string.Format("/home/invoicefile?invoiceId={0}&fileId={1}&filename={2}", filemodel.InvoiceId, filemodel.FileId, FileName); }
/// <summary> /// Inserts the file information. /// </summary> /// <param name="fileInfo">The file information.</param> public void InsertFileInfo(FileInfoModel fileInfo) { SQLiteConnection _con = OpenConnect(); _con.CreateTable <FileInfoModel>(); _con.InsertOrReplace(fileInfo); CloseConenct(_con); }
public ActionResult Index() { fileDetailsDAL = new FileDetailsDAL(); FileInfoModel fileInfoModel = new FileInfoModel(); fileInfoModel = fileDetailsDAL.GetFileInfo(); return(View("CreateFile", fileInfoModel)); }
/// <summary> /// Initializes a new instance of the <see cref="PackingCygestType"/> class. /// </summary> /// <param name="loading">The loading.</param> /// <param name="fileInfo">The file information.</param> public PackingCygestType(NewLoadingModel loading, FileInfoModel fileInfo) { InitializeComponent(); _loading = loading; AdjustStackLayouts(loading); BindingContext = PackingCygestTypeViewModel = new PackingCygestTypeViewModel(new PageService(), loading, fileInfo); InitializeLaser(); }
public static string UploadRequest(FileInfo fileInfo, UploadTypeEnum uploadType) { var fileData = File.ReadAllBytes(fileInfo.FullName); var fileName = fileInfo.Name; var id = DateTime.Now.Ticks; var crc = CalculateCrc(fileData); var cacheInfo = new FileInfoModel() { Crc = crc, Name = fileName, UploadType = uploadType, Size = fileData.Length }; var cacheFile = AppDomain.CurrentDomain.BaseDirectory + "FileCache\\" + id + ".cache"; var infoFile = AppDomain.CurrentDomain.BaseDirectory + "FileCache\\" + id + ".info"; var isPhoto = uploadType == UploadTypeEnum.Photo || uploadType == UploadTypeEnum.MoneyPhoto; if (isPhoto) { using (var img = System.Drawing.Image.FromFile(fileInfo.FullName)) { cacheInfo.Width = img.Width; cacheInfo.Height = img.Height; } } if (uploadType == UploadTypeEnum.Voice) { var result = new Cli(AppDomain.CurrentDomain.BaseDirectory + "BinTools\\MediaInfoMeta\\MediaInfo.exe") .SetArguments("\"" + fileInfo.FullName + "\" --Output=JSON") .Execute(); var jsonResult = JsonConvert.DeserializeObject <AudioMediaInfo>(result.StandardOutput); cacheInfo.Duration = jsonResult.Media.Track[0].Duration; } File.WriteAllBytes(cacheFile, fileData); File.WriteAllText(infoFile, JsonConvert.SerializeObject(cacheInfo)); var request = new FileRequest <UploadRequestBody>() { Body = new UploadRequestBody() { Crc = crc, Type = "GetFileUploadUrl", FileType = isPhoto ? "photo" : "file", IsServer = false, Size = fileData.Length }, Id = id, Service = "files", Type = "Request" }; return(JsonConvert.SerializeObject(request)); }
private async Task <ConcurrentDictionary <string, FileInfoModel> > GetFilesAync() { CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(accessKey); CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient(); string strContainerName = "savegames"; CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference(strContainerName); if (await cloudBlobContainer.CreateIfNotExistsAsync()) { await cloudBlobContainer.SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }); } var result = await cloudBlobContainer.ListBlobsSegmentedAsync(null); BlobContinuationToken continuationToken = null; CloudBlob blob; ConcurrentDictionary <string, FileInfoModel> files = new ConcurrentDictionary <string, FileInfoModel>(); try { // Call the listing operation and enumerate the result segment. // When the continuation token is null, the last segment has been returned // and execution can exit the loop. do { BlobResultSegment resultSegment = await cloudBlobContainer.ListBlobsSegmentedAsync(continuationToken); foreach (var blobItem in resultSegment.Results) { // A flat listing operation returns only blobs, not virtual directories. blob = (CloudBlob)blobItem; var fileModel = new FileInfoModel { Name = blob.Name, Md5 = blob.Properties.ContentMD5, LastModified = blob.Properties.LastModified }; files.TryAdd(fileModel.Name, fileModel); // Write out some blob properties. Console.WriteLine("Blob name: {0}", blob.Name); } Console.WriteLine(); // Get the continuation token and loop until it is null. continuationToken = resultSegment.ContinuationToken; } while (continuationToken != null); } catch (StorageException e) { Console.WriteLine(e.Message); Console.ReadLine(); throw; } return(files); }
public MissingBarcodeViewModel(IPageService pageService, NewLoadingModel barCodeLoading, FileInfoModel fileInfo) { HandleTranslation(_appViewModel.DefaultedCultureInfo); _barCodeLoading = barCodeLoading; _fileInfo = fileInfo; _pageService = pageService; PopulatedMissingBarcodeList(); Back = new Command(GoBack); }
private FileInfoModel GetFileInfoModel(ExcelFileReaderInfo info, string extention) { FileInfoModel FileReaderInfo = new FileInfoModel(); FileReaderInfo.Data = info.Data; FileReaderInfo.Dateformat = info.Dateformat; FileReaderInfo.Decimal = info.Decimal; FileReaderInfo.Offset = info.Offset; FileReaderInfo.Orientation = info.Orientation; FileReaderInfo.Variables = info.Variables; //Use the given file and the given sheet format to create a json-table string filePath = TaskManager.Bus[EasyUploadTaskManager.FILEPATH].ToString(); string jsonTable = "[]"; FileStream fis = null; //FileStream for the users file fis = new FileStream(filePath, FileMode.Open, FileAccess.Read); UploadUIHelper uploadUIHelper = new UploadUIHelper(fis); string activeWorksheet; if (!TaskManager.Bus.ContainsKey(TaskManager.ACTIVE_WOKSHEET_URI)) { activeWorksheet = uploadUIHelper.GetFirstWorksheetUri().ToString(); TaskManager.AddToBus(TaskManager.ACTIVE_WOKSHEET_URI, activeWorksheet); } else { activeWorksheet = TaskManager.Bus[EasyUploadTaskManager.ACTIVE_WOKSHEET_URI].ToString(); } FileReaderInfo.activeSheetUri = activeWorksheet; FileReaderInfo.SheetUriDictionary = uploadUIHelper.GetWorksheetUris(); // Check if the areas have already been selected, if yes, use them (Important when jumping back to this step) if (TaskManager.Bus.ContainsKey(TaskManager.SHEET_DATA_AREA)) { FileReaderInfo.DataArea = (List <string>)TaskManager.Bus[TaskManager.SHEET_DATA_AREA]; } if (TaskManager.Bus.ContainsKey(TaskManager.SHEET_HEADER_AREA)) { FileReaderInfo.HeaderArea = TaskManager.Bus[TaskManager.SHEET_HEADER_AREA].ToString(); } //Generate the table for the active worksheet jsonTable = uploadUIHelper.GenerateJsonTable(activeWorksheet); if (!String.IsNullOrEmpty(jsonTable)) { TaskManager.AddToBus(EasyUploadTaskManager.SHEET_JSON_DATA, jsonTable); } fis.Close(); return(FileReaderInfo); }
public async Task <HttpResponseMessage> HeadPicUpload() { // Check whether the POST operation is MultiPart? if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } string fileSaveLocation = CustomConfigParam.HeadPicUploadPath; string strDate = DateTime.Now.ToString("yyyyMMdd"); string path = ""; if (Environment.OSVersion.Platform == PlatformID.Unix) { path = fileSaveLocation + strDate + "/"; } else { path = fileSaveLocation + strDate + "\\"; } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } // Prepare CustomMultipartFormDataStreamProvider in which our multipart form // data will be loaded. //string fileSaveLocation = HttpContext.Current.Server.MapPath("~/App_Data"); CustomMultipartFormDataStreamProvider1 provider = new CustomMultipartFormDataStreamProvider1(path); List <FileInfoModel> files = new List <FileInfoModel>(); try { // Read all contents of multipart message into CustomMultipartFormDataStreamProvider. await Request.Content.ReadAsMultipartAsync(provider); foreach (MultipartFileData file in provider.FileData) { string FileName = Path.GetFileName(file.LocalFileName); FileInfoModel fileInfoModel = new FileInfoModel(); fileInfoModel.Name = FileName.Substring(FileName.LastIndexOf("\\") + 1, (FileName.LastIndexOf(".") - FileName.LastIndexOf("\\") - 1)); //文件名 fileInfoModel.Ext = FileName.Substring(FileName.LastIndexOf(".") + 1, (FileName.Length - FileName.LastIndexOf(".") - 1)); //扩展名 fileInfoModel.MimeType = MimeMapping.GetMimeMapping(FileName); fileInfoModel.Path = "\\" + strDate + "\\" + FileName; fileInfoModel.Size = ""; fileInfoModel.Type = file.Headers.ContentType.MediaType.ToString(); files.Add(fileInfoModel); } // Send OK Response along with saved file names to the client. return(Request.CreateResponse(HttpStatusCode.OK, files)); } catch (System.Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } }
public string DoReplace(string value, FileInfoModel fileInfoModel) { value = value.Replace("%R", fileInfoModel.Resolution); value = value.Replace("%F", fileInfoModel.FPS); value = value.Replace("%D", fileInfoModel.FPSRounded); value = value.Replace("%S", fileInfoModel.ScanType); value = value.Replace("%P", fileInfoModel.VideoType); return(value.Trim()); }
public async Task <IActionResult> GetFileSync([Guid] string fileId, [Guid] string invoiceId) { IEnumerable <FileInfoModel> files = await _payInvoiceClient.GetFilesAsync(invoiceId); byte[] content = await _payInvoiceClient.GetFileAsync(invoiceId, fileId); FileInfoModel file = files.FirstOrDefault(o => o.Id == fileId); return(File(content, file.Type, file.Name)); }
private void SaveData(string uploadFile, string classJson) { Models.FileInfoModel info = new FileInfoModel(); info.ClassJson = classJson; info.CreateTime = DateTime.Now; info.FileUrl = uploadFile; info.Memo = tbMemo.Text; new BLL.FileInfoModelBLL().Add(info); MessageBox.Show("文件上传成功"); }
public static FileInfoEntity ToEntity(this FileInfoModel entity) { return(new FileInfoEntity { LastModifiedDate = entity.LastModifiedDate, Name = entity.Name, Size = entity.Size, Type = entity.Type }); }
public JsonResult GetFileInfo(string path) { try { path = _mediaServices.MapPath(path); // get the file attributes for file or directory var attr = System.IO.File.GetAttributes(path); FileInfoModel model; //detect whether its a directory or file if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { var info = new DirectoryInfo(path); model = new FileInfoModel { FileName = info.Name, Created = info.CreationTimeUtc.ToLongDateString(), LastUpdated = info.LastWriteTimeUtc.ToLongDateString(), FileSize = string.Empty }; } else { var info = new FileInfo(path); model = new FileInfoModel { FileName = info.Name, Created = info.CreationTimeUtc.ToLongDateString(), LastUpdated = info.LastWriteTimeUtc.ToLongDateString(), FileSize = string.Format("{0} Bytes", info.Length), }; } return Json(new ResponseModel { Success = true, Data = model }); } catch(Exception exception) { return Json(new ResponseModel { Success = true, Message = exception.Message }); } }