示例#1
0
        public List <SCFile> SearchForCheckIn(SCFolder fld, Wildcard user, Wildcard comment, Wildcard fileNameFilter, SearchCondition search, bool bSearchInHistory, CancelCallbackNotify callback)
        {
            QueryHistoryParameters  qhp           = new QueryHistoryParameters(fld.FolderPath, RecursionType.None);
            List <SCFile>           lstFoundFiles = new List <SCFile>();
            IEnumerable <Changeset> changesets    = null;

            int i = 0;

            foreach (Changeset chgset in changesets)
            {
                i++;
                if (user.IsMatch(chgset.Committer))
                {
                    if (callback.DoCallback((double)i / changesets.Count(), chgset.ChangesetId.ToString(), ref lstFoundFiles))
                    {
                        return(lstFoundFiles);
                    }

                    if (comment.IsMatch(chgset.Comment))
                    {
                        SCFile file = new SCFile();
                        file.ChangesetId = chgset.ChangesetId;
                        file.Comment     = chgset.Comment.ToString();
                        file.FilePath    = chgset.Committer;
                        SCFile.AddFileToList(file, lstFoundFiles);
                    }
                }
            }
            return(lstFoundFiles);
        }
示例#2
0
        public List <SCFile> SearchForFile(SCFolder fld, Wildcard fileNameFilter, long minSize)
        {
            ItemSet items = scSrv.GetItems(fld.FolderPath, VersionSpec.Latest, RecursionType.OneLevel, DeletedState.NonDeleted, ItemType.Any);

            List <SCFile> lst = new List <SCFile>();

            foreach (Item itm in items.Items)
            {
                switch (itm.ItemType)
                {
                case ItemType.File:
                    if (itm.ContentLength > minSize)
                    {
                        if (fileNameFilter.IsMatch(itm.ServerItem))
                        {
                            SCFile file = new SCFile();
                            file.ItemId      = itm.ItemId;
                            file.ChangesetId = itm.ChangesetId;
                            file.FilePath    = itm.ServerItem;
                            file.Size        = itm.ContentLength;

                            Changeset chgSet = itm.VersionControlServer.GetChangeset(itm.ChangesetId);

                            file.Committer   = chgSet.Committer;
                            file.CheckInDate = itm.CheckinDate;

                            file.Comment = chgSet.Comment;
                            if (itm.DeletionId != null)
                            {
                                file.Deleted = itm.DeletionId != 0;
                            }

                            SCFile.AddFileToList(file, lst);
                        }
                    }

                    break;

                case ItemType.Folder:
                    if (itm.ServerItem != fld.FolderPath)
                    {
                        SCFolder child = new SCFolder {
                            FolderPath = itm.ServerItem
                        };
                        lst.AddRange(SearchForFile(child, fileNameFilter, minSize));
                    }

                    break;
                }
            }

            return(lst);
        }
示例#3
0
        public void CalcSize(ref SCFolder fld)
        {
            ItemSet items = scSrv.GetItems(fld.FolderPath, VersionSpec.Latest, RecursionType.OneLevel, DeletedState.NonDeleted, ItemType.Any);

            long totalExclusive = 0;
            long totalInclusive = 0;

            foreach (Item itm in items.Items)
            {
                switch (itm.ItemType)
                {
                case ItemType.File:
                    long size = itm.ContentLength;
                    totalExclusive += size;
                    string fileExt = itm.ServerItem.Split('.').Last();
                    if (!fld.FileTypes.Keys.Contains(fileExt))
                    {
                        fld.FileTypes.Add(fileExt, 0);
                    }

                    fld.FileTypes[fileExt] += size;

                    break;

                case ItemType.Folder:
                    if (itm.ServerItem != fld.FolderPath)
                    {
                        SCFolder child = new SCFolder {
                            FolderPath = itm.ServerItem
                        };
                        CalcSize(ref child);
                        fld.SetInclusiveSize();
                        fld.AddFolder(child);
                        totalInclusive += child.SizeInclusive;
                    }

                    break;
                }
            }

            fld.SizeExclusive = totalExclusive;
            fld.SetInclusiveSize();
        }
示例#4
0
        public List <SCFile> SearchForFileContent(SCFolder fld, Wildcard fileNameFilter, SearchCondition search, bool bSearchInHistory, CancelCallbackNotify callback)
        {
            ItemSet       items         = scSrv.GetItems(fld.FolderPath, VersionSpec.Latest, RecursionType.OneLevel, DeletedState.Any, ItemType.Any);
            List <SCFile> lstFoundFiles = new List <SCFile>();
            Regex         t             = new Regex(@"^(.*\.vb|.*\.xaml)$");
            bool          b             = t.IsMatch("foo.vb");

            int i = 0;

            foreach (Item itmLatest in items.Items)
            {
                if (callback.isCanceled)
                {
                    break;
                }
                switch (itmLatest.ItemType)
                {
                case ItemType.File:
                    i++;
                    if (fileNameFilter.IsMatch(itmLatest.ServerItem))
                    {
                        if (callback.DoCallback((double)i / items.Items.Count(), itmLatest.ServerItem, ref lstFoundFiles))
                        {
                            return(lstFoundFiles);
                        }
                        else


                        if (bSearchInHistory)
                        {
                            foreach (Changeset ch in scSrv.QueryHistory(itmLatest.ServerItem,
                                                                        VersionSpec.Latest,
                                                                        0,
                                                                        RecursionType.Full,
                                                                        string.Empty,
                                                                        null,
                                                                        VersionSpec.Latest,
                                                                        int.MaxValue,
                                                                        true,
                                                                        true))
                            {
                                Item myItm = scSrv.GetItem(itmLatest.ItemId, ch.ChangesetId);
                                if (myItm != null)
                                {
                                    FindInItem(search, ref lstFoundFiles, myItm);
                                }
                            }
                        }
                        else
                        {
                            FindInItem(search, ref lstFoundFiles, itmLatest);
                        }
                    }

                    break;

                case ItemType.Folder:
                    if (itmLatest.ServerItem != fld.FolderPath)
                    {
                        i++;
                        if (callback.DoCallback((double)i / items.Items.Count(), itmLatest.ServerItem, ref lstFoundFiles))
                        {
                            return(lstFoundFiles);
                        }
                        else
                        {
                            SCFolder child = new SCFolder {
                                FolderPath = itmLatest.ServerItem
                            };
                            CancelCallbackNotify subCallback = new CancelCallbackNotify();
                            subCallback._delegate = callback._delegate;
                            subCallback.start     = callback.current;
                            subCallback.range     = 1.0 / (items.Items.Count() - 1);

                            lstFoundFiles.AddRange(SearchForFileContent(child, fileNameFilter, search, bSearchInHistory, subCallback));
                        }
                    }

                    break;
                }
            }

            callback.DoCallback(1, "Done searching " + fld.FolderPath, ref lstFoundFiles);
            return(lstFoundFiles);
        }
示例#5
0
 public void AddFolder(SCFolder fld)
 {
     Folders.Add(fld);
     NotifyPropertyChanged("Folders");
 }