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"); }
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"); }
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(); }
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); }
static BlacklsitExtensions() { service = Shared.Application.Provider.GetRequiredService <IBlockService>(); }
public BlocksController(IBlockService blockService) { this.blockService = blockService; }
public BlockMiddleware(IBlockService service, ILogger <BlockMiddleware> logger) { _service = service; _logger = logger; }
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; }
public BlockController(IUnitOfWork unitOfWork, IBlockService blockService) { this._unitOfWork = unitOfWork; this._blockService = blockService; }
public NodeController(ILogger <NodeController> logger, BrokerOptions options, INodeService nodeService, IBlockService blockService) : base(logger, options) { _nodeService = nodeService; _blockService = blockService; }
public BlockServiceProxy(IBlockService bs) { BlockService = bs; }
public CategoryController(IContentService <Category> categoryService, IBlockService blockService) { this.categoryService = categoryService; this.blockService = blockService; }
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; }
public AuthManager(IIdentityProvider identity, IConfirmedEmailSender emailSender, IBlockService blockService) { this.emailSender = emailSender; this.identity = identity; this.blockService = blockService; FirstInitialize(); }
public HomeController(IBlockService blockService) { BlockService = blockService; }
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; }
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; }
public MiningController(IBlockService blockService) { this.blockService = blockService; }
public AdminController(IAdminService adminService, IBlockService blockService, IGenericRepository <Log> logRepository) { this.adminService = adminService; this.blockService = blockService; this.logRepository = logRepository; }
public AddressService(IBlockService blockService, ITransactionService transactionService) { this.blockService = blockService; this.transactionService = transactionService; }
public InfoBlockController(IBaseManager BaseManager, IBlockService BlockService) : base(BaseManager) { this.BaseManager = BaseManager; this.BlockService = BlockService; }
public BlockController(IBlockService blockService) { BlockService = blockService; }
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; }
public BanCtlUnit(IBlockService service) { _service = service; }
public BlockModelService(IBlockService blockService) { _blockService = blockService; }