internal SearchResult(SearchRecord[] records, int skip, int take, long totalResults)
 {
     Records = records;
     Skip = skip;
     Take = take;
     TotalResults = totalResults;
 }
示例#2
0
        /// <summary>
        /// Searches the specified search.
        /// </summary>
        /// <param name="search">The search.</param>
        /// <param name="returnSearchColumns"></param>
        /// <returns>The search result.</returns>
        public override SearchResult Search(SearchRecord search, bool returnSearchColumns)
        {
            var searchPrefs = _svcPoolMgr.ServiceConfiguration.SearchPreferences.Duplicate();

            searchPrefs.returnSearchColumns = returnSearchColumns;
            return(Search(search, searchPrefs));
        }
示例#3
0
        public void FromBinary()
        {
            var loadedSearchRecord = new SearchRecord();

            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "*.bin|*.bin";
                if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    using (var fs = new FileStream(ofd.FileName, FileMode.Open))
                    {
                        if (fs.Length > 0)
                        {
                            var bf = new BinaryFormatter();

                            loadedSearchRecord = (SearchRecord)bf.Deserialize(fs);
                        }
                    }
                }
            }

            App.SearchingRecord = loadedSearchRecord;

            App.FillListView();
            App.FillTextBoxes();
        }
        /// <summary>
        /// 使用二分法和斐波那契查找ip
        /// </summary>
        /// <param name="ipAddr">要查找的ip</param>
        /// <param name="ipRecords">所有的ip</param>
        public static void SearchIpRecord(string ipAddr, IpRecord[] ipRecords, out SearchRecord binary_recorder, out SearchRecord fibonacci_recorder)
        {
            if (!IsStrRegex(ipAddr))
            {
                throw new FormatException();
            }

            Stopwatch sw = Stopwatch.StartNew();

            searchService.Binary_Search(ipRecords, ipAddr.IpAddressToInt(), out binary_recorder);

            sw.Stop();
            binary_recorder.ElapsedMilliseconds = sw.Elapsed.TotalMilliseconds;


            sw.Restart();

            searchService.Fibonacci_Search_Improved(ipRecords, ipAddr.IpAddressToInt(), out fibonacci_recorder);

            sw.Stop();
            fibonacci_recorder.ElapsedMilliseconds = sw.Elapsed.TotalMilliseconds;

            if (binary_recorder.Index != fibonacci_recorder.Index)
            {
                throw new Exception("算法出错, 查找结果不同!");
            }
        }
示例#5
0
        /// <summary>
        /// Searches the specified search.
        /// </summary>
        /// <param name="search">The search.</param>
        /// <param name="returnSearchColumns">
        /// if set to <c>true</c> returns Search Columns rather than entity records.
        /// </param>
        /// <returns>The search result.</returns>
        public override SearchResult Search(SearchRecord search, bool returnSearchColumns)
        {
            SearchPreferences searchPref = Configuration.SearchPreferences.Duplicate();

            searchPref.returnSearchColumns = returnSearchColumns;

            return(Search(search, searchPref));
        }
示例#6
0
 public AppForm()
 {
     InitializeComponent();
     SearchingRecord = new SearchRecord
     {
         FileInfos = new List <FileInfo>()
     };
     FileSearchPlugins = new List <IFileSearchPlugin>();
     LoadPlugins();
 }
示例#7
0
        public virtual async Task <SearchResult> searchAsync(SearchRecord searchRecord, SearchPreferences searchPreferences)
        {
            var originalPreferences = this.searchPreferences;

            this.searchPreferences = searchPreferences;
            var result = await this.searchAsync(searchRecord);

            this.searchPreferences = originalPreferences;

            return(result);
        }
示例#8
0
 public void Add(SearchRecord entity)
 {
     using (SqlConnection sqlconn = new SqlConnection(ConnectionString))
         using (SqlCommand command = new SqlCommand(GetInsertCommand(entity)))
             using (SqlDataAdapter sda = new SqlDataAdapter())
             {
                 command.Connection = sqlconn;
                 sqlconn.Open();
                 sda.InsertCommand = command;
                 command.ExecuteNonQuery();
             }
 }
示例#9
0
        /// <summary>
        /// 搜索记录列表
        /// </summary>
        /// <returns></returns>
        public List <SearchRecord> SearchRecordList()
        {
            var ListModel = CacheHelper.Instance.GetCache <List <SearchRecord> >("SearchRecordList");

            if (ListModel == null)
            {
                int          outTime = CacheHelper.Instance.CacheOutTime;
                SearchRecord model   = new SearchRecord();
                model.OrderBy = "SearchCount Desc";
                ListModel     = SearchRecordOper.Instance.SelectByPage(model, PageSize, 1);
                CacheHelper.Instance.SetCache("SearchRecordList", ListModel, outTime);
            }
            return(ListModel);
        }
