Example #1
0
        /// <summary>
        /// Gets the flight schedules based on the search criteria.
        /// </summary>
        /// <param name="searchInformation"></param>
        /// <exception cref="FlightsNotAvailableException">Thorws an exception when unable to retrieve flights</exception>
        /// <returns>Returns a search log to the caller</returns>
        public SearchLog SearchForFlights(SearchInfo searchInformation)
        {
            SearchResult result = null;;
            SearchLog    log    = new SearchLog();

            try
            {
                result = GetSearchResult(searchInformation);

                //Add the result to searchlog based on it being Onward or Return
                AddSearchResultToLog(TravelDirection.OneWay, result, log);

                if (searchInformation.Direction == TravelDirection.Return)
                {
                    SearchInfo info = new SearchInfo();
                    info.Class    = searchInformation.Class;
                    info.FromCity = searchInformation.ToCity;
                    info.ToCity   = searchInformation.FromCity;

                    SearchResult returnResult = GetSearchResult(info);
                    AddSearchResultToLog(TravelDirection.Return, returnResult, log);
                }
            }
            catch (FlightsNotAvailableException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new FlightsNotAvailableException("Unable to Retrieve Flights", ex);
            }

            //5. Return Log
            return(log);
        }
        //如果有输入关键字,则插入一条数据到 搜索日志表
        public void insertSearchLog()
        {
            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);

            connection.Open();
            SqlTransaction tran = connection.BeginTransaction("SampleTransaction");

            try
            {
                if (RequestSearchKey != "" && RequestSearchType != "")
                {
                    Entities.SearchLog model = new SearchLog();
                    model.SearchKey    = RequestSearchKey;
                    model.Type         = int.Parse(RequestSearchType);
                    model.CreateTime   = DateTime.Now;
                    model.CreateUserID = BLL.Util.GetLoginUserID();

                    BLL.SearchLog.Instance.Insert(tran, model);
                    BLL.Util.InsertUserLog(tran, "【知识库】搜索日志表【插入】搜索关键字:【" + model.SearchKey + "】类型:【知识库】的记录");
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                tran.Rollback();
            }
            finally
            {
                connection.Close();
            }
        }
Example #3
0
        public async Task <ActionResult <List <LogInfo> > > Search(SearchLog search)
        {
            var perSection = 50;

            search.StartDate = search.StartDate.ToLocalTime();
            search.EndDate   = search.EndDate.ToLocalTime();
            var data = db.LogInfos.Where(x => x.DateTime >= search.StartDate && x.DateTime <= search.EndDate);

            var skip = (search.Section - 1) * perSection;

            if (!string.IsNullOrEmpty(search.IpNow))
            {
                data = data.Where(x => x.Ip.Equals(search.IpNow));
            }
            if (!string.IsNullOrEmpty(search.AppNow))
            {
                data = data.Where(x => x.Application.Equals(search.AppNow));
            }

            var dataLength = await data.CountAsync();

            var result = await data.OrderByDescending(x => x.DateTime).Skip(skip).Take(perSection).ToListAsync();

            return(Ok(new { LogInfo = result, DataLength = dataLength }));
        }
Example #4
0
        public ActionResult SearchLog(string searchString, IEnumerable <Guid> tags, int resultCount)
        {
            var logData    = new SearchLog();
            var getTagsRes = _tgSrv.GetAll();

            if (getTagsRes.Success)
            {
                if (tags != null)
                {
                    logData.Tags =
                        getTagsRes.Entities.
                        Where(t => tags.Any(tgId => tgId == t.ID)).
                        ToList();
                }

                logData.SearchString = searchString;
                logData.ResultCount  = resultCount;
                logData.UserID       = User.GetUser().Id;
                logData.DateTime     = DateTime.Now;
                var res = _srchSrv.Add(logData);

                return(Json(res));
            }
            else
            {
                return(Json(new { Success = false, Message = getTagsRes.Message }));
            }
        }
Example #5
0
 public async Task StoreSearchLog(SearchLog log)
 {
     await _unitOfWork.Connection.ExecuteAsync(
         @"INSERT INTO SearchLogs (Surname, Uln, SearchTime, SearchData, NumberOfResults, Username) 
           VALUES (@surname, @uln, @searchTime, @searchData, @numberOfResults, @username)",
         param : new { log.Surname, log.Uln, log.SearchTime, log.SearchData, log.NumberOfResults, log.Username },
         transaction : _unitOfWork.Transaction);
 }
Example #6
0
        public void Update(SearchLog log)
        {
            if (log == null)
            {
                throw new ArgumentNullException("Search log");
            }

            _repository.Update(log);
        }
