public void ProcessProposalNotification(string message, Dictionary <string, int> userPriority) { try { // Obtenemos la notificacion de la queue: notifications ProposalNotification proposalNotification = JsonConvert.DeserializeObject <ProposalNotification>(message); //Aumentamos la prioridad del usuario int Priority = AddUserIfNotExist(userPriority, new Guid(proposalNotification.idUser)); // Encolamos la notificacion al topic de service bus // para que tambien llegue en tiempo real dynamic data = proposalNotification; sbmanager.SendMessageAsync(Priority, data, new Guid(proposalNotification.idUser), proposalNotification.label); } catch (Exception e) { var messageException = telemetry.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name); telemetry.Critical(messageException); } }
public ActionResult Proposal(ProposalViewModel viewModel) { ConversationParametersViewModel conversationParameters = new ConversationParametersViewModel(); viewModel.proposal.AudienceChannelId = TempData["idAudienceChannel"].ToString(); var operationResult = manager.AddProposal(viewModel, User.Identity.GetUserId()); string conversationParametersJson = string.Empty; if (operationResult) { string serviceBusQueueName = "proposaltopicdev"; var audienceChannel = audienceChannelManager.GetAudienceChannelById(viewModel.proposal.AudienceChannelId); var audience = audienceManager.GetAudienceById(audienceChannel.AudienceId); var publisherProfile = manager.GetPublisherProfileById(audience.PublisherId); var advertiserProfile = manager.GetAdvertiserProfile(User.Identity.GetUserId()); conversationParameters.NameConversation = publisherProfile.Name + "_" + audienceChannel.Name + "_" + advertiserProfile.Title; conversationParameters.AdvertiserId = advertiserProfile.Id; conversationParameters.PublisherId = publisherProfile.Id; conversationParameters.AudienceChannelId = audienceChannel.Id; conversationParametersJson = JsonConvert.SerializeObject(conversationParameters); ProposalNotification proposalNotification = new ProposalNotification() { idUser = publisherProfile.UserId, message = "Proposal created successfully" }; string message = JsonConvert.SerializeObject(proposalNotification); notificationManager = new NotificationManager(serviceBusQueueName); notificationManager.ProcessProposalNotification(message, new Dictionary <string, int>()); notificationManager.Close(); } return(operationResult ? Json(new { success = true, message = "Proposal created successfully", conversationParameters = conversationParametersJson, proposalId = viewModel.proposal.Id }) : Json(new { error = "Error creating Proposal" })); }