示例#10
0
        public static void RenderNewsResults(HtmlWriter writer, SearchRecord[] records, bool renderUl = true)
        {
            var visibleCategorizations = CategorizationFolder.GetVisibleCategorizations();

            var newsListUrl = Urls.GetMainNewsListUrl();

            if (renderUl)
                writer.RenderBeginTag(HtmlTextWriterTag.Ul, "news-items");
            foreach (var record in records)
            {
                var date = record.GetDate("date");
                if (date == null)
                    continue;

                writer.RenderBeginTag(HtmlTextWriterTag.Li, "clearfix");

                if (!string.IsNullOrEmpty(record.GetString("thumbnail")))
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Div);
                    writer.RenderImageTag(record.GetString("thumbnail"), record.GetString("title"), null);
                    writer.RenderEndTag(); // div

                }

                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.AddAttribute(HtmlTextWriterAttribute.Href, record.GetString("url"));
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.RenderFullTag(HtmlTextWriterTag.H3, record.GetString("title"));
                writer.RenderEndTag(); // a
                writer.RenderFullTag(HtmlTextWriterTag.Span, "Publiseret " + record.GetDate("date").Value.ToString("dd-MM-yyyy"), "date");

                var categorizations = new IdList(record.GetString("categorizations"));
                if (categorizations.Any())
                {
                    RenderCategorizations(writer, categorizations, visibleCategorizations, newsListUrl);
                }
                writer.RenderBeginTag(HtmlTextWriterTag.A);

                var text = record.GetString("summary");
                if (text.Length > 150)
                    text = text.Substring(0, 150);
                writer.RenderFullTag(HtmlTextWriterTag.P, text);

                writer.RenderEndTag(); // a
                writer.RenderEndTag(); // div
                writer.RenderEndTag(); // li.clearfix
            }
            if (renderUl)
                writer.RenderEndTag();
        }
示例#11
0
    public static Region ClosestRegion(TileSelection tiles, Region to_ignore = null, HashSet <Region> whitelist = null)
    {
        var open      = new List <SearchRecord>();
        var openTiles = new TileSelection();
        var closed    = new TileSelection();

        foreach (var t in tiles.tiles)
        {
            var record = new SearchRecord();
            record.t    = t;
            record.cost = 0;
            open.Add(record);
        }
        var i = 0;

        while (open.Count > 0)
        {
            i++;
            if (i > 1000)
            {
                throw(new Exception("Finding closest Region took too long"));
            }
            open.Sort((a, b) => a.cost - b.cost);
            var node = open[0];
            closed.Add(node.t);
            open.RemoveAt(0);
            openTiles.Remove(node.t);
            if (node.t.region != null && node.t.region != to_ignore)
            {
                if (whitelist == null || whitelist.Contains(node.t.region))
                {
                    return(node.t.region);
                }
            }
            foreach (var n in node.t.adjacent.tiles)
            {
                if (closed.DoesNotContain(n) && openTiles.DoesNotContain(n))
                {
                    var record = new SearchRecord();
                    record.t    = n;
                    record.cost = node.cost + 1;
                    open.Add(record);
                    openTiles.Add(record.t);
                }
            }
        }
        _gui_manager.selected_region = null;
        _gui_manager.selected_tiles  = tiles;
        throw new Exception("Could not find any other Regions after " + i + " iterations");
    }
示例#12
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="searchrecord"></param>
        /// <returns>是否成功</returns>
        public bool Update(SearchRecord searchrecord)
        {
            StringBuilder sql   = new StringBuilder("update SearchRecord set ");
            StringBuilder part1 = new StringBuilder();
            StringBuilder part2 = new StringBuilder();
            var           parm  = new DynamicParameters();
            bool          flag  = true;

            if (!searchrecord.SearchId.IsNullOrEmpty())
            {
                part2.Append("SearchId = @SearchId");
                parm.Add("SearchId", searchrecord.SearchId);
            }
            if (!searchrecord.SearchKey.IsNullOrEmpty())
            {
                if (flag)
                {
                    part1.Append("SearchKey = @SearchKey");
                    flag = false;
                }
                else
                {
                    part1.Append(", SearchKey = @SearchKey");
                }
                parm.Add("SearchKey", searchrecord.SearchKey);
            }
            if (!searchrecord.SearchCount.IsNullOrEmpty())
            {
                if (flag)
                {
                    part1.Append("SearchCount = @SearchCount");
                    flag = false;
                }
                else
                {
                    part1.Append(", SearchCount = @SearchCount");
                }
                parm.Add("SearchCount", searchrecord.SearchCount);
            }

            sql.Append(part1).Append(" where ").Append(part2);
            using (var conn = new SqlConnection(ConnString))
            {
                conn.Open();
                var r = conn.Execute(sql.ToString(), parm);
                conn.Close();
                return(r > 0);
            }
        }
        public virtual async System.Threading.Tasks.Task <SearchResult> searchAsync(SearchRecord searchRecord)
        {
            var request = new searchRequest()
            {
                passport          = passport,
                tokenPassport     = tokenPassport,
                applicationInfo   = applicationInfo,
                partnerInfo       = partnerInfo,
                searchPreferences = searchPreferences,
                searchRecord      = searchRecord,
            };
            var response = await((NetSuitePortType)this).searchAsync(request);

            return(response.searchResult);
        }
