Example #1
0
        public ExecutingQuery(long queryId, ClientConnectionInfo clientConnection, string username, string queryText, MapValue queryParameters, IDictionary <string, object> transactionAnnotationData, System.Func <long> activeLockCount, PageCursorCounters pageCursorCounters, long threadExecutingTheQueryId, string threadExecutingTheQueryName, SystemNanoClock clock, CpuClock cpuClock, HeapAllocation heapAllocation)
        {
            if (!InstanceFieldsInitialized)
            {
                InitializeInstanceFields();
                InstanceFieldsInitialized = true;
            }
            // Capture timestamps first
            this._cpuTimeNanosWhenQueryStarted = cpuClock.CpuTimeNanos(threadExecutingTheQueryId);
            this._startTimeNanos       = clock.Nanos();
            this._startTimestampMillis = clock.Millis();
            // then continue with assigning fields
            this._queryId            = queryId;
            this._clientConnection   = clientConnection;
            this._pageCursorCounters = pageCursorCounters;
            this._username           = username;

            ISet <string> passwordParams = new HashSet <string>();

            this._queryText                   = QueryObfuscation.ObfuscateText(queryText, passwordParams);
            this._queryParameters             = QueryObfuscation.ObfuscateParams(queryParameters, passwordParams);
            this._transactionAnnotationData   = transactionAnnotationData;
            this._activeLockCount             = activeLockCount;
            this._initialActiveLocks          = activeLockCount();
            this._threadExecutingTheQueryId   = threadExecutingTheQueryId;
            this._threadExecutingTheQueryName = threadExecutingTheQueryName;
            this._cpuClock       = cpuClock;
            this._heapAllocation = heapAllocation;
            this._clock          = clock;
            this._heapAllocatedBytesWhenQueryStarted = heapAllocation.AllocatedBytes(this._threadExecutingTheQueryId);
        }
        private void SetValueForExamWorkSheet(byte[] value, IExamInfo examInfo)
        {
            CpuClock c = new CpuClock();

            try
            {
                using (_workSheetsOnExam.LockOnCollectionChanged())
                {
                    using (_fetalBPSInfoNodes.LockOnCollectionChanged())
                    {
                        _fetalBPSInfoNodes.Clear();
                        _workSheetsOnExam.Clear();
                        try
                        {
                            if (value != null && value.Length > 0)
                            {
                                ScanNodeContext context = new ScanNodeContext((ExamInfo)examInfo);

                                var extensibleData = ExtensibleData.DeSerialize(value, context);
                                if (extensibleData != null)
                                {
                                    _fetalBPSInfoNodes.AddRange(extensibleData.BpsNodes);
                                    _workSheetsOnExam.AddRange(extensibleData.ScanNodes);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            _workSheetsOnExam.Clear();
                            _fetalBPSInfoNodes.Clear();
                            Logger.WriteLineError("Failed to parse ExtensibleData value, details:{0}.", ex);
                        }
                    }
                }
            }
            finally
            {
                if (c.TotalMilliSeconds >= 500)
                {
                    Logger.WriteLineError("ExamInfo.SetWorkSheetsXml spent {0:F2} ms", c.TotalMilliSeconds);
                }
            }
        }