Example #1
0
        private static void RetryPolityUsingConfigFile(IUnityContainer container, IBlockService service)
        {
            System.Diagnostics.Trace.WriteLine("Begin sample: RetryPolityUsingConfigFile");
            // Gets the current Retry Manager configuration
            var retryManager = EnterpriseLibraryContainer.Current.GetInstance<RetryManager>();

            // Asks for the default Retry Policy. Keep on mind that it's possible to ask for an specific one.
            var retryPolicy = retryManager.GetRetryPolicy<BlockServiceExceptionDetectionStrategy>();

            // Do some work that may result in a transient fault.
            System.Threading.Tasks.Parallel.For(0, 100, index =>
            {
                try
                {
                    retryPolicy.Retrying += OnRetryPolicyRetrying;
                    retryPolicy.ExecuteAction(() =>
                    {
                        _blockService.PutBlock(index.ToString(), index);
                    });
                    retryPolicy.Retrying -= OnRetryPolicyRetrying;
                }
                catch (Exception exception)
                {
                    // All the retries failed.
                    System.Diagnostics.Trace.WriteLine(string.Format("An Exception has been thrown:\n{0}", exception));
                }
            });

            System.Diagnostics.Trace.WriteLine("End sample: RetryPolityUsingConfigFile");
        }
Example #2
0
        private static void RetryPolityUsingCode(IUnityContainer container, IBlockService service)
        {
            System.Diagnostics.Trace.WriteLine("Begin sample: RetryPolityUsingCode");
            // Define your retry strategy: retry 5 times, starting 1 second apart
            // and adding 2 seconds to the interval each retry.
            var retryStrategy = new Incremental(5, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2));

            // Define your retry policy using the retry strategy and the Windows Azure storage
            // transient fault detection strategy.
            var retryPolicy = new RetryPolicy<BlockServiceExceptionDetectionStrategy>(retryStrategy);

            // Do some work that may result in a transient fault.
            System.Threading.Tasks.Parallel.For(0, 100, index =>
            {
                try
                {
                    retryPolicy.Retrying += OnRetryPolicyRetrying;
                    retryPolicy.ExecuteAction(() =>
                    {
                        _blockService.PutBlock(index.ToString(), index);
                    });
                    retryPolicy.Retrying -= OnRetryPolicyRetrying;
                }
                catch (Exception exception)
                {
                    // All the retries failed.
                    System.Diagnostics.Trace.WriteLine(string.Format("An Exception has been thrown:\n{0}", exception));
                }
            });

            System.Diagnostics.Trace.WriteLine("End sample: RetryPolityUsingCode");
        }
Example #3
0
        static void Main()
        {
            // IoC to inject dependencies 
            var container = GetContainer();

            // Gets three implementation of IService. 
            _blockService = container.Resolve<IBlockService>();
            System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.ConsoleTraceListener());

            System.Diagnostics.Trace.WriteLine("Sample of Transient Fault Handling Block");

            System.Diagnostics.Trace.WriteLine("======================================================");
            RetryPolityUsingConfigFile(container, _blockService);
            System.Diagnostics.Trace.WriteLine("======================================================");

            System.Diagnostics.Trace.WriteLine("======================================================");
            RetryPolityUsingCode(container, _blockService);
            System.Diagnostics.Trace.WriteLine("======================================================");

            System.Diagnostics.Trace.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
Example #4
0
        internal IFacadeUpdateResult <BlockData> SaveBlock(BlockData dto)
        {
            ArgumentValidator.IsNotNull("dto", dto);

            FacadeUpdateResult <BlockData> result = new FacadeUpdateResult <BlockData>();
            IBlockService service  = UnitOfWork.GetService <IBlockService>();
            Block         instance = RetrieveOrNew <BlockData, Block, IBlockService>(result.ValidationResult, dto.Id);

            if (result.IsSuccessful)
            {
                instance.Name         = dto.Name;
                instance.Description  = dto.Description;
                instance.IsBuiltIn    = dto.IsBuiltIn;
                instance.WidgetName   = dto.WidgetName;
                instance.ModifiedDate = DateTime.Now;
                var saveQuery = service.Save(instance);

                result.AttachResult(instance.RetrieveData <BlockData>());
                result.Merge(saveQuery);
            }

            return(result);
        }
Example #5
0
 static BlacklsitExtensions()
 {
     service = Shared.Application.Provider.GetRequiredService <IBlockService>();
 }
Example #6
0
 public BlocksController(IBlockService blockService)
 {
     this.blockService = blockService;
 }
 public BlockMiddleware(IBlockService service, ILogger <BlockMiddleware> logger)
 {
     _service = service;
     _logger  = logger;
 }
