private Task <YetaWF.Core.Image.ImageSupport.GetImageAsFileInfo> RetrieveImageAsync(string name, string location) { Task <YetaWF.Core.Image.ImageSupport.GetImageAsFileInfo> fail = Task.FromResult(new YetaWF.Core.Image.ImageSupport.GetImageAsFileInfo()); if (string.IsNullOrWhiteSpace(location)) { return(fail); } if (string.IsNullOrWhiteSpace(name)) { return(fail); } string[] parts = location.Split(new char[] { ',' }); if (parts.Length != 3) { return(fail); } string folderGuid = parts[0]; string subFolder = parts[1]; string fileType = parts[2]; string storagePath = ImageSelectionInfo.StoragePath(new Guid(folderGuid), subFolder, fileType); return(Task.FromResult(new YetaWF.Core.Image.ImageSupport.GetImageAsFileInfo { File = Path.Combine(storagePath, name), Success = true, })); }
public async Task UpdateAsync(ModuleDefinition module) { ImageName_Info = new ImageSelectionInfo(module, FolderGuid, SubFolder) { AllowUpload = true, }; await ImageName_Info.InitAsync(); }
public async Task UpdateAsync(ModuleDefinition module) { ImageName_Info = new ImageSelectionInfo(module, module.ModuleGuid, null) { AllowUpload = true, }; await ImageName_Info.InitAsync(); FlashImageName_Info = new FlashSelectionInfo(module, module.ModuleGuid, null) { AllowUpload = true, }; await FlashImageName_Info.InitAsync(); }
public async Task <ActionResult> SaveImage(HttpPostedFileBase __filename, string folderGuid, string subFolder, string fileType) #endif { FileUpload upload = new FileUpload(); string storagePath = ImageSelectionInfo.StoragePath(new Guid(folderGuid), subFolder, fileType); string namePlain = await upload.StoreFileAsync(__filename, storagePath, MimeSection.ImageUse); string name = namePlain; System.Drawing.Size size = ImageSupport.GetImageSize(namePlain, storagePath); HtmlBuilder hb = new HtmlBuilder(); foreach (var f in await ImageSelectionInfo.ReadFilesAsync(new Guid(folderGuid), subFolder, fileType)) { string plain = f.RemoveStartingAt(ImageSupport.ImageSeparator); string sel = ""; if (plain == namePlain) { sel = " selected"; name = f; } hb.Append(string.Format("<option title='{0}' value='{1}'{2}>{0}</option>", Utility.HtmlAttributeEncode(plain), Utility.HtmlAttributeEncode(f), sel)); } // Upload control considers Json result a success. result has a function to execute, newName has the file name UploadResponse response = new UploadResponse { Result = $@"$YetaWF.confirm('{Utility.JserEncode(this.__ResStr("saveImageOK", "Image \"{0}\" successfully uploaded", namePlain))}');", FileName = name, FileNamePlain = namePlain, RealFileName = __filename.FileName, Attributes = this.__ResStr("imgAttr", "{0} x {1} (w x h)", size.Width, size.Height), List = hb.ToString(), }; return(new YJsonResult { Data = response }); }
public async Task <ActionResult> RemoveSelectedImage(string name, string folderGuid, string subFolder, string fileType) { string namePlain = name.RemoveStartingAt(ImageSupport.ImageSeparator); FileUpload upload = new FileUpload(); string storagePath = ImageSelectionInfo.StoragePath(new Guid(folderGuid), subFolder, fileType); await upload.RemoveFileAsync(namePlain, storagePath); HtmlBuilder hb = new HtmlBuilder(); foreach (var f in await ImageSelectionInfo.ReadFilesAsync(new Guid(folderGuid), subFolder, fileType)) { string fPlain = f.RemoveStartingAt(ImageSupport.ImageSeparator); hb.Append(string.Format("<option title='{0}' value='{1}'>{2}</option>", Utility.HtmlAttributeEncode(fPlain), Utility.HtmlAttributeEncode(f), Utility.HtmlEncode(fPlain))); } UploadRemoveResponse response = new UploadRemoveResponse { Result = $@"$YetaWF.confirm('{Utility.JserEncode(this.__ResStr("removeImageOK", "Image \"{0}\" successfully removed", namePlain))}');", List = hb.ToString(), }; return(new YJsonResult { Data = response }); }