private DataRow[] GetDomainCache(string strDomain)
        {
            string    exp                 = "DomainName = '" + strDomain + "'";
            string    sortOrder           = "Priority DESC,isPrefixCacheRegex DESC";
            DataTable dtCacheDomainsCache = CseToMongoEtlProvider.GetDataTable("dtCacheDomains", "", "SQLCacheConnectionString", 60);

            //  DataTable dtCacheDomainsCache = CU.GetCacheTable("dtCacheDomains", "SQLCacheConnectionString", 11);
            DataRow[] drw = new DataRow[0];
            try
            {
                //drw = dtCacheDomainsCache.Select(exp, sortOrder);
                DataView dv;
                lock (dtCacheDomainsCache)
                {
                    dv = new DataView(dtCacheDomainsCache, exp, sortOrder, DataViewRowState.Added);

                    if (dv.Count == 0)
                    {
                        dv = new DataView(dtCacheDomainsCache, exp, sortOrder, DataViewRowState.OriginalRows);
                    }

                    drw = dv.ToTable().Select();
                }
            }
            catch
            {
            }
            return(drw);
        }
        private string GetPageTypeByUrl(Dictionary <string, string> debug, string domain, string url)
        {
            var pageTypeMappingDt = CseToMongoEtlProvider.GetDataTable("Get_Domain_PageTypes",
                                                                       new Dictionary <string, object> {
                { "@domain", domain }
            },
                                                                       "SQLCacheConnectionString", 60);

            if (pageTypeMappingDt == null || pageTypeMappingDt.Rows.Count == 0)
            {
                debug.Add("could not find page type mappings for", domain);
                return(null);
            }

            for (int i = 0; i < pageTypeMappingDt.Rows.Count; i++)
            {
                if (Regex.IsMatch(url, (string)pageTypeMappingDt.Rows[i]["Regex"]))
                {
                    string pageType = (string)pageTypeMappingDt.Rows[i]["pagetype"];
                    debug.Add("pagetype", pageType.ToLower());
                    return(pageType);
                }
            }

            debug.Add("could determin page type for", url);

            return(null);
        }
        private string GetSearchKeyword(Dictionary <string, string> debug, string domain, string url)
        {
            var searchParamsDt = CseToMongoEtlProvider.GetDataTable("Get_Domain_SearchParam",
                                                                    new Dictionary <string, object> {
                { "@domain", domain }
            },
                                                                    "SQLCacheConnectionString", 60);

            if (searchParamsDt == null || searchParamsDt.Rows.Count == 0)
            {
                debug.Add("could not find search params for", domain);
                return(null);
            }

            var uri   = new Uri(url);
            var query = HttpUtility.ParseQueryString(uri.Query);

            for (int i = 0; i < searchParamsDt.Rows.Count; i++)
            {
                var param         = (string)searchParamsDt.Rows[i]["SearchParam"];
                var searchKeyword = query[param];

                if (!string.IsNullOrEmpty(searchKeyword))
                {
                    debug.Add("search keyword", searchKeyword);
                    return(searchKeyword);
                }
            }

            debug.Add("could not find search params in", url);
            return(null);
        }
Beispiel #4
0
        public dynamic GetRtSettings()
        {
            var dataTable = CseToMongoEtlProvider.GetDataTable("sp_GET_DealFinder_RT_Settings",
                                                               new Dictionary <string, object>
            {
                { "@CampaignId", _context.CampaignId }
            },
                                                               "SQLCacheConnectionString", 60);

            if (dataTable == null || dataTable.Rows.Count == 0)
            {
                return(new
                {
                    rt_campaign_id = "",
                    is_active = false,
                    freq = 0,
                    non_e_com_rec = 0,
                    e_com_rec = 0
                });
            }

            return(new
            {
                rt_campaign_id = (string)dataTable.Rows[0]["CampaignID_RT"],
                is_active = ((byte)dataTable.Rows[0]["active"]) == 1 ? true : false,
                freq = (short)dataTable.Rows[0]["Frequency_Not30K"],
                non_e_com_rec = (short)dataTable.Rows[0]["Reccency_Not30K"],
                e_com_rec = (short)dataTable.Rows[0]["Reccency_30K"]
            });
        }
        private List <string> GetDomainTriggersAndCountry(DealFinderContext context)
        {
            var timer     = new TimerProvider(context, "get-domain-triggers");
            var dataTable = CseToMongoEtlProvider.GetDataTable("sp_Get_DomainTrigger",

                                                               new Dictionary <string, object>
            {
                { "Domain", context.DomainName }
            },
                                                               "SQLCacheConnectionString", 60);

            timer.StopTimer();

            timer = new TimerProvider(context, "domain-triggers-match-time");

            var domainTriggers = new List <string>();

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                domainTriggers.Add((string)dataTable.Rows[i][0]);
                context.Country = dataTable.Rows[i][1] == DBNull.Value ? "US" : (string)dataTable.Rows[i][1];
            }

            timer.StopTimer();

            return(domainTriggers);
        }
