public bool IsVisitorInSegment(string visitorId, Models.Segment segment) { var umbracoContext = umbracoContextAccessor(); var httpContext = umbracoContext.HttpContext; var request = httpContext.Request; var properties = new Dictionary <string, object> { { NcbtPropertyPrefix + "isMobile", request.Browser.IsMobileDevice }, { NcbtPropertyPrefix + "platform", request.Browser.Platform }, { NcbtPropertyPrefix + "browser", request.Browser.Browser }, { NcbtPropertyPrefix + "userAgent", request.UserAgent }, { NcbtPropertyPrefix + "userIp", GetClientIp(request) }, { NcbtPropertyPrefix + "userDnsName", request.UserHostName }, { NcbtPropertyPrefix + "queryString", request.Url?.Query }, { NcbtPropertyPrefix + "httpReferrer", request.UrlReferrer?.AbsoluteUri ?? "" } }; if (request.Browser.IsMobileDevice) { properties.Add(NcbtPropertyPrefix + "mobileDeviceManufacturer", request.Browser.MobileDeviceManufacturer); properties.Add(NcbtPropertyPrefix + "mobileDeviceModel", request.Browser.MobileDeviceModel); } if (umbracoContext.PageId.HasValue) { properties.Add(NcbtPropertyPrefix + "pageId", UmbracoContext.Current.PageId); } return(segment.Match(properties)); }
public void SaveSegment(string segname, int segID, string array, string polyline, string latlng, int priv, string location) { var DataContext = new DataClasses1DataContext(); var segct = from u in DataContext.Segments where u.SegmentID == segID select u; if (segct.Count() > 0 && priv != 1) { var sc = db.Segments .Where(s => s.SegmentID == segID) .First(); sc.Location = location; db.SubmitChanges(); } else { //save new Segment segnew = new Models.Segment(); segnew.SegmentID = segID; segnew.SegmentName = segname; segnew.BearingArray = array; segnew.Polyline = polyline; segnew.latlng = latlng; segnew.PrivateSeg = priv; datarepo.Add(segnew); datarepo.Save(); } }
public void SaveSegment(string segname, int segID, string array, string polyline, string latlng, int priv, string location) { var DataContext = new DataClasses1DataContext(); var segct = from u in DataContext.Segments where u.SegmentID == segID select u; if (segct.Count() > 0 && priv != 1) { var sc = db.Segments .Where(s => s.SegmentID == segID) .First(); sc.Location = location; db.SubmitChanges(); } else { //save new Segment segnew = new Models.Segment(); segnew.SegmentID = segID; segnew.SegmentName = segname; segnew.BearingArray = array; segnew.Polyline = polyline; segnew.latlng = latlng; segnew.PrivateSeg = priv; datarepo.Add(segnew); datarepo.Save(); } }