예제 #1
0
        /// <summary>
        /// Searches loaded assemblies for Types that implement
        /// Serialiser <T> and builds a cache.
        /// </summary>
        public static SearchResult Search()
        {
            List <Type> serialiserTypes = new List<Type> ();

            Assembly[] assemblies = AppDomain.CurrentDomain
                .GetAssemblies ()
                .Where (a => a.GetName ().Name.ToLower () != "mscorlib")
                .Where (a => !a.GetName ().Name.ToLower ().StartsWith ("microsoft"))
                .Where (a => !a.GetName ().Name.ToLower ().StartsWith ("mono"))
                .Where (a => !a.GetName ().Name.ToLower ().StartsWith ("system"))
                .Where (a => !a.GetName ().Name.ToLower ().StartsWith ("nunit"))
                .ToArray ();

            foreach (var assembly in assemblies)
            {
                SearchResult sr = Search (assembly);
                serialiserTypes.AddRange (sr.SerialiserTypes);
            }

            var result = new SearchResult ()
            {
                SerialiserTypes = serialiserTypes.ToArray ()
            };

            return result;
        }
 void ScanFile(string aFile, string[] aTerms, PluginLib.ISearchPublisher publishTo)
 {
     System.IO.StreamReader file = new System.IO.StreamReader(aFile);
     string line;
     int lineNumber = 1;
     while ((line = file.ReadLine()) != null)
     {
         foreach (string term in aTerms)
         {
             string lCaseLine = line.ToLowerInvariant();
             if (lCaseLine.Contains(term.ToLowerInvariant()))
             {
                 SearchResult result = new SearchResult
                 {
                     Column = line.IndexOf(term),
                     Line = lineNumber,
                     File = aFile,
                     Text = line.Trim().MakeBold(term)
                 };
                 publishTo.PublishSearchResult(result);
             }
         }
         ++lineNumber;
     }
 }
예제 #3
0
        private SingleRecord(string data)
        {
            var subcode = data.Substring(0, 3);
            if (subcode != "MFS")
                throw new InvalidDataException(
                    string.Format("Expected sub-code of \"{0}\" but got \"{1}\".", "MFS", subcode));

            _tableType = data[3];

            if (!int.TryParse(data.Substring(4, 3), NumberStyles.None, CultureInfo.InvariantCulture, out _tableId))
                throw new InvalidDataException("Couldn't parse the table ID from the single record data.");

            int i;
            if (!int.TryParse(data.Substring(7, 1), NumberStyles.None, CultureInfo.InvariantCulture, out i))
                throw new InvalidDataException("Couldn't parse the result code from the single record data.");
            _resultCode = (SearchResult)i;

            if (_resultCode != SearchResult.Success)
                return;

            if (!int.TryParse(data.Substring(8, 6), NumberStyles.None, CultureInfo.InvariantCulture, out _recordNumber))
                throw new InvalidDataException("Couldn't parse the record number from the single record data.");

            if (data.Length > 14)
                _value = data.Substring(14);
        }
        public ActionResult Index(int? pageSize, int? page)
        {
            string sortColumn = !String.IsNullOrEmpty(Request["sortColumn"]) ? Request["sortColumn"] : "TitleEN";
            string sortOption = !String.IsNullOrEmpty(Request["SortOption"]) ? Request["SortOption"] : SortOption.Asc.ToString();
            SearchResult<tblNew> listAllNews = new SearchResult<tblNew>();

            listAllNews = Service.SearchNews(ABDHFramework.Common.Constants.DefautPagingSizeForNews, (page.HasValue ? (int)page : 1), sortColumn, sortOption);
            
            return View(listAllNews);
        }
