private bool UploadFiles(BllFilepathLib lib) { string foldername = Event.Name + " " + DateTime.Now.ToString("dd.MM.yy H-mm-ss"); Event.FilepathLib.FolderName = foldername; foreach (var path in Filepaths) { string fileName = Path.GetFileName(path); using (Stream uploadStream = new FileStream(path, FileMode.Open)) { using (FileServiceClient fileService = new FileServiceClient()) { var msg = new FileUploadMessage() { VirtualPath = fileName, DataStream = uploadStream, FolderName = foldername }; fileService.PutFile(msg); } } Event.FilepathLib.Entities.Add(new BllFilepath { Path = fileName }); } //} return(true); }
public DalFilepathLib MapToDal(BllFilepathLib entity) { return(new DalFilepathLib { Id = entity.Id, FolderName = entity.FolderName }); }
private void PopulateFileListBoxUsingFilepathLib(BllFilepathLib lib) { listBox2.Items.Clear(); foreach (var filename in lib.Entities) { listBox2.Items.Add(filename.Path); } }
public static void DownloadEventFilesUsingFilepathLib(BllFilepathLib lib) { foreach (var name in lib.Entities) { new Thread(delegate() { DownloadFile(name.Path, lib.FolderName); }).Start(); } }
private void DownloadAndLaunchFiles(BllFilepathLib lib) { foreach (var name in lib.Entities) { try { Process.Start(FileDownloader.DownloadFile(name.Path, lib.FolderName)); } catch { MessageBox.Show(Properties.Resources.CANNOT_OPEN_FILE, name.Path); } } }
public BllFilepathLib MapToBll(DalFilepathLib entity) { BllFilepathLib bllEntity = new BllFilepathLib(); bllEntity.Id = entity.Id; bllEntity.FolderName = entity.FolderName; IFilepathMapper mapper = new FilepathMapper(); foreach (var item in ((IGetterByLibId <DalFilepath>)uow.Filepaths).GetEntitiesByLibId(bllEntity.Id)) { BllFilepath bllSelectedEntity = mapper.MapToBll(item); bllEntity.Entities.Add(bllSelectedEntity); } return(bllEntity); }
public BllFilepathLib Create(BllFilepathLib entity) { var ormLib = uow.FilepathLibs.CreateAndReturnOrm(mapper.MapToDal(entity)); uow.Commit(); entity.Id = ormLib.id; FilepathMapper EntityMapper = new FilepathMapper(uow); foreach (var Entity in entity.Entities) { var dalEntity = EntityMapper.MapToDal(Entity); dalEntity.Lib_id = entity.Id; var ormEntity = uow.Filepaths.CreateAndReturnOrm(dalEntity); uow.Commit(); Entity.Id = ormEntity.id; } return(entity); }
public BllFilepathLib Update(BllFilepathLib entity) { FilepathMapper EntityMapper = new FilepathMapper(); foreach (var Entity in entity.Entities) { var dalEntity = EntityMapper.MapToDal(Entity); dalEntity.Lib_id = entity.Id; if (Entity.Id == 0) { var ormEntity = uow.Filepaths.CreateAndReturnOrm(dalEntity); uow.Commit(); Entity.Id = ormEntity.id; } else { uow.Filepaths.Update(dalEntity); } } var EntitysWithLibId = ((IGetterByLibId <DalFilepath>)uow.Filepaths).GetEntitiesByLibId(entity.Id); foreach (var Entity in EntitysWithLibId) { bool isTrashEntity = true; foreach (var item in entity.Entities) { if (item.Id == Entity.Id) { isTrashEntity = false; break; } } if (isTrashEntity == true) { uow.Filepaths.Delete(Entity.Id); } } uow.Commit(); return(entity); }
private BllFilepathLib CreateFilepathLib() { BllFilepathLib filepathLib = new BllFilepathLib(); return(filepathLib); }