Example #7
0
        public void Insert(SearchLog log)
        {
            if (log == null)
            {
                throw new ArgumentNullException("Search log");
            }

            _repository.Insert(log);
        }
        public SearchLog ToModel(SqlDataReader reader)
        {
            SearchLog searchLog = new SearchLog();

            searchLog.Id         = (Guid)ToModelValue(reader, "Id");
            searchLog.Word       = (string)ToModelValue(reader, "Word");
            searchLog.SearchDate = (DateTime)ToModelValue(reader, "SearchDate");
            return(searchLog);
        }
        private void BtnSearch_Click(object sender, RoutedEventArgs e)
        {
            SearchLog SL = new SearchLog();
            string    Query;

            Query = SL.AdvencedSearchGetQuery(inputNumLot, inputNumBloc, inputNiveau, inputNbrPiece, inputNumIlot, inputEtat, inputSurH, inputSurMax, inputSurU, inputSurUMax, RefProjet, RefProgramme, NumEdd, inputTypeBien.Text);

            BienViwer BV = new BienViwer(RefProjet, RefProgramme, NumEdd, Query);

            BV.Show();
        }
Example #10
0
        public SearchLog InsertSearchLog(Case caseObject)
        {
            var p = new SearchLog
            {
                Text        = caseObject.Text,
                ServiceName = caseObject.ServiceName
            };

            _searchLogRepository.Insert(p);
            return(p);
        }
Example #11
0
        public ActionResult SearchResource(string searchText, int pageIndex)
        {
            if (pageIndex <= 1)
            {
                try
                {
                    SearchLog tmpLog = new SearchLog();
                    tmpLog.IPAddress   = Request.UserHostAddress;
                    tmpLog.LogDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    tmpLog.SearchStr   = searchText;
                    db.SearchLogs.Add(tmpLog);
                    db.SaveChanges();
                }
                catch
                {
                }
            }

            SearchResult result = new SearchResult();

            result.PageIndex = pageIndex;

            string htmlStr = HtmlReader.OpenSync(string.Format(SEARCHHTMLFORMAT, searchText, pageIndex));

            if (!string.IsNullOrEmpty(htmlStr))
            {
                HtmlAnalyser analyser             = new HtmlAnalyser(htmlStr);
                HtmlAnalyser.MagnetResult[] tmpMC = analyser.GetResult();
                result.Items = new List <ResourceItem>();
                foreach (HtmlAnalyser.MagnetResult item in tmpMC)
                {
                    ResourceItem resourceItem = new ResourceItem();
                    resourceItem.ResourceName = item.Description;
                    resourceItem.MagnetLink   = item.MargnetLink;
                    resourceItem.Date         = item.Date;
                    resourceItem.Size         = item.Size;
                    resourceItem.SeedLink     = item.SeedLink;
                    resourceItem.DetailUrl    = HOMEPAGEURL + item.DetailLink;
                    result.Items.Add(resourceItem);
                }
                result.PageCount = analyser.GetPageCount();
            }

            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult(result);
                return(Content(jsonStr));
            }
            else
            {
                return(View(result));
            }
        }
Example #12
0
        private void AddSearchLog(string keyword)
        {
            SearchLog searchLog = new SearchLog();

            searchLog.Id         = Guid.NewGuid();
            searchLog.SearchDate = DateTime.Now;
            searchLog.Word       = keyword;

            SearchLogService searchLogService = new SearchLogService();

            searchLogService.Add(searchLog);
        }
Example #13
0
        public static void WriteQueryInLog(string queryXml)
        {
            Database.SetInitializer(new DropCreateDatabaseIfModelChanges <SearchLogContext>());
            SearchLogContext context = new SearchLogContext();

            SearchLog newLog = new SearchLog()
            {
                Date     = DateTime.Now,
                QueryXml = queryXml
            };

            context.SearchLogs.Add(newLog);
            context.SaveChanges();
        }
Example #14
0
        //写入搜索记录
        public void Add_SearchLog(IEnumerable <Manage.Models.Book> BookList)
        {
            var firstBook = BookList.FirstOrDefault();

            if (firstBook != null)
            {
                SearchLog searchLog = new SearchLog
                {
                    Book = firstBook
                };
                _context.SearchLogs.Add(searchLog);
                _context.SaveChanges();
            }
        }
        public SearchLog Add
            (SearchLog searchLog)
        {
            string sql = "INSERT INTO T_SearchLogs (Id, Word, SearchDate)  VALUES (@Id, @Word, @SearchDate)";

            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@Id", ToDBValue(searchLog.Id)),
                new SqlParameter("@Word", ToDBValue(searchLog.Word)),
                new SqlParameter("@SearchDate", ToDBValue(searchLog.SearchDate)),
            };
            SqlHelper.ExecuteNonQuery(sql, para);
            return(searchLog);
        }