Beispiel #6
0
        private string GetDomainToMidMapping(int cse)
        {
            var dt = CseToMongoEtlProvider.GetDataTable("Get_Domain_Mids",
                                                        new Dictionary <string, object>
            {
                { "@domain", _context.DomainName }
            },
                                                        "SQLCacheConnectionString", 24);

            if (dt == null || dt.Rows.Count == 0)
            {
                return("undefined");
            }

            var rows = dt.Select("api = " + cse.ToString());

            if (rows.Length == 0)
            {
                return("undefined");
            }

            string mid = rows[0][0] as string;

            return(mid);
        }
Beispiel #7
0
        private dynamic GetDomainPriceInterval()
        {
            var dt = CseToMongoEtlProvider.GetDataTable("Get_DomainPriceRange",
                                                        new Dictionary <string, object>
            {
                { "@domain", _context.DomainName }
            },
                                                        "SQLCacheConnectionString", 24);

            if (dt == null || dt.Rows.Count == 0)
            {
                return(new
                {
                    min = 0,
                    max = 0
                });
            }
            else
            {
                return(new
                {
                    min = (double)((int)dt.Rows[0]["min"]) / 100,
                    max = (double)((int)dt.Rows[0]["max"]) / 100
                });
            }
        }
Beispiel #8
0
        private List <short> GetCseApisAndCurrencyForCurrentCampaignId()
        {
            var dt = CseToMongoEtlProvider.GetDataTable("Get_Campaign_Apis",
                                                        new Dictionary <string, object>
            {
                { "CampaignID", string.IsNullOrEmpty(_context.Country) ? _context.CampaignId.ToString() : _context.Country }
            },
                                                        "SQLCacheConnectionString", 24);

            if (dt == null || dt.Rows.Count == 0)
            {
                return(new List <short>());
            }

            _context.Currency = dt.Rows[0][1].ToString();

            var apis = new List <short>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                apis.Add((short)dt.Rows[i][0]);
            }

            return(apis);
        }
        private string GetOP(string campaignId, string sid, string nid)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("AID", campaignId);
            parameters.Add("PID", nid == null ? "" : nid);
            parameters.Add("SE", 0);
            parameters.Add("SID", sid == null ? "" : sid);

            DataTable aidMapping = CseToMongoEtlProvider.GetDataTable("SP_DF_GET_MappedCampaign", parameters, "SQLCacheConnectionString", 24);

            string op = aidMapping.Rows[0]["OP"].ToString();

            return(op);
        }
Beispiel #10
0
        public bool IsEcommerceDomain()
        {
            var dataTable = CseToMongoEtlProvider.GetDataTable("sp_Domain_in30K",
                                                               new Dictionary <string, object>
            {
                { "@Domain", _context.DomainName }
            },
                                                               "SQLCacheConnectionString", 60);

            if (dataTable == null || dataTable.Rows.Count == 0)
            {
                return(false);
            }

            return(((int)dataTable.Rows[0][0]) == 0 ? false : true);
        }
        private string GetProductName(Dictionary <string, string> debug, string domain, string url)
        {
            var urlKeywordMappingsDt = CseToMongoEtlProvider.GetDataTable("Get_Domain_UrlProduct",
                                                                          new Dictionary <string, object> {
                { "@domain", domain }
            },
                                                                          "SQLCacheConnectionString", 60);

            if (urlKeywordMappingsDt == null || urlKeywordMappingsDt.Rows.Count == 0)
            {
                return(null);

                //debug.Add("could not find url mapping for domain, executing get site data", domain);

                //try
                //{
                //    var siteData = MarketProvider.GetSiteData(debug, "6000666", url, false);

                //    return siteData.productName;
                //}
                //catch
                //{

                //}
            }
            else
            {
                debug.Add("url mapping found", domain);

                short  level      = (short)urlKeywordMappingsDt.Rows[0]["Level"];
                string stopString = (string)urlKeywordMappingsDt.Rows[0]["StopString"];
                string divider    = (string)urlKeywordMappingsDt.Rows[0]["Divider"];

                var uri = new Uri(url);

                string keyword = uri.Segments[level - 1];
                keyword = keyword.Replace(stopString, "");
                keyword = keyword.Replace(divider, " ");

                return(keyword);
            }

            return(null);
        }