Пример #1
0
 public IGoogleAnalyticsRequestConfigurerDateRange WithProfileId(string value)
 {
     ProfileId = GaMetadata.RemovePrefix(value);
     return(this);
 }
Пример #2
0
        private DataTable ToDataTable(GaData response, string name = "GA")
        {
            var requestResultTable = new DataTable(name);

            if (response != null)
            {
                requestResultTable.Columns.AddRange(response.ColumnHeaders.Select(c => new DataColumn(GaMetadata.RemovePrefix(c.Name), GetDataType(c))).ToArray());

                if (response.Rows != null)
                {
                    foreach (var row in response.Rows)
                    {
                        var dtRow = requestResultTable.NewRow();

                        for (var idx = 0; idx != requestResultTable.Columns.Count; idx++)
                        {
                            var col = requestResultTable.Columns[idx];
                            if (col.DataType == typeof(DateTime))
                            {
                                dtRow.SetField(col,
                                               DateTime.ParseExact(row[idx], "yyyyMMdd", new DateTimeFormatInfo(),
                                                                   DateTimeStyles.AssumeLocal));
                            }
                            else
                            {
                                dtRow.SetField(col, row[idx]);
                            }
                        }
                        requestResultTable.Rows.Add(dtRow);
                    }
                }
                requestResultTable.AcceptChanges();
            }
            return(requestResultTable);
        }