/// <summary> /// Maps a <see cref='Altask.Data.Model.TaskAlertLog'/> object to a <see cref='Altask.Data.Dto.TaskAlertLog'/> object. /// </summary> /// <param name="includeLogs">Indicates whether to load any logs associated with the object when mapping.</param> public static Altask.Data.Dto.TaskAlertLog ToDto(this Altask.Data.Model.TaskAlertLog entity, bool includeLogs = false) { var dto = new Altask.Data.Dto.TaskAlertLog(); dto.Id = entity.Id; dto.TaskAlertId = entity.TaskAlertId; dto.UserId = entity.UserId; dto.Type = entity.Type; dto.Description = entity.Description; dto.AlertDate = entity.AlertDate; 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 NotifyTaskAlertLogUpdate(Guid?clientId, Altask.Data.Dto.TaskAlertLog taskAlertLog) { if (!clientId.HasValue) { _context.Clients.All.notifyTaskAlertLogUpdate(new { taskAlertLog = taskAlertLog }); } else { SignalRConnection connection; if (_connections.TryGetValue(clientId.Value, out connection)) { _context.Clients.AllExcept(connection.ConnectionId).notifyTaskAlertLogUpdate(new { connection = connection, taskAlertLog = taskAlertLog }); } else { _context.Clients.All.notifyTaskAlertLogCreate(new { taskAlertLog = taskAlertLog }); } } }
/// <summary> /// Maps all the non-primary key and tracking properties of a <see cref='Altask.Data.Dto.TaskAlertLog'/> object to a <see cref='Altask.Data.Model.TaskAlertLog'/> object. /// </summary> public static Altask.Data.Model.TaskAlertLog FromDto(this Altask.Data.Model.TaskAlertLog model, Altask.Data.Dto.TaskAlertLog entity) { model.TaskAlertId = entity.TaskAlertId; model.UserId = entity.UserId; model.Type = entity.Type; model.Description = entity.Description; model.AlertDate = entity.AlertDate; model.Metadata = string.Empty; try { model.Metadata = ((XmlDocument)JsonConvert.DeserializeXmlNode(entity.Metadata.ToString(), "Properties")).OuterXml; } catch (Exception) {} return(model); }