6 votes
uCounters
** This package is for Umbraco 4.7+ running on .net 4+ **
uCounters allows the creation of thread safe counters via the Umbraco dashboard - these counters can then be manipulated by an API. Usages include - Generating unique IDs, invoice numbers and basic stock level tracking.
uCounters ships with example Macros that demonstrate counter manipulation via XSLT, Razor, .net UserControl and Ajax - using jQuery.
Each counter has the following properties:
- Key
- Direction - Increment or Decrement
- Initial Value
- Limit
The counters can be Manipulated using the following API methods:
- int Value(string key) - Current value of the counter
- string Step(string key, int amount) - Increment/Decrement the counter
- XPathNodeIterator StepXml(string key, int amount) - Increment/Decrement the counter
The Step method will return an object (JSON or XML) indicating whether the change to the counter was successful and the new value of the counter. The methods above are exposed via
- FergusonMoriyama.Umbraco.Counters.Umbraco.Extension
The extension class is decorated with the following attributes (which make it accessible via XSLT and base)
- [XsltExtension("Counters")]
- [RestExtension("Counters")]
Further to the above api methods you can access the counter service to perform additional operations:
FergusonMoriyama.Umbraco.Counters.Helpers.Instance.Service returns an ICounterService which provides the following additional methods:
- void Remove(string key);
- void Create(string key, Direction direction, int initialValue, int limit);
- void Reset(string key);
- IEnumerable<string> Keys { get; }
Counters are persisted across app pool recycles. Access to Step operations are thread safe.
Counter state can also be manipulated by directly modifying ~/App_Data/counters.coonfig and recycling the app.
- Package Files
- Documentation
- Archived Files