static private ProcessReplaceFields ( string s, Field>.Dictionary |
||
s | string | |
replaceFields | Field>.Dictionary | |
handler | ISaveRequestHandler | |
Результат | string |
private string CopyTemporaryFiles(ISaveRequestHandler handler, UploadedFile[] oldFileList, UploadedFile[] newFileList, FilesToDelete filesToDelete) { foreach (var file in newFileList) { var filename = file.Filename.Trim(); if (oldFileList.Any(x => String.Compare(x.Filename.Trim(), filename, StringComparison.OrdinalIgnoreCase) == 0)) { continue; } if (!filename.ToLowerInvariant().StartsWith("temporary/")) { throw new InvalidOperationException("For security reasons, only temporary files can be used in uploads!"); } ImageUploadBehavior.CheckUploadedImageAndCreateThumbs(attr, ref filename); var idField = (Field)(((IIdRow)handler.Row).IdField); var copyResult = uploadHelper.CopyTemporaryFile(filename, idField.AsObject(handler.Row), filesToDelete, s => ImageUploadBehavior.ProcessReplaceFields(s, this.replaceFields, handler)); if (!attr.SubFolder.IsEmptyOrNull()) { copyResult.DbFileName = copyResult.DbFileName.Substring(attr.SubFolder.Length + 1); } file.Filename = copyResult.DbFileName; } return(JSON.Stringify(newFileList)); }
private CopyTemporaryFileResult CopyTemporaryFile(ISaveRequestHandler handler, FilesToDelete filesToDelete) { var fileName = (StringField)Target; var newFilename = fileName[handler.Row] = fileName[handler.Row].TrimToNull(); CheckUploadedImageAndCreateThumbs(attr, ref newFilename); var idField = (Field)(((IIdRow)handler.Row).IdField); var copyResult = uploadHelper.CopyTemporaryFile(newFilename, idField.AsObject(handler.Row), filesToDelete, s => ImageUploadBehavior.ProcessReplaceFields(s, this.replaceFields, handler.Row)); if (!attr.SubFolder.IsEmptyOrNull()) { copyResult.DbFileName = copyResult.DbFileName.Substring(attr.SubFolder.Length + 1); } return(copyResult); }