public MessageOutput SendEmail(MessageInput messageInput) { var client = new NotificationServiceClient(); client.OpenAsync(); var obj = new SendEmailRequest() { ServiceToken = new ServiceToken { Token = _Token }, Message = new Email() { Destination = messageInput.Destination, EmailMessage = messageInput.Message } }; var reply = client.EmailAsync(obj.ServiceToken, obj.Message).Result; client.CloseAsync(); return(_NotificationMapping.MapNotificationOutput(reply)); }
public override IEnumerable <Location> ParseRange(MessageInput input) { if (input.Client.Device == null) { if (input.DataMessage.Bytes.Length > 16) { string imei = Encoding.ASCII.GetString(input.DataMessage.Bytes[2..17]);
public async Task TestMarkRead() { var user1 = new User() { ID = Guid.NewGuid().ToString(), Role = Role.Admin, }; await this._client.Users.Update(user1); var channel = _client.Channel("messaging", Guid.NewGuid().ToString()); await channel.Create(user1.ID); var readEvent = await channel.MarkRead(user1.ID); Assert.NotNull(readEvent); Assert.AreEqual(EventType.MessageRead, readEvent.Type); Assert.AreEqual(user1.ID, readEvent.User.ID); var inMsg = new MessageInput() { Text = Guid.NewGuid().ToString() }; var msg1 = await channel.SendMessage(inMsg, user1.ID); readEvent = await channel.MarkRead(user1.ID, msg1.ID); Assert.NotNull(readEvent); Assert.AreEqual(EventType.MessageRead, readEvent.Type); Assert.AreEqual(user1.ID, readEvent.User.ID); }
public void Message() { TokenOptions tokenOptions = new TokenOptions() { IamApiKey = apikey, ServiceUrl = url }; AssistantService service = new AssistantService(tokenOptions, versionDate); MessageInput input = new MessageInput() { MessageType = MessageInput.MessageTypeEnumValue.TEXT, Text = inputString, Options = new MessageInputOptions() { ReturnContext = true, AlternateIntents = true } }; var result = service.Message( assistantId: assistantId, sessionId: sessionId, input: input ); Console.WriteLine(result.Response); }
private static Location Position(MessageInput input, long id) { short checksum = input.DataMessage.ByteReader.Get <short>(); short preamble = input.DataMessage.ByteReader.Get <short>(); short type = input.DataMessage.ByteReader.Get <short>(); int length = input.DataMessage.ByteReader.Get <short>(); input.Client.SetDevice($"{id}"); Location location = new Location { Device = input.Client.Device }; location.DateTime = DateTime.UnixEpoch.AddSeconds(input.DataMessage.ByteReader.Get <int>()); location.Latitude = input.DataMessage.ByteReader.Get <int>() * 0.000001m; location.Longitude = input.DataMessage.ByteReader.Get <int>() * 0.000001m; location.Speed = input.DataMessage.ByteReader.Get <short>() * 0.01m; location.Altitude = input.DataMessage.ByteReader.Get <short>(); location.Heading = input.DataMessage.ByteReader.Get <short>(); location.PositionStatus = input.DataMessage.ByteReader.GetOne() > 0; location.Satellites = input.DataMessage.ByteReader.GetOne(); byte @event = input.DataMessage.ByteReader.GetOne(); input.DataMessage.ByteReader.GetOne(); input.DataMessage.ByteReader.Skip(length); return(location); }
public async Task TestSendSilentMessage() { var user1 = new User() { ID = Guid.NewGuid().ToString(), Role = Role.Admin, }; await this._client.Users.Upsert(user1); var channel = this._client.Channel("messaging", Guid.NewGuid().ToString()); await channel.Create(user1.ID, new string[] { user1.ID }); var inMsg = new MessageInput() { Text = Guid.NewGuid().ToString(), Silent = true }; inMsg.SetData("foo", "barsky"); var outMsg = await channel.SendMessage(inMsg, user1.ID); Assert.IsNull(outMsg.DeletedAt); Assert.AreEqual(outMsg.Silent, inMsg.Silent); }
public async Task <string> SendMessageAsync(string topic, string encryptionKey, EncryptionType encryptionType, string payload) { var messageInput = new MessageInput() { Topic = topic.EnsureHexPrefix(), Payload = payload, //TODO: Find a way to calculate it PowTime = 12, PowTarget = 0.4, Ttl = 300, }; switch (encryptionType) { case EncryptionType.Asymmetric: messageInput.PubKey = encryptionKey; break; case EncryptionType.Symmetric: messageInput.SymKeyID = encryptionKey; break; default: throw new ArgumentException( $"Current Encryption type {encryptionType} is not supported.", nameof(encryptionType)); } var messageHash = await _web3.Shh.Post.SendRequestAsync(messageInput); return(messageHash); }
public override Location Parse(MessageInput input) { int?index = GetHDOPIndex(input.DataMessage.CommaSplit); if (index.HasValue) { Location location = new Location { Device = new Device { IMEI = input.DataMessage.CommaSplit.Get <string>(2) }, HDOP = input.DataMessage.CommaSplit.Get <double>(index.Value), Speed = input.DataMessage.CommaSplit.Get <double>(index.Value + 1), Heading = input.DataMessage.CommaSplit.Get <float?>(index.Value + 2), Altitude = input.DataMessage.CommaSplit.Get <double?>(index.Value + 3), Longitude = input.DataMessage.CommaSplit.Get <decimal>(index.Value + 4), Latitude = input.DataMessage.CommaSplit.Get <decimal>(index.Value + 5), DateTime = ConvertDate(input.DataMessage.CommaSplit.Get <string>(index.Value + 6)) }; location.PositionStatus = location.HDOP > 0; return(location); } return(null); }
private static Location ParseLocation(MessageInput input) { GroupCollection lgc = new Regex( @"(\d{2})(\d{2})(\d{2})(A|V)(\d{4}.\d{4})(N|S)(\d{5}.\d{4})(E|W)(.{5})(\d{2})(\d{2})(\d{2})(.{6})(1|0{8})L(.{0,8})(...)") .Matches(input.DataMessage.String)[0].Groups; if (lgc.Count == 17) { Location location = new Location { Device = input.Client.Device, DateTime = DateTimeUtil.New(lgc[1].Value, lgc[2].Value, lgc[3].Value, lgc[10].Value, lgc[11].Value, lgc[12].Value), PositionStatus = lgc[4].Value == "F", Latitude = GpsUtil.ConvertDmmLatToDecimal(lgc[5].Value, lgc[6].Value), Longitude = GpsUtil.ConvertDmmLongToDecimal(lgc[7].Value, lgc[8].Value), Speed = decimal.Parse(lgc[9].Value), Heading = decimal.Parse(lgc[13].Value), Odometer = long.Parse(lgc[15].Value, NumberStyles.HexNumber) }; return(location); } return(null); }
public override Location Parse(MessageInput input) { Match locationMatch = new Regex("\\$SLU" + "(.*?)," + // device id "(\\d+)," + // type "(\\d+)," + //index "(.*?)" + // data "\\*(..)") // checksum .Match(input.DataMessage.String); if (locationMatch.Success) { Location location = new Location { Device = new Device { DeviceId = locationMatch.Groups[1].Value } }; SetData(locationMatch.Groups[4].Value, location); return(location); } return(null); }
public void FillFeedbackForm(FeedbackFormModel model) { EmailInput.SendKeysWithWait(model.Email); NameInput.SendKeysWithWait(model.Name); SubjectInput.SendKeysWithWait(model.Subject); MessageInput.SendKeysWithWait(model.Message); }
public override IEnumerable <Location> ParseRange(MessageInput input) { IEnumerable <Location> locations = ParseRange(input, HandleKeepAlive, HandleTextMessage, HandleBinaryMessage); return(locations); }
public override Location Parse(MessageInput input) { Match locationMatch = new Regex( "(\\d+)," + // device id "(\\d{4}\\d{2}\\d{2}\\d{2}\\d{2}\\d{2})," + // YYYY mm dd hh mm ss "(-?\\d+.\\d+)," + // longitude "(-?\\d+.\\d+)," + // latitude "(\\d+)," + // speed "(\\d+)," + // heading "(.*?)," + // altitude "(\\d+)") // satellites .Match(input.DataMessage.String); if (locationMatch.Success) { input.Client.SetDevice(locationMatch.Groups[1].Value); Location location = new Location { Device = input.Client.Device, DateTime = NewDateTimeUtil.Convert(DateFormat.YYYYMMDDHHMMSS, locationMatch.Groups[2].Value), Longitude = locationMatch.Groups[3].Get <decimal>(), Latitude = locationMatch.Groups[4].Get <decimal>(), Speed = locationMatch.Groups[5].Get <decimal?>(), Heading = locationMatch.Groups[6].Get <decimal?>(), Altitude = locationMatch.Groups[7].Get <decimal?>(), Satellites = locationMatch.Groups[8].Get <short?>(), }; return(location); } return(null); }
private void OnRecognize(SpeechRecognitionEvent result) { if (result != null && result.results.Length > 0) { foreach (var res in result.results) { foreach (var alt in res.alternatives) { string text = string.Format("{0} ({1}, {2:0.00})\n", alt.transcript, res.final ? "Final" : "Interim", alt.confidence); if (res.final) { ResultsField.text = text; string _conversationString = alt.transcript; //We can now call the CONV service? Log.Debug("STT.OnSTTRecognize()", _conversationString); Active = false; //Stop Microphone from listening // Message MessageInput messageRequest = new MessageInput() { Text = _conversationString }; ASService.Message(OnReceiveMessage, workspaceId: workspaceId, input: messageRequest); } } } } }
public ActionResult SendSMS([FromBody] MessageInput messageInput) { try { if (ModelState.IsValid) { var reply = _NotificationOrchestration.SendSMS(messageInput); if (reply != null) { return(Content(reply.Response)); } return(BadRequest()); } else { throw new Exception(); } } catch (Exception e) { return(BadRequest(e.Message)); } }
public override IEnumerable <Location> ParseRange(MessageInput input) { short size = input.DataMessage.ByteReader.GetLe <short>(); long imei = input.DataMessage.ByteReader.GetLe <long>(); input.Client.Device ??= new Device { DeviceId = $"{imei}" }; byte command = input.DataMessage.ByteReader.GetOne(); if (Enum.GetValues(typeof(Command)).Cast <int>().Contains(command)) { byte recordsLeftInDevice = input.DataMessage.ByteReader.GetOne(); byte records = input.DataMessage.ByteReader.GetOne(); List <Location> locations = new List <Location>(); for (int i = 0; i < records; i++) { Location location = GetLocation(input, command == (int)Command.ExtendedRecords); locations.Add(location); } SendResponse(input); return(locations); } return(null); }
private static IEnumerable <Location> ParseText(MessageInput input) { if (input.DataMessage.CommaSplit.Length > 14) { input.Client.SetDevice(input.DataMessage.CommaSplit[1]); Location location = new Location { Device = input.Client.Device, Latitude = input.DataMessage.CommaSplit.Get <decimal>(4), Longitude = input.DataMessage.CommaSplit.Get <decimal>(5), DateTime = ConvertDate(input.DataMessage.CommaSplit[6]), PositionStatus = input.DataMessage.CommaSplit.Get <string>(7) == "A", Satellites = input.DataMessage.CommaSplit.Get <short>(8), GsmSignal = GsmUtil.ConvertSignal(input.DataMessage.CommaSplit.Get <short>(9)), Speed = input.DataMessage.CommaSplit.Get <decimal?>(10), Heading = input.DataMessage.CommaSplit.Get <decimal?>(11), HDOP = input.DataMessage.CommaSplit.Get <decimal?>(12), Altitude = input.DataMessage.CommaSplit.Get <int>(13), Odometer = input.DataMessage.CommaSplit.Get <uint>(14) }; return(new[] { location }); } return(null); }
private static Location GetLocation(MessageInput input, bool extended) { // ReSharper disable once UseObjectOrCollectionInitializer Location location = new Location { Device = input.Client.Device }; location.DateTime = DateTime.UnixEpoch.AddSeconds(input.DataMessage.ByteReader.GetLe <int>()); byte timestampExtension = input.DataMessage.ByteReader.GetOne(); byte?recordExtension = extended ? input.DataMessage.ByteReader.GetOne() : default; byte priority = input.DataMessage.ByteReader.GetOne(); location.Longitude = input.DataMessage.ByteReader.GetLe <int>() / 10000000m; location.Latitude = input.DataMessage.ByteReader.GetLe <int>() / 10000000m; location.Altitude = input.DataMessage.ByteReader.GetLe <short>() / 10m; location.Heading = input.DataMessage.ByteReader.GetLe <short>() / 100m; location.Satellites = input.DataMessage.ByteReader.GetOne(); location.Speed = input.DataMessage.ByteReader.GetLe <short>(); location.HDOP = input.DataMessage.ByteReader.GetOne() / 10; short eventId = extended ? input.DataMessage.ByteReader.GetLe <short>() : input.DataMessage.ByteReader.GetOne(); List <IOData> events = new List <IOData>(); events.AddRange(GetIOData(input.DataMessage.ByteReader, 1, extended)); // 1 byte IO data events.AddRange(GetIOData(input.DataMessage.ByteReader, 2, extended)); // 2 bytes IO data events.AddRange(GetIOData(input.DataMessage.ByteReader, 4, extended)); // 4 bytes IO data events.AddRange(GetIOData(input.DataMessage.ByteReader, 8, extended)); // 8 bytes IO data return(location); }
public async Task TestSearchMessageFilters() { var user1 = new User() { ID = Guid.NewGuid().ToString(), Role = Role.Admin, }; var content = Guid.NewGuid().ToString(); await this._client.Users.Upsert(user1); var channel = this._client.Channel("messaging", Guid.NewGuid().ToString()); await channel.Create(user1.ID, new string[] { user1.ID }); var inMsg = new MessageInput() { Text = content }; var outMsg = await channel.SendMessage(inMsg, user1.ID); var results = await this._client.Search(SearchOptions.Default.WithMessageFilterConditions(new Dictionary <string, object>() { { "text", new Dictionary <string, object>() { { "$q", content } } } }).WithFilter(new Dictionary <string, object>() { { "cid", "messaging:" + channel.ID } })); Assert.AreEqual(outMsg.ID, results.Results[0].Message.ID); }
public async Task <IActionResult> SendMessage(MessageInput input) { string userId = User.Claims.First(c => c.Type == "UserID").Value; var user = await _userManager.FindByIdAsync(userId); var message = new MimeMessage(); message.From.Add(new MailboxAddress(user.FullName, user.Email)); message.To.Add(new MailboxAddress("SLM", input.Email)); message.Subject = "Subject " + input.Email; message.Body = new TextPart("plain") { Text = input.Message }; using (var client = new SmtpClient()) { client.CheckCertificateRevocation = false; client.Connect("smtp.gmail.com", 587, false); client.Authenticate("*****@*****.**", "Peretzz+100500"); client.Send(message); client.Disconnect(true); } return(Ok(new { Succeeded = "Sent" })); }
public void FillCheckoutFormAndSubmit(LetsTalkFormModel model) { EmailInput.SendKeysWithWait(model.Email); NameInput.SendKeysWithWait(model.Name); SubjectInput.SendKeysWithWait(model.Subject); MessageInput.SendKeysWithWait(model.Message); }
public override Location Parse(MessageInput input) { input.Client.SetDevice(input.DataMessage.CommaSplit[0].Replace("$", Empty)); Location location = new Location { Device = input.Client.Device, DateTime = DateTime.Parse($"{input.DataMessage.CommaSplit[2]} {input.DataMessage.CommaSplit[3]}"), Latitude = input.DataMessage.CommaSplit.Get <decimal>(4), Longitude = input.DataMessage.CommaSplit.Get <decimal>(5), Altitude = input.DataMessage.CommaSplit.Get <decimal?>(6), Speed = input.DataMessage.CommaSplit.Get <decimal?>(7), }; if (input.DataMessage.CommaSplit.Length >= 24) { location.Heading = input.DataMessage.CommaSplit.Get <decimal?>(11); location.Satellites = input.DataMessage.CommaSplit.Get <short?>(12); location.HDOP = input.DataMessage.CommaSplit.Get <decimal?>(13); location.Odometer = input.DataMessage.CommaSplit.Get <double?>(14); } else { location.Heading = input.DataMessage.CommaSplit.Get <decimal?>(8); location.Satellites = input.DataMessage.CommaSplit.Get <short?>(9); location.HDOP = input.DataMessage.CommaSplit.Get <decimal?>(10); location.Odometer = input.DataMessage.CommaSplit.Get <double?>(13); } return(location); }
public override Location Parse(MessageInput input) { MeiligaoInputMessage inputMessage = new MeiligaoInputMessage(input.DataMessage); HandleMessage(input, inputMessage); if (inputMessage.MeiligaoDataMessage != null) { Location location = new Location { Device = new Device { IMEI = inputMessage.DeviceIdTrimmed }, PositionStatus = inputMessage.MeiligaoDataMessage.GPRMCArray[1] == "A", Latitude = GpsUtil.ConvertDmmLatToDecimal(inputMessage.MeiligaoDataMessage.GPRMCArray[2], inputMessage.MeiligaoDataMessage.GPRMCArray[3]), Longitude = GpsUtil.ConvertDmmLongToDecimal(inputMessage.MeiligaoDataMessage.GPRMCArray[4], inputMessage.MeiligaoDataMessage.GPRMCArray[5]), DateTime = GetDateTime(inputMessage.MeiligaoDataMessage.GPRMCArray[0], inputMessage.MeiligaoDataMessage.GPRMCArray[8]), Speed = SpeedUtil.KnotsToKph(inputMessage.MeiligaoDataMessage.GPRMCArray.Get <decimal>(6)), Heading = inputMessage.MeiligaoDataMessage.GPRMCArray.Get <decimal?>(7), HDOP = inputMessage.MeiligaoDataMessage.StringSplit.Get <decimal?>(1), Altitude = inputMessage.MeiligaoDataMessage.StringSplit.Get <decimal?>(2), Odometer = inputMessage.MeiligaoDataMessage.StringSplit.Get <uint?>(7) }; return(location); } return(null); }
private static Location GetLocation(MessageInput input, int type) { if (input.Client.Device == null) { return(null); } Location location = new Location { Device = input.Client.Device }; input.DataMessage.ByteReader.GetOne(); input.DataMessage.ByteReader.Get <short>(); short status = input.DataMessage.ByteReader.Get <short>(); location.PositionStatus = !BitUtil.IsTrue(status, 5); location.Latitude = (decimal)input.DataMessage.ByteReader.Get <float>(); location.Longitude = (decimal)input.DataMessage.ByteReader.Get <float>(); location.Heading = input.DataMessage.ByteReader.Get <short>() * 0.1m; location.Speed = input.DataMessage.ByteReader.Get <short>() * 0.1m; input.DataMessage.ByteReader.GetOne(); location.Altitude = input.DataMessage.ByteReader.Get <short>(); location.HDOP = input.DataMessage.ByteReader.GetOne() * 0.1m; location.Satellites = (short?)(input.DataMessage.ByteReader.GetOne() & 0x0f); location.DateTime = DateTime.UnixEpoch.AddSeconds(input.DataMessage.ByteReader.Get <int>()); MarkAsNull(location); return(location); }
public override Location Parse(MessageInput input) { Match locationMatch = new Regex( "IMEI,(\\d{15})," + // imei "(\\d{4}\\/\\d{2}\\/\\d{2}), " + // date YYYY/mm/dd "(\\d{2}:\\d{2}:\\d{2}), " + // hh:mm:ss "(N|S), Lat:(\\d+.\\d+), " + // latitude "(E|W), Lon:(\\d+.\\d+), " + // longitude "Spd:(\\d+.\\d+)") .Match(input.DataMessage.String); if (locationMatch.Success) { input.Client.SetDevice(locationMatch.Groups[1].Value); Location location = new Location { Device = input.Client.Device, DateTime = DateTime.Parse($"{locationMatch.Groups[2].Value} {locationMatch.Groups[3].Value}"), Latitude = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[5].Value, locationMatch.Groups[4].Value), Longitude = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[7].Value, locationMatch.Groups[6].Value), Speed = SpeedUtil.KnotsToKph(locationMatch.Groups[8].Get <decimal>()) }; return(location); } return(null); }
/* For Event handlers */ private void SendMessage() { var selected = ContactList.SelectedItem as ContactDto; var msg = new MessageDto { From = new UserDto { Id = Properties.Settings.Default.UserId, FullName = Properties.Settings.Default.FullName }, To = selected.User, Content = MessageInput.Text, DispatchedAt = DateTimeOffset.Now }; MessageInput.Clear(); selected.Messages.Items.Add(msg); selected.LastMessage = msg; Contacts.Refresh(); MessagesQueue.Add(new SendMessageBindingModel { Content = msg.Content, From = Properties.Settings.Default.UserId, To = selected.User.Id, DispatchedAt = msg.DispatchedAt }); ConversationScrollViewer.ScrollToBottom(); }
public override Location Parse(MessageInput input) { Match locationMatch = new Regex( "simei:(\\d+)," + // imei "(.*?)" + // ignore "(\\d{12})," + // yy mm dd hh mm ss "(A|V)," + // gps fix "(\\d+.\\d+),(N|S)," + // latitude "(\\d+.\\d+),(E|W)," + // longitude "(\\d+.\\d+),") // speed .Match(input.DataMessage.String); if (locationMatch.Success) { input.Client.SetDevice(locationMatch.Groups[1].Value); Location location = new Location { Device = input.Client.Device, DateTime = NewDateTimeUtil.Convert(DateFormat.YYMMDDHHMMSS, locationMatch.Groups[3].Value), PositionStatus = locationMatch.Groups[4].Value == "A", Latitude = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[5].Value, locationMatch.Groups[6].Value), Longitude = GpsUtil.ConvertDmmLongToDecimal(locationMatch.Groups[7].Value, locationMatch.Groups[8].Value), Speed = locationMatch.Groups[9].Get <decimal?>() }; return(location); } return(null); }
public override IEnumerable <Location> ParseRange(MessageInput input) { IEnumerable <Location> location = ParseRange(input, ParseTextMessage, ParseBinaryLogin, ParseLocationMessage); return(location); }
private static Location Authentication(MessageInput input) { try { GroupCollection groups = new Regex(@"##,imei:(.*),A;").Matches(input.DataMessage.String)[0].Groups; string imei = groups[1].Value; if (StringUtil.IsDigitsOnly(imei)) { input.Client.Device = new Device { IMEI = imei }; input.NetworkStream.Write(StringUtil.ConvertStringToByteArray("LOAD")); } } catch (Exception e) { Console.WriteLine(e); throw; } return(null); }
public List <string> SendInput(MessageInput input) { try { var result = _assistant.Message( assistantId: ASSISTANT_ID, sessionId: SESSION_ID, input: input ); var messageResponse = DeserializeMessage(result); List <string> results = new List <string>(); foreach (RuntimeResponseGeneric rg in messageResponse.Output.Generic) { results.Add(rg.Text); } return(results); } catch (Exception) { throw; } }