/// <summary> /// Constructor /// </summary> /// <param name="queryData">Query data</param> /// <param name="filedsMap">The mapped set of Context model fields and Google Analytics fields</param> /// <param name="expression">Delegate which will be invoked to create the instance of the Result object</param> internal SelectedDataContext(QueryData queryData, FieldsMap filedsMap, Func <ContextDataModel, T> expression) { _expression = expression; _fieldsMap = filedsMap; _queryData = queryData; }
/// <summary> /// Constructor /// </summary> /// <param name="queryData">Query data object</param> public CreatedDataContext(QueryData queryData) { _queryData = queryData; }
/// <summary> /// Constructor /// </summary> /// <param name="profileId">Google analytics profile ID</param> /// <param name="service">AnalyticsService object</param> public DataContext(string profileId, AnalyticsService service) { _queryData = new QueryData() { ProfileId = profileId, Service = service }; }
private Google.Apis.Analytics.v3.DataResource.GaResource.GetRequest getRequest(QueryData queryData) { string metrics = string.Join(",", queryData.Metrics); string dimensions = string.Join(",", queryData.Dimensions); string sort = string.Join(",", queryData.SortingFields); string filter = string.Join(";", queryData.Filters); string segment = null; if (queryData.SegmentId != null) { segment = "gaid::" + queryData.SegmentId; } else { segment = string.Join(";", queryData.DynamicSegments); } try { var request = queryData.Service.Data.Ga.Get(queryData.ProfileId, queryData.From.ToString("yyyy-MM-dd"), queryData.To.ToString("yyyy-MM-dd"), metrics); request.Dimensions = dimensions; request.Sort = sort; request.Filters = filter; request.StartIndex = queryData.Skip; request.MaxResults = queryData.Take; request.Segment = segment; return(request); } catch (Exception ex) { var requestExceprion = new GoogleAnalyticsRequestException("Can't get request", ex); throw requestExceprion; } }