Пример #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 List <SCFile> SearchForFileContent(List <SCFolder> fldLst, Wildcard fileNameFilter, SearchCondition search, bool bSearchInHistory, CancelCallbackNotify callback)
        {
            int i = 0;

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

            foreach (SCFolder fld  in fldLst)
            {
                callback.DoCallback((double)i / fldLst.Count(), fld.FolderPath, ref lstFoundFiles);
                CancelCallbackNotify notify = new CancelCallbackNotify();
                notify._delegate  = callback._delegate;
                notify.start      = callback.current;
                notify.range      = callback.range / fldLst.Count;
                notify.isCanceled = callback.isCanceled;

                lstFoundFiles.AddRange(SearchForFileContent(fld, fileNameFilter, search, bSearchInHistory, notify));
                i++;
                if (notify.isCanceled)
                {
                    break;
                }
            }
            return(lstFoundFiles);
        }
Пример #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);
        }