public IHttpActionResult TypedSearch(string query) { var result = _client.Search <ArticlePage>() .For(query) .GetContentResult(); var trackId = new TrackContext().Id; TrackQuery(query, result.TotalMatching, trackId); return(Json(result.Items.Select((x, i) => new { Title = x.PageName, Url = GetTrackingUrl(x, query, trackId, i) }))); }
/// <summary> /// Возвращает соловарь сегментов треков по датаи /// </summary> /// <param name="segments">Отфильтрованные сегменты трека</param> /// <returns>Словарь сегментов треков по датам</returns> /// <exception cref="Exception">A delegate callback throws an exception.</exception> public static TrackContext ToSegmentsDictionary(this IEnumerable <List <IRoutePoint> > segments) { if (segments == null) { throw new ArgumentNullException(nameof(segments)); } var result = new TrackContext(); var enumerable = segments as List <IRoutePoint>[] ?? segments.ToArray(); var dates = enumerable.ToDateList(); //Для каждой даты в полученных данных foreach (var dateTime in dates) { //новый трек var time1 = dateTime; var segmetpoint = (from segment in enumerable let time = time1 select segment.Where(trackPoint => CheckPointInDate(time, trackPoint)).ToList()).ToList(); //для каждого сегмента треков result.Add(dateTime, segmetpoint); } return(result); }
public Repository(TrackContext context) { Context = context; }
public Repository() { //Database.SetInitializer<EBRPContext>(new DropCreateDatabaseIfModelChanges<EBRPContext>()); Context = new TrackContext(); }
public TrackController(TrackContext context) { _context = context; }
protected override void Subscriber_Received(object sender, BasicDeliverEventArgs bdeArgs, IModel channel) { if (this.Process == null) { this._logger.LogWarning($"MessageWorker<{typeof(TInputMessage).FullName}> do not define Process() delegate. Bypass process message."); return; } if (bdeArgs == null) { this._logger.LogWarning($"Bypass message because BasicDeliverEventArgs is null."); return; } Interlocked.Increment(ref this._subscriber_received_count); var props = bdeArgs.BasicProperties; using (this._logger.BeginScope(new Dictionary <string, object> { [nameof(props.CorrelationId)] = props.CorrelationId })) { var processOk = false; var message = string.Empty; TInputMessage input = null; try { message = Encoding.UTF8.GetString(bdeArgs.Body); try { input = JsonConvert.DeserializeObject <TInputMessage>(message); this._logger.LogInformation("ProcessMsg {@Input}", input); } catch { throw new Exception($"Deserialize to {typeof(TInputMessage).FullName} failed: " + message); } if (this._services == null) { this.Process(input, props.CorrelationId, null); } else { using (var scope = this._services.CreateScope()) { TrackContext.TryToContext(scope.ServiceProvider, this.GetHeaders(props)); this.Process(input, props.CorrelationId, scope); } } processOk = true; this._logger.LogInformation("ProcessMsgOk"); } catch (Exception ex) { this._logger.LogError(ex, "ProcessMsgError"); } try { channel.BasicAck( deliveryTag: bdeArgs.DeliveryTag, multiple: false); this._logger.LogInformation("AckMsgOk"); if (!processOk) { if (_messageKeeper != null) { _messageKeeper.Save(new MessageState { Meta = new MessageMeta { RoutingKey = bdeArgs.RoutingKey, CorrelationId = props.CorrelationId }, Message = input ?? (object)message }); } this._logger.LogInformation("MsgDead"); } } catch (Exception ex) { this._logger.LogError(ex, "AckMsgError"); } } Interlocked.Decrement(ref this._subscriber_received_count); this._subscriber_received_wait.Set(); }
public IHttpActionResult TypedSearch(string query) { var result = _client.Search<ArticlePage>() .For(query) .GetContentResult(); var trackId = new TrackContext().Id; TrackQuery(query, result.TotalMatching, trackId); return Json(result.Items.Select((x, i) => new { Title = x.PageName, Url = GetTrackingUrl(x, query, trackId, i) })); }
protected virtual string PublishMessage( string routing, byte[] messageBody, string correlationId = null, Dictionary <string, string> messageHeaders = null) { if (string.IsNullOrWhiteSpace(correlationId)) { correlationId = Guid.NewGuid().ToString("N"); } if (this._options.BusType == MessageClientOptions.MessageBusTypeEnum.QUEUE) { channel.QueueDeclare( //queue: routing, queue: this._options.QueueName, durable: this._options.QueueDurable, exclusive: false, autoDelete: false, arguments: null); } else if (this._options.BusType == MessageClientOptions.MessageBusTypeEnum.EXCHANGE) { channel.ExchangeDeclare( this._options.ExchangeName, this._options.ExchangeType, true, false, null); } else { throw new InvalidOperationException(); } var trackHeaders = new Dictionary <string, string>(); if (TrackContext.TryToHeaders(this._services, trackHeaders)) { } IBasicProperties props = null;//this.PrepareMessageProperties(correlationId, messageHeaders); { props = channel.CreateBasicProperties(); props.ContentType = "application/json"; if (this._options.MessageExpirationTimeout != null) { props.Expiration = this._options.MessageExpirationTimeout.Value.TotalMilliseconds.ToString(); } props.Headers = new Dictionary <string, object>(); if (messageHeaders != null) { foreach (string key in messageHeaders.Keys) { props.Headers[key] = Encoding.UTF8.GetBytes(messageHeaders[key] ?? ""); } } if (trackHeaders != null) { foreach (string key in trackHeaders.Keys) { props.Headers[key] = Encoding.UTF8.GetBytes(trackHeaders[key] ?? ""); } } //if (this._services != null) //{ // var track = this._services.GetService<TrackContext>(); // if (track != null) // { // props.Headers["x-shop-id"] = track.ShopId.ToString(); // props.Headers["x-member-id"] = track.MemberId; // props.Headers["x-session-id"] = track.SessionId; // props.Headers["x-channel-id"] = track.ChannelId; // props.Headers["x-request-id"] = track.RequestId; // } //} props.CorrelationId = correlationId; //Guid.NewGuid().ToString("N"); this.SetupMessageProperties(props); } if (this._options.BusType == MessageClientOptions.MessageBusTypeEnum.EXCHANGE) { channel.BasicPublish( exchange: this._options.ExchangeName ?? "", routingKey: routing, basicProperties: props, body: messageBody); //Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message))); } else if (this._options.BusType == MessageClientOptions.MessageBusTypeEnum.QUEUE) { channel.BasicPublish( exchange: "", routingKey: this._options.QueueName, basicProperties: props, body: messageBody); //Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message))); } return(correlationId); }
public BaseRepository(ITrackContext context) { _context = (TrackContext)context; }
public MeasurementsController(TrackContext context) { _context = context; _context.Database.EnsureCreated(); }
public TrackRepository(TrackContext context) : base(context) { }