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(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); }
internal static LogMySqlPoco ToPoco(this LogMySqlDataModel source) { if (null != source) { return(new LogMySqlPoco { DateTimeStamp = source.DateTimeStamp, Message = source.Message, Function = source.Function, Type = source.Type, Important = source.Important, }); } return(null); }