예제 #5
0
 public void Can_roundtrip_SearchResult_with_empty_string() {
     var item = new SearchResultItem(1, SearchResultType.Page, "", 0.5, DateTime.UtcNow.WithoutMilliseconds());
     var result = new SearchResult("foo", new[] { item });
     using(var ms = new MemoryStream()) {
         _serializer.Serialize(ms, result);
         ms.Position = 0;
         var result2 = _serializer.Deserialize<SearchResult>(ms);
         Assert.AreEqual(result.ExecutedQuery, result2.ExecutedQuery);
         Assert.AreEqual(result.Count, result2.Count);
         Assert.AreEqual(result.First().Title, result2.First().Title);
     }
 }
 public ActionResult ListAllProduct(int? pageSize, int? page)
 {
     SearchResult<tblProduct> listAllNews = new SearchResult<tblProduct>();
     if (Request.Cookies["Culture"] != null && Request.Cookies["Culture"].Value == "en-US")
     {
         listAllNews = Service.GetAllProduct(NguyenHiep.Common.Constants.DefautPagingSizeForProduct, (page.HasValue ? (int)page : 1), true);
     }
     else
     {
         listAllNews = Service.GetAllProduct(NguyenHiep.Common.Constants.DefautPagingSizeForProduct, (page.HasValue ? (int)page : 1), false);
     }
     return View(listAllNews);
 }
예제 #7
0
파일: Utils.cs 프로젝트: usmanghani/Misc
        public static string FormatSearchResultAsHtml(SearchResult sr)
        {
            StringBuilder html = new StringBuilder("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><style>.highlight{background:yellow;}</style><body><font face=Arial size=5>");
            foreach (string s in sr.GetFragments())
            {
                html.Append(s);
                html.Append("<br/><hr/><br/>");

            }
            html.Append("</font><a href=\"contents.html\">View Original Document...</a></body></html>");
            html.Replace("\n", "<br/>");
            return html.ToString();
        }
        public ActionResult ListCategory(int? pageSize, int? page, String sortColunm, String sortOption)
        {
            SearchResult<tblCategory> listAllCategory = new SearchResult<tblCategory>();
            if (Request.Cookies["Culture"] != null && Request.Cookies["Culture"].Value == "en-US")
            {
              listAllCategory = Service.GetAllCategory(Common.Constants.DefautPagingSizeForCategory, (page.HasValue ? (int)page : 1), true,"", sortColunm, sortOption);
            }
            else
            {
              listAllCategory = Service.GetAllCategory(Common.Constants.DefautPagingSizeForCategory, (page.HasValue ? (int)page : 1), false,"", sortColunm, sortOption);
            }

            return View(listAllCategory);
        }
예제 #9
0
파일: Utils.cs 프로젝트: usmanghani/Misc
 public static string GetHilitedContentsWithoutHeaders(SearchResult sr)
 {
     StringBuilder result = new StringBuilder("<font face=Arial size=5>");
     string contents = sr.GetDocContents();
     SimpleHTMLFormatter formatter = new SimpleHTMLFormatter("<span class=\"highlight\">", "</span>");
     SimpleFragmenter fragmenter = new SimpleFragmenter(sr.FragmentSize);
     Highlighter hiliter = new Highlighter(formatter, new QueryScorer(sr.QueryParser.Parse(sr.Query)));
     hiliter.SetTextFragmenter(fragmenter);
     int numfragments = contents.Length / fragmenter.GetFragmentSize() + 1;
     TokenStream tokenstream = sr.Analyzer.TokenStream("contents", new StringReader(contents));
     result.Append(hiliter.GetBestFragments(tokenstream, contents, numfragments, "..."));
     result.Append("</font>");
     result.Replace("\n", "<br/>");
     return result.ToString();
 }
예제 #10
0
파일: Utils.cs 프로젝트: usmanghani/Misc
 public static string GetOriginalHighlightedContents(SearchResult sr)
 {
     StringBuilder result = new StringBuilder("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><style>.highlight{background:yellow;}</style><body><font face=Arial size=5>");
     string contents = sr.GetDocContents();
     SimpleHTMLFormatter formatter = new SimpleHTMLFormatter("<span class=\"highlight\">", "</span>");
     SimpleFragmenter fragmenter = new SimpleFragmenter(sr.FragmentSize);
     Highlighter hiliter = new Highlighter(formatter, new QueryScorer(sr.QueryParser.Parse(sr.Query)));
     hiliter.SetTextFragmenter(fragmenter);
     int numfragments = contents.Length / fragmenter.GetFragmentSize() + 1;
     TokenStream tokenstream = sr.Analyzer.TokenStream("contents", new StringReader(contents));
     result.Append(hiliter.GetBestFragments(tokenstream, contents, numfragments, "..."));
     result.Append("</font></body></html>");
     result.Replace("\n", "<br/>");
     return result.ToString();
 }