Example #16
0
        //--- task 7.
        public static void SaveSearchLog(string queryXml, DateTime searchDate)
        {
            using (SearchLogDbContext dbContext = new SearchLogDbContext())
            {
                SearchLog log = new SearchLog()
                {
                    QueryXml   = queryXml,
                    SearchDate = searchDate,
                };

                dbContext.SearchLogs.Add(log);

                dbContext.SaveChanges();
            }
        }
Example #17
0
        /// <summary>
        /// Gets the flight schedules based on the search criteria.
        /// </summary>
        /// <param name="searchInformation"></param>
        /// <exception cref="FlightsNotAvailableException">Thorws an exception when unable to retrieve flights</exception>
        /// <returns>Returns a search log to the caller</returns>
        public SearchLog SearchForFlights(SearchInfo searchInformation)
        {
            //Declaration
            SearchResult result = new SearchResult();
            SearchLog    log    = new SearchLog();

            try
            {
                bool isValid = ValidateSearchInformation(searchInformation);

                if (isValid)
                {
                    result = GetSearchResult(searchInformation, result);

                    //Add the result to searchlog based on it being Onward or Return
                    AddSearchResultToLog(TravelDirection.OneWay, result, log);

                    if (searchInformation.Direction == TravelDirection.Return)
                    {
                        //Calling the Parameterized Constructor
                        //This is done once the class variables are set to private set
                        //and a paramterized constructor is introduced
                        //Using VS - Effectively - CR - STYCBG09.01
                        SearchInfo info = new SearchInfo(searchInformation.FromCity, searchInformation.ToCity, searchInformation.OnwardDateOfJourney, searchInformation.ReturnDateOfJourney, searchInformation.NoOfSeats, searchInformation.Class, searchInformation.Direction);

                        SearchResult resultReturn = new SearchResult();
                        resultReturn = GetSearchResult(info, resultReturn);
                        AddSearchResultToLog(TravelDirection.Return, resultReturn, log);
                    }
                }
                else
                {
                    throw new FlightsNotAvailableException("Search Information Invalid");
                }
            }
            catch (FlightsNotAvailableException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new FlightsNotAvailableException("Unable to Retrieve Flights", ex);
            }

            //5. Return Log
            return(log);
        }
Example #18
0
        /// <summary>
        /// Gets the flight schedules based on the search criteria.
        /// </summary>
        /// <param name="searchInformation"></param>
        /// <exception cref="FlightsNotAvailableException">Thorws an exception when unable to retrieve flights</exception>
        /// <returns>Returns a search log to the caller</returns>
        public SearchLog SearchForFlights(SearchInfo searchInformation)
        {
            //Declaration
            SearchResult result = new SearchResult();
            SearchLog    log    = new SearchLog();

            try
            {
                bool isValid = ValidateSearchInformation(searchInformation);

                if (isValid)
                {
                    result = GetSearchResult(searchInformation, result);

                    //Add the result to searchlog based on it being Onward or Return
                    AddSearchResultToLog(TravelDirection.OneWay, result, log);

                    if (searchInformation.Direction == TravelDirection.Return)
                    {
                        SearchInfo info = new SearchInfo();
                        info.Class    = searchInformation.Class;
                        info.FromCity = searchInformation.ToCity;
                        info.ToCity   = searchInformation.FromCity;

                        SearchResult resultReturn = new SearchResult();
                        resultReturn = GetSearchResult(info, resultReturn);
                        AddSearchResultToLog(TravelDirection.Return, resultReturn, log);
                    }
                }
                else
                {
                    throw new FlightsNotAvailableException("Search Information Invalid");
                }
            }
            catch (FlightsNotAvailableException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new FlightsNotAvailableException("Unable to Retrieve Flights", ex);
            }

            //5. Return Log
            return(log);
        }
Example #19
0
        public void LogSearchQuery(IList <SearchProductAttributeValue> searchAttributes, IList <SearchProductAttributeValue> customerAttributes, SearchQueryLog query)
        {
            if (searchAttributes != null)
            {
                foreach (var attribute in searchAttributes)
                {
                    var log = new SearchLog()
                    {
                        CategoryProductAttributeId = attribute.CategoryProductAttributeId,
                        ExactValue        = attribute.ExactValue,
                        IdValue           = attribute.IdValue,
                        MaxValue          = attribute.MaxValue,
                        MinValue          = attribute.MinValue,
                        Textvalue         = attribute.Textvalue,
                        CustomerAttribute = false
                    };

                    query.SearchLogs.Add(log);
                    _searchQueryRepository.Update(query);
                }
            }

            if (customerAttributes != null)
            {
                foreach (var attribute in customerAttributes)
                {
                    var log = new SearchLog()
                    {
                        CategoryProductAttributeId = attribute.CategoryProductAttributeId,
                        ExactValue        = attribute.ExactValue,
                        IdValue           = attribute.IdValue,
                        MaxValue          = attribute.MaxValue,
                        MinValue          = attribute.MinValue,
                        Textvalue         = attribute.Textvalue,
                        CustomerAttribute = true
                    };

                    query.SearchLogs.Add(log);
                    _searchQueryRepository.Update(query);
                }
            }
        }
