示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Stress Points Generator");

            DateTime defaultStartDate = new DateTime(2017, 8, 1);

            ProgramConfig config = JsonConvert.DeserializeObject <ProgramConfig>(File.ReadAllText(Path.Combine("conf", "config.json")));

            // Athlete parameters
            AthleteConfig athleteConfig = config.athlete;

            // Strava token
            string stravaToken = config.strava.token;

            // Configuration for Google Sheet
            string            googleAppName = config.google.appName;
            string            sheetId       = config.google.sheetId;
            GoogleSheetOutput output        = new GoogleSheetOutput(googleAppName, sheetId);

            // Try get last date from google sheet data
            DateTime?startDate = output.GetLastDate() ?? defaultStartDate;

            PointsGenerator generator = new PointsGenerator.Builder()
                                        .WithAthleteConfig(athleteConfig)
                                        .WithStravaToken(stravaToken)
                                        .WithOutput(output)
                                        .WithStartDate(startDate.Value)
                                        .Build();

            generator.Run();

            Console.WriteLine("Finished!");
            Console.ReadLine();
        }
        public PointsGenerator(Builder builder)
        {
            this.athleteConfig = builder.AthleteConfig;
            this.output        = builder.Output;
            this.startDate     = builder.StartDate;
            this.activityId    = builder.ActivityId;

            string            accessToken   = builder.StravaToken;
            TestAuthenticator authenticator = new TestAuthenticator(accessToken);

            stravaClient = new Client(authenticator);
        }
 public Builder WithAthleteConfig(AthleteConfig config)
 {
     this.AthleteConfig = config;
     return(this);
 }