Esempio n. 1
0
        private async void DownloadResListAsync()
        {
            BeginHandle?.Invoke(this);

            while (true)
            {
                if (mBeDownloadResKey.Count == 0)
                {
                    break;
                }

                uint tmpKey     = mBeDownloadResKey.Dequeue();
                long tmpResFlag = 0;

                if (!mResInfoDict.TryGetValue(tmpKey, out tmpResFlag))
                {
                    Logger.LogError("");
                    break;
                }

                var tmpResInfo = ResourcesSystem.ResFlag2Info(tmpResFlag);

                while (true)
                {
                    try
                    {
                        using (UnityWebRequestAsync webReqAsync = Game.ObjectPool.Fetch <UnityWebRequestAsync>())
                        {
                            WebRequestAsync = webReqAsync;
                            string tmpUrl    = URL + tmpResInfo.FileHashStr;
                            bool   tmpResult = await webReqAsync.DownloadAsync(tmpUrl);

                            if (tmpResult)
                            {
                                Save(webReqAsync.Request.downloadHandler.data, tmpResInfo.FileHashStr);
                            }
                            else
                            {
                                Failed();
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.LogError($"download res error! {tmpResInfo.FileHashStr} -> {e}");
                        continue;
                    }

                    break;
                }

                mDownloadedSize += tmpResInfo.ResSize;
                DownloadProgressHandle?.Invoke(this);

                WebRequestAsync = null;
                tmpResInfo.Dispose();
            }

            Finish();
        }
Esempio n. 2
0
        protected async override Task RunAsync(Execution <HandleContext> execution)
        {
            try
            {
                using (IHandlerInstance handler = await CreateHandler.RunAsync(execution.Context).ConfigureAwait(false))
                {
                    var handleContext = new HandlerContext(execution.Context.Message.Payload, handler.Current, execution.Context.Message);
                    await BeginHandle.RunAsync(handleContext).ConfigureAwait(false);

                    await ActualHandle.RunAsync(handleContext).ConfigureAwait(false);

                    await EndHandle.RunAsync(handleContext).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                var context = new ErrorContext(ex, execution.Context.Message, execution.Context.HandlerType);
                context.AssignPropertySafely <IWorkflowContextWithServiceProvider>(prop => prop.ServiceProvider = execution.Context.ServiceProvider);
                await Error.RunAsync(context).ConfigureAwait(false);

                throw;
            }
            finally
            {
                await Finalize.RunAsync(execution.Context).ConfigureAwait(false);
            }
        }
Esempio n. 3
0
 public PortsMiddleware(IHandlerFactory factory, IPublisher <ICommand> commandPublisher)
     : base(factory)
 {
     BeginHandle.Use((execution) =>
     {
         IPublisher <ICommand> cronusCommandPublisher = new CronusPublisher <ICommand>(commandPublisher, execution.Context.CronusMessage);
         execution.Context.HandlerInstance.AssignPropertySafely <IPort>(x => x.CommandPublisher = cronusCommandPublisher);
     });
 }
 public ApplicationServiceMiddleware(IHandlerFactory factory, IAggregateRepository aggregateRepository, IPublisher <IEvent> eventPublisher) : base(factory)
 {
     BeginHandle.Use((execution) =>
     {
         IPublisher <IEvent> cronusEventPublisher = new CronusPublisher <IEvent>(eventPublisher, execution.Context.CronusMessage);
         var repo = new CronusAggregateRepository(aggregateRepository, cronusEventPublisher);
         execution.Context.HandlerInstance.AssignPropertySafely <IAggregateRootApplicationService>(x => x.Repository = repo);
     });
 }
Esempio n. 5
0
        public SagasMiddleware(IHandlerFactory factory, IPublisher <ICommand> commandPublisher, IPublisher <IScheduledMessage> schedulePublisher)
            : base(factory)
        {
            BeginHandle.Use((execution) =>
            {
                IPublisher <ICommand> cronusCommandPublisher           = new CronusPublisher <ICommand>(commandPublisher, execution.Context.CronusMessage);
                IPublisher <IScheduledMessage> cronusSchedulePublisher = new CronusPublisher <IScheduledMessage>(schedulePublisher, execution.Context.CronusMessage);

                execution.Context.HandlerInstance.AssignPropertySafely <ISaga>(x => x.CommandPublisher        = cronusCommandPublisher);
                execution.Context.HandlerInstance.AssignPropertySafely <ISaga>(x => x.TimeoutRequestPublisher = cronusSchedulePublisher);
            });
        }
Esempio n. 6
0
        protected override void Run(Execution <HandleContext> execution)
        {
            try
            {
                using (IHandlerInstance handler = CreateHandler.Run(execution.Context))
                {
                    var handleContext = new HandlerContext(execution.Context.Message.Payload, handler.Current, execution.Context.Message);
                    BeginHandle.Run(handleContext);
                    new DiagnosticsWorkflow <HandlerContext>(ActualHandle).Run(handleContext);
                    EndHandle.Run(handleContext);
                }
            }

            catch (Exception ex)
            {
                Error.Run(new ErrorContext(ex, execution.Context.Message, execution.Context.HandlerType));
                throw;
            }
            finally
            {
                Finalize.Run(execution.Context);
            }
        }
Esempio n. 7
0
        protected override void DownloadDescribeFileAsync()
        {
            base.DownloadDescribeFileAsync();

            BeginHandle?.Invoke(this);
        }