예제 #1
0
        /// <summary>
        /// Create a job event (metrics)
        /// </summary>
        /// <returns></returns>
        public async System.Threading.Tasks.Task <Event> GetLogEvent(WpsJob job, string message = null)
        {
            try
            {
                var durations = new Dictionary <string, int>();
                durations.Add("from_start", ((int)(DateTime.UtcNow - job.CreatedTime).TotalSeconds));
                if (job.EndTime != DateTime.MinValue)
                {
                    durations.Add("from_end", ((int)(DateTime.UtcNow - job.EndTime).TotalSeconds));
                }

                var properties = GetJobBasicProperties(job);
                var stacItems  = job.GetJobInputsStacItems();
                properties.Add("stac_items", stacItems);

                var logevent = new Event
                {
                    EventId     = GetEventIdForWpsJob(job.Status),
                    Project     = EventFactory.EventLogConfig.Settings["project"].Value,
                    Status      = job.StringStatus,
                    Durations   = durations,
                    Transmitter = EventFactory.EventLogConfig.Settings["transmitter"].Value,
                    Message     = message,
                    Item        = new EventItem
                    {
                        Created    = job.CreatedTime,
                        Updated    = job.EndTime != DateTime.MinValue ? job.EndTime : job.CreatedTime,
                        Id         = job.Identifier,
                        Title      = job.Name,
                        Type       = "portal_job",
                        Properties = properties
                    }
                };

                return(logevent);
            }catch (Exception e) {
                context.LogError(job, "Log event error: " + e.Message);
            }
            return(null);
        }