예제 #11
0
 public void TestSearch()
 {
     var db = Directory.EnumerateFiles(Environment.CurrentDirectory).FirstOrDefault(x => x.Contains(DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString()));
     if (db == null) return;
     using (var reader = new StreamReader(db))
     {
         var results = new SearchResults();
         results.Results = new List<SearchResult>();
         reader.ReadToEnd().Split(new char[] { '\n' }).ToList().ForEach(x => { var result = new SearchResult(); result.Raw = x; results.Results.Add(result); });
         var info = new SearchResultsInfo();
         var search = new SearchProcessor();
         Assert.IsTrue(results.Results.Count > 0, "no results returned.");
         Assert.IsTrue(search.Execute(results, info), "Search failed.");
     }
 }
예제 #12
0
        public Dictionary<Package.Version.Condition.ConditionType, List<SearchResult>> SearchPackagesByConditions(IEnumerable<Package.Version.Condition> conditions)
        {
            var ret = new Dictionary<Package.Version.Condition.ConditionType, List<SearchResult>>();

            foreach (var repo in Repositories)
            {
                using (var session = repo._store.OpenSession())
                {
                    // Query all packages in this repo. Hopefully RavenDB caches
                    // this properly. I think so.
                    var packagesQueryAsync = session.Query<Package>().ToList();
                    foreach (var condition in conditions)
                    {
                        // Create empty SearchResult list for yet non-existant condition output
                        if (!ret.ContainsKey(condition.Type))
                        {
                            ret.Add(condition.Type, new List<SearchResult>());
                        }

                        // Get all versions by using whole package information
                        var packagesForName = this.SearchPackagesByName(condition.PackageName);

                        foreach (var package in packagesForName)
                        {
                            SearchResult res = new SearchResult();
                            res.Client = this;
                            res.Repository = repo;
                            res.OriginalPackage = package;
                            res.FoundVersions = new List<Package.Version>();

                            // Go through all matching versions
                            foreach (Package.Version version in SearchPackageVersions(package, condition.PackageVersions))
                            {
                                // Add this version to current condition
                                ((List<Package.Version>)res.FoundVersions).Add(version);

                                // Remove exactly this version in other conditions
                                foreach (var c in ret.Keys.Where(k => !k.Equals(condition.Type)))
                                    foreach (var r in ret[c])
                                        ((List<Package.Version>)r.FoundVersions).RemoveAll(m => m == version);
                            }
                        }
                    }
                }
            }

            return ret;
        }
 public ActionResult ListResult(int? page)
 {
   string sortColumn = !String.IsNullOrEmpty(Request["sortColumn"]) ? Request["sortColumn"] : "TitleEN";
   string sortOption = !String.IsNullOrEmpty(Request["SortOption"]) ? Request["SortOption"] : SortOption.Asc.ToString();
   string criteria = !String.IsNullOrEmpty(Request["Title"]) ? Request["Title"] : "";
   if (!String.IsNullOrEmpty(Request["Command"]) && Request["Command"].ToString() == "Search")
   {
     SearchResult<tblNew> listAllNews = new SearchResult<tblNew>();
     listAllNews = Service.SearchNewsByCriteria(ABDHFramework.Common.Constants.DefautPagingSizeForNews, (page.HasValue ? (int)page : 1), criteria, sortColumn, sortOption);
     return View(listAllNews);
   }
   else
   {
     SearchResult<tblNew> listAllNews = new SearchResult<tblNew>();
     listAllNews = Service.SearchNews(ABDHFramework.Common.Constants.DefautPagingSizeForNews, (page.HasValue ? (int)page : 1), sortColumn, sortOption);
     return View(listAllNews);
   }
 }
        //static XDocument searchXhtml = new XDocument();
        public override void PopulateNames(SearchResult result, ChapterInfo chapterInfo, bool includeDurations)
        {
            XDocument xdoc = XDocument.Load(string.Format("http://www.e-home.no/metaservices/XML/GetDVDInfo.aspx?Extended=True&DVDID={0}", result.Id));
              XElement title = xdoc.Descendants("title").Where(t => t.Elements("chapter").Count() > 0)
            .OrderByDescending(t => t.Elements("chapter").Count()).FirstOrDefault();
              if (title == null) return;

              for (int i = 0; i < chapterInfo.Chapters.Count; i++)
              {
            XElement chapter = title.Elements("chapter").Where(c => (int)c.Element("chapterNum") == i+1)
              .FirstOrDefault();
            if (chapter != null)
              chapterInfo.Chapters[i] = new Chapter()
              {
            Time = chapterInfo.Chapters[i].Time,
            Name = includeDurations ? (string)chapter.Element("chapterTitle") :
            ((string)chapter.Element("chapterTitle")).RemoveDuration()
              };
              }
        }
        public override void PopulateNames(SearchResult result, ChapterInfo chapterInfo, bool includeDurations)
        {
            var chapters = searchResults.Where(r => r.ChapterSetId == int.Parse(result.Id)).First();

            if (chapterInfo.Chapters.Count > 0)
            {
                for (int i = 0; i < chapterInfo.Chapters.Count; i++)
                {
                    chapterInfo.Chapters[i] = new ChapterEntry()
                    {
                        Name = chapters.Chapters[i].Name,
                        Time = chapterInfo.Chapters[i].Time
                    };
                }
            }
            else
            {
                chapterInfo.Chapters = chapters.Chapters;
            }
        }
