public virtual void Interprete(ChannelData <Tinput> input) { List <Message> output = InterpreteProcess(input); if (output != null && output.Count > 0) { Envelop e = new Envelop() { OriginalMessage = input.RawData, Messages = output, Address = input.RemoteEndPoint.Address.ToString(), Port = input.RemoteEndPoint.Port, Timestamp = input.Timestamp }; if (_notifyMessageCreated != null) { try { _notifyMessageCreated(e); } catch (Exception ex) { _logWriter.Log("Invoke notifyMessageCreated action exception", ex); } } } else { _logWriter.Log("No Message created"); } }
private void buttonSelectShape_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "加载Shape文件"; ofd.Filter = "Shape文件|*.shp;*.SHP"; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { this.textBoxShapeFilePath.Text = ofd.FileName; this.textBoxShapeLayerName.Text = Path.GetFileNameWithoutExtension(ofd.FileName); Envelop imageEnvelop = m_GlobeControl.QrstGlobe.GetEnvelop(ofd.FileName, true); this.ucGeoBoundingBoxShape.SetGeoValues(imageEnvelop.West, imageEnvelop.North, imageEnvelop.East, imageEnvelop.South, 0); switch (m_GlobeControl.QrstGlobe.GetShapeFeatureType(ofd.FileName)) { case ShapeFeatureType.Point: case ShapeFeatureType.MultiPoint: this.textBoxShapeType.Text = "点状矢量"; break; case ShapeFeatureType.Line: this.textBoxShapeType.Text = "线状矢量"; break; case ShapeFeatureType.Polygon: this.textBoxShapeType.Text = "多边形矢量"; break; case ShapeFeatureType.Unspecified: this.textBoxShapeType.Text = "未知类型矢量"; break; } } }
public Task PostAsync(T message) { var envelop = new Envelop <T>(message); var messageContent = JsonConvert.SerializeObject(envelop as Envelop); var messageBody = Encoding.UTF8.GetBytes(messageContent); return(_queueClient.SendAsync(new Message(messageBody))); }
/// <summary> /// sync /// </summary> /// <param name="message"></param> public void InvokeMessageHandler(Envelop envelop) { if (_messageHandler != null) { _messageHandler(envelop); } else { _logWriter.Log("Envelop created, but there is no MessageHandler"); } }
private void ManageError(Envelop <Person> envelop) { if (envelop.RetriesCount <= 2) { envelop.RetriesCount++; Log.WriteLine($":: Inserting {envelop.Content.Name} to retry queue ::"); QueueUow.Push(RetryQueue, envelop); } else { Log.WriteLine($":: Inserting {envelop.Content.Name} to error queue ::"); QueueUow.Push(ErrorQueue, envelop); } }
private void buttonSelectGeoTiff_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "加载Geotiff文件"; ofd.Filter = "tiff(*.tif)|*.tif|tiff(*.tiff)|*.tiff"; if (ofd.ShowDialog() == DialogResult.OK) { this.textBoxGeoTiffFilePath.Text = ofd.FileName; this.textBoxGeoTiffLayerName.Text = Path.GetFileNameWithoutExtension(ofd.FileName); Envelop imageEnvelop = m_GlobeControl.QrstGlobe.GetEnvelop(ofd.FileName, false); this.ucGeoBoundingBoxGeoTiff.SetGeoValues(imageEnvelop.West, imageEnvelop.North, imageEnvelop.East, imageEnvelop.South, 0); } }
private void buttonSelectJPGOrPNG_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "加载JPG/PNG文件"; ofd.Filter = "jpg(*.jpg;*.jpeg)|*.jpg;*.jpeg|png(*.png)|*.png"; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { this.textBoxJPGOrPNGFilePath.Text = ofd.FileName; this.textBoxJPGOrPNGLayerName.Text = Path.GetFileNameWithoutExtension(ofd.FileName); Envelop imageEnvelop = m_GlobeControl.QrstGlobe.GetEnvelop(ofd.FileName, false); this.ucGeoBoundingBoxJPGOrPNG.SetGeoValues(imageEnvelop.West, imageEnvelop.North, imageEnvelop.East, imageEnvelop.South, 0); } }
public static void ShowEnvelop(Envelop envelop) { if (envelop != null) { foreach (Message message in envelop.Messages) { Console.WriteLine("---------------------------------------------------------------------"); Console.WriteLine("Receive a message"); Console.WriteLine("Name:" + message.MessageType); Console.WriteLine("Address:" + envelop.Address); Console.WriteLine("Port:" + envelop.Port); foreach (var subItem in message.DataItems) { PrintItemValue(subItem.Value); } Console.WriteLine("---------------------------------------------------------------------"); } } }
public void ProcessWay(Way way, int tagCount) { IndexStatistic.IncrementTotal(ElementType.Way); if (way.Id < 0) { IndexStatistic.Skip(way.Id, ElementType.Way); return; } var envelop = new Envelop(); way.Coordinates = new List <GeoCoordinate>(way.NodeIds.Count); foreach (var nodeId in way.NodeIds) { if (!_nodes.ContainsKey(nodeId)) { IndexStatistic.Skip(way.Id, ElementType.Way); return; } var coordinate = _nodes[nodeId]; way.Coordinates.Add(coordinate.Unscale()); envelop.Extend(coordinate.Latitude, coordinate.Longitude); } if (tagCount > 0) { uint offset = Store.Insert(way); Tree.Insert(offset, envelop); _wayOffsets.Add(way.Id, offset); IndexStatistic.Increment(ElementType.Way); } else { // keep it as it may be used by relation _ways.Add(way.Id, way); } }
public async Task <IActionResult> Create([FromBody] SignInModel model) { try { User user; var claims = new List <Claim> { new Claim(ClaimTypes.NameIdentifier, model.UserName), new Claim("name", model.UserName), //new Claim(JwtRegisteredClaimNames.Sub, model.UserName), //new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), }; var isValid = await _userService.ValidateCredentials(model.UserName, model.Password, out user); if (isValid) { var issuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(InMemoryConfig.SecretKey)); //https://stackoverflow.com/questions/49875167/jwt-error-idx10634-unable-to-create-the-signatureprovider-c-sharp var creds = new SigningCredentials(issuerSigningKey, SecurityAlgorithms.HmacSha256Signature); var token = new JwtSecurityToken(InMemoryConfig.Issuer, InMemoryConfig.Audience, claims, expires: DateTime.UtcNow.AddMinutes(5), signingCredentials: creds); var tokenValue = new JwtSecurityTokenHandler().WriteToken(token); return(Ok(Envelop.Ok(tokenValue))); } return(BadRequest(Envelop.Error("User name or password is incorrect!"))); } catch (Exception e) { Console.WriteLine(e); return(BadRequest(e.Message)); } }
/// <summary> /// Reads pbf file using <see cref="ReaderContext"/>. /// </summary> public void Read(ReaderContext context) { _context = context; _envelop = new Envelop(); while (MoveNext()) { var block = Current; ProcessPrimitiveBlock(block); foreach (var primitiveGroup in block.primitivegroup) { if (!primitiveGroup.IsNodeListEmpty) { foreach (var node in primitiveGroup.nodes) { ProcessNode(block, node); } } if (!primitiveGroup.IsWayListEmpty) { foreach (var way in primitiveGroup.ways) { ProcessWay(block, way); } } if (!primitiveGroup.IsRelationListEmpty) { foreach (var relation in primitiveGroup.relations) { ProcessRelation(block, relation); } } } } _context.Builder.ProcessBoundingBox(new BoundingBox(_envelop.MinPoint, _envelop.MaxPoint)); }
public static string ToJson(this Envelop envelop) { return(JsonConvert.SerializeObject(envelop)); }
protected new IActionResult Ok() { return(base.Ok(Envelop.Ok())); }
protected IActionResult Error(string errorMessage) { return(BadRequest(Envelop.Error(errorMessage))); }
protected IActionResult Ok <T>(T result) { return(base.Ok(Envelop.Ok(result))); }
public void Push(Person person) { Envelop <Person> envelop = new Envelop <Person>(person); QueueUow.Push(QueueName, envelop); }
public void ProcessRelation(Relation relation, int tagCount) { IndexStatistic.IncrementTotal(ElementType.Relation); if (relation.Id < 0) { IndexStatistic.Skip(relation.Id, ElementType.Relation); return; } var envelop = new Envelop(); // this cicle prevents us to insert ways which are part of unresolved relation foreach (var member in relation.Members) { var type = (ElementType)member.TypeId; if (type == ElementType.Node || type == ElementType.Relation || // TODO not supported yet (!_wayOffsets.ContainsKey(member.MemberId) && !_ways.ContainsKey(member.MemberId))) { // outline relations should be ignored if (type == ElementType.Relation && member.Role == "outline") { _skippedRelations.Add(member.MemberId); } _skippedRelations.Add(relation.Id); IndexStatistic.Skip(relation.Id, ElementType.Relation); return; } } foreach (var member in relation.Members) { var type = (ElementType)member.TypeId; uint memberOffset = 0; switch (type) { case ElementType.Way: Way way = null; if (_wayOffsets.ContainsKey(member.MemberId)) { memberOffset = _wayOffsets[member.MemberId]; way = Store.Get(memberOffset) as Way; } else if (_ways.ContainsKey(member.MemberId)) { way = _ways[member.MemberId]; memberOffset = Store.Insert(way); _wayOffsets.Add(member.MemberId, memberOffset); } foreach (GeoCoordinate t in way.Coordinates) { envelop.Extend(new PointEnvelop(t)); } break; default: throw new InvalidOperationException("Unknown element type!"); } // TODO merge tags? member.Offset = memberOffset; } _relations.Add(new MutableTuple <Relation, Envelop>(relation, envelop)); }