private void LogError(string error)
 {
     if (_errorStore != null)
     {
         lock (_lockErrorType)
         {
             _errorStore.ReportError(error, _errorType, ErrorSeverity.Warning);
         }
     }
 }
        public IEnumerable <IPropertyBag> GetEventsForUpload()
        {
            lock (_lockActionIdToPropertyBag)
            {
                var keysToRemove = new List <string>();
                var retval       = new List <PropertyBag>();

                foreach (var kvp in _actionIdToPropertyBag)
                {
                    var propertyBag = kvp.Value;

                    if (!propertyBag.ReadyForUpload)
                    {
                        var contents = propertyBag.GetContents();
                        if (!contents.Int64Properties.TryGetValue(ActionPropertyNames.StartTimeConstStrKey, out long startTime))
                        {
                            _errorStore.ReportError("No start time on action", ErrorType.Action, ErrorSeverity.LibraryError);
                            continue;
                        }

                        long currentTimeInMs = DateTimeUtils.GetMillisecondsSinceEpoch(DateTime.UtcNow);
                        long durationInMs    = currentTimeInMs - startTime;

                        if (propertyBag.IsAggregable && durationInMs > _maxActionDurationMillis)
                        {
                            propertyBag.ReadyForUpload = true;
                        }
                        else if (durationInMs > _maxAggregationDurationMillis)  // todo: report bug in C++ code where they're doing microseconds around this value instead of milliseconds
                        {
                            propertyBag.Add(ActionPropertyNames.EndTimeConstStrKey, currentTimeInMs);
                            propertyBag.Add(ActionPropertyNames.OutcomeConstStrKey, MatsConverter.AsString(AuthOutcome.Incomplete));
                            propertyBag.ReadyForUpload = true;
                        }
                        else
                        {
                            // not ready for upload...
                            continue;
                        }
                    }

                    retval.Add(kvp.Value);
                    keysToRemove.Add(kvp.Key);
                }

                foreach (string key in keysToRemove)
                {
                    _actionIdToPropertyBag.Remove(key);
                }

                return(retval);
            }
        }
 private void ReportError(string errorMessage, ErrorType errorType, ErrorSeverity errorSeverity)
 {
     _errorStore.ReportError(errorMessage, errorType, errorSeverity);
 }