Exemplo n.º 1
0
        public void MarkRecommendeedRelevances()
        {
            CanonDataContext      db          = Cdb.Instance;
            Dictionary <int, int> recommended = this.ChooseBestPairs();

            foreach (KeyValuePair <int, int> pair in recommended)
            {
                CurrentRelevance relevance = db.CurrentRelevances.First(r => r.ChannelMonitorId == pair.Value &&
                                                                        r.ProductId == pair.Key);
                relevance.BestForMapping = true;
            }
            db.SubmitChanges();
        }
Exemplo n.º 2
0
        protected bool IsForbiddenToRecommend(List <MappingRule> rules, int productId, int channelMonId)
        {
            CanonDataContext db        = Cdb.Instance;
            CurrentRelevance relevance = db.CurrentRelevances.First(r => r.ChannelMonitorId == channelMonId &&
                                                                    r.ProductId == productId);

            foreach (MappingRule rule in rules)
            {
                if ((rule.MonitoredName == relevance.ProductName) &&
                    (rule.MonitoredUrl == relevance.ProductUrl) &&
                    (rule.ProductId != productId))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 3
0
        public static void AddRecommendedMapping(int channelId, int productId)
        {
            CanonDataContext db = Cdb.Instance;

            try
            {
                CurrentRelevance cr = db.CurrentRelevances.Where(c => c.BestForMapping == true &&
                                                                 c.ChannelId == channelId &&
                                                                 c.ProductId == productId).FirstOrDefault();
                if (cr != null)
                {
                    MappingRule rule = db.MappingRules.Where(r => r.ChannelId == channelId &&
                                                             r.ProductId == productId).FirstOrDefault();
                    if (rule == null)
                    {
                        //NEW rule
                        MappingRule mr = new MappingRule();
                        mr.ChannelId     = channelId;
                        mr.ProductId     = productId;
                        mr.MonitoredName = cr.ProductName;
                        mr.MonitoredUrl  = cr.ProductUrl;
                        db.MappingRules.InsertOnSubmit(mr);
                        CanonProductsLog.Add(channelId, productId, MappingLogEnum.NewMappingRule);
                    }
                    else
                    {
                        //UPDATED rule
                        rule.MonitoredName = cr.ProductName;
                        rule.MonitoredUrl  = cr.ProductUrl;
                        CanonProductsLog.Add(channelId, productId, MappingLogEnum.ChangedMappingRule);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception)
            {
            }
        }