Example #20
0
        public JsonResult RandomGif(string lastWord)
        {
            string apiKey = System.Web.Configuration.WebConfigurationManager.AppSettings["APIKEY"];

            Debug.WriteLine("apikey : " + apiKey);

            string giphyUrl = "http://api.giphy.com/v1/stickers/translate?api_key=" + apiKey + "&s=" + lastWord;

            Debug.WriteLine("giphy url : " + giphyUrl);

            WebRequest sendRequest = WebRequest.Create(giphyUrl);

            WebResponse getResponse = sendRequest.GetResponse();

            Debug.WriteLine("get response : " + getResponse);

            Stream data = getResponse.GetResponseStream();

            StreamReader reader          = new StreamReader(data);
            string       convertResponse = reader.ReadToEnd();

            Debug.WriteLine("convert response : " + convertResponse);

            var serialize    = new System.Web.Script.Serialization.JavaScriptSerializer();
            var jsonResponse = serialize.DeserializeObject(convertResponse);

            SearchLog searchLogDb = SearchLog.SearchLogs.Create();

            searchLogDb.TIMESTAMP   = DateTime.Now;
            searchLogDb.REQUESTTYPE = Request.Url.OriginalString;
            searchLogDb.CLIENTIP    = Request.UserHostAddress;
            searchLogDb.BROWSER     = Request.Browser.Type;

            SearchLog.SearchLogs.Add(searchLogDb);
            SearchLog.SaveChanges();

            reader.Close();
            data.Close();
            getResponse.Close();

            return(Json(jsonResponse, JsonRequestBehavior.AllowGet));
        }
Example #21
0
        public IActionResult SearchWeb([FromBody] SearchDto searchDto)
        {
            var result = _searchService.SearchWeb(searchDto);

            if (result.Success)
            {
                var log       = result.Data;
                var searchLog = new SearchLog()
                {
                    URL        = log.URL,
                    Query      = log.Query,
                    HitCount   = log.HitCount,
                    SearchDate = DateTime.UtcNow
                };

                _searchLogService.AddSearchLog(searchLog);
            }

            return(Ok(result));
        }
        public int Update(SearchLog searchLog)
        {
            string sql =
                "UPDATE T_SearchLogs " +
                "SET " +
                " Word = @Word"
                + ", SearchDate = @SearchDate"

                + " WHERE Id = @Id";


            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@Id", searchLog.Id)
                , new SqlParameter("@Word", ToDBValue(searchLog.Word))
                , new SqlParameter("@SearchDate", ToDBValue(searchLog.SearchDate))
            };

            return(SqlHelper.ExecuteNonQuery(sql, para));
        }
Example #23
0
        public SearchTerm Post([FromBody] SearchRequest request)
        {
            var searchTerm = new SearchTerm
            {
                SearchedAt = DateTime.Now,
                Term       = request.Term
            };

            var youtube = new YouTubeService(
                new Google.Apis.Services.BaseClientService.Initializer()
            {
                ApiKey = "AIzaSyDfEOoWTX0fTlfkOru4k2ZPDXOQYZmp-J0"
            }
                );

            var listRequest = youtube.Search.List("snippet");

            listRequest.Q     = request.Term;
            listRequest.Order = SearchResource.ListRequest.OrderEnum.Relevance;
            var searchResponse = listRequest.Execute();
            var videos         = new List <SearchLog>();

            foreach (SearchResult searchResult in searchResponse.Items)
            {
                if (searchResult.Id.Kind.Equals("youtube#video"))
                {
                    var log = new SearchLog {
                        VideoId      = searchResult.Id.VideoId,
                        VideoTitle   = searchResult.Snippet.Title,
                        PublishedAt  = searchResult.Snippet.PublishedAt,
                        ChannelId    = searchResult.Snippet.ChannelId,
                        ChannelTitle = searchResult.Snippet.ChannelTitle,
                        Description  = searchResult.Snippet.Description,
                        Thumbnails   = searchResult.Snippet.Thumbnails.Default__.Url,
                    };
                    searchTerm.SearchLog.Add(log);
                }
            }
            _repository.SaveSearch(searchTerm);
            return(searchTerm);
        }