예제 #16
0
        public YoutubeVideoItem(SearchResult item, int relevance) :
            base(item.Snippet.Title, item, relevance)
        {
            ChannelTitle = item.Snippet.ChannelTitle;
            ChannelId = item.Snippet.ChannelId;

            ResourceId = item.Id;
            Thumbnail = item.Snippet.Thumbnails;
          
            PublishedAt = item.Snippet.PublishedAt;
            Description = item.Snippet.Description;

            VideoId = item.Id.VideoId;

            IsEmbeddedOnly = false;

            Info = item;

            StreamedItem = new List<YoutubeVideoStreamedItem>();                
        }
예제 #17
0
파일: Utils.cs 프로젝트: usmanghani/Misc
        public static SearchResult GetFastSearchResultFragments(ref SearchResult sr)
        {
            Document doc = sr.Document;
            string contents = doc.Get("contents");
            SimpleHTMLFormatter formatter = new SimpleHTMLFormatter("<span class=\"highlight\">", "</span>");
            SimpleFragmenter fragmenter = new SimpleFragmenter(sr.FragmentSize);
            Highlighter hiliter = new Highlighter(formatter, new QueryScorer(sr.QueryParser.Parse(sr.Query)));
            hiliter.SetTextFragmenter(fragmenter);
            int numfragments = contents.Length / fragmenter.GetFragmentSize() + 1;
            TokenStream tokenstream = sr.Analyzer.TokenStream("contents", new StringReader(contents));
            TextFragment[] frags = hiliter.GetBestTextFragments(tokenstream, contents, false, numfragments);
            //SearchResult sr = new SearchResult(doc, _analyzer, query, _fragmentSize);
            foreach (TextFragment frag in frags)
            {

                if (frag.GetScore() > 0)
                    sr.AddFragment(frag.ToString());

            }
            return sr;
        }
