private void ParseTicketData()
 {
     // try to parse tickets userData
     if (string.IsNullOrEmpty(ticket.UserData))
     {
         return;
     }
     values.FillFromString(ticket.UserData);
 }
        private void ProcessScore(HttpContext context)
        {
            Interlocked.Increment(ref RequestCount);

            // GET RESPONSE
            ItemScoreResponse itemScoreResponse;

            // Get XML
            using (XmlReader reader = XmlReader.Create(context.Request.InputStream))
            {
                itemScoreResponse = HttpWebHelper.DeserializeXml <ItemScoreResponse>(reader);
                reader.Close();
            }

            // decrypt token
            string decryptedToken = EncryptionHelper.DecryptFromBase64(itemScoreResponse.Score.ContextToken);

            // get test data
            WebValueCollection tokenData = new WebValueCollection();

            tokenData.FillFromString(decryptedToken);

            // parse test data and collect up the information needed to persist this score
            ScoredResponse scoredResponse = new ScoredResponse
            {
                OppKey          = tokenData.Get <Guid>("oppKey"),
                ItemKey         = tokenData.Get("itemKey"),
                Position        = tokenData.Get <int>("position"),
                Sequence        = tokenData.Get <int>("sequence"),
                ScoreMark       = tokenData.Get <Guid>("scoremark"),
                Score           = itemScoreResponse.Score.ScoreInfo.Points,
                ScoreStatus     = itemScoreResponse.Score.ScoreInfo.Status.ToString(),
                ScoreRationale  = HttpWebHelper.SerializeXml(itemScoreResponse.Score.ScoreInfo),
                ScoreDimensions = GetDimensionsXmlForSP(itemScoreResponse.Score.ScoreInfo)
            };

            string hubDBIP     = tokenData.Get <String>("hubDBIP");
            string hubDBName   = tokenData.Get <String>("hubDBName");
            string clientName  = tokenData.Get <String>("clientName");
            string environment = tokenData.Get <String>("environment");

            // create function for submitting scores
            Action submitScore = delegate
            {
                Interlocked.Increment(ref ProgressCount);

                try
                {
                    // Save score to DB
                    IResponseRepository responseRepo = ServiceLocator.Resolve <IResponseRespositoryFactory>()
                                                       .Create(ScoringDaemonSettings.HubConnectionString(hubDBIP, hubDBName), clientName, environment);

                    if (responseRepo != null)
                    {
                        responseRepo.UpdateItemScore(scoredResponse);
                    }
                    else
                    {
                        // this is really unusual. We got a item score response for an unknown hub.
                        string errorMessage =
                            String.Format(
                                "Got a score response for a hub that we dont monitor. oppKey:{0}, itemKey: {1}, position: {2}, sequence:{3}, scoreMark: {4}, clientName: {5}, environment: {6}",
                                scoredResponse.OppKey, scoredResponse.ItemKey, scoredResponse.Position,
                                scoredResponse.Sequence, scoredResponse.ScoreMark, clientName, environment);
                        throw new InvalidDataException(errorMessage);
                    }
                }
                catch (Exception ex)
                {
                    Interlocked.Decrement(ref ProgressCount);
                    Interlocked.Increment(ref ErrorCount);

                    LastError = String.Format("{0} ({1})", ex.Message, DateTime.Now);
                    TDSLogger.Application.Error(new TraceLog("Item Scoring: Error submitting callback score.", ex));

                    return;
                }

                Interlocked.Decrement(ref ProgressCount);
                Interlocked.Increment(ref SuccessCount);
            };

            // check if thread pooling is enabled for callbacks
            if (WorkerPool != null)
            {
                // async
                if (!WorkerPool.Enqueue(submitScore))
                {
                    Interlocked.Increment(ref RejectCount);
                }
            }
            else
            {
                // sync
                submitScore();
            }
        }