Skip to content

Scoring

Verified against source (11)

  • score/Score.cs
  • score/ScoreItem.cs
  • score/Enumerations.cs
  • Interfaces/IScore.cs
  • Engines/AbstractEngine.cs
  • Engines/ApiEngine.cs
  • Config/Score.config
  • Config/ScoreEngine.config
  • Extensions/ScoreExtensions.cs
  • qbo4.AI.Bridge/AIScoreEngine.cs
  • Extensions/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.
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.

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
GET /api/score/calculate?Template=Application Risk&Object=Contact&ObjectID=42

QBO 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=310
GET /api/score/queue/calculate?Template=Application Risk&Object=Contact&ObjectID=42

savecalculate saves the supplied properties as a new score and calculates it in one call.

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=5678

The 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.

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=1

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,311

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 Risk

Each row becomes a queued Score/Calculate call, tracked as an import row item. See Imports.

GET /api/score/pivotbytemplate?Template=Invoice Fields

Returns 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.

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" />