예제 #18
0
        public static void NewResult(SearchResult searchResult)
        {
            lock (FileLocker)
            {

                using (System.IO.StreamWriter w = System.IO.File.AppendText("outputTest"))
                {
                    w.WriteLine("PEER NUMBER : " + searchResult.PeerCollection.Count.ToString());
                    w.WriteLine("FILE NUMBER : " + searchResult.FileCollection.Count.ToString());

                    foreach (Peer p in searchResult.PeerCollection)
                    {
                        w.WriteLine(p.Ip + "\t" + p.Files.Count.ToString() + "files, " + p.SharedLocalfilesList.Count + " shared files ...");
                        if (p.Files.Count >= 1)
                        {

                            w.WriteLine("------------------------------------------");
                            w.WriteLine ("Searched files: ");

                            foreach (File f in p.Files)
                            {
                                w.WriteLine(f.Name + " hash : " + f.Hash);
                            }
                        }
                        if (p.SharedLocalfilesList.Count >= 1) {
                            w.WriteLine ("-------------------------------------------");
                            w.WriteLine ("Shared files: ");
                            foreach (File f in p.SharedLocalfilesList) {
                                w.WriteLine (f.Name + " from ip " + p.Ip + " or first peerdiffusedfiles : " + f.PeerDiffusedFiles [0].Ip);
                            }
                        }
                        w.WriteLine("###################################################################################");
                        w.WriteLine("###################################################################################");

                    }

                }
            }
        }
        public ActionResult IndexForProduct(Guid? categoryID, int? pageSize, int? page)
        {

            SearchResult<tblProduct> listAllProduct = new SearchResult<tblProduct>();
            ViewData["Type"] = NewsTypes.NormalProduct;
            if (categoryID.HasValue && categoryID.Value != Guid.Empty)
            {
                listAllProduct = Service.GetAllProductByCategory(Constants.DefautPagingSizeForProduct, (page.HasValue ? (int)page : 1), (Guid)categoryID);
            }
            else
            {
                if (Request.Cookies["Culture"] != null && Request.Cookies["Culture"].Value == "en-US")
                {
                    listAllProduct = Service.GetAllProduct(Constants.DefautPagingSizeForProduct, (page.HasValue ? (int)page : 1), Languages.EN, "", "", "");
                }
                else
                {
                    listAllProduct = Service.GetAllProduct(Constants.DefautPagingSizeForProduct, (page.HasValue ? (int)page : 1), Languages.VN, "", "", "");
                }
            }
            return View(listAllProduct);
        }
예제 #20
0
        public override void PopulateNames(SearchResult result, ChapterInfo chapterInfo, bool includeDurations)
        {
            var chapters = searchResults.Where(r => r.ChapterSetId == int.Parse(result.Id)).First();

            if (chapterInfo.Chapters.Count > 0)
            {
                for (int i = 0; i < chapterInfo.Chapters.Count; i++)
                {
                    if (i < chapters.Chapters.Count)
                    {
                        chapterInfo.Chapters[i] = new ChapterEntry()
                        {
                            Name = chapters.Chapters[i].Name,
                            Time = chapterInfo.Chapters[i].Time
                        };
                    }
                    else Trace.WriteLine("Chapter was ignored because it doesn't fit in current chapter set.");
                }
            }
            else
            {
                chapterInfo.Chapters = chapters.Chapters;
            }
        }
        public ActionResult ListProduct(Guid? categoryID, int? pageSize, int? page, String sortColunm, String sortOption)
        {
            String criteria = "";
            if (Request["Command"] != null && Request["Command"] == "Search" && Request["ProductName"] != null)
                criteria = Request["ProductName"];
            SearchResult<tblProduct> listAllProduct = new SearchResult<tblProduct>();
            if (categoryID.HasValue && categoryID.Value != Guid.Empty)
            {
                listAllProduct = Service.GetAllProductByCategory(Constants.DefautPagingSizeForProduct, (page.HasValue ? (int)page : 1), (Guid)categoryID);
            }
            else
            {
                if (Request.Cookies["Culture"] != null && Request.Cookies["Culture"].Value == "en-US")
                {
                    listAllProduct = Service.GetAllProduct(Common.Constants.DefautPagingSizeForCategory, (page.HasValue ? (int)page : 1), Languages.EN, criteria, sortColunm, sortOption);
                }
                else
                {
                    listAllProduct = Service.GetAllProduct(Common.Constants.DefautPagingSizeForCategory, (page.HasValue ? (int)page : 1), Languages.VN, criteria, sortColunm, sortOption);
                }
            }

            return View(listAllProduct);
        }
        private SearchResult CreateSearchResult(Segment searchSegment, Segment translation,
            string sourceSegment)
        {
            #region "TranslationUnit"
            TranslationUnit tu = new TranslationUnit();
            tu.SourceSegment = searchSegment.Duplicate();//this makes the original source segment, with tags, appear in the search window
            tu.TargetSegment = translation;
            #endregion

            tu.ResourceId = new PersistentObjectToken(tu.GetHashCode(), Guid.Empty);

            int score = 0; //score to 0...change if needed to support scoring
            tu.Origin = TranslationUnitOrigin.MachineTranslation;
            SearchResult searchResult = new SearchResult(tu);
            searchResult.ScoringResult = new ScoringResult();
            searchResult.ScoringResult.BaseScore = score;
            tu.ConfirmationLevel = ConfirmationLevel.Draft;

            return searchResult;
        }
