public int UndoUpdate(CombinedLogDataModel LogToUpdate) { try { using (AsignioDatabase db = new AsignioDatabase(ConnectionStringName)) { string sqlFormattedTimeStamp = LogToUpdate.TimeStamp.ToString("yyyy-MM-dd HH:mm:ss"); PetaPoco.Sql sql = new PetaPoco.Sql(); string nullString = "null"; sql.Append("SET SQL_SAFE_UPDATES = 0; "); sql.Append(string.Format("UPDATE log SET Important = {0} ", nullString)); string where = string.Format("WHERE TimeStamp = \"{0}\" AND LogID = GuidToBinary(\"{1}\") AND Level = \"{2}\" AND Source = \"{3}\" ; ", sqlFormattedTimeStamp, LogToUpdate.LogID, LogToUpdate.Level, LogToUpdate.Source); sql.Append(where); sql.Append("SET SQL_SAFE_UPDATES = 1; "); db.Execute(sql); return(1); } } catch (Exception ex) { string errorMessage = ex.Message; return(0); } finally { } }
public int UndoUpdate(LogMySqlDataModel LogToUpdate) { try { using (AsignioDatabase db = new AsignioDatabase(ConnectionStringName)) { string sqlFormattedTimeStamp = LogToUpdate.DateTimeStamp.ToString("yyyy-MM-dd HH:mm:ss"); PetaPoco.Sql sql = new PetaPoco.Sql(); string nullString = "null"; sql.Append("SET SQL_SAFE_UPDATES = 0; "); sql.Append(string.Format("UPDATE logmysql SET Important = {0} ", nullString)); string where = string.Format("WHERE DateTimeStamp = \"{0}\" AND logmysql.Function = \"{1}\" AND Message = \"{2}\" AND Type = \"{3}\"; ", sqlFormattedTimeStamp, LogToUpdate.Function, LogToUpdate.Message, LogToUpdate.Type); sql.Append(where); sql.Append("SET SQL_SAFE_UPDATES = 1; "); db.Execute(sql); return(1); } } catch (Exception ex) { string errorMessage = ex.Message; return(0); } finally { } }
public int Update(CombinedLogControllerActionDataModel LogToUpdate, string username) { try { using (AsignioDatabase db = new AsignioDatabase(ConnectionStringName)) { Byte[] bytes = new Byte[16]; Guid allZeros = new Guid(bytes); Guid UserID = GetUserIDFromUsername(username); if (UserID != allZeros) { if (username.Contains("@")) //format email { string[] sections = username.Split(new[] { '@' }); sections[1] = sections[1].Insert(0, "@@"); username = string.Join("", sections); } string sqlFormattedTimeStamp = LogToUpdate.TimeStamp.ToString("yyyy-MM-dd HH:mm:ss"); PetaPoco.Sql sql = new PetaPoco.Sql(); username = string.Format("\"{0}\"", username); sql.Append("SET SQL_SAFE_UPDATES = 0; "); sql.Append(string.Format("UPDATE logcontrolleraction SET Important = {0} ", username)); string where = string.Format("WHERE TimeStamp = \"{0}\" AND WebRequestID = GuidToBinary(\"{1}\") AND ControllerName = \"{2}\" AND ActionName = \"{3}\" AND UserID = GuidToBinary(\"{4}\"); ", sqlFormattedTimeStamp, LogToUpdate.WebRequestID, LogToUpdate.ControllerName, LogToUpdate.ActionName, LogToUpdate.UserID); sql.Append(where); sql.Append("SET SQL_SAFE_UPDATES = 1; "); db.Execute(sql); return(1); } else { return(0); } } } catch (Exception ex) { string errorMessage = ex.Message; } finally { } return(0); }
public int Update(LogMySqlDataModel LogToUpdate, string username) { try { using (AsignioDatabase db = new AsignioDatabase(ConnectionStringName)) { Byte[] bytes = new Byte[16]; Guid allZeros = new Guid(bytes); Guid UserID = GetUserIDFromUsername(username); //checking if username is in User table if (UserID != allZeros) { if (username.Contains("@")) //format email { string[] sections = username.Split(new[] { '@' }); sections[1] = sections[1].Insert(0, "@@"); username = string.Join("", sections); } string sqlFormattedTimeStamp = LogToUpdate.DateTimeStamp.ToString("yyyy-MM-dd HH:mm:ss"); PetaPoco.Sql sql = new PetaPoco.Sql(); username = string.Format("\"{0}\"", username); sql.Append("SET SQL_SAFE_UPDATES = 0; "); sql.Append(string.Format("UPDATE logmysql SET Important = {0} ", username)); string where = string.Format("WHERE DateTimeStamp = \"{0}\" AND logmysql.Function = \"{1}\" AND Message = \"{2}\" AND Type = \"{3}\"; ", sqlFormattedTimeStamp, LogToUpdate.Function, LogToUpdate.Message, LogToUpdate.Type); sql.Append(where); sql.Append("SET SQL_SAFE_UPDATES = 1; "); db.Execute(sql); return(1); } else { return(0); } } } catch (Exception ex) { string errorMessage = ex.Message; } finally { } return(0); }