示例#14
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            SearchRecord sr = new SearchRecord();

            sr.Sconn = Sconn;
            sr.ShowDialog();
            if (sr.SelectedID != 0)
            {
                DataTable dtSelectedRecords = cf.dtGetApplicantRecord(sr.SelectedID);
                if (dtSelectedRecords.Rows.Count == 1)
                {
                    loadRecord(dtSelectedRecords);
                }
            }
        }
示例#15
0
 /// <summary>
 /// Invokes NetSuite's search(..) method.
 /// </summary>
 /// <param name="searchRec">The search options.</param>
 /// <param name="session">The session to which the search and subsequent SearchMore(..),
 /// SearchNext(..) operations will belong.</param>
 /// <returns>Response from the WebService</returns>
 /// <remarks>Use this method only when SearchMore(..) or
 /// SearchNext(..) etc. calls are required.</remarks>
 public SearchResult Search(SearchRecord searchRec, SearchSession session)
 {
     try
     {
         SearchResult result = session.ServiceManager.Search(searchRec);
         session.PageIndex = result.pageIndex;
         session.SearchId  = result.searchId;
         return(result);
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
         throw new NsException(ex);
     }
 }
        private void AddAssetIndex(string assetId)
        {
            var asset        = _docuementRepository.Get(assetId);
            var searchRecord = new SearchRecord
            {
                id          = asset.Id,
                Author      = asset.Author,
                Category    = asset.Category,
                ContentType = asset.ContentType,
                Description = asset.Description,
                Keywords    = asset.Keywords,
                Name        = asset.Name,
                Type        = asset.Type,
                Url         = asset.Url
            };

            _searchClient.AddSearchRecord("defaultassetindex", searchRecord);
        }
示例#17
0
        private List <SearchRecord> ParseResults(string p_WebResponse, string p_SiteURL)
        {
            int l_SitePosition = 1;
            List <SearchRecord> l_SearchRecords = new List <SearchRecord>();

            //Get DIV level tags from html
            foreach (Match l_GroupMatch in Regex.Matches(p_WebResponse, Constants.REGEX.DIV_REGEX))
            {
                if (l_GroupMatch != null && l_GroupMatch.Groups.Count > 0)
                {
                    //Get H3 level tags from html
                    foreach (Match l_ResultMatch in Regex.Matches(l_GroupMatch.Groups[Constants.RegexIndex.GROUP].Value, Constants.REGEX.H3_REGEX))
                    {
                        if (l_ResultMatch != null && l_ResultMatch.Groups.Count > 0)
                        {
                            //Get A level tags from html
                            MatchCollection l_LinktMatchs = Regex.Matches(l_ResultMatch.Groups[Constants.RegexIndex.GROUP].Value, Constants.REGEX.ATAG_REGEX);

                            if (l_LinktMatchs.Count > 0 && l_LinktMatchs[Constants.RegexIndex.VALUE].Groups.Count > 0)
                            {
                                if (l_LinktMatchs[Constants.RegexIndex.VALUE].Value.Contains(p_SiteURL))
                                {
                                    Log4netWrapper.Debug(string.Format("Site link [ {0} ] found in URL [ {1} ]", p_SiteURL, l_LinktMatchs[Constants.RegexIndex.VALUE].Value));

                                    SearchRecord l_MatchRecord = new SearchRecord();

                                    l_MatchRecord.URLDetails = l_LinktMatchs[Constants.RegexIndex.VALUE].Value;
                                    l_MatchRecord.Position   = l_SitePosition;

                                    l_SearchRecords.Add(l_MatchRecord);
                                }
                            }
                        }
                    }
                }

                l_SitePosition++;
            }

            return(l_SearchRecords);
        }
