예제 #1
0
        public string DecryptIp(ClientIPData clientIp, IPAddressDecryptor ipDecryptor)
        {
            if (!String.IsNullOrWhiteSpace(clientIp.EncryptedIP))
            {
                var ip = ipDecryptor.DecryptIP(
                    clientIp.KeyParty,
                    clientIp.KeyAlgorithm,
                    clientIp.KeyVersion,
                    clientIp.IV,
                    clientIp.EncryptedIP,
                    format: IPFormat.IPv4);

                if (!String.IsNullOrWhiteSpace(ip))
                {
                    return(ip);
                }
            }

            if (!String.IsNullOrWhiteSpace(clientIp.EncryptedIPv6))
            {
                return(ipDecryptor.DecryptIP(
                           clientIp.KeyParty,
                           clientIp.KeyAlgorithm,
                           clientIp.KeyVersion,
                           clientIp.IV,
                           clientIp.EncryptedIPv6,
                           format: IPFormat.IPv6));
            }

            return(null);
        }
예제 #2
0
        public IEnumerable <string> GetData(KeyValuePair <string, string> line)
        {
            var uetLogsWithSameUAIPTag = line.Value.Split(new char[] { delimeter }, StringSplitOptions.RemoveEmptyEntries);
            //List<string> output = new List<string>();
            var          eventGroups  = new Dictionary <string, List <UETEvent> >();
            var          firstRow     = true;
            ClientIPData clientIP     = null;
            var          visitization = new VisitizationSchema();

            foreach (var uetLogStr in uetLogsWithSameUAIPTag)
            {
                var uetLog = UETLogView.Deserialize(uetLogStr);
                if (uetLog == null)
                {
                    continue;
                }
                if (firstRow)
                {
                    visitization.UAIPId  = uetLog.UAIPId;
                    visitization.TagId   = uetLog.TagId;
                    visitization.TagName = uetLog.TagName;
                    //visitization.UserAgent = uetLog.UserAgent;  //why UserAgent is needed in the Original VisitizationReducer

                    clientIP = uetLog.ClientIP;
                    firstRow = false;
                }
                var anid            = uetLog.ANID;
                var muid            = uetLog.MUID;
                var isNewMuid       = uetLog.IsNewMUID;
                var analyticsGuid   = uetLog.AnalyticsGuid;
                var uetMatchingGuid = uetLog.UETMatchingGuid;

                var currentUetEvent = new UETEvent();
                currentUetEvent.EventDateTime    = uetLog.EventDateTime;
                currentUetEvent.ANID             = (!anid.HasValue) ? null : new GUID(anid.Value);
                currentUetEvent.MUID             = (!muid.HasValue) ? null : new GUID(muid.Value);
                currentUetEvent.IsNewMUID        = isNewMuid;
                currentUetEvent.ReferrerURL      = uetLog.ReferrerURL;
                currentUetEvent.PageTitle        = uetLog.PageTitle;
                currentUetEvent.customEvent      = uetLog.customEvent;
                currentUetEvent.NavigatedFromURL = uetLog.NavigatedFromURL;
                currentUetEvent.GoalValue        = uetLog.GoalValue;
                currentUetEvent.PageLoad         = uetLog.PageLoad;
                currentUetEvent.Version          = uetLog.Version;
                currentUetEvent.LogServerName    = uetLog.LogServerName;
                currentUetEvent.EventType        = uetLog.EventType;
                currentUetEvent.AnalyticsGuid    = (!analyticsGuid.HasValue) ? null : new GUID(analyticsGuid.Value);
                currentUetEvent.UETMatchingGuid  = (!uetMatchingGuid.HasValue) ? null : new GUID(uetMatchingGuid.Value);

                AddToEventGroups(eventGroups, anid, muid, isNewMuid, currentUetEvent);
            }
            List <UETEvent> newMuidsList;

            if (eventGroups.TryGetValue(GroupKeyNewMuids, out newMuidsList))
            {
                var eventsToBeRemoved = new List <UETEvent>();

                foreach (var uetEvent in newMuidsList)
                {
                    List <UETEvent> events;
                    if (eventGroups.TryGetValue(uetEvent.MUID.ToSystemGuid().ToString(), out events))
                    {
                        eventsToBeRemoved.Add(uetEvent);
                        events.Insert(0, uetEvent);
                    }
                }

                foreach (var ev in eventsToBeRemoved)
                {
                    newMuidsList.Remove(ev);
                }
            }
            foreach (var eventGroup in eventGroups)
            {
                // Build the Visit List from the event groups
                var events = eventGroup.Value;
                if (events.Count > 0)
                {
                    var factObject = BuildVisitEventGroupFromEventsList(sessionTimeoutThreshold, endOfDelta, events, maxEventsPerVisit, maxVisitsPerIPTag);
                    if (factObject.Visits.Count > 0)
                    {
                        factObject.ClientIP = clientIP;

                        var firstEvent = events[0];
                        factObject.ANID      = firstEvent.ANID;
                        factObject.MUID      = firstEvent.MUID;
                        factObject.IsNewMUID = firstEvent.IsNewMUID;

                        visitization.AnalyticsGuid = firstEvent.AnalyticsGuid == null ? (Guid?)null : firstEvent.AnalyticsGuid.ToSystemGuid();

                        FixCustomGoalValues(factObject);
                        visitization.SAEventConversionFactsRow = factObject;
                        yield return(VisitizationSchema.Serialize(visitization));
                        //output.Add(VisitizationSchema.Serialize(visitization));
                    }
                }
            }
            //return output;
        }