private void getPicture(ProductChildInitializer item, ProductChild pc) { IHasUploads pcHasuploads = pc as IHasUploads; pc.IsNullThrowException(string.Format("Programming Error. Product Child is not showing as IHasUploads. It is. Currently initializing '{0}'", item.ProductName)); string originalname = item.ProductName.RemoveAllSpaces().ToString(); string relative_SrcPath = pc.MiscFilesLocation_Initialization(); string relative_targetPath = pc.MiscFilesLocation(UserName); string filenameNoExtention = getFileNameWithoutExtention(relative_SrcPath, originalname); if (!imageFileExists(filenameNoExtention)) { return; } #region Copy File string originalnameWithoutExtention = originalname; List <UploadedFile> uploadedFileLst = new List <UploadedFile>(); //copy the actual file to the new spot. We need to do it here so we can get it's new name //== COPY FILE string newNameWithMappedPathPlusExtention = CopyFile(relative_SrcPath, relative_targetPath, Path.ChangeExtension(originalnameWithoutExtention, ExtentionFound)); //create the upload file UploadedFile uf = new UploadedFile( originalnameWithoutExtention, Path.GetFileNameWithoutExtension(newNameWithMappedPathPlusExtention), ExtentionFound, relative_targetPath); //add to uploadlist uploadedFileLst.Add(uf); #endregion if (!uploadedFileLst.IsNullOrEmpty()) { foreach (UploadedFile file in uploadedFileLst) { file.MetaData.Created.SetToTodaysDate(UserName, UserId); //initializes navigation if it is null //You need to add a refrence here to save the file in the UploadedFile as well. file.ProductChild = pc; file.ProductChildId = pc.Id; if (pcHasuploads.MiscFiles.IsNull()) { pcHasuploads.MiscFiles = new List <UploadedFile>(); //intializing } pcHasuploads.MiscFiles.Add(file); UploadedFileBiz.Create(CreateControllerCreateEditParameter(file as ICommonWithId)); } } }
//public override void Event_AddUploadedFileInfoIntoDb(IHasUploads entity, UploadObject uploadObj) //{ // if (uploadObj.NumberOfFiles > 0) // { // foreach (var file in uploadObj.FilesSavedList) // { // file.MetaData.Created.SetToTodaysDate(""); // file.ProductCategory3 = entity as ProductCategory3; // file.ProductCategory3Id = entity.Id; // entity.UploadedFiles.Add(file); // UploadedFileBiz.Create(file); // } // } //} /// <summary> /// This deletes/Removes the uploaded file. /// </summary> /// <param name="id"></param> /// <param name="uploadedObjectId"></param> public async Task DeleteUploadedFile(string uploadedObjectId) { //Delete the upload await UploadedFileBiz.DeleteAsync(uploadedObjectId); //Note. this just marks delete as true. //first locate the object //ProductCategory3 pc3 = await FindAsync(id); //if (pc3.IsNull()) //{ // ErrorsGlobal.Add("Unable to locate the Product Category", MethodBase.GetCurrentMethod()); // return; //} ////remove the object from Category 3 //UploadedFile upf = pc3.UploadedFiles.FirstOrDefault(x => x.Id == uploadedObjectId); //if (!upf.IsNull()) //{ // pc3.UploadedFiles.Remove(upf); //} }
private void deleteUploadsAndPhysicalFiles(ICollection <UploadedFile> uploads) { if (!uploads.IsNullOrEmpty()) { List <string> lstOfUploadsToDelete = new List <string>(); //delete the physical files and note the Upload Id foreach (var upload in uploads) { //delete the physical file. AliKuli.ToolsNS.FileTools.Delete(upload.AbsolutePathWithFileName()); lstOfUploadsToDelete.Add(upload.Id); } //delete the records now if (!lstOfUploadsToDelete.IsNull()) { foreach (var id in lstOfUploadsToDelete) { UploadedFileBiz.DeleteActuallyAndSave(id); } } uploads.Clear(); } }
public AbstractBiz(UploadedFileBiz uploadedFileBiz, IMemoryMain memoryMain, PageViewBiz pageViewBiz, IErrorSet errorSet, ConfigManagerHelper configManagerHelper, BreadCrumbManager breadCrumbManager) { _uploadedFileBiz = uploadedFileBiz; _memoryMain = memoryMain; _pageViewBiz = pageViewBiz; _errorSet = errorSet; _configManagerHelper = configManagerHelper; _breadCrumbManager = breadCrumbManager; errorSet.SetLibAndClass("Uow Library", "UOW_Abstract"); }
public BizParameters( UploadedFileBiz uploadedFileBiz, IMemoryMain memoryMain, IErrorSet errorSet, ConfigManagerHelper configManager, BreadCrumbManager breadCrumbManager, PageViewBiz pageViewBiz) : base( memoryMain, errorSet, configManager, breadCrumbManager, pageViewBiz) { _uploadedFileBiz = uploadedFileBiz; }
public override void Event_AddUploadedFileInfoIntoDb(IHasUploads entity, UploadObject uploadObj) { if (uploadObj.NumberOfFilesInFileList > 0) { foreach (var file in uploadObj.FileList) { file.MetaData.Created.SetToTodaysDate(UserId, UserName); file.MenuPath1 = entity as MenuPath1; file.MenuPath1Id = entity.Id; //add the owner of the file here.... entity.MiscFiles.Add(file); UploadedFileBiz.Create(CreateControllerCreateEditParameter(file as ICommonWithId)); } } }
/// <summary> /// This deletes/Removes the uploaded file. /// </summary> /// <param name="id"></param> /// <param name="uploadedObjectId"></param> public async Task DeleteUploadedFile(string uploadedObjectId) { //Delete the upload await UploadedFileBiz.DeleteAsync(uploadedObjectId); }
public UserAndRightsAndUploadsBiz(UserBiz userBiz, RightBiz rightBiz, UploadedFileBiz uploadedFileBiz) { _userBiz = userBiz; _rightBiz = rightBiz; _uploadedFileBiz = uploadedFileBiz; }