예제 #23
0
 private static string moveString(SearchResult res)
 {
     return Conversions.moveToString(res.Move);
 }
예제 #24
0
 private static string resultString(SearchResult res, bool wld, int mid)
 {
     if (mid != 0) {
         return res.MidEvaluationString + " @ " + mid.ToString();
     } else if (wld) {
         if (res.Evaluation > 0) {
             return "Win";
         } else if (res.Evaluation < 0) {
             return "Loss";
         } else {
             return "Draw";
         }
     } else {
         if (res.Evaluation > 0) {
             return "+" + res.Evaluation;
         } else {
             return res.Evaluation.ToString();
         }
     }
 }
예제 #25
0
		public string ToJson(SearchResult<ISource> aSearchResult)
		{
			return theSourceDataMapper.ToJson(aSearchResult);
		}
예제 #26
0
 internal abstract TSource CreateObject(SearchResult result);
예제 #27
0
 internal abstract bool IsResultIncluded(SearchResult result);
예제 #28
0
 internal override String CreateObject(SearchResult result)
 {
     return(result.UserPath);
 }
예제 #29
0
 internal override bool IsResultIncluded(SearchResult result)
 {
     return(Win32FileSystemEnumerableHelpers.IsDir(result.FindData));
 }
예제 #30
0
		public string ToJson(SearchResult<IPlay> aSearchResult)
		{
			ArgCheck.NotNull("aSearchResult", aSearchResult);
			return thePlayDataMapper.ToJson(aSearchResult);
		}
예제 #31
0
        public override bool MoveNext()
        {
            Win32Native.WIN32_FIND_DATA data = new Win32Native.WIN32_FIND_DATA();
            switch (base.state)
            {
            case 1:
                if (!this.empty)
                {
                    if (this.searchData.searchOption == SearchOption.TopDirectoryOnly)
                    {
                        base.state = 3;
                        if (base.current != null)
                        {
                            return(true);
                        }
                        goto Label_017A;
                    }
                    base.state = 2;
                    break;
                }
                base.state = 4;
                goto Label_0250;

            case 2:
                break;

            case 3:
                goto Label_017A;

            case 4:
                goto Label_0250;

            default:
                goto Label_0256;
            }
Label_015D:
            while (this.searchStack.Count > 0)
            {
                this.searchData = this.searchStack[0];
                this.searchStack.RemoveAt(0);
                this.AddSearchableDirsToStack(this.searchData);
                string fileName = this.searchData.fullPath + this.searchCriteria;
                this._hnd = Win32Native.FindFirstFile(fileName, data);
                if (this._hnd.IsInvalid)
                {
                    int hr = Marshal.GetLastWin32Error();
                    switch (hr)
                    {
                    case 2:
                    case 0x12:
                    case 3:
                    {
                        continue;
                    }
                    }
                    this._hnd.Dispose();
                    this.HandleError(hr, this.searchData.fullPath);
                }
                base.state = 3;
                this.needsParentPathDiscoveryDemand = true;
                SearchResult result = this.CreateSearchResult(this.searchData, data);
                if (!this._resultHandler.IsResultIncluded(result))
                {
                    goto Label_017A;
                }
                if (this.needsParentPathDiscoveryDemand)
                {
                    FileSystemEnumerableIterator <TSource> .DoDemand(this.searchData.fullPath);

                    this.needsParentPathDiscoveryDemand = false;
                }
                base.current = this._resultHandler.CreateObject(result);
                return(true);
            }
            base.state = 4;
            goto Label_0250;
Label_017A:
            if ((this.searchData != null) && (this._hnd != null))
            {
                while (Win32Native.FindNextFile(this._hnd, data))
                {
                    SearchResult result2 = this.CreateSearchResult(this.searchData, data);
                    if (this._resultHandler.IsResultIncluded(result2))
                    {
                        if (this.needsParentPathDiscoveryDemand)
                        {
                            FileSystemEnumerableIterator <TSource> .DoDemand(this.searchData.fullPath);

                            this.needsParentPathDiscoveryDemand = false;
                        }
                        base.current = this._resultHandler.CreateObject(result2);
                        return(true);
                    }
                }
                int num2 = Marshal.GetLastWin32Error();
                if (this._hnd != null)
                {
                    this._hnd.Dispose();
                }
                if (((num2 != 0) && (num2 != 0x12)) && (num2 != 2))
                {
                    this.HandleError(num2, this.searchData.fullPath);
                }
            }
            if (this.searchData.searchOption == SearchOption.TopDirectoryOnly)
            {
                base.state = 4;
            }
            else
            {
                base.state = 2;
                goto Label_015D;
            }
Label_0250:
            base.Dispose();
Label_0256:
            return(false);
        }
