C# Класс ActivEarth.Server.Service.Competition.ChallengeManager

Serves as a wrapper class for the ChallengeDAO class, further abstracting actions.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
CleanUp ( ) : void

Cleans up the challenge list, moving expired transient challenges to the archive and refreshing persistent challenges. Should be called daily at the challenge cutoff time.

CreateChallenge ( string name, string description, int points, bool persistent, System.DateTime start, int durationInDays, Statistic statistic, float requirement ) : int

Creates a new Challenge and adds it to the collection.

GenerateNewChallenges ( ) : void

Creates new challenges such that the correct number of each type of challenge (daily, weekly, monthly) are active.

GetChallenge ( int id, int userId ) : Challenge

Retrieves an active challenge based on its ID.

GetFormattedProgress ( int challengeId, int userId ) : string

Returns the formatted text progress report for the Challenge (e.g., "34.5 / 40.0").

GetProgress ( int challengeId, int userId ) : int

Gets the progress made by a user in the challenge as a percentage (0-100).

InitializeUser ( int challengeId, int userId ) : void

Sets a user's initial value for a challenge (to allow calculation of the user's delta from the beginning of the challenge).

IsComplete ( int challengeId, int userId ) : bool

Returns true if the user has met the requirements to complete the challenge, false otherwise.

Приватные методы

Метод Описание
ChallengeManager ( ) : System

Private constructor, can't instantiate class.

Описание методов

CleanUp() публичный статический Метод

Cleans up the challenge list, moving expired transient challenges to the archive and refreshing persistent challenges. Should be called daily at the challenge cutoff time.
public static CleanUp ( ) : void
Результат void

CreateChallenge() публичный статический Метод

Creates a new Challenge and adds it to the collection.
public static CreateChallenge ( string name, string description, int points, bool persistent, System.DateTime start, int durationInDays, Statistic statistic, float requirement ) : int
name string Challenge Name.
description string Challenge Description.
points int Points to be awarded upon completion of the Challenge.
persistent bool True if the Challenge is persistent, false otherwise.
start System.DateTime Time at which the challenge should begin.
durationInDays int Number of days that the challenge should be active.
statistic Statistic Statistic on which the Challenge is based.
requirement float Statistic value required to complete the challenge.
Результат int

GenerateNewChallenges() публичный статический Метод

Creates new challenges such that the correct number of each type of challenge (daily, weekly, monthly) are active.
public static GenerateNewChallenges ( ) : void
Результат void

GetChallenge() публичный статический Метод

Retrieves an active challenge based on its ID.
public static GetChallenge ( int id, int userId ) : Challenge
id int ID of the Challenge to be retrieved.
userId int Optional. UserID to load progress from.
Результат ActivEarth.Objects.Competition.Challenges.Challenge

GetFormattedProgress() публичный статический Метод

Returns the formatted text progress report for the Challenge (e.g., "34.5 / 40.0").
public static GetFormattedProgress ( int challengeId, int userId ) : string
challengeId int Challenge to report progress for.
userId int User to evaluate.
Результат string

GetProgress() публичный статический Метод

Gets the progress made by a user in the challenge as a percentage (0-100).
public static GetProgress ( int challengeId, int userId ) : int
challengeId int The challenge to evaluate progress for.
userId int The user to evaluate.
Результат int

InitializeUser() публичный статический Метод

Sets a user's initial value for a challenge (to allow calculation of the user's delta from the beginning of the challenge).
public static InitializeUser ( int challengeId, int userId ) : void
challengeId int
userId int
Результат void

IsComplete() публичный статический Метод

Returns true if the user has met the requirements to complete the challenge, false otherwise.
public static IsComplete ( int challengeId, int userId ) : bool
challengeId int Challenge to test for completion.
userId int User to evaluate.
Результат bool