public async Task HandleLocationEventAsync(GameEventData data) { const int GeoHashBitPrecision = 32; //bits const int LocationLookupGeoHashBitPrecistion = 30; //bits var inEvent = JsonConvert.DeserializeObject <IncommingLocationEvent>(data.Data); var geoHash = GeoHash.EncodeInt(inEvent.Lat, inEvent.Lon, GeoHashBitPrecision); var geoHashCenterCoordinates = GeoHash.DecodeInt(geoHash, GeoHashBitPrecision).Coordinates; var locationLookupGeoHash = GeoHash.EncodeInt(inEvent.Lat, inEvent.Lon, LocationLookupGeoHashBitPrecistion); var l = new LocationEventHandler(_locationLookupProvider); var location = l.LookupGeoHash(locationLookupGeoHash, LocationLookupGeoHashBitPrecistion); var outEvent = new OutgoingLocationEvent { EnqueueTime = data.EnqueuedTime, DequeueTime = data.DequeuedTime, ClientUtcTime = inEvent.ClientUtcTime, GameSessionId = inEvent.GameSessionId, Lat = inEvent.Lat, Lon = inEvent.Lon, GeoHash = geoHash, GeoHashPrecision = GeoHashBitPrecision, GeoHashCenterLat = geoHashCenterCoordinates.Lat, GeoHashCenterLon = geoHashCenterCoordinates.Lon, Country = location.Country, District = location.District, City = location.City, Properties = inEvent.Properties }; //TODO: Optimize this so we don't serialize back to JSON first and then to CSV var jsonObject = JsonConvert.SerializeObject( outEvent, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); data.Data = jsonObject; var csvObject = data.ToCsv("gameSessionId", "lat", "lon", "geoHash", "geoHashPrecision", "geoHashCenterLat", "geoHashCenterLon", "country", "district", "city"); // Output CSV to BLOB Storage and JSON to StreamAnalytics (via EventHub) await _blobOutputManager.QueueAppendToBlobAsync(data, csvObject); await _eventHubOutputManager.SendToEventHubAsync(data, jsonObject); }
/// <summary> /// 当子窗体坐标改变时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ChildForm_LocationChanged(object sender, EventArgs e) { if (!this.isFirstPos) { this.isFirstPos = true; return; } //委托 LocationEventHandler locationEventHandler = new LocationEventHandler(OnMove); //调用 MainForm.BeginInvoke(locationEventHandler); }
/// <summary> /// Raises the <see cref="ColumnChanged" /> event. /// </summary> /// <param name="column">The <see cref="LocationColumn"/> which has raised the event.</param> /// <param name="value">The changed value.</param> public virtual void OnColumnChanged(LocationColumn column, object value) { if (!SuppressEntityEvents) { LocationEventHandler handler = ColumnChanged; if (handler != null) { handler(this, new LocationEventArgs(column, value)); } // warn the parent list that i have changed OnEntityChanged(); } }
public static void UnsubscribeFromLocationEvent(LocationEventHandler handler) { if (AllLocations == null) { FindAllLocations(); } if (AllLocations != null) { for (int i = 0; i < AllLocations.Length; i++) { AllLocations[i].UnsubscribeFromLocationEvent(handler); } } }
/// <summary> /// Raises the <see cref="ColumnChanging" /> event. /// </summary> /// <param name="column">The <see cref="LocationColumn"/> which has raised the event.</param> /// <param name="value">The changed value.</param> public virtual void OnColumnChanging(LocationColumn column, object value) { if (IsEntityTracked && EntityState != EntityState.Added && !EntityManager.TrackChangedEntities) { EntityManager.StopTracking(entityTrackingKey); } if (!SuppressEntityEvents) { LocationEventHandler handler = ColumnChanging; if (handler != null) { handler(this, new LocationEventArgs(column, value)); } } }
/// <summary> /// 解析事件并执行相应逻辑 /// </summary> /// <param name="msgStr">微信post过来的事件数据,xml格式</param> /// <returns>回复给用户的消息,将使用客服接口进行回复</returns> /// <exception cref="NotSupportedException"></exception> public static string ParseEvent(string msgStr) { var eventBase = Xml.Net.XmlConvert.DeserializeObject <EventMessageBase>(msgStr); IWxMsgHandler handler; switch (eventBase.Event.ToLower()) { case "subscribe": // 关注事件 // 分扫码关注和普通关注 handler = new SubscribeEventHandler( ); break; case "unsubscribe": // 取关事件 handler = new UnsubscribeEventHandler( ); break; case "scan": // 已关注用户扫描带参数二维码事件 handler = new ScanWithSubscribeEventHandler( ); break; case "location": // 上报地理位置事件 handler = new LocationEventHandler( ); break; case "click": // 自定义菜单click事件 handler = new ClickEventHandler( ); break; case "view": // 自定义菜单view事件 handler = new ViewEventHandler( ); break; default: // todo: 实现更多事件处理,比如自定义菜单的事件 throw new System.NotSupportedException("不支持的事件类型: " + eventBase.Event); } return(handler.Handle(msgStr)); }
public void UnsubscribeFromLocationEvent(LocationEventHandler handler) { LocationEvent -= handler; }
public void SubscribeToLocationEvent(LocationEventHandler handler) { LocationEvent += handler; }