示例#1
0
 public static void HandleFilters(FolderUnit path, List<string> FilterSt)
 {
     FiltArg filarg = new FiltArg();
     filarg.path = path;
     filarg.FilterSt = FilterSt;
     new Thread(ThreadHandleFilter).Start((object) filarg);
 }
示例#2
0
        public async Task <FolderUnitDto> CreateAsync(FolderUnitDto dto)
        {
            var user = await _usersService?.GetCurrentUser();

            var localUser = await _unitOfWork?.Users?.Query.FirstOrDefaultAsync(x => x.GlobalId == user.id);

            var space = await _unitOfWork?.Spaces?.GetByIdAsync(dto.SpaceId);

            var parentFolder = await _unitOfWork?.Folders?.GetByIdAsync(dto.ParentId);

            List <User> ReadPermittedUsers = new List <User>();

            ReadPermittedUsers.Add(localUser);

            List <User> ModifyPermittedUsers = new List <User>();

            ModifyPermittedUsers.Add(localUser);


            if (space != null)
            {
                var folder = new FolderUnit
                {
                    Description = dto.Description,
                    Name        = dto.Name,

                    CreatedAt            = DateTime.Now,
                    LastModified         = DateTime.Now,
                    IsDeleted            = false,
                    Space                = space,
                    FolderUnit           = parentFolder,
                    Owner                = await _unitOfWork.Users.Query.FirstOrDefaultAsync(u => u.GlobalId == user.id),
                    ModifyPermittedUsers = ModifyPermittedUsers,
                    ReadPermittedUsers   = ReadPermittedUsers
                };

                _unitOfWork?.Folders?.Create(folder);
                await _unitOfWork?.SaveChangesAsync();

                dto.Id           = folder.Id;
                dto.CreatedAt    = folder.CreatedAt;
                dto.LastModified = folder.LastModified;
                dto.Author       = new AuthorDto()
                {
                    Id = folder.Owner.Id, Name = user.name + ' ' + user.surname
                };

                return(dto);
            }
            return(null);
        }
示例#3
0
        public FilterFileForm(FolderUnit path, List<string> CurList, List<string> FilterSt, List<string> monitor)
        {
            InitializeComponent();
            this.ResizeRedraw = true;
            FilterPanelList = new PanelList<FilterObject>();
            this.FilterPanel.Controls.Add(FilterPanelList);
            FilterRowFromFilterObject fromMo = new FilterRowFromFilterObject();
            fromMo.monitor = monitor;
            fromMo.FilterStrings = FilterSt;
            FilterPanelList.PanelFromData = fromMo;
            FilterPanelList.Dock = DockStyle.Fill;
            FilterObList = new List<FilterObject>();

            if (path != null && path.externalLocation.Length > 0)
            {
                FillFilterPanelList(path, CurList, FilterSt);
            }
            this.DialogResult = DialogResult.Cancel;
        }