示例#18
0
        /// <summary>
        /// 插入搜索记录
        /// </summary>
        /// <returns></returns>
        public void InsertSearchRecord(string Key)
        {
            SearchRecord model = new SearchRecord();

            model.OrderBy   = "SearchCount Desc";
            model.SearchKey = Key.Trim();
            lock (objLock)
            {
                var ListModel = SearchRecordOper.Instance.Select(model).FirstOrDefault();
                if (ListModel == null)
                {
                    model.SearchCount = 1;
                    SearchRecordOper.Instance.Insert(model);
                }
                else
                {
                    ListModel.SearchCount++;
                    SearchRecordOper.Instance.Update(ListModel);
                }
            }
        }
示例#19
0
 protected string GetPGLValue(SearchRecord record)
 {
     string value = ConfigurationManager.AppSettings[record.Caption];
     if (string.IsNullOrEmpty(value))
         return string.Empty;
     int start = value.IndexOf('[');
     int end = value.IndexOf(']');
     if (start <= 0 || end <= 0)
         return string.Empty;
     string item = value.Substring(start + 1, end - start - 1);
     item = item.Substring(item.IndexOf(":")+1);
     SearchField sf = record[item];
     if (sf == null)
         return string.Empty;
     else
         return sf.Value;
 }
示例#20
0
            //private static readonly int PRIORITY_QUEUE_INIT_SIZE = 100;
            /**
             *
             * @param graph
             * @param start a node with valid coords
             * @param goal a node with valid coords
             * @param heuristic an admissible heuristic
             * @return null if no path found, otherwise the path
             */
            public List<Connection> pathfindAStar(Graph graph, Node start, Node goal, Heuristic heuristic)
            {
                //long totalClosedListIterationTime = 0;
                //long totalOpenListIterationTime = 0;
                //long heuristicTime = 0;
                //long openAddTime = 0;
                //long openRemoveTime = 0;
                //long closedAddTime = 0;
                //long closedRemoveTime = 0;
                //long containTime = 0;

                int openCount = 0; //keep track of how many open nodes are visited

                SearchRecord startRecord = new SearchRecord (start);
                startRecord.setEstimatedTotalCost (heuristic.estimate (start));

                //SmallestEstimatedCostComparator comparator = new SmallestEstimatedCostComparator ();
                //PriorityQueue<SearchRecord> openList = new PriorityQueue<SearchRecord> (PRIORITY_QUEUE_INIT_SIZE, comparator);
                List<SearchRecord> openList = new List<SearchRecord>();
                int numNodes = graph.getNumNodes ();
                SearchRecord[] openListLookup = new SearchRecord[numNodes];

                SearchRecord[] closedListLookup = new SearchRecord[numNodes];

                openList.Add (startRecord);
                openCount++;
                openListLookup [startRecord.GetHashCode()] = startRecord;

                SearchRecord current = null;
                while (openList.Count > 0) {
                    openList.Sort();
                    SearchRecord[] openListRecords = openList.ToArray();
                    current = openListRecords[0]; //retrieve, but do not remove
                    //Console.WriteLine("current node: " + current);
                    //current = openList.peek (); //retrieve, but do not remove

                    if (current.getNode ().Equals (goal)) {
                        break;
                    }

                    List<Connection> connections = graph.getConnections (current.getNode ());

                    foreach (Connection conn in connections) {

                        //Console.WriteLine("checking connection " + conn);
                        Node endNode = conn.getToNode ();
                        double endNodeCost = current.getCostSoFar () + conn.getCost ();
                        SearchRecord endNodeRecord = null;
                        double endNodeHeuristic = 0.0;
                        //create temporary SearchRecord to wrap endNode... for purposes of searching the open and closed lists
                        SearchRecord endNodeRecordTemplate = new SearchRecord (endNode);

                        //long containStart = System.currentTimeMillis ();
                        bool closedListContains = (closedListLookup [endNodeRecordTemplate.GetHashCode()] != null);
                        bool openListContains = false;
                        //only need to determine openListContains value if closedListContains is false (due to the if/else ordering below)
                        if (!(closedListContains)) {
                            openListContains = (openListLookup [endNodeRecordTemplate.GetHashCode()] != null);
                        }
                        //long containEnd = System.currentTimeMillis ();
                        //containTime += (containEnd - containStart);

                        if (closedListContains) {

                            //find end node record from closed list
                            //long closedListIterationStart = System.currentTimeMillis ();
                            endNodeRecord = closedListLookup [endNodeRecordTemplate.GetHashCode()];
                            //long closedListIterationEnd = System.currentTimeMillis ();
                            //totalClosedListIterationTime += (closedListIterationEnd - closedListIterationStart);

                            if (endNodeRecord.getCostSoFar () <= endNodeCost) {
                                continue;
                            }

                            //long closedRemoveStart = System.currentTimeMillis ();
                            closedListLookup [endNodeRecord.GetHashCode()] = null;
                            //long closedRemoveEnd = System.currentTimeMillis ();
                            //closedRemoveTime += closedRemoveEnd - closedRemoveStart;
                            endNodeHeuristic = endNodeRecord.getEstimatedTotalCost () - endNodeRecord.getCostSoFar ();

                        } else if (openListContains) {

                            //find end node record from open list
                            //long openListIterationStart = System.currentTimeMillis ();
                            endNodeRecord = openListLookup [endNodeRecordTemplate.GetHashCode()];
                            //long openListIterationEnd = System.currentTimeMillis ();
                            //totalOpenListIterationTime += (openListIterationEnd - openListIterationStart);

                            if (endNodeRecord.getCostSoFar () <= endNodeCost) {
                                continue;
                            }

                            endNodeHeuristic = endNodeRecord.getEstimatedTotalCost () - endNodeRecord.getCostSoFar ();
                        } else {
                            //unvisited node
                            endNodeRecord = new SearchRecord (endNode);
                            //long heuristicStartTime = System.currentTimeMillis ();
                            endNodeHeuristic = heuristic.estimate (endNode);
                            //long heuristicEndTime = System.currentTimeMillis ();
                            //heuristicTime += (heuristicEndTime - heuristicStartTime);
                        }

                        //update the cost, estimate, and connection
                        endNodeRecord.setCostSoFar (endNodeCost);
                        endNodeRecord.setConnection (conn);
                        //Console.WriteLine("record " + endNodeRecord + ", setting connection: " + conn);
                        endNodeRecord.setEstimatedTotalCost (endNodeCost + endNodeHeuristic);

                        //long containsCheckStart = System.currentTimeMillis ();
                        bool openListContainsEndNodeRecord = (openListLookup [endNodeRecord.GetHashCode()] != null);
                        //long containsCheckEnd = System.currentTimeMillis ();
                        //containTime += (containsCheckEnd - containsCheckStart);

                        if (!(openListContainsEndNodeRecord)) {
                            //long openAddStart = System.currentTimeMillis ();
                            openList.Add (endNodeRecord);
                            //Console.WriteLine("Adding " + endNodeRecord + " to open list");
                            openList.Sort();
                            openCount++;
                            openListLookup [endNodeRecord.GetHashCode()] = endNodeRecord;
                            //long openAddEnd = System.currentTimeMillis ();
                            //openAddTime += (openAddEnd - openAddStart);
                        }
                    }

                    //long openRemoveStart = System.currentTimeMillis ();
                    //openList.Sort();
                    openList.Remove(current); //RemoveAt(0);
                    //openList.poll (); //NOTE: current is always the head of the open list... old code: //openList.remove(current);
                    openListLookup [current.GetHashCode()] = null;
                    //long openRemoveEnd = System.currentTimeMillis ();
                    //openRemoveTime += (openRemoveEnd - openRemoveStart);
                    //long closedAddStart = System.currentTimeMillis ();
                    closedListLookup [current.GetHashCode()] = current;
                    //long closedAddEnd = System.currentTimeMillis ();
                    //closedAddTime += (closedAddEnd - closedAddStart);

                }

                if (!(current.getNode ().Equals (goal))) {
                    return null;
                } else {
                    List<Connection> reversePath = new List<Connection> ();

                    //retrieve path
                    while (!(current.getNode().Equals(start))) {
                        //Console.WriteLine("adding to reversePath: " + current.getConnection());
                        reversePath.Add (current.getConnection ());
                        Node fromNode = current.getConnection ().getFromNode ();
                        SearchRecord placeholder = new SearchRecord (fromNode);
                        SearchRecord previous = closedListLookup [placeholder.GetHashCode()];
                        if (previous == null) {
                            String to = (placeholder.getConnection ().getToNode () != null) ? placeholder.getConnection ().getToNode ().ToString () : "null";
                            String from = (placeholder.getConnection ().getFromNode () != null) ? placeholder.getConnection ().getFromNode ().ToString () : "null";
                            //Console.WriteLine ("retrieving path NPE. Data: Placeholder connection from: " + from + ", placeholder connection to: " + to + ", goal: " + goal + ", start: " + start);
                        }
                        //find SearchRecord for fromNode in the closed list
                        current = previous;

                    }

                    //reverse the path
                    List<Connection> path = new List<Connection> ();
                    //Enumerator enumerator = reversePath.GetEnumerator();
                    //Iterator<Connection> reverseIt = reversePath.iterator ();
                    //while (enumerator.hasNext()) {
                    foreach (Connection reverseConn in reversePath) {
                        //Console.WriteLine("reverseConn " + reverseConn);
                        //Connection reverseConn = reverseIt.next ();
                        //path.addFirst (reverseConn);
                        path.Insert(0, reverseConn);
                    }

                //			System.out.println("total closed it time: " + totalClosedListIterationTime);
                //			System.out.println("total open it time: " + totalOpenListIterationTime);
                //			System.out.println("heuristic time: " + heuristicTime);
                //			System.out.println("open add time: " + openAddTime);
                //			System.out.println("open remove time: " + openRemoveTime);
                //			System.out.println("closed add time: " + closedAddTime);
                //			System.out.println("contain time: " + containTime);
                //			System.out.println("closed remove time: " + closedRemoveTime);
                //			long sum = totalClosedListIterationTime + totalOpenListIterationTime + heuristicTime + openAddTime + openRemoveTime + closedAddTime + containTime + closedRemoveTime;
                //			System.out.println("total accounted time: " + sum);
                //			System.out.println("open nodes visited: " + openCount);

                    return path;
                }
            }
