/// <summary> /// Maps a <see cref='Altask.Data.Model.UserLog'/> object to a <see cref='Altask.Data.Dto.UserLog'/> object. /// </summary> /// <param name="includeLogs">Indicates whether to load any logs associated with the object when mapping.</param> public static Altask.Data.Dto.UserLog ToDto(this Altask.Data.Model.UserLog entity, bool includeLogs = false) { var dto = new Altask.Data.Dto.UserLog(); dto.Id = entity.Id; dto.UserId = entity.UserId; dto.Type = entity.Type; dto.Description = entity.Description; dto.Metadata = JsonConvert.DeserializeObject("{Properties: []}"); if (!string.IsNullOrEmpty(entity.Metadata)) { try { XmlDocument doc = new XmlDocument(); doc.LoadXml(entity.Metadata); string json = Json.SerizlieXmlDocument(doc); dto.Metadata = JsonConvert.DeserializeObject(json); } catch (Exception) {} } dto.CreatedBy = entity.CreatedBy; dto.CreatedOn = entity.CreatedOn; dto.UpdatedBy = entity.UpdatedBy; dto.UpdatedOn = entity.UpdatedOn; if (entity.User != null) { dto.User = entity.User.ToDto(); } return(dto); }
internal static void NotifyUserLogUpdate(Guid?clientId, Altask.Data.Dto.UserLog userLog) { if (!clientId.HasValue) { _context.Clients.All.notifyUserLogUpdate(new { userLog = userLog }); } else { SignalRConnection connection; if (_connections.TryGetValue(clientId.Value, out connection)) { _context.Clients.AllExcept(connection.ConnectionId).notifyUserLogUpdate(new { connection = connection, userLog = userLog }); } else { _context.Clients.All.notifyUserLogCreate(new { userLog = userLog }); } } }
/// <summary> /// Maps all the non-primary key and tracking properties of a <see cref='Altask.Data.Dto.UserLog'/> object to a <see cref='Altask.Data.Model.UserLog'/> object. /// </summary> public static Altask.Data.Model.UserLog FromDto(this Altask.Data.Model.UserLog model, Altask.Data.Dto.UserLog entity) { model.UserId = entity.UserId; model.Type = entity.Type; model.Description = entity.Description; model.Metadata = string.Empty; try { model.Metadata = ((XmlDocument)JsonConvert.DeserializeXmlNode(entity.Metadata.ToString(), "Properties")).OuterXml; } catch (Exception) {} return(model); }