Exemple #1
0
        private static string AbsoluteUrl(UrlHelper helper)
        {
            // should be null only when called by trace writer
            if (HttpContext.Current == null)
            {
                return("{{SiteUrl}}");
            }

            var url    = HttpContext.Current.Request.Url;
            var suffix = string.Empty;

            // if hosted in local IIS as virtual directory, add the name
            if (url.Port == 80 && !DataConfig.IsLiveMode() && url.Segments.Length >= 2)
            {
                suffix += url.Segments[1].TrimEnd('/') + "/";
            }

            return(string.Format("{0}://{1}/{2}", url.Scheme, url.Authority, suffix));
        }
Exemple #2
0
        public Repository()
        {
            if (DataConfig.IsLiveMode())
            {
                this.Context = this.GetDataContext();
            }
            else
            {
                //profile sql queries
                SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["Bets"].ConnectionString);

                // wrap the connection with a profiling connection that tracks timings
                this.Context = new BetsDataContext(sqlConn);
            }

            if (DataConfig.EnableTracing())
            {
                this.Context.Log = new TextToTraceWriter {
                    Category = "DatabaseQuery"
                };
            }
            this.Context.CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimeout"]);
        }