예제 #32
0
        private TvdbSearchResult SearchSeries(string idOrName, bool stringIsIMDB = false)
        {
            TvdbSearchResult result;
              if (stringIsIMDB)
              {
            try
            {
              result = TVDB.GetSeriesByRemoteId(ExternalId.ImdbId, idOrName);
              if (result == null)
            return null;
            }
            catch (Exception ex)
            {
              MessageBox.Show("An error occured: " + ex.Message);
              return null;
            }
              }
              else
              {
            try
            {
              var list = TVDB.SearchSeries(idOrName);
              if (list.Count == 0)
              {
            MessageBox.Show("nothing found");
            return null;
              }

              int iResult;
              if (list.Count > 1)
              {
            SearchResult w = new SearchResult();
            w.SetItemSource(list);
            w.ShowDialog();
            iResult = w.SelectedIndex;
              }
              else
            iResult = 0;

              if (iResult < 0)
            return null;

              result = list[iResult];
            }
            catch (Exception ex)
            {
              MessageBox.Show("An error occured: " + ex.Message);
              return null;
            }
              }

              return result;
        }
 public ActionResult AdminListProduct(int? page)
 {
     string sortColumn = !String.IsNullOrEmpty(Request["sortColumn"]) ? Request["sortColumn"] : "ProductName";
     string sortOption = !String.IsNullOrEmpty(Request["SortOption"]) ? Request["SortOption"] : SortOption.Asc.ToString();
     SearchResult<tblProduct> listAllProduct = new SearchResult<tblProduct>();
     if (Request.Cookies["Culture"] != null && Request.Cookies["Culture"].Value == "en-US")
     {
         listAllProduct = Service.GetAllProduct(Common.Constants.DefautPagingSizeForProduct, (page.HasValue ? page.Value : 1), Languages.EN, "", sortColumn, sortOption);
     }
     else
     {
         listAllProduct = Service.GetAllProduct(Common.Constants.DefautPagingSizeForProduct, (page.HasValue ? page.Value : 1), Languages.VN, "", sortColumn, sortOption);
     }
     ViewData["Page"] = (page.HasValue ? page.Value : 1);
     return View("Admin/AdminListProduct", listAllProduct);
 }
 public ActionResult AdminListCategory(int? page)
 {
   string sortColumn = !String.IsNullOrEmpty(Request["sortColumn"]) ? Request["sortColumn"] : "CategoryName";
   string sortOption = !String.IsNullOrEmpty(Request["SortOption"]) ? Request["SortOption"] : SortOption.Asc.ToString();
   SearchResult<tblCategory> listAllCategory = new SearchResult<tblCategory>();
   if (Request.Cookies["Culture"] != null && Request.Cookies["Culture"].Value == "en-US")
   {
     listAllCategory = Service.GetAllCategory(Common.Constants.DefautPagingSizeForCategory, (page.HasValue ? page.Value : 1), true, "", sortColumn, sortOption);
   }
   else
   {
     listAllCategory = Service.GetAllCategory(Common.Constants.DefautPagingSizeForCategory, (page.HasValue ? page.Value : 1), false, "", sortColumn, sortOption);
   }
   ViewData["Page"] = (page.HasValue ? page.Value : 1);
   return View("Admin/AdminListCategory", listAllCategory);
 }