示例#4
0
        public void FillFilterPanelList(FolderUnit path,List<string> CurList,List<string> FilterSt)
        {
            List<string> CpyFil = new List<string>();
            if (FilterSt != null)
            {
                CpyFil.AddRange(FilterSt);
            }
            string filPath = path.externalLocation;
            if (path.type == Delimiter.FOLDER)
            {
                if (filPath.EndsWith(Convert.ToString(Path.DirectorySeparatorChar)) == false)
                {
                    filPath = filPath + Path.DirectorySeparatorChar;
                }
            }

            FilterObject fil = new FilterObject();

            fil.filter = filPath;
            fil.Custom = false;
            if (CurList.Contains(fil.filter))
            {
                fil.discription = "Exact Path (already in use)";
                fil.mode = FilterObject.FilterObjectMode.KEEP;
                fil.use = true;
            }
            else
            {
                fil.discription = "Exact Path";
                fil.mode = FilterObject.FilterObjectMode.SELECT;
                fil.use = false;
            }
            CpyFil.Remove(fil.filter);
            FilterObList.Add(fil);

            fil = new FilterObject();
            string filSla = filPath;
            if(filSla.EndsWith(Convert.ToString(Path.DirectorySeparatorChar)))
            {
                filSla = filSla.Substring(0, filSla.Length - 2);
            }

            fil.filter = ZlpPathHelper.GetDirectoryNameFromFilePath(filSla);
            if (fil.filter.EndsWith(Convert.ToString(Path.DirectorySeparatorChar)) == false)
            {
                fil.filter = fil.filter + Path.DirectorySeparatorChar;
            }
            fil.Custom = false;
            if (CurList.Contains(fil.filter))
            {
                fil.discription = "Parent Folder (already in use)";
                fil.mode = FilterObject.FilterObjectMode.KEEP;
                fil.use = true;
            }
            else
            {
                fil.discription = "Parent Folder";
                fil.mode = FilterObject.FilterObjectMode.SELECT;
                fil.use = false;
            }
            CpyFil.Remove(fil.filter);
            FilterObList.Add(fil);

            if (path.type == Delimiter.FILE && ZlpPathHelper.GetExtension(filPath).Length > 0)
            {
                string extention = "*" + ZlpPathHelper.GetExtension(filPath);
                if (extention != null && extention.Length > 0)
                {
                    fil = new FilterObject();
                    fil.filter = extention;
                    fil.Custom = false;
                    if (CurList.Contains(fil.filter))
                    {
                        fil.discription = "Extention (already in use)";
                        fil.mode = FilterObject.FilterObjectMode.KEEP;
                        fil.use = true;
                    }
                    else
                    {
                        fil.discription = "Extention";
                        fil.mode = FilterObject.FilterObjectMode.SELECT;
                        fil.use = false;
                    }
                    CpyFil.Remove(fil.filter);
                    FilterObList.Add(fil);
                }
            }

            string customPa = ZlpPathHelper.GetFileNameFromFilePath(filPath);
            if (customPa.Length == 0)
            {
                customPa = filPath.Substring(0, filPath.Length - 1);
                customPa = Path.DirectorySeparatorChar +
                           ZlpPathHelper.GetFileNameFromFilePath(customPa) +
                           Path.DirectorySeparatorChar;
            }

            fil = new FilterObject();
            fil.filter = "*" + customPa + "*";

            if (CurList.Contains(fil.filter))
            {
                fil.discription = "Custom (already in use)";
                fil.Custom = false;
                fil.mode = FilterObject.FilterObjectMode.KEEP;
                fil.use = true;
                CpyFil.Remove(fil.filter);
                FilterObList.Add(fil);

                fil = new FilterObject();
                fil.discription = "Custom";
                fil.Custom = true;
                fil.filter = "";
                fil.mode = FilterObject.FilterObjectMode.SELECT;
                fil.use = false;
                FilterObList.Add(fil);

            }
            else
            {
                fil.discription = "Custom";
                fil.Custom = true;
                fil.mode = FilterObject.FilterObjectMode.SELECT;
                fil.use = false;
                CpyFil.Remove(fil.filter);
                FilterObList.Add(fil);
            }
            foreach (string filt in CpyFil)
            {
                fil = new FilterObject();
                fil.filter = filt;
                if (CurList.Contains(filt))
                {
                    fil.discription = "Curently filtering " + filPath + " (already in use)";
                    fil.mode = FilterObject.FilterObjectMode.KEEP;
                    fil.use = true;

                }
                else
                {
                    fil.discription = "Use to filter " + filPath + " (not in use)";
                    fil.mode = FilterObject.FilterObjectMode.SELECT;
                    fil.use = false;
                }
                fil.Custom = false;

                FilterObList.Insert(0,fil);
            }

            FilterPanelList.AddData(FilterObList);
        }
