The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Reporting.cs 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Teknik.Configuration;
  8. namespace Teknik.Tracking
  9. {
  10. public static class Reporting
  11. {
  12. public static List<VisitorData> GetVisitSummaryByDays(Config config, int days)
  13. {
  14. List<VisitorData> visitorData = new List<VisitorData>();
  15. try
  16. {
  17. if (config.PiwikConfig.Enabled)
  18. {
  19. //PiwikAnalytics.URL = config.PiwikConfig.API;
  20. //VisitsSummary visitSummary = new VisitsSummary();
  21. //visitSummary.setTokenAuth(config.PiwikConfig.TokenAuth);
  22. //Hashtable results = visitSummary.Get(
  23. // config.PiwikConfig.SiteId,
  24. // PiwikPeriod.DAY,
  25. // RelativeRangeDate.LAST(days)
  26. // );
  27. //foreach (string period in results.Keys)
  28. //{
  29. // // Create a new object to return
  30. // VisitorData data = new VisitorData();
  31. // // Set Period Date
  32. // DateTime date = new DateTime(1900, 1, 1);
  33. // DateTime.TryParse(period, out date);
  34. // data.Date = date;
  35. // // Pull Out Data
  36. // if (results[period].GetType() == typeof(Hashtable))
  37. // {
  38. // Hashtable result = (Hashtable) results[period];
  39. // int UniqueVisitors = 0;
  40. // int.TryParse(result["nb_uniq_visitors"].ToString(), out UniqueVisitors);
  41. // data.UniqueVisitors = UniqueVisitors;
  42. // int visits = 0;
  43. // int.TryParse(result[VisitsSummary.NB_VISITS].ToString(), out visits);
  44. // data.Visits = visits;
  45. // int VisitsConverted = 0;
  46. // int.TryParse(result[VisitsSummary.NB_VISITS_CONVERTED].ToString(), out VisitsConverted);
  47. // data.VisitsConverted = VisitsConverted;
  48. // int Actions = 0;
  49. // int.TryParse(result[VisitsSummary.NB_ACTIONS].ToString(), out Actions);
  50. // data.Actions = Actions;
  51. // decimal ActionsPerVisit = 0;
  52. // decimal.TryParse(result[VisitsSummary.NB_ACTIONS_PER_VISIT].ToString(), out ActionsPerVisit);
  53. // data.ActionsPerVisit = ActionsPerVisit;
  54. // int MaxActions = 0;
  55. // int.TryParse(result[VisitsSummary.MAX_ACTIONS].ToString(), out MaxActions);
  56. // data.MaxActions = MaxActions;
  57. // int BounceCount = 0;
  58. // int.TryParse(result[VisitsSummary.BOUNCE_COUNT].ToString(), out BounceCount);
  59. // data.BounceCount = BounceCount;
  60. // data.BounceRate = result[VisitsSummary.BOUNCE_RATE].ToString();
  61. // int AverageTimeOnSite = 0;
  62. // int.TryParse(result[VisitsSummary.AVG_TIME_ON_SITE].ToString(), out AverageTimeOnSite);
  63. // data.AverageTimeOnSite = AverageTimeOnSite;
  64. // int VisitLengthTotal = 0;
  65. // int.TryParse(result[VisitsSummary.SUM_VISIT_LENGTH].ToString(), out VisitLengthTotal);
  66. // data.VisitLengthTotal = VisitLengthTotal;
  67. // }
  68. // visitorData.Add(data);
  69. //}
  70. }
  71. }
  72. catch (Exception)
  73. {
  74. }
  75. return visitorData;
  76. }
  77. }
  78. }