<commit_before>﻿//-----------------------------------------------------------------------
// <copyright file="NotificationAddChiamataInCorso.cs" company="CNVVF">
// Copyright (C) 2017 - CNVVF
//
// This file is part of SOVVF.
// SOVVF is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// SOVVF is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// </copyright>
//-----------------------------------------------------------------------

using DomainModel.CQRS.Commands.ChiamataInCorsoMarker;
using Microsoft.AspNetCore.SignalR;
using SO115App.Models.Servizi.Infrastruttura.Notification.GestioneChiamateInCorso;
using SO115App.SignalR.Utility;
using System;
using System.Threading.Tasks;

namespace SO115App.SignalR.Sender.GestioneChiamateInCorso
{
    public class NotificationAddChiamataInCorso : INotificationAddChiamataInCorso
    {
        private readonly IHubContext<NotificationHub> _notificationHubContext;
        private readonly GetGerarchiaToSend _getGerarchiaToSend;

        public NotificationAddChiamataInCorso(IHubContext<NotificationHub> NotificationHubContext,
            GetGerarchiaToSend getGerarchiaToSend)
        {
            _getGerarchiaToSend = getGerarchiaToSend;
            _notificationHubContext = NotificationHubContext;
        }

        public async Task SendNotification(ChiamataInCorsoMarkerCommand chiamata)
        {
            var SediDaNotificare = _getGerarchiaToSend.Get(chiamata.AddChiamataInCorso.CodiceSedeOperatore);

            foreach (var sede in SediDaNotificare)
                await _notificationHubContext.Clients.Group(sede).SendAsync("NotifyChiamataInCorsoMarkerAdd", chiamata);
        }
    }
}<commit_msg>Fix - Corretta notifica Add Chiamata In Corso<commit_after>﻿//-----------------------------------------------------------------------
// <copyright file="NotificationAddChiamataInCorso.cs" company="CNVVF">
// Copyright (C) 2017 - CNVVF
//
// This file is part of SOVVF.
// SOVVF is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// SOVVF is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// </copyright>
//-----------------------------------------------------------------------

using DomainModel.CQRS.Commands.ChiamataInCorsoMarker;
using Microsoft.AspNetCore.SignalR;
using SO115App.Models.Servizi.Infrastruttura.Notification.GestioneChiamateInCorso;
using SO115App.Models.Servizi.Infrastruttura.SistemiEsterni.Competenze;
using SO115App.SignalR.Utility;
using System;
using System.Threading.Tasks;

namespace SO115App.SignalR.Sender.GestioneChiamateInCorso
{
    public class NotificationAddChiamataInCorso : INotificationAddChiamataInCorso
    {
        private readonly IHubContext<NotificationHub> _notificationHubContext;
        private readonly GetGerarchiaToSend _getGerarchiaToSend;
        private readonly IGetCompetenzeByCoordinateIntervento _getCompetenze;

        public NotificationAddChiamataInCorso(IHubContext<NotificationHub> NotificationHubContext,
            GetGerarchiaToSend getGerarchiaToSend,
            IGetCompetenzeByCoordinateIntervento getCompetenze)
        {
            _getGerarchiaToSend = getGerarchiaToSend;
            _getCompetenze = getCompetenze;
            _notificationHubContext = NotificationHubContext;
        }

        public async Task SendNotification(ChiamataInCorsoMarkerCommand chiamata)
        {
            var Competenza = _getCompetenze.GetCompetenzeByCoordinateIntervento(chiamata.AddChiamataInCorso.Localita.Coordinate);

            string[] CodUOCompetenzaAppo = {
                Competenza.CodProvincia + "." + Competenza.CodDistaccamento,
                Competenza.CodProvincia + "." + Competenza.CodDistaccamento2,
                Competenza.CodProvincia + "." + Competenza.CodDistaccamento3,
                Competenza.CodProvincia + ".1000"
            };

            var SediDaNotificare = _getGerarchiaToSend.Get(CodUOCompetenzaAppo[0]);

            foreach (var sede in SediDaNotificare)
                await _notificationHubContext.Clients.Group(sede).SendAsync("NotifyChiamataInCorsoMarkerAdd", chiamata);
        }
    }
}
{'fraction_non_alphanumeric': 0.12252042007001167, 'fraction_numerical': 0.007390120575651498, 'mean_word_length': 2.8237918215613385, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4235230', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1393, 'n_words': 361}