Exemple #1
0
 public static IQueryable <DeviceConfig> Project(
     this IQueryable <DeviceConfig> query, DeviceConfigQueryProjection projection)
 {
     foreach (var f in projection.GetFieldsArr())
     {
         if (DeviceConfigQueryProjection.MAPS.ContainsKey(f))
         {
             foreach (var prop in DeviceConfigQueryProjection.MAPS[f])
             {
                 query = query.Include(prop);
             }
         }
     }
     return(query);
 }
Exemple #2
0
        public IDictionary <string, object> GetDeviceConfigDynamic(
            DeviceConfig row, DeviceConfigQueryProjection projection,
            DeviceConfigQueryOptions options)
        {
            var obj = new Dictionary <string, object>();

            foreach (var f in projection.GetFieldsArr())
            {
                switch (f)
                {
                case DeviceConfigQueryProjection.INFO:
                {
                    var entity = row;
                    obj["id"]             = entity.Id;
                    obj["identifier"]     = entity.Identifier;
                    obj["is_current"]     = entity.IsCurrent;
                    obj["kafka_server"]   = entity.KafkaServer;
                    obj["kafka_username"] = entity.KafkaUsername;
                    obj["remove_old_events_job_settings"]  = entity.RemoveOldEventsJobSettings;
                    obj["send_unsent_events_job_settings"] = entity.SendUnsentEventsJobSettings;
                    var time = entity.CreatedTime
                               .ToDefaultTimeZone();
                    var timeStr = time.ToString(options.date_format);
                    obj["created_time"] = new
                    {
                        display = timeStr,
                        iso     = $"{time.ToUniversalTime():s}Z"
                    };
                    time = entity.LastUpdated
                           .ToDefaultTimeZone();
                    timeStr             = time.ToString(options.date_format);
                    obj["last_updated"] = new
                    {
                        display = timeStr,
                        iso     = $"{time.ToUniversalTime():s}Z"
                    };
                    if (entity.NextROEJobStart != null)
                    {
                        time = entity.NextROEJobStart.Value
                               .ToDefaultTimeZone();
                        timeStr = time.ToString(options.date_format);
                        obj["next_roe_job_start"] = new
                        {
                            display = timeStr,
                            iso     = $"{time.ToUniversalTime():s}Z"
                        };
                    }
                    if (entity.NextSUEJobStart != null)
                    {
                        time = entity.NextSUEJobStart.Value
                               .ToDefaultTimeZone();
                        timeStr = time.ToString(options.date_format);
                        obj["next_sue_job_start"] = new
                        {
                            display = timeStr,
                            iso     = $"{time.ToUniversalTime():s}Z"
                        };
                    }
                }
                break;
                }
            }
            return(obj);
        }