Ejemplo n.º 1
0
        public ActionResult DeleteFile()
        {
            DeleteFileModel tempdatafile = (DeleteFileModel)Session["FileDelete"];
            var             deleteFile   = db.Document_Repository.Where(f => f.Document_Seq.Equals(tempdatafile.Document_Seq)).FirstOrDefault();

            var sessionLog = db.Person_Session_Log.Where(p => p.Person_ID == User.Identity.Name).OrderByDescending(p => p.Login_DateTime).FirstOrDefault();

            Document_Access_Log ac = new Document_Access_Log();

            ac.Access_DateTime = DateTime.Now;
            ac.Document_Seq    = deleteFile.Document_Seq;
            ac.Session_ID      = sessionLog.Session_ID;

            db.Document_Access_Log.Add(ac);
            db.SaveChanges();

            //record action
            global.addAudit("Repository", "Repository: Delete File", "Delete", User.Identity.Name);

            deleteFile.Document_Status = "Deleted";
            var virtualDirectoryPath = deleteFile.Directory_Path;

            if (System.IO.File.Exists(virtualDirectoryPath))
            {
                System.IO.File.Delete(virtualDirectoryPath);
            }
            db.Entry(deleteFile).State = EntityState.Modified;
            db.SaveChanges();
            TempData["Message"]    = "File '" + deleteFile.Document_Name + "' successfuly deleted";
            TempData["classStyle"] = "success";
            Session.Remove("FileDelete");
            return(RedirectToAction("ViewFile"));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> DeleteFile(DeleteFileModel model)
        {
            await db.DeleteFile(model.FileId);

            Session["Message"]   = "Файл успешно удален";
            ViewBag.UpdateEvents = true;
            return(await GetCourseTopicFile(model.CourseId, true));
        }
Ejemplo n.º 3
0
        public async Task <Result <bool> > DeleteBugTicketCommentFile([FromBody] DeleteFileModel model)
        {
            await _helpService.DeleteBugFileFromStoreAsync(BugFileType.Comment, model.FileName, model.PublicId);

            if (model.Id != 0)
            {
                await _helpService.DeleteBugFileAsync(model.Id);
            }

            return(true);
        }
Ejemplo n.º 4
0
        private async Task <string> DeleteFileReferences(DeleteFileModel model)
        {
            if (model.ModuleType == (int)Enums.DeleteModule.Tender)
            {
                string isDeletedFile  = "";
                var    physicalDelete = await _tenderService.DeleteAttachmentAsync(model.FileName);

                if (physicalDelete)
                {
                    isDeletedFile = await _fileNetService.deleteFile(model.FileName);
                }
                return(isDeletedFile);
            }
            var isDeleted = await _fileNetService.deleteFile(model.FileName);

            switch (model.ModuleType)
            {
            case (int)Enums.DeleteModule.Tender:
                await _tenderService.DeleteAttachmentAsync(model.FileName);

                break;

            case (int)Enums.DeleteModule.QuantityTable:
                break;

            case (int)Enums.DeleteModule.Offer:
                await _offerService.DeleteAttachement(model.FileName);

                break;

            case (int)Enums.DeleteModule.Block:
                break;

            case (int)Enums.DeleteModule.TechniciansReport:
                await _tenderService.DeleteAttachmentAsync(model.FileName);

                break;

            case (int)Enums.DeleteModule.TenderAttachementChanges:
                await _tenderService.DeleteTenderAttachmentChangesAsync(model.FileName);

                break;

            case (int)Enums.DeleteModule.Qualification:
                await _tenderService.DeleteQualificationAttachments(model.FileName);

                break;
            }
            return(isDeleted);
        }
Ejemplo n.º 5
0
        public static async Task <string> DeleteAsync(DeleteFileModel model)
        {
            string[] fileNetRefIds;
            if (model.FileName.Contains("/GetFile/"))
            {
                fileNetRefIds = model.FileName.Split("/GetFile/")[1].Split(":");
            }
            else
            {
                fileNetRefIds = model.FileName.Split(":");
            }
            model.FileName = fileNetRefIds[0];
            //Deserializing the response recieved from web api and storing into the Tender List
            var tenderList = JsonConvert.DeserializeObject <string>(await deleteRequest.PostAsync("FileNet/Delete", model));

            return(tenderList);
        }
Ejemplo n.º 6
0
        public IActionResult DeleteFile(int id, [FromServices] DeleteFileCommand delFileCommand)
        {
            var model = new DeleteFileModel();

            model.Id = id;
            var file = _dataContext.Photos
                       .Include(p => p.ParentFolder)
                       .FirstOrDefault(p => p.Id == id);

            var parentId = file.ParentFolder?.Id;

            delFileCommand.Execute(model);
            if (parentId == null)
            {
                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("Details", new { id = parentId }));
        }
Ejemplo n.º 7
0
        public IResult Delete(DeleteFileModel model)
        {
            if (string.IsNullOrWhiteSpace(model.Filename))
            {
                return(new Result <IResult>(null, Common.Enums.StatusCode.BAD_REQUEST));
            }

            var    uploadDirs = GetUploadDirectories();
            string dir        = uploadDirs.Where(x => x.Name == model.Folder).Select(y => y.Path).FirstOrDefault();

            if (dir == null)
            {
                _logger.LogWarning("Invalid folder name provided. Protected file deletion attempt by " + _user.Name + " @ " + _user.IP + " - Filename=" + model.Filename);
                return(new Result <IResult>(null, Common.Enums.StatusCode.BAD_REQUEST));
            }

            FileInfo fi = new FileInfo(Path.Combine(dir, model.Filename));

            if (fi.Exists)
            {
                try
                {
                    fi.Delete();
                }
                catch (UnauthorizedAccessException)
                {
                    _logger.LogWarning("Unauthorized protected file deletion attempt by " + _user.Name + " @ " + _user.IP + " - Filename=" + model.Filename);
                    return(new Result <IResult>(null, Common.Enums.StatusCode.UNAUTHORIZED));
                }
                catch (SecurityException) {
                    _logger.LogWarning("Security exception in protected file deletion attempt by " + _user.Name + " @ " + _user.IP + " - Filename=" + model.Filename);
                    return(new Result <IResult>(null, Common.Enums.StatusCode.UNAUTHORIZED));
                }
                catch (IOException)
                {
                    _logger.LogWarning("IO exception in protected file deletion attempt by " + _user.Name + " @ " + _user.IP + " - Filename=" + model.Filename);
                    return(new Result <IResult>(null, Common.Enums.StatusCode.BAD_REQUEST));
                }
            }

            return(new Result <IResult>(null, Common.Enums.StatusCode.OK));
        }
Ejemplo n.º 8
0
        public ActionResult DeleteFile(int id)
        {
            var file = db.Document_Repository.Where(m => m.Document_Seq.Equals(id)).FirstOrDefault();

            //create an instance of a deletefilemodel
            DeleteFileModel a = new DeleteFileModel
            {
                //get details of file to be deleted
                Document_Seq  = id,
                Document_Name = file.Document_Name,
                Description   = file.Description,
                Category      = (from b in db.Document_Category
                                 where b.Category_ID.Equals(file.Category_ID)
                                 select b.Category_Name).FirstOrDefault(),
                Document_Type_Name = (from c in db.Document_Type
                                      where c.Document_Type_ID.Equals(file.Document_Type_ID)
                                      select c.Document_Type_Name).FirstOrDefault(),
            };

            Session["FileDelete"] = a;
            return(View(a));
        }
Ejemplo n.º 9
0
        public async Task <ActionResult> DeleteFileAsync(DeleteFileModel model)
        {
            try
            {
                string[] fileNetRefIds;
                if (model.FileName.Contains("/GetFile/"))
                {
                    fileNetRefIds = model.FileName.Split("/GetFile/")[1].Split(":");
                }
                else
                {
                    fileNetRefIds = model.FileName.Split(":");
                }
                model.FileName = fileNetRefIds[0];
                await _ApiClient.PostAsync <string>("FileNet/Delete", null, model);

                return(Json(new { status = 1, success = true }));
            }
            catch
            {
                return(Json(new { status = 0, success = false, message = "خطأ أثناء حذف الملف!" }));
            }
        }
Ejemplo n.º 10
0
 public async Task <string> Delete([FromBody] DeleteFileModel model)
 {
     return(await DeleteFileReferences(model));
 }
Ejemplo n.º 11
0
 public HttpResponseMessage DeleteFile(DeleteFileModel model)
 {
     return(fileService.Delete(model, Request));
 }
Ejemplo n.º 12
0
 public HttpResponseMessage Delete(DeleteFileModel model, HttpRequestMessage request)
 {
     fileManager.Delete(model.Path, model.Name);
     return(request.CreateResponse(HttpStatusCode.OK, string.Format(Resources.FileHasBeenRemoved, model.Name)));
 }
Ejemplo n.º 13
0
 //[Authorize(AuthenticationSchemes = "Identity.Application", Roles = "Administrator")]
 public IActionResult Delete([FromBody] DeleteFileModel model)
 {
     return(_codeFactory.GetStatusCode(_service.Delete(model)));
 }