/// <summary> /// The Constructor /// </summary> /// <param name="reader">The ICSVReader instance</param> /// <exception cref="BusinessObject.Exception.CalculationException"></exception> public GoogleMeetMissingDataCalculator(IDictionary <string, IList <IGoogleMeetLogTO> > readerDictionary, string language = Constants.Langauges.ITA, bool forceUpdate = false) { if (readerDictionary == null) { throw new ArgumentNullException("readerDictionary is null"); } this._readerDictionary = readerDictionary; this._forceUpdate = forceUpdate; this._language = language; this.MeetingLogsDictionary = new Dictionary <string, IList <GoogleMeetLogModel> >(); foreach (string meetingKey in this._readerDictionary.Keys) { IList <GoogleMeetLogModel> logsModel = new List <GoogleMeetLogModel>(); try { IDictionary <string, IGoogleMeetLogTO> resultAdditionalDataDictionary = calculateAdditionalData(this._readerDictionary[meetingKey]); foreach (string keyLog in resultAdditionalDataDictionary.Keys) { try { string[] keysLog = splitKeyLog(keyLog); IGoogleMeetLogTO log = this._readerDictionary[meetingKey]. Where(item => item.Date == keysLog[0] && getPartecipantLogIdentifier(item) == keysLog[1] && item.ClientType == keysLog[2]).FirstOrDefault(); logsModel.Add(log.MapTransferObjectInModel(this._language)); } catch (Exception ex) { throw new BusinessObject.Exception.CalculationException($"Errore durante il calcolo dei dati mancanti del log con chiave: {keyLog}", ex); } } this.MeetingLogsDictionary.Add(meetingKey, logsModel.OrderByDescending(item => item.Date).ToList()); } catch (Exception ex) { throw new BusinessObject.Exception.CalculationException(ex.Message, ex); } } }
/// <summary> /// /// </summary> /// <param name="googleMeetLogTO"></param> /// <param name="dataToUpdate"></param> /// <returns></returns> public static GoogleMeetLogModel MapTransferObjectInModel(this IGoogleMeetLogTO googleMeetLogTO, string languageForDateString) { try { return(new GoogleMeetLogModel { Date = googleMeetLogTO.Date.ConvertGooogleMeetDataInDateTime(languageForDateString), EventName = googleMeetLogTO.EventName, EventDescription = googleMeetLogTO.EventDescription, MeetingCode = googleMeetLogTO.MeetingCode, PartecipantIdentifier = googleMeetLogTO.PartecipantIdentifier, ExternalPartecipantIdentifier = googleMeetLogTO.ExternalPartecipantIdentifier.ToUpper() == "YES", ClientType = googleMeetLogTO.ClientType, MeetingOwnerEmail = googleMeetLogTO.MeetingOwnerEmail, ProductType = googleMeetLogTO.ProductType, Duration = string.IsNullOrEmpty(googleMeetLogTO.Duration) ? 0 : int.Parse(googleMeetLogTO.Duration), EffectiveMeetingDurationInHours = string.IsNullOrEmpty(googleMeetLogTO.EffectiveMeetingDurationInHours) ? new TimeSpan() : TimeSpan.Parse(googleMeetLogTO.EffectiveMeetingDurationInHours), EffectiveMeetingDurationInSeconds = string.IsNullOrEmpty(googleMeetLogTO.EffectiveMeetingDurationInSeconds) ? 0 : double.Parse(googleMeetLogTO.EffectiveMeetingDurationInSeconds), EffectiveMeetingDurationInMinutes = string.IsNullOrEmpty(googleMeetLogTO.EffectiveMeetingDurationInMinutes) ? 0 : double.Parse(googleMeetLogTO.EffectiveMeetingDurationInMinutes), CallEvaluationOn5 = googleMeetLogTO.CallEvaluationOn5, PartecipantName = googleMeetLogTO.PartecipantName, IPAddress = googleMeetLogTO.IPAddress, City = googleMeetLogTO.City, Country = googleMeetLogTO.Country, ActionReason = googleMeetLogTO.ActionReason, ActionDescription = googleMeetLogTO.ActionDescription, TargetDisplayNames = googleMeetLogTO.TargetDisplayNames, TargetEmail = googleMeetLogTO.TargetEmail, TargetPhoneNumber = googleMeetLogTO.TargetPhoneNumber, CalendarEventIdentifier = googleMeetLogTO.CalendarEventIdentifier, ConferenceID = googleMeetLogTO.ConferenceID, NETRoundTrip = googleMeetLogTO.NETRoundTrip, TransportProtocol = googleMeetLogTO.TransportProtocol, EstimatedUploadBandwidthInkbps = string.IsNullOrEmpty(googleMeetLogTO.EstimatedUploadBandwidthInkbps) ? 0 : int.Parse(googleMeetLogTO.EstimatedUploadBandwidthInkbps), EstimatedDownloadBandwidthInkbps = string.IsNullOrEmpty(googleMeetLogTO.EstimatedDownloadBandwidthInkbps) ? 0 : int.Parse(googleMeetLogTO.EstimatedDownloadBandwidthInkbps), AudioReceivePacketLossMax = string.IsNullOrEmpty(googleMeetLogTO.AudioReceivePacketLossMax) ? 0 : int.Parse(googleMeetLogTO.AudioReceivePacketLossMax), AudioReceivePacketLossMean = string.IsNullOrEmpty(googleMeetLogTO.AudioReceivePacketLossMean) ? 0 : double.Parse(googleMeetLogTO.AudioReceivePacketLossMean), AudioReceiveDuration = string.IsNullOrEmpty(googleMeetLogTO.AudioReceiveDuration) ? 0 : int.Parse(googleMeetLogTO.AudioReceiveDuration), BitRatioAudioSending = string.IsNullOrEmpty(googleMeetLogTO.BitRatioAudioSending) ? 0 : double.Parse(googleMeetLogTO.BitRatioAudioSending), AudioSendPacketLossMax = string.IsNullOrEmpty(googleMeetLogTO.AudioSendPacketLossMax) ? 0 : int.Parse(googleMeetLogTO.AudioSendPacketLossMax), AudioSendPacketLossMean = string.IsNullOrEmpty(googleMeetLogTO.AudioSendPacketLossMean) ? 0 : double.Parse(googleMeetLogTO.AudioSendPacketLossMean), AudioSendDuration = string.IsNullOrEmpty(googleMeetLogTO.AudioSendDuration) ? 0 : int.Parse(googleMeetLogTO.AudioSendDuration), NetworkRecvJitterMeaninms = string.IsNullOrEmpty(googleMeetLogTO.NetworkRecvJitterMeaninms) ? 0 : double.Parse(googleMeetLogTO.NetworkRecvJitterMeaninms), NetworkRecvJitterMaxinms = string.IsNullOrEmpty(googleMeetLogTO.NetworkRecvJitterMaxinms) ? 0 : int.Parse(googleMeetLogTO.NetworkRecvJitterMaxinms), NetworkSendJitterMeaninms = string.IsNullOrEmpty(googleMeetLogTO.NetworkSendJitterMeaninms) ? 0 : double.Parse(googleMeetLogTO.NetworkSendJitterMeaninms), BitRatioScreencastReception = string.IsNullOrEmpty(googleMeetLogTO.BitRatioScreencastReception) ? 0 : double.Parse(googleMeetLogTO.BitRatioScreencastReception), ScreencastReceiveFPSMean = string.IsNullOrEmpty(googleMeetLogTO.ScreencastReceiveFPSMean) ? 0 : double.Parse(googleMeetLogTO.ScreencastReceiveFPSMean), ScreencastReceiveLongSideMedian = string.IsNullOrEmpty(googleMeetLogTO.ScreencastReceiveLongSideMedian) ? 0 : int.Parse(googleMeetLogTO.ScreencastReceiveLongSideMedian), ScreencastReceivePacketLossMax = string.IsNullOrEmpty(googleMeetLogTO.ScreencastReceivePacketLossMax) ? 0 : int.Parse(googleMeetLogTO.ScreencastReceivePacketLossMax), ScreencastReceivePacketLossMean = string.IsNullOrEmpty(googleMeetLogTO.ScreencastReceivePacketLossMean) ? 0 : double.Parse(googleMeetLogTO.ScreencastReceivePacketLossMean), ScreencastReceiveDuration = string.IsNullOrEmpty(googleMeetLogTO.ScreencastReceiveDuration) ? 0 : int.Parse(googleMeetLogTO.ScreencastReceiveDuration), ScreencastReceiveShortSideMedian = string.IsNullOrEmpty(googleMeetLogTO.ScreencastReceiveShortSideMedian) ? 0 : int.Parse(googleMeetLogTO.ScreencastReceiveShortSideMedian), BitRatioScreencastSending = string.IsNullOrEmpty(googleMeetLogTO.BitRatioScreencastSending) ? 0 : double.Parse(googleMeetLogTO.BitRatioScreencastSending), ScreencastSendFPSMean = string.IsNullOrEmpty(googleMeetLogTO.ScreencastSendFPSMean) ? 0 : double.Parse(googleMeetLogTO.ScreencastSendFPSMean), ScreencastSendLongSideMedian = string.IsNullOrEmpty(googleMeetLogTO.ScreencastSendLongSideMedian) ? 0 : int.Parse(googleMeetLogTO.ScreencastSendLongSideMedian), ScreencastSendPacketLossMax = string.IsNullOrEmpty(googleMeetLogTO.ScreencastSendPacketLossMax) ? 0 : int.Parse(googleMeetLogTO.ScreencastSendPacketLossMax), ScreencastSendPacketLossMean = string.IsNullOrEmpty(googleMeetLogTO.ScreencastSendPacketLossMean) ? 0 : double.Parse(googleMeetLogTO.ScreencastSendPacketLossMean), ScreencastSendDuration = string.IsNullOrEmpty(googleMeetLogTO.ScreencastSendDuration) ? 0 : int.Parse(googleMeetLogTO.ScreencastSendDuration), ScreencastSendShortSideMedian = string.IsNullOrEmpty(googleMeetLogTO.ScreencastSendShortSideMedian) ? 0 : int.Parse(googleMeetLogTO.ScreencastSendShortSideMedian), VideoReceiveFPSMean = string.IsNullOrEmpty(googleMeetLogTO.VideoReceiveFPSMean) ? 0 : double.Parse(googleMeetLogTO.VideoReceiveFPSMean), VideoReceiveLongSideMedian = string.IsNullOrEmpty(googleMeetLogTO.VideoReceiveLongSideMedian) ? 0 : int.Parse(googleMeetLogTO.VideoReceiveLongSideMedian), MaxVideoReceptionPacketsLost = string.IsNullOrEmpty(googleMeetLogTO.VideoReceivePacketLossMax) ? 0 : int.Parse(googleMeetLogTO.VideoReceivePacketLossMax), VideoReceivePacketLossMax = string.IsNullOrEmpty(googleMeetLogTO.VideoReceivePacketLossMean) ? 0 : double.Parse(googleMeetLogTO.VideoReceivePacketLossMean), VideoReceiveDuration = string.IsNullOrEmpty(googleMeetLogTO.VideoReceiveDuration) ? 0 : int.Parse(googleMeetLogTO.VideoReceiveDuration), VideoReceiveShortSideMedian = string.IsNullOrEmpty(googleMeetLogTO.VideoReceiveShortSideMedian) ? 0 : int.Parse(googleMeetLogTO.VideoReceiveShortSideMedian), BitRatioVideoSending = string.IsNullOrEmpty(googleMeetLogTO.BitRatioVideoSending) ? 0 : double.Parse(googleMeetLogTO.BitRatioVideoSending), VideoSendFPSMean = string.IsNullOrEmpty(googleMeetLogTO.VideoSendFPSMean) ? 0 : double.Parse(googleMeetLogTO.VideoSendFPSMean), VideoSendLongSideMedian = string.IsNullOrEmpty(googleMeetLogTO.VideoSendLongSideMedian) ? 0 : int.Parse(googleMeetLogTO.VideoSendLongSideMedian), VideoSendPacketLossMax = string.IsNullOrEmpty(googleMeetLogTO.VideoSendPacketLossMax) ? 0 : int.Parse(googleMeetLogTO.VideoSendPacketLossMax), VideoSendDuration = string.IsNullOrEmpty(googleMeetLogTO.VideoSendDuration) ? 0 : int.Parse(googleMeetLogTO.VideoSendDuration), VideoSendShortSideMedian = string.IsNullOrEmpty(googleMeetLogTO.VideoSendShortSideMedian) ? 0 : int.Parse(googleMeetLogTO.VideoSendShortSideMedian), NetworkCongestionRatio = googleMeetLogTO.NetworkCongestionRatio, MeetingStartDate = googleMeetLogTO.MeetingStartDate.GetSafeString().ConvertGooogleMeetDataInDateTime(languageForDateString), EffectiveMeetingStartDate = string.IsNullOrEmpty(googleMeetLogTO.EffectiveMeetingStartDate) ? googleMeetLogTO.MeetingStartDate.GetSafeString().ConvertGooogleMeetDataInDateTime(languageForDateString) : googleMeetLogTO.EffectiveMeetingStartDate.ConvertGooogleMeetDataInDateTime(languageForDateString), MeetingEndDate = googleMeetLogTO.MeetingEndDate.GetSafeString().ConvertGooogleMeetDataInDateTime(languageForDateString), EffectiveMeetingEndDate = string.IsNullOrEmpty(googleMeetLogTO.EffectiveMeetingEndDate) ? googleMeetLogTO.MeetingEndDate.GetSafeString().ConvertGooogleMeetDataInDateTime(languageForDateString) : googleMeetLogTO.EffectiveMeetingEndDate.ConvertGooogleMeetDataInDateTime(languageForDateString), MeetingEnteringDate = googleMeetLogTO.MeetingEnteringDate.GetSafeString().ConvertGooogleMeetDataInDateTime(languageForDateString), TotalMeetingUserPartecipationInDecimal = string.IsNullOrEmpty(googleMeetLogTO.TotalMeetingUserPartecipationInDecimal) ? 0.0 : double.Parse(googleMeetLogTO.TotalMeetingUserPartecipationInDecimal), TotalMeetingUserPartecipationInSeconds = string.IsNullOrEmpty(googleMeetLogTO.TotalMeetingUserPartecipationInSeconds) ? 0.0 : double.Parse(googleMeetLogTO.TotalMeetingUserPartecipationInSeconds), TotalMeetingUserPartecipationInMinutes = string.IsNullOrEmpty(googleMeetLogTO.TotalMeetingUserPartecipationInMinutes) ? 0.0 : double.Parse(googleMeetLogTO.TotalMeetingUserPartecipationInMinutes), TotalMeetingUserPartecipationInHours = string.IsNullOrEmpty(googleMeetLogTO.TotalMeetingUserPartecipationInHours) ? new TimeSpan() : TimeSpan.Parse(googleMeetLogTO.TotalMeetingUserPartecipationInHours), TimeZone = googleMeetLogTO.TimeZone }); } catch (Exception ex) { throw new TransferException("Errore durante la conversione", ex); } }
/// <summary> /// Private method to get partecipant identifier /// </summary> /// <param name="log">The Log</param> /// <returns>The partecipant identifier</returns> private string getPartecipantLogIdentifier(IGoogleMeetLogTO log) { return(string.IsNullOrEmpty(log.PartecipantIdentifier) ? log.PartecipantName : log.PartecipantIdentifier); }
/// <summary> /// Private method to create key of treated log /// </summary> /// <param name="log">The Log</param> /// <returns>Log's key</returns> private string createLogkey(IGoogleMeetLogTO log) { return(log.Date + "_" + getPartecipantLogIdentifier(log) + "_" + log.ClientType); }