internal static void NotifyTaskUpdate(Guid?clientId, Altask.Data.Dto.Task task) { if (!clientId.HasValue) { _context.Clients.All.notifyTaskUpdate(new { task = task }); } else { SignalRConnection connection; if (_connections.TryGetValue(clientId.Value, out connection)) { _context.Clients.AllExcept(connection.ConnectionId).notifyTaskUpdate(new { connection = connection, task = task }); } else { _context.Clients.All.notifyTaskCreate(new { task = task }); } } }
/// <summary> /// Maps all the non-primary key and tracking properties of a <see cref='Altask.Data.Dto.Task'/> object to a <see cref='Altask.Data.Model.Task'/> object. /// </summary> public static Altask.Data.Model.Task FromDto(this Altask.Data.Model.Task model, Altask.Data.Dto.Task entity) { model.Active = entity.Active; model.TaskTypeId = entity.TaskTypeId; model.TaskCategoryId = entity.TaskCategoryId; model.FormId = entity.FormId; model.Name = entity.Name; model.Description = entity.Description; model.IdleTimeout = entity.IdleTimeout; model.Metadata = string.Empty; try { model.Metadata = ((XmlDocument)JsonConvert.DeserializeXmlNode(entity.Metadata.ToString(), "Properties")).OuterXml; } catch (Exception) {} return(model); }
/// <summary> /// Maps a <see cref='Altask.Data.Model.Task'/> object to a <see cref='Altask.Data.Dto.Task'/> object. /// </summary> /// <param name="includeLogs">Indicates whether to load any logs associated with the object when mapping.</param> public static Altask.Data.Dto.Task ToDto(this Altask.Data.Model.Task entity, bool includeLogs = false) { var dto = new Altask.Data.Dto.Task(); dto.Id = entity.Id; dto.Active = entity.Active; dto.TaskTypeId = entity.TaskTypeId; dto.TaskCategoryId = entity.TaskCategoryId; dto.FormId = entity.FormId; dto.Name = entity.Name; dto.Description = entity.Description; dto.IdleTimeout = entity.IdleTimeout; 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.Form != null) { dto.Form = entity.Form.ToDto(); } dto.Schedules = new List <Altask.Data.Dto.Schedule>(); if (entity.Schedules != null) { foreach (var item in entity.Schedules) { dto.Schedules.Add(item.ToDto()); } } if (entity.Category != null) { dto.Category = entity.Category.ToDto(); } if (entity.Type != null) { dto.Type = entity.Type.ToDto(); } dto.Alerts = new List <Altask.Data.Dto.TaskAlert>(); if (entity.Alerts != null) { foreach (var item in entity.Alerts) { dto.Alerts.Add(item.ToDto()); } } return(dto); }