示例#21
0
 /// <summary>
 /// Searches NetSuite using the specified search parameters.
 /// </summary>
 /// <param name="searchRec">The search parameter.</param>
 /// <param name="prefs">The search preferences.</param>
 /// <returns>Results of the search.</returns>
 public override SearchResult Search(SearchRecord searchRec, SearchPreferences prefs)
 {
     return(InvokeService <SearchResult>(searchRec, "search", prefs));
 }
示例#22
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="searchrecord"></param>
        /// <param name="pageSize">页面大小</param>
        /// <param name="pageNo">页面编号</param>
        /// <returns>对象列表</returns>
        public List <SearchRecord> SelectByPage(SearchRecord searchrecord, int pageSize, int pageNo)
        {
            StringBuilder sql = new StringBuilder("Select Top ").Append(pageSize).Append(" ");

            if (!searchrecord.Field.IsNullOrEmpty())
            {
                sql.Append(searchrecord.Field);
            }
            else
            {
                sql.Append("*");
            }
            sql.Append(" from SearchRecord ");
            StringBuilder part1          = new StringBuilder();
            StringBuilder part2          = new StringBuilder();
            StringBuilder strBuliderPage = new StringBuilder();
            var           parm           = new DynamicParameters();
            bool          flag           = true;

            if (!searchrecord.SearchId.IsNullOrEmpty())
            {
                if (flag)
                {
                    part1.Append("SearchId = @SearchId");
                    flag = false;
                }
                else
                {
                    part1.Append(" and SearchId = @SearchId");
                }
                parm.Add("SearchId", searchrecord.SearchId);
            }
            if (!searchrecord.SearchKey.IsNullOrEmpty())
            {
                if (flag)
                {
                    part1.Append("SearchKey = @SearchKey");
                    flag = false;
                }
                else
                {
                    part1.Append(" and SearchKey = @SearchKey");
                }
                parm.Add("SearchKey", searchrecord.SearchKey);
            }
            if (!searchrecord.SearchCount.IsNullOrEmpty())
            {
                if (flag)
                {
                    part1.Append("SearchCount = @SearchCount");
                    flag = false;
                }
                else
                {
                    part1.Append(" and SearchCount = @SearchCount");
                }
                parm.Add("SearchCount", searchrecord.SearchCount);
            }
            if (!flag)
            {
                strBuliderPage.Append(" and");
            }
            strBuliderPage.Append(" SearchId not in (").Append("Select Top ").Append(pageSize * (pageNo - 1)).Append(" SearchId from SearchRecord ");
            if (!searchrecord.GroupBy.IsNullOrEmpty())
            {
                strBuliderPage.Append(" Group By ").Append(searchrecord.GroupBy).Append(" ");
                flag = false;
            }
            if (!searchrecord.OrderBy.IsNullOrEmpty())
            {
                strBuliderPage.Append(" Order By ").Append(searchrecord.OrderBy).Append(" ");
                flag = false;
            }
            strBuliderPage.Append(" )");
            if (!flag)
            {
                sql.Append(" where ");
            }
            sql.Append(part1).Append(strBuliderPage).Append(part1);
            if (!searchrecord.GroupBy.IsNullOrEmpty())
            {
                part2.Append(" Group By ").Append(searchrecord.GroupBy).Append(" ");
            }
            if (!searchrecord.OrderBy.IsNullOrEmpty())
            {
                part2.Append(" Order By ").Append(searchrecord.OrderBy).Append(" ");
            }
            sql.Append(part2);
            using (var conn = new SqlConnection(ConnString))
            {
                conn.Open();
                var r = (List <SearchRecord>)conn.Query <SearchRecord>(sql.ToString(), parm);
                conn.Close();
                if (r == null)
                {
                    r = new List <SearchRecord>();
                }
                return(r);
            }
        }
