private void updateSendLoadResult(ref EsasSyncResult syncResult, EsasSendResult iterativeDeliveryResult)
 {
     if (syncResult.esasSendResult.SendStartTimeUTC == null)
     {
         syncResult.esasSendResult = new EsasSendResult()
         {
             SendDestinationStrategyName = iterativeDeliveryResult.SendDestinationStrategyName,
             SendStartTimeUTC            = iterativeDeliveryResult.SendStartTimeUTC,
             SendEndTimeUTC          = iterativeDeliveryResult.SendEndTimeUTC,
             SendTimeMs              = iterativeDeliveryResult.SendTimeMs,
             SendToDestinationStatus = iterativeDeliveryResult.SendToDestinationStatus
         };
     }
     else
     {
         syncResult.esasSendResult.SendEndTimeUTC          = iterativeDeliveryResult.SendEndTimeUTC;
         syncResult.esasSendResult.SendTimeMs             += iterativeDeliveryResult.SendTimeMs;
         syncResult.esasSendResult.SendToDestinationStatus = iterativeDeliveryResult.SendToDestinationStatus;
     }
 }
Exemple #2
0
        public EsasSendResult Deliver(object[] objects)
        {
            EsasSendResult esasSendResult = new EsasSendResult();

            esasSendResult.SendDestinationStrategyName = this.GetType().Name;
            esasSendResult.SendStartTimeUTC            = DateTime.UtcNow;

            if (!objects.Any())
            {
                // TODO: do some logging here
                esasSendResult.SendToDestinationStatus = EsasOperationResultStatus.OperationFailed;
            }
            else
            {
                Type t = objects.First().GetType(); // used to discern which destination-strategy we'll use.
                var  stagingDbSyncStrategy = _esasStagingDbSyncStrategies.Single(strat => strat.IsStrategyMatch(t));

                Stopwatch sp = new Stopwatch();
                sp.Start();

                try
                {
                    stagingDbSyncStrategy.Deliver(objects, _esasDbContextFactory);
                    esasSendResult.SendToDestinationStatus = EsasOperationResultStatus.OperationSuccesful;
                }
                catch (Exception ex)
                {
                    esasSendResult.SendToDestinationStatus = EsasOperationResultStatus.OperationFailed;
                }

                sp.Stop();
                esasSendResult.SendTimeMs = sp.ElapsedMilliseconds;
            }

            esasSendResult.SendEndTimeUTC = DateTime.UtcNow;
            return(esasSendResult);
        }