示例#5
0
        private async Task CopyFolder(int folderToCopyId, string folderName, User owner, Space space, FolderUnit destination)
        {
            var folder = await _unitOfWork?.Folders?.Query
                         .Include(f => f.DataUnits.Select(u => u.ReadPermittedUsers))
                         .Include(f => f.DataUnits.Select(u => u.ModifyPermittedUsers))
                         .Include(f => f.DataUnits.Select(u => u.ReadPermittedRoles))
                         .Include(f => f.DataUnits.Select(u => u.MorifyPermittedRoles))
                         .Include(f => f.ModifyPermittedUsers)
                         .Include(f => f.ReadPermittedUsers)
                         .Include(f => f.MorifyPermittedRoles)
                         .Include(f => f.ReadPermittedRoles)
                         .SingleOrDefaultAsync(f => f.Id == folderToCopyId);

            if (folder == null)
            {
                return;
            }

            var copy = new FolderUnit
            {
                Name                 = folderName,
                Description          = folder.Description,
                IsDeleted            = folder.IsDeleted,
                CreatedAt            = DateTime.Now,
                LastModified         = DateTime.Now,
                Space                = space,
                Owner                = owner,
                ModifyPermittedUsers = folder.ReadPermittedUsers,
                ReadPermittedUsers   = folder.ModifyPermittedUsers,
                MorifyPermittedRoles = folder.MorifyPermittedRoles,
                ReadPermittedRoles   = folder.ReadPermittedRoles,
                FolderUnit           = destination
            };

            _unitOfWork.Folders.Create(copy);

            foreach (var subfolder in folder.DataUnits.OfType <FolderUnit>())
            {
                await CopyFolder(subfolder.Id, subfolder.Name, owner, space, copy);
            }
            foreach (var file in folder.DataUnits.OfType <FileUnit>().Where(x => !x.IsDeleted))
            {
                var newFile = new FileUnit
                {
                    Name                 = file.Name,
                    Description          = file.Description,
                    IsDeleted            = file.IsDeleted,
                    CreatedAt            = DateTime.Now,
                    LastModified         = DateTime.Now,
                    FileType             = file.FileType,
                    Link                 = file.Link,
                    Owner                = owner,
                    Space                = space,
                    FolderUnit           = copy,
                    ModifyPermittedUsers = file.ReadPermittedUsers,
                    ReadPermittedUsers   = file.ModifyPermittedUsers,
                    MorifyPermittedRoles = file.MorifyPermittedRoles,
                    ReadPermittedRoles   = file.ReadPermittedRoles
                };

                _unitOfWork.Files.Create(newFile);
            }

            await _unitOfWork?.SaveChangesAsync();
        }
 private void SetFilteredFiles()
 {
     TreeNode nodeToadd;
     string filWoPa;
     MgprF.SetOptions(m_options.proper);
     int type;
     foreach (string fil in EveryFolderAndFile)
     {
         nodeToadd = null;
         foreach (TreeNode SearcNod in TreeNodeFromString.Values)
         {
             nodeToadd = FindNo(SearcNod, fil);
             if (nodeToadd != null)
             {
                 break;
             }
         }
         if (nodeToadd != null)
         {
             if (ZlpIOHelper.DirectoryExists(fil))
             {
                 filWoPa = fil + Path.DirectorySeparatorChar;
                 type = Delimiter.FOLDER;
             }
             else
             {
                 filWoPa = fil;
                 type = Delimiter.FILE;
             }
             FolderUnit fu = new FolderUnit(fil,type);
             if (filt.isFiltered(filWoPa) || MgprF.isExcluded(filWoPa,fu))
             {
                 nodeToadd.BackColor = Color.LightCoral;
             }
             else
             {
                 nodeToadd.BackColor = Color.White;
             }
         }
     }
 }
        public void HandleFilDoubleClick(object patO)
        {
            string pat = (string) patO;
            FolderUnit fole = new FolderUnit();
            fole.externalLocation = pat;
            if (ZlpIOHelper.DirectoryExists(pat))
            {
                fole.externalLocation += Path.DirectorySeparatorChar;
                fole.type = Delimiter.FOLDER;
            }
            else
            {
                fole.type = Delimiter.FILE;
            }
            FilterFileForm fiFor = new FilterFileForm(fole, FilterString, null, null);
            fiFor.ShowDialog();
            if (fiFor.DialogResult == DialogResult.OK)
            {
               FilterChangeOb list= fiFor.GetLists();
               foreach (string addl in list.addFilfer)
               {
                   filt.AddFilter(addl);
               }

               foreach (string remol in list.removeFilter)
               {
                   filt.RemoveFilter(remol);
               }

                FilterObject defFiltOb;
                List<FilterObject> Addit = new List<FilterObject>();
                foreach (string listIt in list.addFilfer)
                {
                    if (FilterString.Contains(listIt) == false)
                    {
                        defFiltOb = new FilterObject();
                        defFiltOb.filter = listIt;
                        defFiltOb.use = true;
                        defFiltOb.mode = FilterObject.FilterObjectMode.KEEP;
                        defFiltOb.AddToCa(this);
                        //Note needed because cusfil.AddFil(Addit);
                        // will do FilterO.Add(defFiltOb);
                        Addit.Add(defFiltOb);
                        FilterString.Add(listIt);
                    }

                }

                cusfil.AddFil(Addit);
                UserAddFilter.AddRange(Addit);
            }
            try
            {
                this.MonGroTreeView.Invoke(new VoidNoArgDelegate(SetFilteredFiles));
            }
            catch (InvalidOperationException)
            {
                //throw away
            }
        }