public ActionResult DownLoadSelectedHistoricalFile(ProcessDownloadingOfSelectedFileModel PDOSFM) { FileModel FM = WDBL.DownloadHistoricalFile(PDOSFM); //FileModel FM = await Common.Helper.Files.DownloadHelper.DownloadFile(PDOSFM); if (!(FM is null)) { return(File(FM.FileBlob.FileImage, FM.ContentType, FM.FullFileName)); }
public FileModel DownloadHistoricalFile(ProcessDownloadingOfSelectedFileModel PDOSFM) { //Incomplete must updtea the CompletedTransactionResponses to include the data return. FileModel FM = _FileRepsoitory.GetSingle( //Where a => a.FileID == PDOSFM.FileID, //Include the following in the object graph. a => a.FileBlob, a => a.UserThatDownloadedFile); return(FM); }
public async Task <FileModel> DownloadSelectedFile(ProcessDownloadingOfSelectedFileModel PDOSFM) { //Incomplete must updtea the CompletedTransactionResponses to include the data return. FileModel FM = _FileRepsoitory.GetSingle( //Where a => a.FileID == PDOSFM.FileID, //Include the following in the object graph. a => a.FileBlob, a => a.UserThatDownloadedFile); /* Lock the file that is being downloaded and link the person that downloadedd the file to it. * this is done by inserting a record into the UserThatDownloadedFile table. * This links the user to the file that was downloaded and set the file status from avaiable to Locked in the Files table. * */ if (FM.UserThatDownloadedFile is null) { FM.UserThatDownloadedFile = new UserThatDownloadedFileModel() { FileID = PDOSFM.FileID, UserIDThatDownloadedFIle = PDOSFM.UserIDOfPersonThatDownloadedTheFile, DateDownloaded = DateTime.Now, HasFileBeenReturned = false, EntityState = DomainModels.EntityState.Added }; FM.FileLookupStatusID = (int)WebDocs.Common.Enum.DbLookupTables.EnumFileViewStatuses.Locked; FM.EntityState = DomainModels.EntityState.Modified; CompletedTransactionResponses CTR = await _FileRepsoitory.AsyncUpdate(FM); if (CTR.WasSuccessfull) { return(FM); } else { return(FM); // return View("Error", new HandleErrorInfo(new Exception(), "ContentManagement", "DownLoadSelectedFile")); } } else { return(FM); } }
public static async Task <FileModel> DownloadFile(ProcessDownloadingOfSelectedFileModel PDOSFM) { FileRepository FR = new FileRepository(); FileModel FM = FR.GetSingle( //Where a => a.FileID == PDOSFM.FileID, //Include the following in the object graph. a => a.FileBlob, a => a.UserThatDownloadedFile); /* Lock the file that is being downloaded and link the person that downloadedd the file to it. * this is done by inserting a record into the UserThatDownloadedFile table. * This links the user to the file that was downloaded and set the file status from avaiable to Locked in the Files table. * */ if (FM.UserThatDownloadedFile is null) { FM.UserThatDownloadedFile = new UserThatDownloadedFileModel() { FileID = PDOSFM.FileID, UserIDThatDownloadedFIle = PDOSFM.UserIDOfPersonThatDownloadedTheFile, DateDownloaded = DateTime.Now, HasFileBeenReturned = false, EntityState = DomainModels.EntityState.Added }; FM.FileLookupStatusID = (int)Common.Enum.DbLookupTables.EnumFileViewStatuses.Locked; FM.EntityState = DomainModels.EntityState.Modified; CompletedTransactionResponses CTR = await FR.AsyncUpdate(FM); if (CTR.WasSuccessfull) { return(FM);// File(FM.FileBlob.FileImage, FM.ContentType, FM.FullFileName); } else { return(null); } } else { return(FM); } }
public CompletedTransactionResponses SendFileUploadNotification(ProcessDownloadingOfSelectedFileModel PDOSFM) { FileModel FM = _FileRepsoitory.GetSingle( a => a.FileID == PDOSFM.FileID,//where a => a.FileOwner, a => a.UserThatDownloadedFile, a => a.UserThatDownloadedFile.PersonTahtDownloadedTheFile);//include UsersModel UserThatLoggedOn = _UserRepository.GetSingle(a => a.Id == PDOSFM.UserIDOfPersonThatDownloadedTheFile); NotificationModel NM = _NotificationsRepsoitory.GetSingle( a => a.FileID == PDOSFM.FileID && a.UserHasAcknowledgement == false && a.UserIDOfNotificationSender == PDOSFM.UserIDOfPersonThatDownloadedTheFile && a.UserIDOfNotificationRecipient == FM.UserThatDownloadedFile.UserIDThatDownloadedFIle, //where a => a.RecipientUsers, //include a => a.SendingUsers, a => a.File); //include if (NM is null) { NotificationModel newUploadNotification = new NotificationModel() { FileID = PDOSFM.FileID, UserIDOfNotificationRecipient = FM.UserThatDownloadedFile.UserIDThatDownloadedFIle, UserIDOfNotificationSender = PDOSFM.UserIDOfPersonThatDownloadedTheFile, DateCreated = DateTime.Now, NotificationTypeID = (int)EnumNotificationTypes.Request_File_Upload, UserHasAcknowledgement = false, EntityState = DomainModels.EntityState.Added }; CTR = _NotificationsRepsoitory.Add(newUploadNotification); if (CTR.WasSuccessfull) { WriteToSystemTransactionLog(new SystemTransactionLogsModel() { SystemTransactionTypeID = (int)Common.Enum.DbLookupTables.EnumSystemTransactionTypes.SendFileUploadNotification, UserIDThatPerformedTansaction = PDOSFM.UserIDOfPersonThatDownloadedTheFile, DateTansactionPerformed = DateTime.Now, TransactionComments = UserThatLoggedOn.UserFullName + ": has sent a request to : " + FM.UserThatDownloadedFile.PersonTahtDownloadedTheFile.UserFullName + " to upload to file.", FileID = PDOSFM.FileID }); //add email that will be sent tot the recipient _EmailCacheRepsoitory.AsyncAdd(new EmailCacheModel() { IDOfPersonSender = PDOSFM.UserIDOfPersonThatDownloadedTheFile, IDOfRecipient = FM.UserThatDownloadedFile.PersonTahtDownloadedTheFile.Id, EmailMessage = "A request to upload the following File# " + FM.FileID + " to be uploaded as the following user requires to gain access to the file.<br/>The File that is required name:<b>" + FM.FullFileName + "</b><br/>Regards Web Docs Team.", EmailSubject = "Upload Notification for - (File# " + FM.FileID + ")", HasBeenSent = false, EntityState = DomainModels.EntityState.Added, RetryAttempt = 0 }); } } else // already exists { WriteToSystemTransactionLog(new SystemTransactionLogsModel() { SystemTransactionTypeID = (int)Common.Enum.DbLookupTables.EnumSystemTransactionTypes.SendFileUploadNotification, UserIDThatPerformedTansaction = PDOSFM.UserIDOfPersonThatDownloadedTheFile, DateTansactionPerformed = DateTime.Now, TransactionComments = UserThatLoggedOn.UserFullName + ": has previously sent a request to : " + FM.UserThatDownloadedFile.PersonTahtDownloadedTheFile.UserFullName + " to upload to file, has sent another upload request.", FileID = PDOSFM.FileID }); //add email that will be sent tot the recipient _EmailCacheRepsoitory.AsyncAdd(new EmailCacheModel() { IDOfPersonSender = PDOSFM.UserIDOfPersonThatDownloadedTheFile, IDOfRecipient = FM.UserThatDownloadedFile.PersonTahtDownloadedTheFile.Id, EmailMessage = "A follow up request to kindly upload the following File# " + FM.FileID + " to be uploaded as the following user requires to gain access to the file.<br/>The File that is required name:<b>" + FM.FullFileName + "</b><br/>Regards Web Docs Team.", EmailSubject = "Follow up request to Upload Notification for - (File# " + FM.FileID + ")", HasBeenSent = false, EntityState = DomainModels.EntityState.Added, RetryAttempt = 0 }); } CompletedTransactionResponses RTN = new CompletedTransactionResponses() { Message = "Notification has been sent to : " + FM.UserThatDownloadedFile.PersonTahtDownloadedTheFile.UserFullName, TransActionType = TransactionType.NoneExecuted, WasSuccessfull = true }; return(RTN); }