Skip to content

Commit

Permalink
added logging
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-nelson committed Nov 8, 2016
1 parent 875ec91 commit 84b9347
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/hwMobileApi/Modules/ApiModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ public BaseResponse HandleMatchTag(DynamicDictionary _parameters)
if (tagId != null
&& hydrantId != null)
{


Tag tag = hwm.GetTag(tagId.Value);

if (tag != null)
Expand Down Expand Up @@ -271,6 +269,9 @@ public BaseResponse HandleApproveTag(DynamicDictionary _parameters)
}

hwm.LogWarning(user.Guid, string.Format("Tag Approve Error ({0})", message));
} else
{
LogUnauthorized(Request);
}

return new ReviewTagResponse { Success = false, Message = message };
Expand Down Expand Up @@ -328,6 +329,10 @@ public BaseResponse HandleRejectTag(DynamicDictionary _parameters)

hwm.LogWarning(user.Guid, string.Format("Tag Reject Error ({0})", message));
}
else
{
LogUnauthorized(Request);
}

return new ReviewTagResponse { Success = false, Message = message};
}
Expand Down Expand Up @@ -405,6 +410,7 @@ private BaseResponse HandleGetTagsToReview(DynamicDictionary _parameters)
}
else
{
LogUnauthorized(Request);
return new BaseResponse
{
Error = "Not authenticated",
Expand Down Expand Up @@ -441,6 +447,7 @@ private BaseResponse HandleGetMyTags(DynamicDictionary _parameters)
}
else
{
LogUnauthorized(Request);
response = new BaseResponse
{
Success = false,
Expand All @@ -467,6 +474,7 @@ private BaseResponse HangleGetTagCount(DynamicDictionary _parameters)
}
else
{
LogUnauthorized(Request);
response = new BaseResponse
{
Success = false,
Expand Down Expand Up @@ -494,6 +502,7 @@ private BaseResponse HandleGetMyTagCount(DynamicDictionary _parameters)
}
else
{
LogUnauthorized(Request);
response = new BaseResponse
{
Success = false,
Expand Down Expand Up @@ -572,11 +581,10 @@ private BaseResponse HandleImagePost(DynamicDictionary _parameters)
fileData = ImageHelper.GetThumbnailBytesOfMaxSize(original, 100);
hwManager.PersistThumbnailImage(imageGuid, ".jpg", "image/jpg", fileData);

TraceFileHelper.Info("Saved Image ({0})", imageGuid);
hwManager.LogInfo(user.Guid, string.Format("Saved Image ({0})", imageGuid));

response.Success = true;
return response;

}
}
}
Expand All @@ -588,13 +596,20 @@ private BaseResponse HandleImagePost(DynamicDictionary _parameters)
}
else
{
LogUnauthorized(Request);
response.Error = "Unauthorized";
response.Message = "Reauthenticate";
}

return response;
}

private void LogUnauthorized(Request _request)
{
string username = _request.Headers["Username"].First();
TraceFileHelper.Warning("{0} - {1} ({2})", _request.UserHostAddress, _request.Url, username);
}

private BaseResponse HandleTagPost(DynamicDictionary _parameters)
{
HydrantWikiManager hwManager = new HydrantWikiManager();
Expand Down Expand Up @@ -657,6 +672,7 @@ private BaseResponse HandleTagPost(DynamicDictionary _parameters)
}
else
{
LogUnauthorized(Request);
response.Error = "Unauthorized";
response.Message = "Reauthenticate";
}
Expand Down Expand Up @@ -687,6 +703,9 @@ public BaseResponse HangleGetHydrantsByCenterDistance(DynamicDictionary _paramet
hwm.LogInfo(user.Guid, "Retrieved Hydrants by Center and Distance");

return response;
} else
{
LogUnauthorized(Request);
}

return response;
Expand Down Expand Up @@ -727,6 +746,9 @@ public BaseResponse HangleGetHydrantsByGeobox(DynamicDictionary _parameters)
hwm.LogInfo(user.Guid, "Retrieved Hydrants by Geobox");

return response;
} else
{
LogUnauthorized(Request);
}

return response;
Expand Down

0 comments on commit 84b9347

Please sign in to comment.