Beispiel #1
0
        internal static void NotifyAssetAlertLogUpdate(Guid?clientId, Altask.Data.Dto.AssetAlertLog assetAlertLog)
        {
            if (!clientId.HasValue)
            {
                _context.Clients.All.notifyAssetAlertLogUpdate(new { assetAlertLog = assetAlertLog });
            }
            else
            {
                SignalRConnection connection;

                if (_connections.TryGetValue(clientId.Value, out connection))
                {
                    _context.Clients.AllExcept(connection.ConnectionId).notifyAssetAlertLogUpdate(new { connection = connection, assetAlertLog = assetAlertLog });
                }
                else
                {
                    _context.Clients.All.notifyAssetAlertLogCreate(new { assetAlertLog = assetAlertLog });
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Maps a <see cref='Altask.Data.Model.AssetAlertLog'/> object to a <see cref='Altask.Data.Dto.AssetAlertLog'/> object.
        /// </summary>
        public static Altask.Data.Dto.AssetAlertLog ToDto(this Altask.Data.Model.AssetAlertLog entity)
        {
            var dto = new Altask.Data.Dto.AssetAlertLog();

            dto.Id           = entity.Id;
            dto.AssetAlertId = entity.AssetAlertId;
            dto.UserId       = entity.UserId;
            dto.Type         = entity.Type;
            dto.Comment      = entity.Comment;
            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;
            dto.AssetLogId = entity.AssetLogId;

            if (entity.User != null)
            {
                dto.User = entity.User.ToDto();
            }

            if (entity.AssetLog != null)
            {
                dto.AssetLog = entity.AssetLog.ToDto();
            }

            return(dto);
        }
Beispiel #3
0
        /// <summary>
        /// Maps all the non-primary key and tracking properties of a <see cref='Altask.Data.Dto.AssetAlertLog'/> object to a <see cref='Altask.Data.Model.AssetAlertLog'/> object.
        /// </summary>
        public static Altask.Data.Model.AssetAlertLog FromDto(this Altask.Data.Model.AssetAlertLog model, Altask.Data.Dto.AssetAlertLog entity)
        {
            model.AssetAlertId = entity.AssetAlertId;
            model.UserId       = entity.UserId;
            model.Type         = entity.Type;
            model.Comment      = entity.Comment;
            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) {}

            model.AssetLogId = entity.AssetLogId;
            return(model);
        }