예제 #35
0
		public string ToJson(SearchResult<IUser> aSearchResult)
		{
			return theUserDataMapper.ToJson(aSearchResult);
		}
예제 #36
0
        public override bool MoveNext()
        {
            Interop.WIN32_FIND_DATA data = new Interop.WIN32_FIND_DATA();
            switch (state)
            {
            case STATE_INIT:
            {
                if (_empty)
                {
                    state = STATE_FINISH;
                    goto case STATE_FINISH;
                }
                if (_searchData.searchOption == SearchOption.TopDirectoryOnly)
                {
                    state = STATE_FIND_NEXT_FILE;
                    if (current != null)
                    {
                        return(true);
                    }
                    else
                    {
                        goto case STATE_FIND_NEXT_FILE;
                    }
                }
                else
                {
                    state = STATE_SEARCH_NEXT_DIR;
                    goto case STATE_SEARCH_NEXT_DIR;
                }
            }

            case STATE_SEARCH_NEXT_DIR:
            {
                Debug.Assert(_searchData.searchOption != SearchOption.TopDirectoryOnly, "should not reach this code path if searchOption == TopDirectoryOnly");
                // Traverse directory structure. We need to get '*'
                while (_searchStack.Count > 0)
                {
                    _searchData = _searchStack[0];
                    Debug.Assert((_searchData.fullPath != null), "fullpath can't be null!");
                    _searchStack.RemoveAt(0);

                    // Traverse the subdirs
                    AddSearchableDirsToStack(_searchData);

                    // Execute searchCriteria against the current directory
                    String searchPath = Path.Combine(_searchData.fullPath, _searchCriteria);

                    // Open a Find handle
                    _hnd = Interop.mincore.FindFirstFile(searchPath, ref data);
                    if (_hnd.IsInvalid)
                    {
                        int errorCode = Marshal.GetLastWin32Error();
                        if (errorCode == Interop.ERROR_FILE_NOT_FOUND || errorCode == Interop.ERROR_NO_MORE_FILES || errorCode == Interop.ERROR_PATH_NOT_FOUND)
                        {
                            continue;
                        }

                        _hnd.Dispose();
                        HandleError(errorCode, _searchData.fullPath);
                    }

                    state = STATE_FIND_NEXT_FILE;

                    SearchResult searchResult = CreateSearchResult(_searchData, data);
                    if (_resultHandler.IsResultIncluded(searchResult))
                    {
                        current = _resultHandler.CreateObject(searchResult);
                        return(true);
                    }
                    else
                    {
                        goto case STATE_FIND_NEXT_FILE;
                    }
                }
                state = STATE_FINISH;
                goto case STATE_FINISH;
            }

            case STATE_FIND_NEXT_FILE:
            {
                if (_searchData != null && _hnd != null)
                {
                    // Keep asking for more matching files/dirs, add it to the list
                    while (Interop.mincore.FindNextFile(_hnd, ref data))
                    {
                        SearchResult searchResult = CreateSearchResult(_searchData, data);
                        if (_resultHandler.IsResultIncluded(searchResult))
                        {
                            current = _resultHandler.CreateObject(searchResult);
                            return(true);
                        }
                    }

                    // Make sure we quit with a sensible error.
                    int errorCode = Marshal.GetLastWin32Error();

                    if (_hnd != null)
                    {
                        _hnd.Dispose();
                    }

                    // ERROR_FILE_NOT_FOUND is valid here because if the top level
                    // dir doen't contain any subdirs and matching files then
                    // we will get here with this errorcode from the searchStack walk
                    if ((errorCode != 0) && (errorCode != Interop.ERROR_NO_MORE_FILES) &&
                        (errorCode != Interop.ERROR_FILE_NOT_FOUND))
                    {
                        HandleError(errorCode, _searchData.fullPath);
                    }
                }
                if (_searchData.searchOption == SearchOption.TopDirectoryOnly)
                {
                    state = STATE_FINISH;
                    goto case STATE_FINISH;
                }
                else
                {
                    state = STATE_SEARCH_NEXT_DIR;
                    goto case STATE_SEARCH_NEXT_DIR;
                }
            }

            case STATE_FINISH:
            {
                Dispose();
                break;
            }
            }
            return(false);
        }