Exemplo n.º 1
0
        public void InitializeTest()
        {
            _queryProvider     = new QueryProvider <NamedFluentModel>();
            _conditionResolver = new ConditionResolverBase();

            ObjectMapperConfiguration.Use(_conditionResolver);
        }
Exemplo n.º 2
0
        /// <summary>
        /// <para>执行分支判断策略,即设置token的alive属性 首先,如果this.alive==false,则所有的token的Alive属性皆为false</para>
        /// <para>然后,如果在nexttransitionList中有值,则直接执行列表中的tansition</para>
        /// 否则,通过计算Transition的表达式来确定下一个transition,
        /// </summary>
        /// <param name="vars"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        private Boolean determineTheAliveOfToken(Dictionary <String, Object> vars, String condition)
        {
            // TODO通过计算transition上的表达式来确定alive的值
            IConditionResolver elResolver = this.RuntimeContext.ConditionResolver;
            Boolean            b          = elResolver.resolveBooleanExpression(vars, condition);

            return(b);
        }
        public static void Use(IConditionResolver conditionResolver)
        {
            if (conditionResolver == null)
            {
                throw new ArgumentNullException("conditionResolver", "'ConditionResolver' parameter should be set to non nullable value.");
            }

            ConditionResolver = conditionResolver;
        }
Exemplo n.º 4
0
 public static IEnumerable<Models.SearchResult> MapSearchItemsToSearchResults(SearchItem[] items, IConditionResolver resolver, int productId)
 {
     return items.Select(i => new Models.SearchResult()
     {
         DateOfMatch = DateTime.Now,
         Link = i.viewItemURL,
         Title = i.title,
         Price = i.sellingStatus.currentPrice.Value,
         ItemNumber = i.itemId,
         StartTime = i.listingInfo.startTime,
         EndTime = i.listingInfo.endTime,
         NumberOfBidders = i.listingInfo.listingType.ToLowerInvariant() == "auction" ? i.sellingStatus.bidCount : 0,
         ImageURL = i.galleryURL,
         Currency = i.sellingStatus.currentPrice.currencyId,
         Location = i.location,
         SiteID = i.globalId,
         Type = i.listingInfo.listingType,
         ShippingCost = (i.shippingInfo.shippingServiceCost != null) ? i.shippingInfo.shippingServiceCost.Value : 0.0f,
         ConditionId = resolver.ConditionIdFromEBayConditionId((i.condition == null)? 0 : i.condition.conditionId),
         ProductId = productId
     });
 }
 static ConditionExtensions()
 {
     _conditionResolver = ObjectMapperConfiguration.ConditionResolver;
 }
Exemplo n.º 6
0
        public void Start()
        {
            // Reset the search we last ran
            _currentSearchId = 0;

            // Calculate the delay between searches
            SearchScheduleInterval = CalculateScheduleInterval();

            // Create the condition resolver
            _conditionResolver = CreateConditionResolver();

            // Kick off the first search
            Task.Delay(100, _cts.Token).ContinueWith(_searchTask, _cts.Token);

            // Mark start time
            StartTime = DateTime.Now;

            // Start the result notifier
            _resultAggregator.Start();

            _log.Info($"SearchMonkey v{Version} Started");
#if (DEBUG == false)
            _notifier.PostMessage($"SearchMonkey v{Version} Started");
#endif
        }
Exemplo n.º 7
0
 public AllConditionEvaluator(IConditionResolver conditionResolver)
 {
     _conditionResolver = conditionResolver;
 }
Exemplo n.º 8
0
 public RuleService(IConditionResolver conditionResolver)
 {
     _conditionResolver = conditionResolver;
 }
Exemplo n.º 9
0
        private void Run()
        {
            try
            {
                var repo = new SoldOutRepository();

                // Create the search catalogue
                var searches = repo.GetAllSearchesWithSearchCriteria();
                conditionResolver = new ConditionResolver(repo.GetConditions());

                var finder = new EbayFinder()
                    .Configure(c =>
                   {
                       // Initialize service end-point configuration
                       c.EndPointAddress = "http://svcs.ebay.com/services/search/FindingService/v1";
                       c.GlobalId = "EBAY-GB";
                       // set eBay developer account AppID here!
                       c.ApplicationId = ConfigurationManager.AppSettings["eBayApplicationId"];
                   });

                foreach (var search in searches)
                {
                    Console.WriteLine("Requesting completed items for '{0}' {1}",
                        search.Name,
                        (search.LastRun != null) ? "since " + search.LastRun.ToString() : string.Empty);

                    // Create a request to get our completed items
                    var response = finder.GetCompletedItems(search, 1);

                    // Show output
                    if (response.ack == AckValue.Success || response.ack == AckValue.Warning)
                    {
                        Console.WriteLine("Found " + response.searchResult.count + " new items");

                        // Set the last ran time
                        search.LastRun = response.timestamp;

                        if (response.searchResult.count > 0)
                        {
                            // Map returned items to our SoldItems model
                            var newItems = eBayMapper.MapSearchItemsToSearchResults(response.searchResult.item, conditionResolver, search.ProductId); 

                            // Add them to the relevant search
                            repo.AddSearchResults(search.SearchId, newItems);
                        }

                        repo.SaveAll();
                    }
                    else
                    {
                        Console.WriteLine(string.Format("Request failed: {0}", response.ack.ToString()));

                        response.errorMessage.ToList().ForEach(e => Console.WriteLine(e.message));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex);
            }

        }
Exemplo n.º 10
0
 public BaseDao(string connectionString, IConditionResolver conditionResolver)
     : base(connectionString)
 {
     _conditionResolver = (IConditionResolver <ICriteria>)conditionResolver;
 }
Exemplo n.º 11
0
 public void InitializeTest()
 {
     _conditionResolver = new ConditionResolverBase();
 }