Example #8
0
 public InfoBlockController(IBaseApiManager BaseApiManager, IHttpContextAccessor Accessor, IBlockService BlockService) : base(BaseApiManager)
 {
     this.BaseApiManager = BaseApiManager;
     this.Accessor       = Accessor;
     this.BlockService   = BlockService;
 }
 public TicketController(UserManager <MyUser> userManager, ITicketService ticketService, IBlockService blockService, IFamilyService familyService, ICustomerService customerService, IDoctorBasicService doctorService, IHubContext <CenterHub> hubContext)
 {
     _userManager     = userManager;
     _ticketService   = ticketService;
     _blockService    = blockService;
     _familyService   = familyService;
     _customerService = customerService;
     _doctorService   = doctorService;
     _hubContext      = hubContext;
 }
 public CachedBlockService(ICacheManager cacheManager,
                           IBlockService blockService)
 {
     _cacheManager = cacheManager;
     _blockService = blockService;
 }
 public AddressController(IAddressService addressService, IBlockService blockService)
 {
     _addressService = addressService;
     _blockService   = blockService;
 }
Example #12
0
 public BlockController(IUnitOfWork unitOfWork, IBlockService blockService)
 {
     this._unitOfWork   = unitOfWork;
     this._blockService = blockService;
 }
Example #13
0
 public NodeController(ILogger <NodeController> logger, BrokerOptions options, INodeService nodeService, IBlockService blockService) : base(logger, options)
 {
     _nodeService  = nodeService;
     _blockService = blockService;
 }
Example #14
0
 public BlockServiceProxy(IBlockService bs)
 {
     BlockService = bs;
 }
Example #15
0
 public CategoryController(IContentService <Category> categoryService, IBlockService blockService)
 {
     this.categoryService = categoryService;
     this.blockService    = blockService;
 }
Example #16
0
 public AddressController(IBlockService blockService, IAddressService addressService)
 {
     BlockService   = blockService;
     AddressService = addressService;
 }
 public BlockController(IBlockService blocks, IPaginatingService paginating, IStateService state)
 {
     this.blocks     = blocks;
     this.paginating = paginating;
     this.state      = state;
 }
 public HadithController(AppDbContext _db, IBlockService _blockService)
 {
     db           = _db;
     blockService = _blockService;
 }
 public BlocksController(IBlockService blockService, IMapper mapper)
 {
     this.blockService = blockService;
     this.mapper       = mapper;
 }
Example #20
0
 public AuthManager(IIdentityProvider identity, IConfirmedEmailSender emailSender, IBlockService blockService)
 {
     this.emailSender  = emailSender;
     this.identity     = identity;
     this.blockService = blockService;
     FirstInitialize();
 }
Example #21
0
 public HomeController(IBlockService blockService)
 {
     BlockService = blockService;
 }
Example #22
0
 public BlockController(ILoggingService loggingService, IUnitOfWorkManager unitOfWorkManager, IMembershipService membershipService, 
     ILocalizationService localizationService, IRoleService roleService, ISettingsService settingsService, IBlockService blockService) : 
     base(loggingService, unitOfWorkManager, membershipService, localizationService, roleService, settingsService)
 {
     _blockService = blockService;
 }
Example #23
0
 public TopListService(IAddressService addressService, IBlockService blockService, ILoggerFactory loggerFactory)
 {
     _addressService = addressService;
     _blockService   = blockService;
     _logger         = loggerFactory.CreateLogger(GetType());
 }
 public TransactionsController(IBlockService blockService, ITransactionService transactionService)
 {
     this.blockService       = blockService;
     this.transactionService = transactionService;
 }
Example #25
0
 public MiningController(IBlockService blockService)
 {
     this.blockService = blockService;
 }
Example #26
0
 public AdminController(IAdminService adminService, IBlockService blockService, IGenericRepository <Log> logRepository)
 {
     this.adminService  = adminService;
     this.blockService  = blockService;
     this.logRepository = logRepository;
 }
Example #27
0
 public AddressService(IBlockService blockService, ITransactionService transactionService)
 {
     this.blockService       = blockService;
     this.transactionService = transactionService;
 }
Example #28
0
 public InfoBlockController(IBaseManager BaseManager, IBlockService BlockService) : base(BaseManager)
 {
     this.BaseManager  = BaseManager;
     this.BlockService = BlockService;
 }
Example #29
0
 public BlockController(IBlockService blockService)
 {
     BlockService = blockService;
 }
Example #30
0
 public FriendService(IFriendRepository friendRepository, IBlockService blockService)
 {
     _friendRepository = friendRepository;
     _blockService     = blockService;
 }
 public StatsBackgroundService(ILogger <StatsBackgroundService> logger, IApiClient apiService, IBlockService blockService,
                               ITransactionService transactionService)
 {
     _logger             = logger;
     _apiService         = apiService;
     _blockService       = blockService;
     _transactionService = transactionService;
 }
Example #32
0
 public BlockController(ILoggingService loggingService, IUnitOfWorkManager unitOfWorkManager, IMembershipService membershipService,
                        ILocalizationService localizationService, IRoleService roleService, ISettingsService settingsService, IBlockService blockService) :
     base(loggingService, unitOfWorkManager, membershipService, localizationService, roleService, settingsService)
 {
     _blockService = blockService;
 }
Example #33
0
 public BanCtlUnit(IBlockService service)
 {
     _service = service;
 }
 public BlockModelService(IBlockService blockService)
 {
     _blockService = blockService;
 }