示例#23
0
 /// <summary>
 /// Invokes NetSuite's asyncSearch(..) method.
 /// </summary>
 /// <param name="searchRec">The search options.</param>
 /// <returns>Response from the WebService.</returns>
 public virtual AsyncStatusResult AsyncSearch(SearchRecord searchRec)
 {
     return(InvokeService <AsyncStatusResult>(searchRec, "asyncSearch"));
 }
 public void Add(SearchRecord record)
 {
     Database.Add(record);
 }
示例#25
0
 /// <summary>
 /// Searches using the specified search options.
 /// </summary>
 /// <param name="searchRec">The search record.</param>
 /// <returns>Response from the WebService.</returns>
 public override SearchResult Search(SearchRecord searchRec)
 {
     return(Search(searchRec, null));
 }
 public override Task <SearchResult> searchAsync(SearchRecord searchRecord)
 {
     return(_retryPolicy.ExecuteAsync(() => base.searchAsync(searchRecord)));
 }
        private SearchResult getSearch(SearchRecord searchAdvanced)
        {
            SearchResult searchResult = null;

            int tryTimes = 0;

            while (tryTimes < WEB_SERVICES_TRY_TIMES_LIMIT)
            {
                try
                {
                    //setTokenPassport();
                    searchResult = _service.search(searchAdvanced);
                    break; // if working properly, break here.
                }
                catch (System.Web.Services.Protocols.SoapException ex)
                {
                    // Get the fault type. It's the only child element of the detail element.
                    string fault   = ex.Detail.FirstChild.Name;
                    string code    = null;
                    string message = null;

                    // Get the list of child elements of the fault type element.
                    // It should include the code and message elements
                    System.Collections.IEnumerator ienum = ex.Detail.FirstChild.ChildNodes.GetEnumerator();

                    while (ienum.MoveNext())
                    {
                        XmlNode node = (XmlNode)ienum.Current;

                        if (node.Name == "code")
                        {
                            code = node.InnerText;
                        }
                        else if (node.Name == "message")
                        {
                            message = node.InnerText;
                        }
                    }
                    Console.WriteLine("\n***   SOAP FAULT: fault type={0} with code={1}. {2}", fault, code, message);
                }
                catch (System.Net.WebException ex)
                {
                    Console.WriteLine("[SOAP Fault Web Exception]: {0}", ex.Message);
                }
                catch (System.InvalidOperationException ex)
                {
                    Console.WriteLine("[SOAP Fault Invalid Operation Exception]: {0}", ex.Message);
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine("[Error]: {0}", ex.Message);
                }
                finally
                {
                    tryTimes++; // ensure whether exception or not, retry time++ here

                    if (tryTimes >= 2)
                    {
                        Thread.Sleep(1000);
                    }
                }
            }

            return(searchResult);
        }
