Example #1
0
 public override void FileDeleted(FileResponse res, FileDeleteRequest req)
 {
     GetResizedImageMetaData(req.FileId)
     .ForEach(x =>
     {
         _fileManager.Delete(AppDir + x.MetaData.ToObject <ImageData>().Path);
         _unitOfWork.Delete(x);
     });
 }
        private async Task HandleFileDeleteRequest(FileDeleteRequest msg)
        {
            var fileInfo = new LockerObject {
                name = msg.filename
            };

            Database.Instance.DeleteFile(_user, fileInfo);
            IOController.Instance.Delete($"{UserPath}/{msg.filename}");
            _user = Database.Instance.GetUser(_user._id);
            await SendFileCatalogUpdate(_user.locker);
        }
        public async Task <FileResponse> Delete(FileDeleteRequest request)
        {
            var res = await _fileService.Delete(request);

            if (res.Access == ResponseAccess.Granted)
            {
                _observers.ForEach(x => x.FileDeleted(res, request));
                await _unitOfWork.SaveChangesAsync();
            }
            return(res);
        }
Example #4
0
        public async Task <FileResponse> Delete(FileDeleteRequest request)
        {
            var file = _fileDataService.Query.First(x => x.Id == request.FileId);
            await base.BaseBeforeDeleteAsync(file, request.RequestOwner);

            _fileManager.Delete(_appDir + file.Path);
            await _fileDataService.DeleteAsync(request.FileId);

            await base.BaseAfterDeleteAsync(file, request.RequestOwner);

            return(Success());
        }
Example #5
0
        //public WebApiResult<LogEntity> GetList(LogReadRequest Request)
        //{
        //    List<LogEntity> loglist = new List<LogEntity>();

        //    XmlDocument xmlDoc = new XmlDocument();
        //    xmlDoc.Load(HttpContext.Current.Server.MapPath("/Log/Log.xml"));

        //    XmlNodeList nodeList = xmlDoc.SelectSingleNode("DataItem").ChildNodes;

        //    foreach (XmlElement item in nodeList)
        //    {
        //        loglist.Add(new LogEntity() { GUID = item.GetAttribute("GUID"), Type = item.SelectSingleNode("Type").InnerText, Name = item.SelectSingleNode("Name").InnerText, Description = item.SelectSingleNode("Description").InnerText, DataInfo = item.SelectSingleNode("DataInfo").InnerText, ErrorMsg = item.SelectSingleNode("ErrorMsg").InnerText, Parameter = item.SelectSingleNode("Parameter").InnerText, AddTime = item.SelectSingleNode("AddTime").InnerText, Status = item.SelectSingleNode("Status").InnerText });
        //    }

        //    return new WebApiResult<LogEntity>() { success = 1, msg = "", results = JsonHelper.ToJson(loglist) };
        //}


        //public WebApiResult<string> Delete(LogDeleteRequest Request)
        //{
        //    XmlDocument xmlDoc = new XmlDocument();
        //    xmlDoc.Load(HttpContext.Current.Server.MapPath("/Log/Log.xml"));

        //    XmlNode root = xmlDoc.SelectSingleNode("DataItem");

        //    XmlNode nodeList = xmlDoc.SelectSingleNode("/DataItem/Log[@GUID='" + Request.GUID + "']");
        //    if (nodeList != null)
        //    {
        //        root.RemoveChild(nodeList);

        //        xmlDoc.Save(HttpContext.Current.Server.MapPath("/Log/Log.xml"));
        //        return new WebApiResult<string>() { success = 1, msg = "删除成功" };
        //    }
        //    else
        //    {
        //        return new WebApiResult<string>() { success = 0, msg = "删除失败,该数据不存在" };
        //    }

        //}

        /// 清空指定的文件夹,同时删除文件夹
        /// </summary>
        /// <param name="dir"></param>
        public WebApiResult <string> FileDelete(FileDeleteRequest Request)
        {
            try
            {
                string dir = Request.Path;
                foreach (string d in Directory.GetFileSystemEntries(dir))
                {
                    if (File.Exists(d))
                    {
                        FileInfo fi = new FileInfo(d);
                        if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                        {
                            fi.Attributes = FileAttributes.Normal;
                        }
                        File.Delete(d);//直接删除其中的文件
                    }
                    else
                    {
                        DeleteFolder(d);////递归删除子文件夹
                        Directory.Delete(d);
                    }
                }

                Directory.Delete(dir);
                return(new WebApiResult <string>()
                {
                    success = 1, msg = "删除成功"
                });
            }
            catch (Exception ex)
            {
                return(new WebApiResult <string>()
                {
                    success = 0, msg = "删除失败,该文件不存在: " + ex.ToString()
                });
            }
        }
 public abstract void FileDeleted(FileResponse res, FileDeleteRequest req);
Example #7
0
        /// <summary>
        /// 文件删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public WebApiResult <string> Any(FileDeleteRequest request)
        {
            LogService service = new LogService();

            return(service.FileDelete(request));
        }