static AppEnvironment() { IsProduction = WebConfig.Get <bool>("Environment:IsProduction"); IsLocalDev = WebConfig.Get <bool>("Environment:IsLocalDev"); IsQaStage = !IsProduction && !IsLocalDev; ServerName = HttpContext.Current.Server.MachineName; try { BuildVersion = IsLocalDev ? "(local dev)" : File.ReadAllText(Server.MapPath("~/build.txt")); } catch (Exception ex) { const string missingBuildVersionBlurb = "FATAL: A NON-LocalDev environment has been enabled, but the ./build.txt file could NOT be found in the application root."; Log.Fatal(missingBuildVersionBlurb); throw new Exception(missingBuildVersionBlurb, ex); } WwwAssetsUrlPrefix = "/assets/"; AssetsUrlPrefix = IsLocalDev ? "/app_assets/dist" : WebConfig.Get <string>("Environment:StaticUrlPrefix"); StaticDistributionScriptUrlPrefix = AssetsUrlPrefix + "/js/"; StaticDistributionStyleUrlPrefix = AssetsUrlPrefix + "/css/"; StaticLibrariesUrlPrefix = String.Format("{0}/libs/", AssetsUrlPrefix); }
static DeviceDetector() { Log.Info("Start: Initializing the WURFL Manager"); try { var wurflDataFilePath = HttpContext.Current.Server.MapPath(String.Format("~/{0}", WebConfig.Get <string>("WURFL:DatabaseFilePath")).Replace("//", "/")); var configurer = new WURFL.Config.InMemoryConfigurer().MainFile(wurflDataFilePath); var patches = WebConfig.Get <string>("WURFL:PatchFilePaths").Split(new[] { '|', ';', ':' }, StringSplitOptions.RemoveEmptyEntries); if (patches.Length > 0) { foreach (var patch in patches) { var wurflPatchFilePath = HttpContext.Current.Server.MapPath(String.Format("~/{0}", patch).Replace("//", "/")); configurer.PatchFile(wurflPatchFilePath); } } WurflManager = WURFLManagerBuilder.Build(configurer); Log.Info("Stop: Initializing the WURFL Manager"); } catch (Exception ex) { Log.Error("DeviceDetector() ctor:", ex); throw; } }
/// <summary> /// Explores given file, using parent batch command's methods as callbacks /// </summary> /// <param name="parentCommand"></param> /// <param name="projectItem"></param> /// <param name="maxLine">Line where parser should stop</param> /// <param name="maxIndex">Column where parser should stop</param> public void Explore(AbstractBatchCommand parentCommand, ProjectItem projectItem, int maxLine, int maxIndex) { if (parentCommand == null) { throw new ArgumentNullException("parentCommand"); } if (projectItem == null) { throw new ArgumentNullException("projectItem"); } lock (syncObject) { fullPath = projectItem.GetFullPath(); if (string.IsNullOrEmpty(fullPath)) { throw new Exception("Cannot process item " + projectItem.Name); } this.parentCommand = parentCommand; this.declaredNamespaces.Clear(); this.ClassFileName = Path.GetFileNameWithoutExtension(fullPath); this.projectItem = projectItem; this.openedElements.Clear(); // initialize type resolver if (parentCommand is BatchMoveCommand) { webConfig = WebConfig.Get(projectItem, VisualLocalizerPackage.Instance.DTE.Solution); } else { webConfig = null; } fileText = null; if (RDTManager.IsFileOpen(fullPath)) // file is open { var textLines = VLDocumentViewsManager.GetTextLinesForFile(fullPath, false); // get text buffer if (textLines == null) { return; } int lastLine, lastLineIndex; int hr = textLines.GetLastLineIndex(out lastLine, out lastLineIndex); Marshal.ThrowExceptionForHR(hr); hr = textLines.GetLineText(0, 0, lastLine, lastLineIndex, out fileText); // get plain text Marshal.ThrowExceptionForHR(hr); } else // file is closed - read it from disk { fileText = File.ReadAllText(fullPath); } Parser parser = new Parser(fileText, this, maxLine, maxIndex); // run ASP .NET parser parser.Process(); } }
static ApiCacheabilityAttribute() { var configStringForDownstream = WebConfig.Get <string>("Cacheability:Timeouts:Downstream"); var configStringForEdge = WebConfig.Get <string>("Cacheability:Timeouts:Edge"); CacheConfig.ParseTimeToLives(TimeToLivesForDownstream, configStringForDownstream); CacheConfig.ParseTimeToLives(TimeToLivesForEdge, configStringForEdge); CacheConfig.Validate(TimeToLivesForDownstream, TimeToLivesForEdge); }
public CarsForSaleService() { if (IsLocalDev) { var loadAmount = WebConfig.Get <int>("Environment:LocalDev:CarsForSaleLoadAmount"); if (loadAmount != 0) { _loadAmount = loadAmount; } } }
/// <summary> /// Gets the absolute root of the website. /// </summary> /// <value>A string that ends with a '/'.</value> public static Uri AbsoluteWebRoot(bool forceConfig = false) { if (System.Web.HttpContext.Current == null || forceConfig) { return(new Uri(WebConfig.Get("siteroot"))); } if (string.Compare(WebConfig.Get("Application"), "LOCAL", true) == 0) { return(new Uri(System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Authority + System.Web.HttpContext.Current.Request.ApplicationPath)); } else { return(new Uri(System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Authority)); } }
public ActionResult FillIn(IDictionary <string, string> SubmitFields, TemplateViewModel model, FormCollection formCollection) { InsertValuesIntoTempData(SubmitFields, formCollection); using (var formManager = new FormAccessManager(GetLoginUser())) { var template = formManager.FindTemplate(model.TemplateID.Value); var templateView = TemplateViewModel.CreateFromObject(template, Constants.TemplateFieldMode.INPUT); string result = formManager.FillIn(SubmitFields, model, formCollection); if (result.Equals("success")) { //send notification if (!templateView.NotificationEmail.IsNullOrEmpty() && WebConfig.Get <bool>("enablenotifications", true)) { var notificationView = new NotificationEmailViewModel(); notificationView.FormName = templateView.Title; notificationView.Email = templateView.NotificationEmail; //TODO if need to use this, need to retrieve the entries //notificationView.Entries = ??; NotifyViaEmail(notificationView); } RemoveValuesFromTempData(formCollection); TempData["success"] = templateView.ConfirmationMessage; return(RedirectToRoute("form-submitconfirmation", new { id = template.TemplateID, embed = model.Embed })); } else { TempData["error"] = result; return(View("FillIn", templateView)); } } }
public override void OnException(ExceptionContext filterContext) { // First, log any errors that come through here. Log.Error(filterContext.Exception); // Then, check if we should show pretty error pages, as opposed to the default ASP.NET style. if (!WebConfig.Get <bool>("Environment:IsLocalDev")) { filterContext.HttpContext.Response.TrySkipIisCustomErrors = true; filterContext.HttpContext.Response.StatusCode = 500; filterContext.ExceptionHandled = true; filterContext.HttpContext.Response.Clear(); using (var httpErrorController = new HttpErrorController()) { httpErrorController.ControllerContext = new ControllerContext(filterContext.HttpContext, new RouteData(), httpErrorController); filterContext.Result = httpErrorController.Status500(); } } base.OnException(filterContext); }
public DealerService() : base(WebConfig.Get <int>("DealerService:Timeout_ms")) { }
public void SendSubmissionNotificationEmail(string toEmail, string subject, string message) { SendMail(WebConfig.Get("senderemail"), toEmail, subject, message); }
private MailMessage BuildMessageWith(string fromAddress, string toAddress, string subject, string body, string fileName, MemoryStream data) { MailMessage msg = BuildMessageWith(fromAddress, toAddress, subject, body, WebConfig.Get("sendername")); var a = new Attachment(data, fileName); msg.Attachments.Add(a); return(msg); }
private void SendMail(string fromAddress, string toAddress, string subject, string body) { using (MailMessage mail = BuildMessageWith(fromAddress, toAddress, subject, body, WebConfig.Get("sendername"))) { SendMail(mail); } }
public VehicleContentService() : base(WebConfig.Get <int>("VehicleContentService:Timeout_ms")) { }
static VehicleContentService() { RedisReadable = ConnectionMultiplexer.Connect(WebConfig.Get <string>("Redis:Readable:Config")); PathPrefix = String.Format("/api/v{0}/", WebConfig.Get <string>("VehicleContentService:ApiVersion")); Endpoint = new Uri(String.Format("http://{0}", WebConfig.Get <string>("VehicleContentService:Endpoint"))); }
public ImageMetaService() : base(WebConfig.Get <int>("ImageMetaService:Timeout_ms")) { }
public DataWrapper GetAutowebAds([FromBody] string queryStr) { var query = JsonConvert.DeserializeObject <AutowebAdsQuery>(queryStr); var make = query.Make; var model = query.Model; var zip = query.Zip; var campaignId = query.PublisherCampaignId; var userIpAddress = HttpContext.Current.Request.UserHostAddress; var userAgent = HttpContext.Current.Request.UserAgent; var urlReferer = HttpContext.Current.Request.UrlReferrer != null?HttpContext.Current.Request.UrlReferrer.ToString() : ""; if (string.IsNullOrEmpty(userAgent)) { userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"; } if (string.IsNullOrEmpty(urlReferer)) { urlReferer = "http://www.car.com/"; } if (!ValidIpAddress(userIpAddress)) { userIpAddress = "207.8.110.64"; } var urlPrefix = WebConfig.Get <string>("AdService:Autoweb:Endpoint") + "?format=json"; var privateKey = WebConfig.Get <string>("AdService:Autoweb:PrivateKey"); var sharedSecret = WebConfig.Get <string>("AdService:Autoweb:SharedSecret"); string publisherInput = "{Make:" + make.ToLower() + ",Model:" + model.ToLower() + ",ZipCode:" + zip + ",DisplayCount:5,PublisherCampaignId:" + campaignId + ",ProductCategoryID:1,NoTracking:1}"; if (WebConfig.Get <string>("Environment:IsProduction") == "true") { publisherInput = "{Make:" + make.ToLower() + ",Model:" + model.ToLower() + ",ZipCode:" + zip + ",DisplayCount:5,PublisherCampaignId:" + campaignId + ",ProductCategoryID:1}"; } var url = urlPrefix + "&PublisherInput=" + publisherInput + "&UserIpAddress=" + userIpAddress + "&UserAgent=" + HttpUtility.UrlEncode(userAgent) + "&UrlReferer=" + HttpUtility.UrlEncode(urlReferer); var awDate = DateTime.UtcNow.ToString("yyyy-MM-dd/HH\\:mm\\:ss"); var awSignature = CreateHashedValue(awDate, privateKey); var awSharedSecret = sharedSecret; var request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; request.UserAgent = userAgent; request.Headers.Add("awDate", awDate); request.Headers.Add("awSignature", awSignature); request.Headers.Add("awSharedSecret", awSharedSecret); string result = string.Empty; try { var response = request.GetResponse() as HttpWebResponse; if (response != null) { using (Stream stream = response.GetResponseStream()) { if (stream != null) { var reader = new StreamReader(stream, Encoding.UTF8); result = reader.ReadToEnd(); } else { result = "none"; } } } } catch (Exception ex) { result = "none"; } if (result == "none") { return(DataWrapper()); } var autowebAdResponse = new AutowebAdResponse { AutowebAdJson = result }; return(DataWrapper(autowebAdResponse)); }
public static bool UseCloudStorage() { return(WebConfig.Get <bool>("usecloudstorage", false)); }
public GeoService() : base(WebConfig.Get <int>("VehicleSpecService:Timeout_ms")) { }
static GeoService() { PathPrefix = String.Format("/api/v{0}/geo/locationzip", WebConfig.Get <string>("GeoIpService:ApiVersion")); Endpoint = new Uri(String.Format("http://{0}", WebConfig.Get <string>("GeoIpService:Endpoint"))); }