/// <summary> /// Writes the log, truncates the strings to the maximum allowed length. /// </summary> /// <param name="operation">The operation.</param> /// <param name="userName">Name of the user.</param> /// <param name="key">The key.</param> /// <param name="type">The type.</param> /// <param name="source">The source.</param> /// <param name="notes">The notes.</param> /// <param name="succeeded">if set to <c>true</c> [succeeded].</param> public static void WriteLog(string operation, string userName, string key, string type, string source, string notes, bool succeeded) { LogAdmin admin = new LogAdmin(new LogDto()); LogDto dto = admin.CurrentDto; LogDto.ApplicationLogRow row = dto.ApplicationLog.NewApplicationLogRow(); row.ApplicationId = AppContext.Current.ApplicationId; row.Created = DateTime.UtcNow; row.Notes = (notes.Length > 255) ? notes.Substring(0, 255) : notes; row.ObjectKey = (key.Length > 100) ? key.Substring(0, 100) : key; row.Source = (source.Length > 100) ? source.Substring(0, 100) : source; row.ObjectType = (type.Length > 50) ? type.Substring(0, 50) : type; row.Operation = (operation.Length > 50) ? operation.Substring(0, 50) : operation; row.Succeeded = succeeded; row.Username = (userName.Length > 50) ? userName.Substring(0, 50) : userName; row.IPAddress = GetIPAddress(); dto.ApplicationLog.AddApplicationLogRow(row); admin.Save(); }
/// <summary> /// Records the specified address. /// </summary> /// <param name="address">The address.</param> private void Record(CustomerAddress address) { LogAdmin admin = new LogAdmin(new LogDto()); LogDto dto = admin.CurrentDto; LogDto.ApplicationLogRow row = dto.ApplicationLog.NewApplicationLogRow(); row.ApplicationId = AppContext.Current.ApplicationId; row.Created = DateTime.UtcNow; row.Notes = String.Empty; row.ObjectKey = address.PrincipalId.ToString(); row.ObjectType = "address"; string operation = String.Empty; if (address.ObjectState == MetaObjectState.Added) { operation = DataRowState.Added.ToString(); } else if (address.ObjectState == MetaObjectState.Deleted) { operation = DataRowState.Deleted.ToString(); } else if (address.ObjectState == MetaObjectState.Modified) { operation = DataRowState.Modified.ToString(); } else if (address.ObjectState == MetaObjectState.Unchanged) { operation = DataRowState.Unchanged.ToString(); } row.Operation = operation; row.Succeeded = true; row.Source = "profile"; row.Username = GetUsername(); row.IPAddress = GetIPAddress(); dto.ApplicationLog.AddApplicationLogRow(row); admin.Save(); }
/// <summary> /// Records the specified entry. /// </summary> /// <param name="entry">The entry.</param> /// <param name="action">The action.</param> private void Record(CatalogEntryDto.CatalogEntryRow entry, DataRowAction action) { if ( action == DataRowAction.Commit || action == DataRowAction.Delete || action == DataRowAction.Change ) { if (entry.RowState == DataRowState.Added || entry.RowState == DataRowState.Deleted || entry.RowState == DataRowState.Modified ) { LogDto dto = _admin.CurrentDto; LogDto.ApplicationLogRow row = dto.ApplicationLog.NewApplicationLogRow(); row.ApplicationId = CatalogConfiguration.Instance.ApplicationId; row.Created = DateTime.UtcNow; row.Notes = String.Empty; if (entry.RowState == DataRowState.Deleted) { row.ObjectKey = entry["CatalogEntryId", DataRowVersion.Original].ToString(); } else { row.ObjectKey = entry.CatalogEntryId.ToString(); } row.Source = "catalog"; row.ObjectType = "entry"; row.Operation = entry.RowState.ToString(); row.Succeeded = true; row.Username = GetUsername(); row.IPAddress = GetIPAddress(); dto.ApplicationLog.AddApplicationLogRow(row); } } }