示例#28
0
 protected string GetXmlRecord(XmlSerializer xmlSerializer ,SearchRecord record)
 {
     StringBuilder builder = new StringBuilder();
     StringWriter writer = new StringWriter(builder);
     xmlSerializer.Serialize(writer, record);
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(builder.ToString());
     writer.Close();
     return doc.DocumentElement.OuterXml;
 }
示例#29
0
 /// <summary>Searches using the specified search options.</summary>
 /// <param name="record">The search record</param>
 /// <returns>Response from the WebService.</returns>
 public override SearchResult Search(SearchRecord record)
 {
     return(InvokeService <SearchResult>(record, "search", null));
 }
示例#30
0
        public void ReadXml(XmlReader reader)
        {
            string startElementName = reader.Name;
            string currentElementName;
            string currentNodeName;
            string fieldName,fieldValue,fieldCaption;
            float fieldBoost;
            bool isTitle;

            this.recordList.Clear();
            do
            {
                currentElementName = reader.Name;
                if (currentElementName == startElementName && (reader.MoveToContent() == XmlNodeType.EndElement || reader.IsEmptyElement))
                {
                    reader.Read();
                    break;
                }
                switch (currentElementName)
                {
                    case "PageNum":
                        this.pageNum = int.Parse(reader.ReadElementString());
                        break;

                    case "TotalPages":
                        this.totalPages = int.Parse(reader.ReadElementString());
                        break;

                    case "Doc":
                        SearchRecord record = new SearchRecord();
                        record.Name = SupportClass.FileUtil.GetXmlAttribute(reader, "Name", typeof(string));
                        record.Caption = SupportClass.FileUtil.GetXmlAttribute(reader, "Caption", typeof(string));
                        record.IndexName = SupportClass.FileUtil.GetXmlAttribute(reader, "Index", typeof(string));
                        do
                        {
                            currentNodeName = reader.Name;
                            if (currentNodeName == currentElementName && (reader.MoveToContent() == XmlNodeType.EndElement || reader.IsEmptyElement))
                            {
                                break;
                            }
                            switch (currentNodeName)
                            {
                                case "Field":
                                    fieldName = SupportClass.FileUtil.GetXmlAttribute(reader, "Name", typeof(string));
                                    fieldValue = SupportClass.FileUtil.GetXmlAttribute(reader, "Value", typeof(string));
                                    fieldBoost = float.Parse(SupportClass.FileUtil.GetXmlAttribute(reader, "Boost", typeof(float)));
                                    fieldCaption = SupportClass.FileUtil.GetXmlAttribute(reader, "Caption", typeof(string));
                                    isTitle = bool.Parse(SupportClass.FileUtil.GetXmlAttribute(reader, "IsTitle", typeof(bool)));
                                    record.Add(new SearchField(fieldName,fieldCaption,fieldValue,fieldBoost,isTitle));
                                    reader.Read();
                                    break;
                                default:
                                    reader.Read();
                                    break;
                            }
                        } while (true);
                        this.recordList.Add(record);
                        reader.Read();
                        break;
                    default:
                        reader.Read();
                        break;

                }
            } while (true);
        }
