Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        private static void FindInItem(SearchCondition search, ref List <SCFile> lstFoundFiles, Item itm)
        {
            try
            {
                Stream       fileStream = itm.DownloadFile();
                StreamReader r          = new StreamReader(fileStream);
                int          lineNo     = 0;
                do
                {
                    lineNo++;
                    string s = r.ReadLine();
                    if (search.Matches(s))
                    {
                        SCFile file = new SCFile();
                        file.FilePath    = itm.ServerItem;
                        file.Size        = itm.ContentLength;
                        file.ItemId      = itm.ItemId;
                        file.ChangesetId = itm.ChangesetId;
                        file.Comment     = lineNo.ToString();



                        file.PreviewText = ReadPreviewTextFromStream(itm, lineNo, search, 5);

                        lstFoundFiles.Add(file);

                        break;
                    }
                } while (!r.EndOfStream);
                r.Dispose();
                fileStream.Dispose();
            }
            catch (Exception ex)
            {
                SCFile file = new SCFile();
                file.FilePath = itm.ServerItem;
                file.Size     = itm.ContentLength;
                file.Comment  = "ERROR reading file content: " + ex.Message;
                lstFoundFiles.Add(file);
            }
        }
Exemplo n.º 4
0
 public static void AddFileToList(SCFile file, List <SCFile> lst)
 {
     lst.Add(file);
     file.NotifyPropertyChanged("FoundFiles");
 }