protected override void ApplicationStartup(TinyIoCContainer _container, IPipelines _pipelines) { base.ApplicationStartup(_container, _pipelines); m_ApiToken = Config.GetSettingValue("ApiAccessKey", null); Trace.Listeners.Add(new LogglyTraceListener()); _pipelines.BeforeRequest.AddItemToStartOfPipeline(_context => { //Validate the API Token string apiToken = _context.Request.Headers["ApiAccessKey"].FirstOrDefault(); if (apiToken != null && apiToken.Equals(m_ApiToken)) { return(null); } TraceFileHelper.Warning("Missing or invalid api access key"); return(new Response() { StatusCode = HttpStatusCode.BadRequest }); }); _pipelines.OnError.AddItemToStartOfPipeline((context, exception) => { TraceFileHelper.Exception(exception); return(Response.NoBody); }); }
//Gets all tags public List <TagRow> GetTagRows(string _username, bool _activeOnly) { try { string startKey = null; return(GetTagRows(_username, _activeOnly, 0, ref startKey)); } catch (Exception ex) { TraceFileHelper.Exception(ex); } return(null); }
public static void CreateScaledImages(HydrantWikiManager _manager, Guid _originalGuid) { //Get the image from the originals folder from S3 //Load the original byte[] data = _manager.GetOriginal(_originalGuid, ".jpg"); try { using (Image full = ImageHelper.GetImage(data)) { //Standard sizes must fit in 800 x 800 SizeF thumbSize = ImageSizeHelper.SizeThatFits(full, 800); using (Image reduced = ImageHelper.GetThumbnail(full, Convert.ToInt32(thumbSize.Height), Convert.ToInt32(thumbSize.Width))) { data = ImageHelper.GetBytes(reduced, ImageFormat.Jpeg); _manager.PersistWebImage(_originalGuid, ".jpg", "image/jpg", data); } //Thumbnails must fit in 100 x 100 thumbSize = ImageSizeHelper.SizeThatFits(full, 100); using (Image reduced = ImageHelper.GetThumbnail(full, Convert.ToInt32(thumbSize.Height), Convert.ToInt32(thumbSize.Width))) { data = ImageHelper.GetBytes(reduced, ImageFormat.Jpeg); _manager.PersistThumbnailImage(_originalGuid, ".jpg", "image/jpg", data); } } } catch (Exception ex) { //Bad Image TraceFileHelper.Exception(ex); } }
public bool SendCannedEmail(TGUser _tgUser, string _cannedEmailName, NameValueCollection _additionParameters) { try { CannedEmail cannedEmail = GetCannedEmail(_cannedEmailName); if (cannedEmail != null) { SystemEmail email = new SystemEmail(cannedEmail.Guid); TGSerializedObject tgso = _tgUser.GetTGSerializedObject(); foreach (string key in _additionParameters.Keys) { string value = _additionParameters.Get(key); tgso.Add(key, value); } CannedEmailHelper.PopulateEmail(cannedEmail, email, tgso); SESHelper.SendMessage(email); Persist(email); return(true); } TraceFileHelper.Warning("Canned email not found"); } catch (Exception ex) { TraceFileHelper.Exception(ex); } return(false); }
public void LogException(Guid _userGuid, Exception _message) { TraceFileHelper.Exception(_message + "|UserGuid - {0}", _userGuid); }