public static async Task AcmeContextEntity(
            [EntityTrigger] IDurableEntityContext ctx,
            [ActorService(Name = "AcmeContext")] IActorService actorservice,
            [OrchestrationClient] IDurableOrchestrationClient starter)
        {
            switch (ctx.OperationName)
            {
            case "Initialize":
                await actorservice.ExecuteAsync <AcmeContextInitializeInput, object, AcmeContextState>(ctx);

                break;

            case "CreateOrder":
                await actorservice.ExecuteAsync <OrderInput, object, AcmeContextState>(ctx);

                break;

            case "FinalizeOrder":
                await actorservice.ExecuteAsync <FinalizeInput, FinalizeOutput, AcmeContextState>(ctx);

                break;

            case "ValidateAuthorization":
                await actorservice.ExecuteAsync <ValidateAuthorizationInput, object, AcmeContextState>(ctx);

                break;

            default:
                throw new InvalidOperationException(ctx.OperationName + " is not known");
            }
        }
Пример #2
0
 public MovieService(IMovieRepository movieRepository, IReviewRepository reviewRepository, IMovieInfoRepository movieInfoRepository, IActorService actorService)
 {
     _movieRepository     = movieRepository;
     _reviewRepository    = reviewRepository;
     _movieInfoRepository = movieInfoRepository;
     _actorService        = actorService;
 }
        public static async Task AuthorizationEntity(
            [EntityTrigger] IDurableEntityContext ctx,
            [ActorService(Name = "Authorization")] IActorService actorservice,
            [OrchestrationClient] IDurableOrchestrationClient starter)
        {
            switch (ctx.OperationName)
            {
            case "AuthorizeHttp":
                await actorservice.ExecuteAsync <AuthorizeHttpInput, object, AuthorizationActorState>(ctx);

                break;

            case "AuthorizeDns":
                await actorservice.ExecuteAsync <AuthorizeDnsInput, object, AuthorizationActorState>(ctx);

                break;

            case "AuthorizationCompleted":
                await actorservice.ExecuteAsync <object, object, AuthorizationActorState>(ctx);

                break;

            default:
                throw new InvalidOperationException(ctx.OperationName + " is not known");
            }
        }
        private async Task <long> GetCountAsync(string serviceName)
        {
            string serviceUri = _serviceContext.CodePackageActivationContext.ApplicationName + "/" + serviceName;

            ServicePartitionList partitions = await _fabricClient.QueryManager.GetPartitionListAsync(new Uri(serviceUri));

            long count = 0;

            foreach (Partition partition in partitions)
            {
                long          partitionKey      = ((Int64RangePartitionInformation)partition.PartitionInformation).LowKey;
                IActorService actorServiceProxy = ActorServiceProxy.Create(new Uri(serviceUri), partitionKey);

                ContinuationToken continuationToken = null;

                do
                {
                    PagedResult <ActorInformation> page = await actorServiceProxy.GetActorsAsync(continuationToken, CancellationToken.None);

                    count += page.Items.Where(x => x.IsActive).LongCount();

                    continuationToken = page.ContinuationToken;
                }while (continuationToken != null);
            }

            return(count);
        }
Пример #5
0
 public ActorsController(IActorService service, IMapper mapper, ILogger <ActorsController> logger, IMovieService movieService)
 {
     _service      = service;
     _mapper       = mapper;
     _logger       = logger;
     _movieService = movieService;
 }
