Ejemplo n.º 1
0
        public static Dictionary <string, int> GetReferers(string url, int siteId)
        {
            var dataAccess = DataAccessBaseEx.GetWorker();
            var referersDs = dataAccess.GetRequestReferers(url, siteId);

            Dictionary <string, int> referers = new Dictionary <string, int>();

            if (referersDs.Tables[0] != null)
            {
                int unknownReferers = 0;
                for (int i = 0; i < referersDs.Tables[0].Rows.Count; i++)
                {
                    var referer = referersDs.Tables[0].Rows[i][0].ToString();
                    int count   = Convert.ToInt32(referersDs.Tables[0].Rows[i][1].ToString());
                    if (referer.Trim() != string.Empty && !referer.Contains("(null)"))
                    {
                        if (!referer.Contains("://"))
                        {
                            referer = referer.Insert(0, "/");
                        }
                        referers.Add(referer, count);
                    }
                    else
                    {
                        unknownReferers += count;
                    }
                }
                if (unknownReferers > 0)
                {
                    referers.Add(UknownReferer, unknownReferers);
                }
            }
            return(referers);
        }
Ejemplo n.º 2
0
        public static int GetCurrentSiteId()
        {
            var host = HttpContext.Current.Request.Url.Host;

            try
            {
                var dataAccess  = DataAccessBaseEx.GetWorker();
                var hostDataSet = dataAccess.FindSiteIdByHost(host);
                foreach (DataTable table in hostDataSet.Tables)
                {
                    if (table.Rows.Count > 0)
                    {
                        var row = table.Rows[0];
                        return(Convert.ToInt32(row[0]));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(String.Format("Fel vid GetCurrentSiteId Fix: {0} Hosten var: {1}", ex, host));
                return(-1);
            }

            return(-1);
        }
Ejemplo n.º 3
0
        public static int GetTotalSuggestionCount(int siteId)
        {
            var dataAccess             = DataAccessBaseEx.GetWorker();
            var totalSuggestionCountDs = dataAccess.GetTotalNumberOfSuggestions(siteId);

            if (totalSuggestionCountDs != null && totalSuggestionCountDs.Tables.Count > 0)
            {
                return(Convert.ToInt32(totalSuggestionCountDs.Tables[0].Rows[0][0]));
            }
            return(0);
        }
Ejemplo n.º 4
0
        public static List <int> GetAllSiteIds()
        {
            List <int> siteIds     = new List <int>();
            var        dataAccess  = DataAccessBaseEx.GetWorker();
            var        hostDataSet = dataAccess.FindSiteIds();

            foreach (DataTable table in hostDataSet.Tables)
            {
                if (table.Rows.Count > 0)
                {
                    siteIds.AddRange(from DataRow row in table.Rows select Convert.ToInt32(row[0]));
                }
            }
            return(siteIds);
        }
Ejemplo n.º 5
0
        public static Dictionary <string, int> GetRedirects(int siteId)
        {
            var keyCounts         = new Dictionary <string, int>();
            DataAccessBaseEx dabe = DataAccessBaseEx.GetWorker();
            var allkeys           = dabe.GetAllClientRequestCount(siteId);

            foreach (DataTable table in allkeys.Tables)
            {
                foreach (DataRow row in table.Rows)
                {
                    var oldUrl = row[0].ToString();
                    keyCounts.Add(oldUrl, Convert.ToInt32(row[1]));
                }
            }
            return(keyCounts);
        }
Ejemplo n.º 6
0
        public static int GetSiteIdFromUrl(string url)
        {
            var host = HttpContext.Current.Request.Url.Host;

            var dataAccess  = DataAccessBaseEx.GetWorker();
            var hostDataSet = dataAccess.FindSiteIdByHost(host);

            foreach (DataTable table in hostDataSet.Tables)
            {
                if (table.Rows.Count > 0)
                {
                    var row = table.Rows[0];
                    return(Convert.ToInt32(row[0]));
                }
            }
            return(-1);
        }