public async Task <IActionResult> GetOutboxMessageList() { var messagesJson = new List <MessageJson>(); var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId); var messages = await _messageService.GetSentMessagesByUserIdAsync(UserId); foreach (var message in messages) { var json = new MessageJson(); json.MessageId = message.MessageId; json.Subject = message.Subject; json.SystemGenerated = message.SystemGenerated; json.Body = message.Body; json.SentOn = message.SentOn.FormatForDepartment(department); json.IsDeleted = message.IsDeleted; json.ReadOn = message.ReadOn; json.Type = message.Type; json.ExpireOn = message.ExpireOn; messagesJson.Add(json); } return(Json(messagesJson)); }
public TrendbarJson[] getMinuteTredbars(long accountId, string symbolName, DateTime from, DateTime to) { IDictionary <string, string> pathParams = new Dictionary <string, string>(); pathParams["id"] = accountId.ToString(); pathParams["symbolName"] = symbolName; IDictionary <string, string> requestParams = new Dictionary <string, string>(); requestParams["from"] = from.ToString("yyyyMMddHHmmss"); requestParams["to"] = to.ToString("yyyyMMddHHmmss"); string service = getServiceURLString(MINUTE_TRENDBARS_SERVICE, pathParams, requestParams); try { MessageJson <TrendbarJson[]> messageJson = JsonConvert.DeserializeObject <MessageJson <TrendbarJson[]> >(callURL(service)); ErrorJson error = messageJson.Error; if (error != null) { throw new AccountsAPIException(error.ErrorCode, error.Description); } return(messageJson.Data); } catch (System.Exception e) { throw new AccountsAPIException(e); } }
public async Task <IActionResult> PostMessage(MessageJson message) { var mapped = _mapper.Map <Data.Entities.Message>(message); await _service.PostMessages(mapped); return(Ok()); }
public static string CreateRequestMessage(string requestAction, string idProcesso, string tipologiaEsito) { var message = new MessageJson(); message.message = new Message(); message.message.MessageType = "SCBridge"; message.message.FlowData = new FlowData() { ID_PROCESSO = idProcesso, STEP_CURR = 0, STEP_FINALE = 1, ESITO = "OK", CODICE_ESITO = "0", TIPOLOGIA_ESITO = tipologiaEsito }; message.message.RequestAction = requestAction; //message.message.TrackingAnalytics = new Models.WebView.Tracking() //{ // LIVELLO2 = string.Empty, // LIVELLO3 = string.Empty //}; var json = JsonConvert.SerializeObject(message); return(json); }
public static MessageJson JsonToModel(string json) { MessageJson result = null; json = JsonConvert.DeserializeObject <string>(json); try { //if (XLabs.Ioc.Resolver.Resolve<IGetDevice>().OS.Equals("iOS")) //{ // result = (JsonConvert.DeserializeObject<Root>(json)).content.messageJson; //} //else //{ // result = JsonConvert.DeserializeObject<MessageJson>(json); //} result = JsonConvert.DeserializeObject <MessageJson>(json); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("JsonToModel - Errore di Deserializzazione [" + json + "] " + e.Message); //TODO add logmanager //LogManager.ExceptionThrow(e); } return(result); }
/// <summary> /// Generate the base <c>MessageJson</c> for a message /// </summary> /// <param name="message">The base interface, <c>IMessageBase</c>, of the message to be sent.</param> /// <returns>A <c>MessageJson</c> object for generating an InjectionRequest</returns> internal virtual MessageJson GenerateBaseMessageJson(IMessageBase message) { var jsonMsg = new MessageJson { Subject = message.Subject, TextBody = message.PlainTextBody, HtmlBody = message.HtmlBody, MailingId = message.MailingId, MessageId = message.MessageId, CharSet = message.CharSet, CustomHeaders = PopulateCustomHeaders(message.CustomHeaders), From = new AddressJson(message.From.Email, message.From.FriendlyName), Attachments = PopulateList(message.Attachments) }; if (message.ReplyTo != null) { jsonMsg.ReplyTo = new AddressJson(message.ReplyTo.Email, message.ReplyTo.FriendlyName); } if (message.ApiTemplate.HasValue) { jsonMsg.ApiTemplate = message.ApiTemplate.ToString(); } return(jsonMsg); }
public IActionResult SendEmail([FromBody] MessageJson meal) { try { accountRepository.SendDiet(meal.Message); return(Ok()); } catch { return(new BadRequestResult()); } }
public static MessageJson JsonToModelIOS(string json) { MessageJson result = null; try { result = JsonConvert.DeserializeObject <MessageJson>(json); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("JsonToModel - Errore di Deserializzazione [" + json + "] " + e.Message); } return(result); }
internal void OnCallBackJS(MessageJson messageJson) { if (messageJson != null) { if (messageJson.message.RequestAction.Equals("stopLoading")) { ShowLoader(false, 0); } else if (messageJson.message.RequestAction.Equals("startLoading")) { ShowLoader(true, 0); } else { //TODO } } }
public TradingAccountJson[] getTradingAccounts() { string service = getServiceURLString(TRADING_ACCOUNTS_SERVICE); try { MessageJson <TradingAccountJson[]> messageJson = JsonConvert.DeserializeObject <MessageJson <TradingAccountJson[]> >(callURL(service)); ErrorJson error = messageJson.Error; if (error != null) { throw new AccountsAPIException(error.ErrorCode, error.Description); } return(messageJson.Data); } catch (System.Exception e) { throw new AccountsAPIException(e); } }
public override int GetHashCode() { int hash = 1; if (SessionId.Length != 0) { hash ^= SessionId.GetHashCode(); } if (MessageId.Length != 0) { hash ^= MessageId.GetHashCode(); } if (CommChannel.Length != 0) { hash ^= CommChannel.GetHashCode(); } if (MessageJson.Length != 0) { hash ^= MessageJson.GetHashCode(); } if (stampOne_ != null) { hash ^= StampOne.GetHashCode(); } if (stampTwo_ != null) { hash ^= StampTwo.GetHashCode(); } if (stampThree_ != null) { hash ^= StampThree.GetHashCode(); } if (stampFour_ != null) { hash ^= StampFour.GetHashCode(); } if (stampFive_ != null) { hash ^= StampFive.GetHashCode(); } return(hash); }
// send message to html tiles page public bool SignalTilesHtmlPage(string message, object data) { bool bOK = true; try { var msg = new MessageJson(); msg.Message = message; msg.Data = data; string json = msg.GetJsonString(); string script = $"tiles.handleMsgFromApp('{json}')"; WebViewTiles.RunJSScript(script); } catch (Exception ex) { //Logger.Instance.Error($"SignalTilesHtmlPage exception, {ex.Message}"); bOK = false; } return(bOK); }
// callback from JS body html page void ScoresJSCallback(string message) { try { Device.BeginInvokeOnMainThread(() => { ViewModel.HasHtmlPageSignalled = true; System.Diagnostics.Debug.WriteLine($"Got local callback: {message}"); MessageJson msg = new MessageJson(message); switch (msg.Message) { case "ping": break; case "closeWindow": // back to main page ViewModel.CloseWindow(); break; case "clearScores": ViewModel.ClearHighScores(); break; case "Error": if (msg.Data != null) { Logger.Instance.Error(msg.Data.ToString()); } break; default: Debug.Assert(false, $"ScoresJSCallback unexpected message {message}"); break; } }); } catch (Exception ex) { Logger.Instance.Error($"ScoresJSCallback exception, {ex.Message}"); } }
public async Task <IActionResult> GetInboxMessageList() { var messagesJson = new List <MessageJson>(); var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId); var messages = await _messageService.GetInboxMessagesByUserIdAsync(UserId); foreach (var message in messages) { var json = new MessageJson(); json.MessageId = message.MessageId; json.Subject = message.Subject; json.SystemGenerated = message.SystemGenerated; json.Body = message.Body; json.SentOn = message.SentOn.FormatForDepartment(department); json.IsDeleted = message.IsDeleted; json.ReadOn = message.ReadOn; json.Type = message.Type; json.ExpireOn = message.ExpireOn; json.Read = message.HasUserRead(UserId); if (message.SystemGenerated) { json.SentBy = "System"; } else if (!String.IsNullOrWhiteSpace(message.SendingUserId)) { json.SentBy = await UserHelper.GetFullNameForUser(message.SendingUserId); } else { json.SentBy = "System"; } messagesJson.Add(json); } return(Json(messagesJson)); }
/// <summary> /// GET request for a list of messages /// <param name="f">type message: inbox = 0, outbox = -1, saveimage = 1</param> /// <param name="p">1</param> /// </summary> public async Task <MessageJson> Message(string f, string p) { MessageJson message = null; string url = $"https://profile.onliner.by/messages/load/?f={f}&p={p}&token=" + ConvertToAjaxTime.ConvertToUnixTimestamp().ToString(); try { if (!HasInternet()) { return(message); } HttpClient httpClient = new HttpClient(HandlerCookie()); var response = httpClient.SendAsync(new HttpRequestMessage(System.Net.Http.HttpMethod.Get, url)).Result; var resultJson = await response.Content.ReadAsStringAsync(); var regex = new Regex("(\"m\\d+\":)", RegexOptions.Compiled | RegexOptions.Multiline); var myString = regex.Replace(resultJson, "").Replace("\"messages\":{", "\"messages\":[").Replace("}}}", "}]}"); message = (MessageJson)JsonConvert.DeserializeObject <MessageJson>(myString); } catch (WebException) { } return(message); }
public SymbolJson[] getSymbols(long accountId) { IDictionary <string, string> pathParams = new Dictionary <string, string>(); pathParams["id"] = accountId.ToString(); string service = getServiceURLString(SYMBOLS_SERVICE, pathParams); try { MessageJson <SymbolJson[]> messageJson = JsonConvert.DeserializeObject <MessageJson <SymbolJson[]> >(callURL(service)); ErrorJson error = messageJson.Error; if (error != null) { throw new AccountsAPIException(error.ErrorCode, error.Description); } return(messageJson.Data); } catch (System.Exception e) { throw new AccountsAPIException(e); } }
// callback from JS header html page void HeaderJSCallback(string message) { try { Device.BeginInvokeOnMainThread(() => { ViewModel.HasHeaderPageSignalled = true; MessageJson msg = new MessageJson(message); switch (msg.Message) { case "LogMsg": Debug.WriteLine(msg.Data.ToString()); break; case "Error": if (msg.Data != null) { Logger.Instance.Error(msg.Data.ToString()); } break; case "LoadWordsHeader": LoadWordsHeader(); break; default: Debug.Assert(false, $"HeaderJSCallback unexpected message {message}"); break; } }); } catch (Exception ex) { Logger.Instance.Error($"HeaderJSCallback exception, {ex.Message}"); } }
protected virtual void OnGetMessage(Room room, MessageJson message) { this.Clients.OthersInGroup(this.GetGroup(room.Id)).onGetMessage(message); }
/// <summary> /// 我的消息 /// </summary> /// <param name="isPre">"n"</param> /// <param name="page">1</param> /// <param name="pageType">"notify" or "remind" or "itemsetupdate"</param> /// <returns></returns> private static async Task <NotifiesItem[]> Message(string isPre, int page, string pageType) => MessageJson.FromJson(await BcyJson.Message(isPre, page, pageType)).Data.Notifies;
public static async Task <NotifiesItem[]> Message_Remind(int page) => MessageJson.FromJson(await BcyJson.Message_Remind(page)).Data.Notifies;
public static List <MessageJson> GetNewsFeed(int UserId, int LastMessageId = 0) { List <Message> messages = null; if (LastMessageId == 0) { // load all messages at first messages = (from message in db.Messages from recipient in db.MessageRecipients where message.MessageId == recipient.MessageId && recipient.RecipientId == UserId orderby message.MessageId select message).ToList(); } else { // load new messages only messages = (from message in db.Messages from recipient in db.MessageRecipients where message.MessageId == recipient.MessageId && recipient.RecipientId == UserId && recipient.MessageId > LastMessageId && recipient.IsRead == false orderby message.MessageId select message).ToList(); } List <MessageType> types = db.MessageTypes.ToList(); List <MessageJson> msgJsonList = new List <MessageJson>(); MessageJson msgJson = null; ObjJson subJson = null; ObjJson objJson = null; MessageRecipient rep = null; foreach (var m in messages) { msgJson = new MessageJson(); subJson = new ObjJson(); objJson = new ObjJson(); switch (m.SubjectTypeId) { case Constant.PRONOUN_TYPE_USER: UserProfile user = db.UserProfiles.Find(m.SubjectId); subJson.Id = user.UserId; subJson.ImageId = user.Profile.ProfileImageId; subJson.Name = user.Profile.DisplayName; subJson.Url = "/User/Id/" + user.UserId; break; case Constant.PRONOUN_TYPE_STORE: Store store = db.Stores.Find(m.SubjectId); subJson.Id = store.StoreId; subJson.ImageId = store.CoverImageId; subJson.Name = store.StoreName; subJson.Url = "/Store/Id/" + store.StoreId; break; case Constant.PRONOUN_TYPE_PRODUCT: Product product = db.Products.Find(m.SubjectId); subJson.Id = product.ProductId; subJson.ImageId = product.ProductImages.First().ImageId; subJson.Name = product.Name; subJson.Url = "/Product/Id/" + product.ProductId; break; case Constant.PRONOUN_TYPE_CATEGORY: Category category = db.Categories.Find(m.SubjectId); subJson.Id = category.CategoryId; subJson.ImageId = category.CoverImageId; subJson.Name = category.Name; subJson.Url = "/Category/Id/" + category.CategoryId; break; } switch (m.ObjectTypeId) { case Constant.PRONOUN_TYPE_USER: UserProfile user = db.UserProfiles.Find(m.ObjectId); objJson.Id = user.UserId; objJson.ImageId = user.Profile.ProfileImageId; objJson.Name = user.Profile.DisplayName; objJson.Url = "/User/Id/" + user.UserId; break; case Constant.PRONOUN_TYPE_STORE: Store store = db.Stores.Find(m.ObjectId); objJson.Id = store.StoreId; objJson.ImageId = store.CoverImageId; objJson.Name = store.StoreName; objJson.Url = "/Store/Id/" + store.StoreId; break; case Constant.PRONOUN_TYPE_PRODUCT: Product product = db.Products.Find(m.ObjectId); objJson.Id = product.ProductId; objJson.ImageId = product.ProductImages.First().ImageId; objJson.Name = product.Name; objJson.Url = "/Product/Id/" + product.ProductId; break; case Constant.PRONOUN_TYPE_CATEGORY: Category category = db.Categories.Find(m.ObjectId); objJson.Id = category.CategoryId; objJson.ImageId = category.CoverImageId; objJson.Name = category.Name; objJson.Url = "/Category/Id/" + category.CategoryId; break; } rep = m.Recipients.Where(r => r.RecipientId == UserId).FirstOrDefault(); msgJsonList.Add(new MessageJson { MessageId = m.MessageId, Subj = subJson, Verb = m.MessageType.Content, Obj = objJson, IsRead = rep.IsRead, CreateDate = rep.CreateDate }); } return(msgJsonList); }
public static async Task <NotifiesItem[]> Message_ItemSetUpdate(int page) => MessageJson.FromJson(await BcyJson.Message_ItemSetUpdate(page)).Data.Notifies;
void OnReceivedMatchState(Nakama.IMatchState _e) { //Debug.Log("OnReceivedMatchState 1 => "+_e); if (_e.OpCode == 1) { var _s = System.Text.Encoding.UTF8.GetString(_e.State); PositionJson _p = JsonUtility.FromJson <PositionJson>(_s); lock (actionQueue) { actionQueue.Enqueue(() => { move_other_players(_p.x, _p.z, _p.r, _e.UserPresence.UserId); //StartCoroutine(load_other_players(myObject.players)); }); } } else if (_e.OpCode == 2) { var _s = System.Text.Encoding.UTF8.GetString(_e.State); MessageJson _p = JsonUtility.FromJson <MessageJson>(_s); ChatHandler.insertTextChat("<color=green>" + _e.UserPresence.Username + ":</color> " + _p.m); } else if (_e.OpCode == 31) { var _State = System.Text.Encoding.UTF8.GetString(_e.State); if (_State.Length <= 5) { return; } _State = "{\"players\":" + _State + "}"; OpCode_51_Json myObject = JsonUtility.FromJson <OpCode_51_Json>(_State); lock (actionQueue) { actionQueue.Enqueue(() => { find_other_players(myObject.players, true); //StartCoroutine(load_other_players(myObject.players)); }); } } else if (_e.OpCode == 13) { var _State = System.Text.Encoding.UTF8.GetString(_e.State); if (_State == "{}" || _State == "") { _State = "[]"; } _State = "{\"seats\":" + _State + "}"; Seats_Json myObject = JsonUtility.FromJson <Seats_Json>(_State); lock (actionQueue) { actionQueue.Enqueue(() => { ReAssignSeats(myObject.seats); //StartCoroutine(load_other_players(myObject.players)); }); } } else if (_e.OpCode == 44) { Debug.Log("OpCode ALERT => 44"); var _s = System.Text.Encoding.UTF8.GetString(_e.State); Debug.Log(_s); } else if (_e.OpCode == 99) { Debug.Log("OpCode => 99"); var _s = System.Text.Encoding.UTF8.GetString(_e.State); Debug.Log(_s); } }
// callback from JS body html page void TilesJSCallback(string message) { try { Device.BeginInvokeOnMainThread(() => { ViewModel.HasTilesPageSignalled = true; MessageJson msg = new MessageJson(message); switch (msg.Message) { case "ping": break; case "tilePageReady": ViewModel.IsLoading = false; FlexScoreHeader.BackgroundColor = Color.LightBlue; break; case "tileClick": if (!ViewModel.GameCompleted && ViewModel.SecondsRemaining > 0) { if (Manager.CheckForSelectedWord(msg.Data as JObject, out bool isPartOfWord)) { if (!isPartOfWord && Manager.DifficultyLevel == Defines.GameDifficulty.hard) { // Remove score on missed tile hit ViewModel.SubtractPenaltyScore(); if (SoundSettingIsOn && !ScorePenaltyWarned) { ScorePenaltyWarned = true; TextToSpeech.SpeakAsync($"You lost {Defines.PENALTY_POINTS} points. Only click on tiles that are part of a word."); } } } // reload tiles ViewModel.SignalTilesHtmlPage("UpdateTileSelectedSates", Manager.TileViewModels); } break; case "hightscoreName": SaveHighScore(msg.Data.ToString()); break; case "LogMsg": Debug.WriteLine(msg.Data.ToString()); break; case "Error": if (msg.Data != null) { Logger.Instance.Error(msg.Data.ToString()); } break; default: Debug.Assert(false, $"TilesJSCallback unexpected message {message}"); break; } }); } catch (Exception ex) { Logger.Instance.Error($"TilesJSCallback exception, {ex.Message}"); } }