Scoring
Verified against source (11)
score/Score.csscore/ScoreItem.csscore/Enumerations.csInterfaces/IScore.csEngines/AbstractEngine.csEngines/ApiEngine.csConfig/Score.configConfig/ScoreEngine.configExtensions/ScoreExtensions.csqbo4.AI.Bridge/AIScoreEngine.csExtensions/ImportFileExtensions.cs
Scores are Score records created from a ScoreTemplate, with one ScoreItem per ScoreItemTemplate. Operations follow the standard route pattern:
/api/score/{operation}runs synchronously on the web server./api/score/queue/{operation}queues the operation for an app server. Use it for AI extraction, Excel models, and anything slow.
Classes and interfaces
Section titled “Classes and interfaces”| Type | Purpose |
|---|---|
ScoreTemplate |
ScoreEngine, Method (data source), ValueType, EngineParameters, RenderID, Repeatable; AppliesTo maps to Object. |
ScoreItemTemplate |
ScoreItemTemplate (name), ValueType, Prompt, Enumeration, Weight, Sequence, Label, Mask, UnmaskPermission, XPath. |
Score |
One calculation, bound to a record by Object / ObjectID, with typed value columns, Confidence, and RenderID (output workbook). |
ScoreItem |
One value, with typed columns, Confidence, and ChildScoreID. |
IScore |
Engine contract: Calculate(object data, ScoreObject score), CreateTemplate, GetItems. |
AbstractEngine |
Base engine that dispatches on the data type: IDataReader, XmlReader, DataSet, a record (AbstractObject), or none. |
Typed values
Section titled “Typed values”ValueType decides which column holds the value, on both Score and ScoreItem:
ValueType |
Value | Column |
|---|---|---|
Money |
0 | ScoreMoney |
Int |
1 | ScoreInt |
Float |
2 | ScoreFloat |
Boolean |
3 | ScoreBoolean |
String |
4 | ScoreChar |
Date |
5 | ScoreDate |
Enumerated |
6 | ScoreChar |
Calculate a score
Section titled “Calculate a score”GET /api/score/calculate?Template=Application Risk&Object=Contact&ObjectID=42QBO finds or creates the score for that record (following the template’s Repeatable setting), gets the input data, runs the engine, and saves the score and its items. The input depends on ScoreTemplate.Method:
Method |
Engine receives |
|---|---|
A method signature (for example Contact/Summary?ID={ObjectID}) |
The method’s result, with substitution from the score and the request. |
Parameters |
The request parameters, as XML. |
| Empty | The parent record (Object / ObjectID). |
Recalculate an existing score, or queue the work:
GET /api/score/calculate?ID=310GET /api/score/queue/calculate?Template=Application Risk&Object=Contact&ObjectID=42savecalculate saves the supplied properties as a new score and calculates it in one call.
Extract data from a document
Section titled “Extract data from a document”Bind the score to the document. AI and text-parsing engines read documents (Attachment) and messages (Message):
GET /api/score/queue/calculate?Template=Invoice Fields&Object=Attachment&ObjectID=5678The AI engine converts the document to text (stored in Attachment.Description for reuse) unless text already exists, sends each item’s Prompt and type to the model, and saves values and confidences.
Set values directly
Section titled “Set values directly”Score binds request parameters whose names match an item’s safe name to that item, creating missing items from the template. ApiEngine relies on this: any column in the method’s first row (or XML from the method) that matches the score or an item is saved.
POST /api/score/save?Template=Order Stats&Object=Contact&ObjectID=42&OpenOrders=3&LateOrders=1Confidence
Section titled “Confidence”The score’s Confidence is the weighted average of its items’ confidences, using ScoreItemTemplate.Weight (null counts as 1). Recompute it for existing scores with:
GET /api/score/calculateconfidence?ID=310,311Score in batches
Section titled “Score in batches”Upload a spreadsheet as a document and score each row through the import pipeline:
GET /api/importfile/scorecalculatebatch?Attachment=Applications.xlsx&AttachmentID=5678&ImportFileTemplate=Application RiskEach row becomes a queued Score/Calculate call, tracked as an import row item. See Imports.
Analyze results
Section titled “Analyze results”GET /api/score/pivotbytemplate?Template=Invoice FieldsReturns one row per score with a column per item and a matching {Item}Confidence column (safe names by default; pass SafeName=false to keep the original names). analyzebyobject and analyzebytemplate join item values to the scored records for reporting.
Write an engine
Section titled “Write an engine”Derive from AbstractEngine, override the CalculateAsync overload for the data your engine accepts, set values with ScoreItem.SetValue (which writes the typed column), and register the class by name in ScoreEngine.config:
<Engine Name="Matrix" Type="qbo.Score.Engines.MatrixEngine, qbo.Score" />