Пример #6
0
        public void TestRemotingActors_NoSerializationError()
        {
            FabricClient         fabricClient  = new FabricClient("localhost:19000");
            ServicePartitionList partitionList = fabricClient.QueryManager.GetPartitionListAsync(new Uri("fabric:/Codit.Core.Application/DeviceActorService")).Result;

            ContinuationToken continuationToken  = null;
            var cancellationTokenSource          = new CancellationTokenSource();
            List <ActorInformation> activeActors = new List <ActorInformation>();

            foreach (var partition in partitionList)
            {
                var           key = partition.PartitionInformation as Int64RangePartitionInformation;
                IActorService actorServiceProxy = ActorServiceProxy.Create <IMyService>(new Uri("fabric:/Codit.Core.Application/DeviceActorService"), key.LowKey);

                do
                {
                    PagedResult <ActorInformation> page = actorServiceProxy.GetActorsAsync(continuationToken, cancellationTokenSource.Token).Result;
                    activeActors.AddRange(page.Items.Where(x => x.IsActive));
                    continuationToken = page.ContinuationToken;
                }while (continuationToken != null);
            }

            foreach (var actor in activeActors)
            {
                Assert.NotNull(actor.ActorId.ToString());
            }
        }
Пример #7
0
        public async Task Delete(string actorId)
        {
            var           actorIdObj        = new ActorId(actorId);
            IActorService actorServiceProxy = null;

            try
            {
                actorServiceProxy = ActorServiceProxy.Create(
                    new Uri("fabric:/DataLossCheckApp/ConActorService"),
                    actorIdObj);
                await actorServiceProxy.DeleteActorAsync(actorIdObj, CancellationToken.None);

                // log message
                await Helper.LogMessage(actorId, $"DELETED");
            }
            catch (Exception ex)
            {
                // log message
                await Helper.LogMessage(actorId, $"DELETE ERROR - {ex.ToString()}");
            }
            finally
            {
                if (actorIdObj != null)
                {
                    actorIdObj = null;
                }
                if (actorServiceProxy != null)
                {
                    actorServiceProxy = null;
                }
            }
        }
Пример #8
0
 public WalletController(IActorService actorService, IWalletService walletService, IVaultServiceClient vaultServiceClient, IUnitOfWork unitOfWork)
 {
     this.actorService       = actorService;
     this.walletService      = walletService;
     this.vaultServiceClient = vaultServiceClient;
     this.unitOfWork         = unitOfWork;
 }
 public SMFController(AbstractBridgeService abstractBridgeService, IPendingService pendingService, IActorService actorService, IQuery <IList <Category> > categoryService)
 {
     _abstractBridgeService = abstractBridgeService;
     _pendingService        = pendingService;
     _actorService          = actorService;
     _categoryService       = categoryService;
 }
Пример #10
0
        public async Task <IActionResult> GetAsync()
        {
            string serviceUri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/" + this.configSettings.ActorBackendServiceName;

            ServicePartitionList partitions = await this.fabricClient.QueryManager.GetPartitionListAsync(new Uri(serviceUri));

            long count = 0;

            foreach (Partition partition in partitions)
            {
                long          partitionKey      = ((Int64RangePartitionInformation)partition.PartitionInformation).LowKey;
                IActorService actorServiceProxy = ActorServiceProxy.Create(new Uri(serviceUri), partitionKey);

                ContinuationToken continuationToken = null;

                do
                {
                    PagedResult <ActorInformation> page = await actorServiceProxy.GetActorsAsync(continuationToken, CancellationToken.None);

                    count += page.Items.Where(x => x.IsActive).LongCount();

                    continuationToken = page.ContinuationToken;
                }while (continuationToken != null);
            }

            return(this.Json(new { Count = count, Date = DateTime.Now }));
        }
Пример #11
0
        public async Task <IActionResult> GetAsync()
        {
            string serviceUri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/" + this.configSettings.ActorBackendServiceName;

            ServicePartitionList partitions = await this.fabricClient.QueryManager.GetPartitionListAsync(new Uri(serviceUri));

            long count = 0;

            foreach (Partition partition in partitions)
            {
                long          partitionKey      = ((Int64RangePartitionInformation)partition.PartitionInformation).LowKey;
                IActorService actorServiceProxy = ActorServiceProxy.Create(new Uri(serviceUri), partitionKey);

                // https://docs.microsoft.com/it-it/azure/service-fabric/service-fabric-reliable-actors-enumerate
                // Gli Actors sono ranged partitioned stateful service, quindi l'enumeration è fatta per partizione.
                // Ogni partizione contiene più attori, e il risultato è un loop su un elenco di "pagine".
                ContinuationToken continuationToken = null;

                do
                {
                    PagedResult <ActorInformation> page = await actorServiceProxy.GetActorsAsync(continuationToken, CancellationToken.None);

                    count += page.Items.Where(x => x.IsActive).LongCount();

                    continuationToken = page.ContinuationToken;
                }while (continuationToken != null);
            }

            return(this.Json(new CountViewModel()
            {
                Count = count
            }));
        }