Example #24
0
        public ActionResult Get(string search, bool insertLog = true)
        {
            try
            {
                var array = search.Split(',');

                //validation
                if (array.Count() < 2)
                {
                    return(BadRequest("please enter at least one option"));
                }

                //Search Period
                var resultadoPeriod = _periodService.Get().Where(x => x.Name.ToLower() == array[0].ToLower().Trim()).FirstOrDefault();

                if (resultadoPeriod == null)
                {
                    return(BadRequest("Period not found"));
                }

                var result = new DishOrderHelper().BuildDishModel(array, resultadoPeriod.Id);

                var resultString = new DishOrderHelper().BuildStringReturn(result);

                if (insertLog)
                {
                    var searchLog = new SearchLog()
                    {
                        SearchKey = search, Result = resultString, Active = true, CreatedDate = DateTime.Now
                    };
                    _searchLogService.Post <SearchLogValidators>(searchLog);
                }

                //return new ObjectResult(resultString);
                return(Ok(resultString));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #25
0
        public void createSearchLog(string searchText)
        {
            Console.WriteLine("in search service create search log");

            SearchLog searchLog = new SearchLog();

            searchLog.Username = _httpContextAccessor.HttpContext.Request.Headers["X-MS-CLIENT-PRINCIPAL-NAME"].ToString();
            searchLog.FreeText = searchText;

            string json = JsonConvert.SerializeObject(searchLog);

            Console.WriteLine(json);

            // Create a hash for the API signature
            var    datestring   = DateTime.UtcNow.ToString("r");
            var    jsonBytes    = Encoding.UTF8.GetBytes(json);
            string stringToHash = "POST\n" + jsonBytes.Length + "\napplication/json\n" + "x-ms-date:" + datestring + "\n/api/logs";
            string hashedString = BuildSignature(stringToHash, sharedKey);
            string signature    = "SharedKey " + customerId + ":" + hashedString;

            PostData(signature, datestring, json);
        }
        private static void SaveQueryToLog(string query)
        {
            var queryText = query.ToString();
            using (var logContext = new BookstoreLogContext())
            {
                Database.SetInitializer(new MigrateDatabaseToLatestVersion<BookstoreLogContext, Configuration>());

                var log = new SearchLog();
                log.Date = DateTime.Now;
                log.Content = queryText;
                logContext.SearchLog.Add(log);
                logContext.SaveChanges();
            }
        }
Example #27
0
        protected void BindData()
        {
            try
            {
                string keywords = txtSearchTerm.Text.Trim();
                pagerProducts.PageSize = this.ProductService.SearchPageProductsPerPage;

                if (!String.IsNullOrEmpty(keywords))
                {
                    int searchTermMinimumLength = this.SettingManager.GetSettingValueInteger("Search.ProductSearchTermMinimumLength", 3);
                    if (keywords.Length < searchTermMinimumLength)
                    {
                        throw new NopException(string.Format(GetLocaleResourceString("Search.SearchTermMinimumLengthIsNCharacters"), searchTermMinimumLength));
                    }

                    bool    advSearch                   = cbAdvancedSearch.Checked;
                    int     categoryId                  = 0;
                    int     manufacturerId              = 0;
                    decimal?minPriceConverted           = null;
                    decimal?maxPriceConverted           = null;
                    bool    searchInProductDescriptions = false;
                    if (advSearch)
                    {
                        //categories
                        if (ddlCategories.Items.Count > 0)
                        {
                            categoryId = int.Parse(this.ddlCategories.SelectedItem.Value);
                        }

                        //manufacturers
                        if (ddlManufacturers.Items.Count > 0)
                        {
                            manufacturerId = int.Parse(this.ddlManufacturers.SelectedItem.Value);
                        }

                        //min price
                        decimal?minPrice = null;
                        try
                        {
                            if (!string.IsNullOrEmpty(txtPriceFrom.Text.Trim()))
                            {
                                minPrice = decimal.Parse(txtPriceFrom.Text.Trim());
                                if (minPrice.HasValue)
                                {
                                    minPriceConverted = this.CurrencyService.ConvertCurrency(minPrice.Value, NopContext.Current.WorkingCurrency, this.CurrencyService.PrimaryStoreCurrency);
                                }
                            }
                        }
                        catch
                        {
                            txtPriceFrom.Text = string.Empty;
                        }

                        //max price
                        decimal?maxPrice = null;
                        try
                        {
                            if (!string.IsNullOrEmpty(txtPriceTo.Text.Trim()))
                            {
                                maxPrice = decimal.Parse(txtPriceTo.Text.Trim());
                                if (maxPrice.HasValue)
                                {
                                    maxPriceConverted = this.CurrencyService.ConvertCurrency(maxPrice.Value, NopContext.Current.WorkingCurrency, this.CurrencyService.PrimaryStoreCurrency);
                                }
                            }
                        }
                        catch
                        {
                            txtPriceTo.Text = string.Empty;
                        }

                        //search in descriptions
                        searchInProductDescriptions = cbSearchInProductDescriptions.Checked;
                    }

                    int totalRecords = 0;
                    var products     = this.ProductService.GetAllProducts(categoryId,
                                                                          manufacturerId, 0, null,
                                                                          minPriceConverted, maxPriceConverted,
                                                                          keywords, searchInProductDescriptions,
                                                                          100, 0, new List <int>(), out totalRecords);

                    lvProducts.DataSource = products;
                    lvProducts.DataBind();
                    lvProducts.Visible    = products.Count > 0;
                    pagerProducts.Visible = products.Count > pagerProducts.PageSize;
                    lblNoResults.Visible  = !lvProducts.Visible;

                    int customerId = 0;
                    if (NopContext.Current.User != null)
                    {
                        customerId = NopContext.Current.User.CustomerId;
                    }

                    var searchLog = new SearchLog()
                    {
                        SearchTerm = txtSearchTerm.Text.Trim(),
                        CustomerId = customerId,
                        CreatedOn  = DateTime.UtcNow
                    };

                    this.SearchLogService.InsertSearchLog(searchLog);
                }
                else
                {
                    pagerProducts.Visible = false;
                    lvProducts.Visible    = false;
                }
            }
            catch (Exception exc)
            {
                lvProducts.Visible    = false;
                pagerProducts.Visible = false;
                lblError.Text         = Server.HtmlEncode(exc.Message);
            }
        }
Example #28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.BiblioSearchControl1.Location = this.TitleBarControl1.SelectedLibraryCode;

        if (WebUtil.PrepareEnvironment(this,
                                       ref app,
                                       ref sessioninfo) == false)
        {
            return;
        }

        string strSideBarFile = Server.MapPath("./search_sidebar.xml");

        if (File.Exists(strSideBarFile) == true)
        {
            this.SideBarControl1.CfgFile = strSideBarFile;
        }
        else
        {
            this.SideBarControl1.Visible = false;
        }

        SetSideBarVisible();

        /*
         * // 是否登录?
         * if (sessioninfo.UserID == "")
         * {
         *  sessioninfo.LoginCallStack.Push(Request.RawUrl);
         *  Response.Redirect("login.aspx", true);
         *  return;
         * }
         * */

        if (this.BrowseSearchResultControl1.ResultCount > 0)
        {
            this.BrowseSearchResultControl1.Visible = true;
#if FILTER
            VisibleFilter(true);
#endif
        }

        // 是否登录?
        if (sessioninfo.UserID == "")
        {
            if (this.Page.Request["forcelogin"] == "on")
            {
                sessioninfo.LoginCallStack.Push(Request.RawUrl);
                Response.Redirect("login.aspx", true);
                return;
            }
            if (this.Page.Request["forcelogin"] == "userid")
            {
                sessioninfo.LoginCallStack.Push(Request.RawUrl);
                Response.Redirect("login.aspx?loginstyle=librarian", true);
                return;
            }
            sessioninfo.UserID   = "public";
            sessioninfo.IsReader = false;

            /*
             * sessioninfo.LoginCallStack.Push(Request.RawUrl);
             * Response.Redirect("login.aspx", true);
             * return;
             * */
        }

        string strError = "";
        int    nRet     = 0;

#if NO
        string strAction = this.Request["action"];
        if (strAction == "getdblist")
        {
            DoGetDbNameList();
            return;
        }
#endif

        // 如果有参数
        string strWord = this.Request["word"];
        if (String.IsNullOrEmpty(strWord) == false &&
            this.IsPostBack == false)
        {
            string strXml = "";

            // string strWord = "";
            string strDbName     = "";
            string strFrom       = "";
            string strMatchStyle = "";

            GetSearchParams(out strWord,
                            out strDbName,
                            out strFrom,
                            out strMatchStyle);

            // 根据检索参数创建XML检索式
            nRet = OpacApplication.BuildQueryXml(
                this.app,
                strDbName,     // this.Request["dbname"],
                strWord,
                strFrom,       // this.Request["from"],
                strMatchStyle, // this.Request["matchstyle"],
                null,
                null,
                app.SearchMaxResultCount,
                this.BiblioSearchControl1.SearchStyle, // strSearchStyle
                out strXml,
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            string strResultSetNamePrefix = "";

            strResultSetNamePrefix = this.Request["resultsetname"];
            if (String.IsNullOrEmpty(strResultSetNamePrefix) == true)
            {
                strResultSetNamePrefix = Session.SessionID + "_opac_1";
            }
            else
            {
                strResultSetNamePrefix = Session.SessionID + "_" + strResultSetNamePrefix;
            }

            string strResultSetName = GetResultSetName(strResultSetNamePrefix);

            LibraryChannel channel = sessioninfo.GetChannel(true);
            //sessioninfo.Channel.
            channel.Idle += new IdleEventHandler(channel_Idle);
            try
            {
                long lRet = // sessioninfo.Channel.
                            channel.Search(
                    null,
                    strXml,
                    strResultSetName,
                    "", // strOutputStyle
                    out strError);
                if (lRet == -1)
                {
                    goto ERROR1;
                }
#if FILTER
                app.SetFilterTask(strResultSetName, null);
#endif

                if (app.SearchLog != null)
                {
                    SearchLogItem log = new SearchLogItem();
                    log.IP    = this.Request.UserHostAddress.ToString();
                    log.Query = SearchLog.BuildLogQueryString(
                        this.Request["dbname"],
                        strWord,
                        this.Request["from"],
                        this.Request["matchstyle"]);
                    log.Time     = DateTime.UtcNow;
                    log.HitCount = nRet;
                    log.Format   = "searchcount";
                    app.SearchLog.AddLogItem(log);
                }

                // not found
                if (lRet == 0)
                {
                    this.BrowseSearchResultControl1.Visible = false;
#if FILTER
                    this.filter.Visible = false;
#endif
                    strError = "没有找到";
                    goto ERROR1;
                }

                this.BrowseSearchResultControl1.Clear();
                this.BrowseSearchResultControl1.Visible = true;
#if FILTER
                VisibleFilter(true);
#endif

                this.BrowseSearchResultControl1.ResultSetName = strResultSetName;
                this.BrowseSearchResultControl1.ResultCount   = (int)lRet;
                this.BrowseSearchResultControl1.StartIndex    = 0; // 2008/12/15

#if FILTER
                this.filter.ResultSetName = strResultSetName;
#endif

                string strFormat = this.Request["format"];
                if (String.IsNullOrEmpty(strFormat) == false)
                {
                    this.BrowseSearchResultControl1.FormatName = strFormat;
                }
                return;
            }
            finally
            {
                // sessioninfo.Channel.
                channel.Idle -= new IdleEventHandler(channel_Idle);
                sessioninfo.ReturnChannel(channel);
            }
        }

        // 观察特定的结果集
        if (this.IsPostBack == false)
        {
            string strResultSet     = this.Request["resultset"];
            string strBaseResultSet = this.Request["base"];
            string strTitle         = this.Request["title"];
            if (string.IsNullOrEmpty(strResultSet) == false)
            {
                string strResultsetFilename = PathUtil.MergePath(app.TempDir,   // sessioninfo.GetTempDir(), // ??
                                                                 strResultSet);
                if (File.Exists(strResultsetFilename) == true)
                {
                    long lHitCount = CacheBuilder.GetCount(app, strResultsetFilename, true);

                    this.BrowseSearchResultControl1.ResultsetFilename = strResultsetFilename;

                    this.BrowseSearchResultControl1.Visible = true;
#if FILTER
                    VisibleFilter(true);

                    this.filter.ResultSetName = strBaseResultSet;
#endif

                    string strOffset = this.Request["offset"];
                    this.BrowseSearchResultControl1.ResultsetOffset = strOffset;

#if FILTER
                    this.filter.SelectedNodePath = MakeSelectedPath(strResultSet, strOffset);
#endif
                    if (string.IsNullOrEmpty(strOffset) == false)
                    {
                        int nStart  = 0;
                        int nLength = -1;
                        BrowseSearchResultControl.ParseOffsetString(strOffset,
                                                                    out nStart,
                                                                    out nLength);
                        if (nLength == -1)
                        {
                            nLength = (int)lHitCount - nStart;
                        }
                        this.BrowseSearchResultControl1.ResultCount = nLength;
                    }
                    else
                    {
                        this.BrowseSearchResultControl1.ResultCount = (int)lHitCount;
                    }

                    if (string.IsNullOrEmpty(strTitle) == false)
                    {
                        this.BrowseSearchResultControl1.Title = strTitle;
                    }
                }
                else
                {
                    strError = "结果集文件 '" + strResultSet + "' 不存在";
                    goto ERROR1;
                }
            }
            else if (string.IsNullOrEmpty(strBaseResultSet) == false)
            {
                // 只用了base参数
                this.BrowseSearchResultControl1.Clear();
                this.BrowseSearchResultControl1.Visible = true;
#if FILTER
                VisibleFilter(true);
#endif

                this.BrowseSearchResultControl1.ResultSetName = strBaseResultSet;
                this.BrowseSearchResultControl1.ResultCount   = (int)MyWebPage.GetServerResultCount(sessioninfo, strBaseResultSet);
                this.BrowseSearchResultControl1.StartIndex    = 0;

#if FILTER
                this.filter.ResultSetName = strBaseResultSet;
#endif
            }
        }

        //this.AdvanceSearchControl1.Channels = sessioninfo.Channels;
        //this.AdvanceSearchControl1.ServerUrl = app.WsUrl;

        // this.HeadBarControl1.CurrentColumn = HeaderColumn.Search;
        return;

ERROR1:
        Response.Write(HttpUtility.HtmlEncode(strError));
        Response.End();
    }
Example #29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    long   FromCityId  = Convert.ToInt64(Request.QueryString["frmid"].ToString());
                    long   ToCityId    = Convert.ToInt64(Request.QueryString["toid"].ToString());
                    string flightclass = Request.QueryString["clss"].ToString();
                    int    td          = Convert.ToInt16(Request.QueryString["td"].ToString());

                    hdnTravelDirection.Value = td.ToString();
                    lblHeaderDepart.Text     = Convert.ToDateTime(Request.QueryString["depart_date"]).ToString("ddd, dd MMM, yyyy");
                    lblHeaderReturn.Text     = Convert.ToDateTime(Request.QueryString["return_date"]).ToString("ddd, dd MMM, yyyy");

                    TravelDirection traveldirection = (TravelDirection)td;
                    SearchInfo      searchinfo      = new SearchInfo();
                    City            fromcity        = new City();
                    searchinfo.OnwardDateOfJourney = Convert.ToDateTime(Request.QueryString["depart_date"]);
                    searchinfo.ReturnDateOfJourney = Convert.ToDateTime(Request.QueryString["return_date"]);
                    fromcity.CityId = FromCityId;
                    City tocity = new City();
                    tocity.CityId = ToCityId;
                    TravelClass travelclass = (TravelClass)Enum.Parse(typeof(TravelClass), flightclass);
                    searchinfo.FromCity  = fromcity;
                    searchinfo.ToCity    = tocity;
                    searchinfo.Class     = travelclass;
                    searchinfo.Direction = traveldirection;

                    ISearchManager searchmanager = SearchManagerFactory.GetInstance().Create();
                    SearchLog      searchlog     = searchmanager.SearchForFlights(searchinfo);

                    SearchResult searchresult = searchlog.GetSearchResult(TravelDirection.OneWay);

                    List <TravelSchedule> lstTravelSchedule = searchresult.GetTravelSchedules();
                    dlOuterOnward.DataSource = lstTravelSchedule;
                    dlOuterOnward.DataBind();

                    Session["flightbookingonwardresults"] = lstTravelSchedule;

                    if (lstTravelSchedule.Count > 0)
                    {
                        lblOneWayFromCity.Text = lblHeaderFromCity.Text = lstTravelSchedule[0].GetSchedules()[0].RouteInfo.FromCity.Name;
                        lblOneWayToCity.Text   = lblHeaderToCity.Text = lstTravelSchedule[0].GetSchedules()[0].RouteInfo.ToCity.Name;
                    }

                    if (traveldirection == TravelDirection.Return)
                    {
                        SearchResult searchresultreturn = searchlog.GetSearchResult(TravelDirection.Return);

                        List <TravelSchedule> lstTravelScheduleReturn = searchresultreturn.GetTravelSchedules();
                        dlOuterReturn.DataSource = lstTravelScheduleReturn;
                        dlOuterReturn.DataBind();

                        Session["flightbookingreturnresults"] = lstTravelScheduleReturn;

                        if (lstTravelScheduleReturn.Count > 0)
                        {
                            lblReturnFromCity.Text = lstTravelScheduleReturn[0].GetSchedules()[0].RouteInfo.FromCity.Name;
                            lblReturnToCity.Text   = lstTravelScheduleReturn[0].GetSchedules()[0].RouteInfo.ToCity.Name;
                        }
                    }
                    else
                    {
                        outbound_div.Style.Add("width", "70%");
                        return_div.Visible             = false;
                        lblHeaderReturn.Visible        = false;
                        lblHeaderDateSeparator.Visible = false;
                    }
                }
                catch
                {
                    Response.Redirect("~/Error.aspx");
                }
            }
        }
Example #30
0
 public void AddSearchLog(SearchLog searchLog)
 {
     _context.SearchLogs.Add(searchLog);
     _context.SaveChanges();
 }
Example #31
0
 /// <summary>
 /// Adds the search result to log
 /// </summary>
 /// <param name="direction"></param>
 /// <param name="result"></param>
 /// <param name="log"></param>
 private void AddSearchResultToLog(TravelDirection direction, SearchResult result, SearchLog log)
 {
     log.AddSearchResultToLog(direction, result);
 }