public Engagement(Traffic trafficParameter, string ip, int percentage, string engagementMode, string engagementGoals)
 {
     this.IP = ip;
     this.TrafficParameter = trafficParameter;
     this.Percentage = percentage;
     this.Mode = this.GetMode(engagementMode);
     this.SpecificGoalNames = StringOperations.SplitStringToEnumerable(engagementGoals, ',');
 }
 public RequestSource(Traffic trafficParameter, Item itemInstance, string urlReferrer, string campaign,
     string trafficType, string keyword, int numberOfRequests, bool trafficInSameSession, string trafficMode, string trafficUrls)
 {
     this.TrafficParameter = trafficParameter;
     this.ItemInstance = itemInstance;
     this.UrlReferrer = urlReferrer;
     this.Campaign = campaign;
     this.TrafficType = trafficType;
     this.Keyword = keyword;
     this.NumberOfRequests = numberOfRequests;
     this.TrafficInSameSession = trafficInSameSession;
     this.Mode = this.GetTrafficMode(trafficMode);
     this.Urls = StringOperations.SplitStringToEnumerable(trafficUrls, ',');
 }
        public List<Traffic> GetTrafficParameters(StreamReader sr)
        {
            List<Traffic> trafficParameters = new List<Traffic>();

            int lineNumber = 0;
            // 2. Read through file
            while (sr.Peek() >= 0)
            {
                string line = sr.ReadLine();

                // 3. Skip first line, as this contains headers only
                if (lineNumber > 0)
                {
                    string[] columns = line.Split(';');

                    if (columns.Length > 0)
                    {
                        var urlReferrer = columns[0];
                        var ip = columns[1];

                        // 4. Skip empty file lines
                        if (!String.IsNullOrEmpty(ip) && StringOperations.IsIP(ip, true) && columns.Length >= 11)
                        {
                            var trafficType = columns[2];
                            var campaign = columns[3] != "-" ? columns[3].Trim().Replace("\"", "") : string.Empty;
                            var keyword = columns[4] != "-" ? columns[4].Trim().Replace("\"", "") : string.Empty;
                            var dateFrom = columns[5] != "-" ? columns[5].Trim().Replace("\"", "") : string.Empty;
                            var dateTo = columns[6] != "-" ? columns[6].Trim().Replace("\"", "") : string.Empty;

                            int numberOfRequests = 0;
                            Int32.TryParse(columns[7], out numberOfRequests);

                            bool trafficInSameSession = false;
                            Boolean.TryParse(columns[8], out trafficInSameSession);

                            var trafficMode = columns[9] != "-" ? columns[9].Trim().Replace("\"","") : string.Empty;
                            var trafficUrls = columns[10] != "-" ? columns[10].Trim().Replace("\"", "") : string.Empty;

                            var engagementPercentage = 0;
                            Int32.TryParse(columns[11], out engagementPercentage);

                            var engagementType = columns[12] != "-" ? columns[12].Trim().Replace("\"", "") : string.Empty;
                            var engagementGoals = columns[13] != "-" ? columns[13].Trim().Replace("\"", "") : string.Empty;

                            // 5. Create Object Representation
                            Traffic trafficParameter = new Traffic(
                                Sitecore.Context.Item,
                                urlReferrer,
                                ip,
                                dateFrom,
                                dateTo,
                                campaign,
                                trafficType, keyword, numberOfRequests, trafficInSameSession, trafficMode, trafficUrls,
                                engagementPercentage, engagementType, engagementGoals
                                );

                            trafficParameters.Add(trafficParameter);
                        }
                    }
                }

                lineNumber++;
            }

            return trafficParameters;
        }
 public DateRange(Traffic trafficParameter, string dateFrom, string dateTo)
 {
     this.TrafficParameter = trafficParameter;
     this.DateFrom = this.ConvertToDateTime(dateFrom, DateTime.Now.AddMonths(-1));
     this.DateTo = this.ConvertToDateTime(dateTo, DateTime.Now);
 }