Пример #12
0
        static void Main(string[] args)
        {
            FabricClient         fabricClient  = new FabricClient("localhost:19000");
            ServicePartitionList partitionList = fabricClient.QueryManager.GetPartitionListAsync(new Uri("fabric:/Codit.Core.Application/DeviceActorService")).Result;

            ContinuationToken continuationToken  = null;
            var cancellationTokenSource          = new CancellationTokenSource();
            List <ActorInformation> activeActors = new List <ActorInformation>();

            foreach (var partition in partitionList)
            {
                var           key = partition.PartitionInformation as Int64RangePartitionInformation;
                IActorService actorServiceProxy = ActorServiceProxy.Create(new Uri("fabric:/Codit.Core.Application/DeviceActorService"), key.LowKey);

                do
                {
                    PagedResult <ActorInformation> page = actorServiceProxy.GetActorsAsync(continuationToken, cancellationTokenSource.Token).Result;
                    activeActors.AddRange(page.Items.Where(x => x.IsActive));
                    continuationToken = page.ContinuationToken;
                }while (continuationToken != null);
            }

            foreach (var actor in activeActors)
            {
                Console.WriteLine($"Active Actor: {actor.ActorId.ToString()}");
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadLine();
        }
Пример #13
0
 public ProducerController(IMovieService movies, IActorService actors, IProducerService producers, IGenderService genders)
 {
     _movieDbService    = movies;
     _actorDbService    = actors;
     _producerDbService = producers;
     _genderDbService   = genders;
 }
Пример #14
0
 public MovieController(IGenreService genreService, IActorService actorService,
                        IMovieService movieService, IMapper mapper) : base(mapper)
 {
     _genreService = genreService;
     _actorService = actorService;
     _movieService = movieService;
 }
Пример #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="kpuIdSearchFor"></param>
        /// <returns></returns>
        public Task <IToHActor> GetActorFromKpuId(string kpuIdSearchFor)
        {
            CancellationTokenSource source            = new CancellationTokenSource();
            CancellationToken       cancellationToken = source.Token;

            int partitionKey = 0;

            IActorService actorServiceProxy = ActorServiceProxy.Create(new Uri("fabric:/CWF.Fabric.Services/ToHActorService"), 0);

            ContinuationToken       continuationToken = null;
            List <ActorInformation> activeActors      = new List <ActorInformation>();

            do
            {
                Task <PagedResult <ActorInformation> > pageTask = actorServiceProxy.GetActorsAsync(continuationToken, cancellationToken);

                PagedResult <ActorInformation> page = pageTask.Result;
                activeActors.AddRange(page.Items.Where(x => x.IsActive));

                continuationToken = page.ContinuationToken;
            }while (continuationToken != null);

            foreach (ActorInformation info in activeActors)
            {
                var           proxy = ActorProxy.Create <IToHActor>(info.ActorId, "fabric:/CWF.Fabric.Services");
                Task <string> kpuId = proxy.GetKpuId();
                var           kpuid = kpuId.Result;
                if (kpuid.CompareTo(kpuIdSearchFor) == 0)
                {
                    return(Task.FromResult <IToHActor>(proxy));
                }
            }
            return(null);
        }
Пример #16
0
        //RETURN VALUE??
        /// <summary>
        /// Deletes a game session on the server (SQL register)
        /// </summary>
        /// <param name="i_gameId">Game session ID</param>
        public async Task DeleteGameAsync(string i_gameId, string i_uri)
        {
            try
            {
                IActorService actor = ActorServiceProxy.Create(new Uri(i_uri), new ActorId(i_gameId));
                await actor.DeleteActorAsync(new ActorId(i_gameId), new CancellationToken());

                //Connects to the SQL Server and close when exiting
                using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
                {
                    //Opens SQL connection
                    connection.Open();
                    //Creates query string
                    string query = "DELETE FROM Games WHERE Id ='" + i_gameId + "'";
                    //Creates SQL Command using query and connection
                    using (SqlCommand command = new SqlCommand(query, connection))
                    {
                        //Executes command
                        command.ExecuteNonQuery();
                    }
                };
            }
            catch (Exception e)
            {
                Console.Write(e.ToString());
            }
        }
Пример #17
0
 public void SetUp()
 {
     _mockActorRepo = new Mock <IActorRepository>()
     {
         CallBase = true
     };
     _actorService = new BusinessLogic.Services.ActorCrudService.ActorService(_mockActorRepo.Object);
 }
Пример #18
0
 public MoviesController(ILogger <HomeController> logger,
                         IActorService actorService,
                         IMovieService movieService) : base(logger)
 {
     _logger       = logger;
     _actorService = actorService;
     _movieService = movieService;
 }
Пример #19
0
        public WalletTransferCommand(IServiceProvider serviceProvider)
        {
            actorService = serviceProvider.GetService <IActorService>();
            console      = serviceProvider.GetService <IConsole>();
            logger       = serviceProvider.GetService <ILogger>();

            actorService.MessagePump += ActorService_MessagePump;
        }
 public SMFController(AbstractBridgeService abstractService, IPendingService pendingService, IBridgeService bridgeService, IActorService actorService, IMapper mapper)
 {
     _abstractService = abstractService;
     _pendingService  = pendingService;
     _bridgeService   = bridgeService;
     _actorService    = actorService;
     _mapper          = mapper;
 }
 public ActorsController(IActorService actorService,
                         IViewModelMapper <Actor, ActorViewModel> actorMapper,
                         IViewModelMapper <Movie, MovieViewModel> movieMapper)
 {
     this.actorService = actorService ?? throw new ArgumentNullException(nameof(actorService));
     this.actorMapper  = actorMapper ?? throw new ArgumentNullException(nameof(actorMapper));
     this.movieMapper  = movieMapper ?? throw new ArgumentNullException(nameof(movieMapper));
 }
Пример #22
0
 public CrawlingService(
     IActorService actorService,
     IMovieService movieService,
     ICategoryService categoryService)
 {
     _actorService    = actorService;
     _movieService    = movieService;
     _categoryService = categoryService;
 }
        public WalletReceivePaymentCommand(IServiceProvider serviceProvider)
        {
            actorService  = serviceProvider.GetService <IActorService>();
            console       = serviceProvider.GetService <IConsole>();
            vaultService  = serviceProvider.GetService <IVaultService>();
            walletService = serviceProvider.GetService <IWalletService>();

            actorService.MessagePump += ActorService_MessagePump;
        }
Пример #24
0
 public MovieCrawlerController(
     IMovieService movieService,
     IGenreService genreService,
     IActorService actorService)
 {
     _movieService = movieService;
     _actorService = actorService;
     _genreService = genreService;
 }
Пример #25
0
 public CrawlingService(
     IActorService actorService,
     IMovieService movieService,
     IGenreService genreService)
 {
     _actorService = actorService;
     _movieService = movieService;
     _genreService = genreService;
 }
        private async Task <KeyValuePair <string, string> > GetRandomIdsAsync()
        {
            ServiceUriBuilder serviceUri = new ServiceUriBuilder(this.GetSetting(DeviceServiceName));
            Uri fabricServiceName        = serviceUri.ToUri();

            CancellationTokenSource cts        = new CancellationTokenSource(TimeSpan.FromMinutes(5));
            CancellationToken       token      = cts.Token;
            FabricClient            fc         = new FabricClient();
            ServicePartitionList    partitions = await fc.QueryManager.GetPartitionListAsync(fabricServiceName);

            string doctorId = null;

            while (!token.IsCancellationRequested && doctorId == null)
            {
                try
                {
                    foreach (Partition p in partitions)
                    {
                        long partitionKey = ((Int64RangePartitionInformation)p.PartitionInformation).LowKey;
                        token.ThrowIfCancellationRequested();
                        ContinuationToken queryContinuationToken = null;
                        IActorService     proxy = ActorServiceProxy.Create(fabricServiceName, partitionKey);
                        PagedResult <ActorInformation> result = await proxy.GetActorsAsync(queryContinuationToken, token);

                        foreach (ActorInformation info in result.Items)
                        {
                            token.ThrowIfCancellationRequested();

                            ActorId      deviceActorId = info.ActorId;
                            IDeviceActor deviceActor   = ActorProxy.Create <IDeviceActor>(deviceActorId, fabricServiceName);

                            try
                            {
                                doctorId = (await deviceActor.GetAssociatedDoctorAsync()).ToString();

                                return(new KeyValuePair <string, string>(deviceActorId.ToString(), doctorId));
                            }
                            catch (Exception e)
                            {
                                ServiceEventSource.Current.Message("Exception when obtaining actor ID. No State? " + e.ToString());
                                continue;
                            }
                        }
                        //otherwise we will bounce around other partitions until we find an actor
                    }
                }
                catch (Exception e)
                {
                    ServiceEventSource.Current.Message("Exception when obtaining actor ID: " + e.ToString());
                    continue;
                }
            }

            throw new InvalidOperationException("Couldn't find actor within timeout");
        }
        public ActorsListViewModel(RegionManager regionManager, TheMovieDBDataService dataService, ActorService actorService)
        {
            _regionManager = regionManager;
            _dataService   = dataService;
            _actorService  = actorService;
            _logger        = LogManager.GetCurrentClassLogger();

            NotificationRequest            = new InteractionRequest <INotification>();
            NotificationRequestNull        = new InteractionRequest <INotification>();
            NavigateCommandShowDirectActor = new DelegateCommand <int?>(ShowDirectActor);
        }
Пример #28
0
 public MovieActorViewComponent(
     IPictureService pictureService, IMovieActorService movieActorService,
     IMemoryCache cacheManager,
     IActorService actorService)
 {
     _actorService      = actorService;
     _movieActorService = movieActorService;
     //_categoryService = categoryService;
     _pictureService = pictureService;
     _cacheManager   = cacheManager;
 }
 public ActivityService(IRequestBuilder requestBuilder, IRestClient restClient,
                        IResponseValidator responseValidator,
                        IActivityConvertor activityConvertor, IActionService actionService, IActionConvertor actionConvertor,
                        IAddActivityValidator addActivityValidator, IActorService actorService)
     : base(requestBuilder, restClient, responseValidator)
 {
     _activityConvertor    = activityConvertor;
     _actionService        = actionService;
     _actionConvertor      = actionConvertor;
     _addActivityValidator = addActivityValidator;
     _actorService         = actorService;
 }
 public SettingController(AbstractBridgeService abstractService, ISummaryService summaryService, IRecordService recordService, IQuery <IList <Constraint> > constraintService, IOrganizationService organizationService, IActorService actorService, IQuery <IList <Category> > categoryService, IBridgeService bridgeService, IMapper mapper)
 {
     _abstractService     = abstractService;
     _constraintService   = constraintService;
     _organizationService = organizationService;
     _actorService        = actorService;
     _categoryService     = categoryService;
     _bridgeService       = bridgeService;
     _recordService       = recordService;
     _summaryService      = summaryService;
     _mapper = mapper;
 }
 public PreferenceController(IPreferenceService service, IActorService actService)
 {
     this.preferenceService = service;
     this.actorService = actService;
 }
Пример #32
0
 public ActorController(IActorService service)
 {
     this.actorService = service;
 }