示例#31
0
 private string GetInsertCommand(SearchRecord entity) => $@"INSERT INTO SearchRecords
         VALUES ('{Guid.NewGuid()}','{MapDate(entity.DateCreated)}','{entity.Positions}','{entity.NumberOfResult}')";
示例#32
0
 public void AddResult(SearchRecord[] records)
 {
     if (this.recordList == null)
         this.recordList = new List<SearchRecord>();
     this.recordList.AddRange(records);
 }
 /// <summary>
 /// Searches using the specified search options.
 /// </summary>
 /// <param name="record">The search record.</param>
 /// <returns>Response from the WebService.</returns>
 public virtual SearchResult Search(SearchRecord record)
 {
     return(Search(record, null));
 }
 /// <summary>
 /// Searches the specified search.
 /// </summary>
 /// <param name="search">The search.</param>
 /// <param name="returnSearchColumns">if set to <c>true</c> returns search columns instead of entities.</param>
 /// <returns>The search result.</returns>
 public abstract SearchResult Search(SearchRecord search, bool returnSearchColumns);
示例#35
0
 public void AddSearchRecord(string indexName, SearchRecord searchRecord) => new SearchWebRequestFacade(_endpoints.SearchDocument(indexName), "POST", searchRecord.GetIndexUploadDocument())
 .Invoke();
 /// <summary>
 /// Searches using the specified search options.
 /// </summary>
 /// <param name="record">The search record.</param>
 /// <param name="prefs">Search Preferences</param>
 /// <returns>Response from the WebService.</returns>
 public abstract SearchResult Search(SearchRecord record, SearchPreferences prefs);
示例#37
0
 public void AddResult(SearchRecord record)
 {
     if (this.recordList == null)
         this.recordList = new List<SearchRecord>();
     this.recordList.Add(record);
 }
示例#38
0
 protected string GetRedirectUrl(SearchRecord record)
 {
     string value = ConfigurationManager.AppSettings[record.Caption];
     StringBuilder url = new StringBuilder();
     if (string.IsNullOrEmpty(value))
         return "#";
     int start = value.IndexOf('{');
     int end = value.IndexOf('}');
     if (start <= 0 || end <=0)
         return "#";
     string href=value.Substring(start+1,end-start-1);
     if (href.IndexOf("?") > 0)
     {
         url.Append(href + "&");
     }
     else
     {
         url.Append(href + "?");
     }
     string rest = value.Substring(end + 1);
     string[] paramArray = rest.Split("[]".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
     Dictionary<string, string> paramDict = new Dictionary<string, string>();
     foreach (string param in paramArray)
     {
         string[] keyValue = param.Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
         if(keyValue.Length!=2)
             continue;
         paramDict.Add(keyValue[1], keyValue[0]);
     }
     bool find=false;
     foreach (SearchField field in record.Fields)
     {
         if (paramDict.ContainsKey(field.Name))
         {
             if (!find)
             {
                 url.Append(paramDict[field.Name] + "=" + field.Value);
                 find = true;
             }
             else
             {
                 url.Append("&" + paramDict[field.Name] + "=" + field.Value);
             }
         }
     }
     return url.ToString();
 }