public static void LogActionRequest(ActionRequestLog log) { using (var storage = new ActionRequestLogStorage()) { var utc = DateTime.UtcNow; var entity = new ActionRequestLogEntry { PartitionKey = log.SchoolId.ToString(CultureInfo.InvariantCulture), RowKey = string.Format("{0}_{1}_{2}_{3}_{4}_{5}", log.CreatorId.ToString(CultureInfo.InstalledUICulture), utc.ToLongDateString(), utc.ToLongTimeString(), log.ControllerName, log.ActionName, log.ActionParameters), ControllerName = log.ControllerName, ActionParameters = log.ActionParameters, ActionName = log.ActionName, AccessDate = log.AccessDate, IpAddress = log.IpAddress, CreatorId = log.CreatorId, }; storage.Insert(entity); } }
private static string GetSQLRowStatement(ActionRequestLogEntry logEntry) { if (Convert.ToInt32(logEntry.CreatorId) > 0) { var paramTokens = string.IsNullOrWhiteSpace(logEntry.ActionParameters) ? null : logEntry.ActionParameters.Split("|||".ToCharArray()).Where(pt => pt.Length > 0).Select(pt => pt).ToArray(); var eventCodeDictionaryKey = string.Format("{0}_{1}", logEntry.ControllerName.ToLower(), logEntry.ActionName.ToLower()); var eventCode = EVENT_CODE.Keys.Contains(eventCodeDictionaryKey) ? EVENT_CODE[eventCodeDictionaryKey] : string.Empty; if (paramTokens != null && string.IsNullOrWhiteSpace(eventCode)) { if (string.Compare(logEntry.ControllerName, "Feed", true) == 0) { eventCode = GetFeedEventCode(logEntry.ActionName, paramTokens); } } if (!string.IsNullOrWhiteSpace(eventCode)) { var param1 = paramTokens == null ? "null" : string.Format("'{0}'", paramTokens[0]); var param2 = paramTokens == null || paramTokens.Length < 2 ? "null" : string.Format("'{0}'", paramTokens[1]); var param3 = paramTokens == null || paramTokens.Length < 3 ? "null" : string.Format("'{0}'", paramTokens[2]); return(SQLTemplatePassiveSocialEvents.Insert .Replace("DESTINATIONTABLE", DESTINATIONTABLE) .Replace("USERID", logEntry.CreatorId.ToString()) .Replace("CONTROLLERNAME", logEntry.ControllerName) .Replace("ACTIONNAME", logEntry.ActionName) .Replace("ACTIONPARAM1", param1) .Replace("ACTIONPARAM2", param2) .Replace("ACTIONPARAM3", param3) .Replace("ACCESSDATE", logEntry.AccessDate.ToString()) .Replace("ACTIONPARAMS", string.IsNullOrWhiteSpace(logEntry.ActionParameters) ? "null" : string.Format("'{0}'", logEntry.ActionParameters)) .Replace("EVENTCODE", eventCode)); } } return(string.Empty); }