public static MvcHtmlString ActionLinkWithPermission(this HtmlHelper helper, string linkText, string action, string controller, PermissionKeys required) { if (helper == null || helper.ViewContext == null || helper.ViewContext.RequestContext == null || helper.ViewContext.RequestContext.HttpContext == null || helper.ViewContext.RequestContext.HttpContext.User == null) return MvcHtmlString.Empty; using (var proxy = new ServiceProxy<IUserService>()) { var role = proxy.Channel.GetUserRoleByUserName(helper.ViewContext.RequestContext.HttpContext.User.Identity.Name); if (role == null) return MvcHtmlString.Empty; var keyName = ByteartRetailConfigurationReader.Instance.GetKeyNameByRoleName(role.Name); if (keyName == null) throw new ConfigurationErrorsException(string.Format("在配置文件中没有定义与角色名称 {0} 相对应的权限键(Permission Key)名称。", role.Name)); var namesInEnum = Enum.GetNames(typeof(PermissionKeys)); if (!namesInEnum.Contains(keyName)) throw new ConfigurationErrorsException(string.Format("在配置文件中对角色名称 {0} 设定的权限键(Permission Key)名称无效。", role.Name)); var permissionKey = (PermissionKeys)Enum.Parse(typeof(PermissionKeys), keyName); if ((permissionKey & required) == permissionKey) return MvcHtmlString.Create(HtmlHelper.GenerateLink(helper.ViewContext.RequestContext, helper.RouteCollection, linkText, null, action, controller, null, null)); return MvcHtmlString.Empty; } }
public ActionResult ProductsPartial(string categoryID = null, bool? fromIndexPage = null, int pageNumber = 1) { using (var proxy = new ServiceProxy<IProductService>()) { var numberOfProductsPerPage = ByteartRetailConfigurationReader.Instance.ProductsPerPage; var pagination = new Pagination { PageSize = numberOfProductsPerPage, PageNumber = pageNumber }; ProductDataObjectListWithPagination productsWithPagination = string.IsNullOrEmpty(categoryID) ? proxy.Channel.GetProductsWithPagination(pagination) : proxy.Channel.GetProductsForCategoryWithPagination(new Guid(categoryID), pagination); if (fromIndexPage != null && !fromIndexPage.Value) { if (string.IsNullOrEmpty(categoryID)) ViewBag.CategoryName = "所有商品"; else { var category = proxy.Channel.GetCategoryByID(new Guid(categoryID), QuerySpec.Empty); ViewBag.CategoryName = category.Name; } } else ViewBag.CategoryName = null; ViewBag.CategoryID = categoryID; ViewBag.FromIndexPage = fromIndexPage; if (fromIndexPage == null || fromIndexPage.Value) ViewBag.Action = "Index"; else ViewBag.Action = "Category"; ViewBag.IsFirstPage = productsWithPagination.Pagination.PageNumber == 1; ViewBag.IsLastPage = productsWithPagination.Pagination.PageNumber == productsWithPagination.Pagination.TotalPages; return PartialView(productsWithPagination); } }
public ActionResult EditCategory(string id) { using (var proxy = new ServiceProxy<IProductService>()) { var model = proxy.Channel.GetCategoryByID(new Guid(id), QuerySpec.Empty); return View(model); } }
public ActionResult Product(string id) { using (ServiceProxy<IProductService> proxy = new ServiceProxy<IProductService>()) { var product = proxy.Channel.GetProductByID(new Guid(id), QuerySpec.VerboseOnly); return View(product); } }
public Teams() { this.InitializeComponent(); this.navigationHelper = new NavigationHelper(this); this.navigationHelper.LoadState += navigationHelper_LoadState; this.navigationHelper.SaveState += navigationHelper_SaveState; var result = new ServiceProxy<ITeamsService>().Invoke(x => x.Get()); }
public ActionResult ShoppingCart() { using (ServiceProxy<IOrderService> proxy = new ServiceProxy<IOrderService>()) { var model = proxy.Channel.GetShoppingCart(UserID); return View(model); } }
public ActionResult UpdateShoppingCartItem(string shoppingCartItemID, int quantity) { using (ServiceProxy<IOrderService> proxy = new ServiceProxy<IOrderService>()) { proxy.Channel.UpdateShoppingCartItem(new Guid(shoppingCartItemID), quantity); return Json(null); } }
public ActionResult DeleteShoppingCartItem(string shoppingCartItemID) { using (ServiceProxy<IOrderService> proxy = new ServiceProxy<IOrderService>()) { proxy.Channel.DeleteShoppingCartItem(new Guid(shoppingCartItemID)); return Json(null); } }
public ActionResult Checkout() { using (ServiceProxy<IOrderService> proxy = new ServiceProxy<IOrderService>()) { var model = proxy.Channel.Checkout(this.UserID); return View(model); } }
public ActionResult CategoriesPartial() { using (var proxy = new ServiceProxy<IProductService>()) { var categories = proxy.Channel.GetCategories(QuerySpec.Empty); return PartialView(categories); } }
public ActionResult FeaturedProductsPartial() { using (var proxy = new ServiceProxy<IProductService>()) { var featuredProducts = proxy.Channel.GetFeaturedProducts(4); return PartialView(featuredProducts); } }
public void SimpleRunnerTests() { IClientChannel clientChannel = (new Mock<IClientChannel>()).Object; IMessage message = (new Mock<IMessage>()).Object; // This one should NOT fail IBaseTestService service = new ServiceProxy<IBaseTestService>(message, clientChannel, "RemoteService").Service; service.TestMethod2("1", 2); }
public ActionResult EditCategory(CategoryDataObject category) { using (var proxy = new ServiceProxy<IProductService>()) { var categoryList = new CategoryDataObjectList { category }; proxy.Channel.UpdateCategories(categoryList); return RedirectToSuccess("更新商品分类成功!", "Categories", "Admin"); } }
public ActionResult _LoginPartial() { if (User.Identity.IsAuthenticated) { using (var proxy = new ServiceProxy<IOrderService>()) { ViewBag.ShoppingCartItems = proxy.Channel.GetShoppingCartItemCount(UserID); } } return PartialView(); }
public ActionResult AddToCart(string productID, string items) { using (ServiceProxy<IOrderService> proxy = new ServiceProxy<IOrderService>()) { int quantity = 0; if (!int.TryParse(items, out quantity)) quantity = 1; proxy.Channel.AddProductToCart(UserID, new Guid(productID), quantity); return RedirectToAction("ShoppingCart"); } }
public void MethodCallWithComplexParameters() { TestStructure first = new TestStructure { FieldA = "First", FieldB = 42, FieldC = true }; TestStructure second = new TestStructure { FieldA = "Second", FieldB = 314, FieldC = false }; TestStructure single = new TestStructure { FieldA = "Single", FieldB = 2, FieldC = true }; ITestService service = new ServiceProxy<ITestService>(this._serverUrl, "TestService").Service; Assert.AreEqual(first.FieldA, service.MethodWithComplexTypes(new[] { first, second }, single, TestEnum.First).FieldA); Assert.AreEqual(second.FieldB, service.MethodWithComplexTypes(new[] { first, second }, single, TestEnum.Second).FieldB); Assert.AreEqual(single.FieldC, service.MethodWithComplexTypes(new[] { first, second }, single, TestEnum.Single).FieldC); }
public ActionResult Confirm(string id) { using (ServiceProxy<IOrderService> proxy = new ServiceProxy<IOrderService>()) { proxy.Channel.Confirm(new Guid(id)); return RedirectToSuccess("确认收货成功!", "SalesOrders", "Home"); } }
public IShippingService Create() { return(ServiceProxy.Create <IShippingService>(FabricUri, new ServicePartitionKey(1))); }
public ActionResult DispatchOrder(string id) { using (var proxy = new ServiceProxy<IOrderService>()) { proxy.Channel.Dispatch(new Guid(id)); return RedirectToSuccess(string.Format("订单 {0} 已成功发货!", id.ToUpper()), "SalesOrders", "Admin"); } }
public ActionResult AddRole(RoleDataObject model) { using (var proxy = new ServiceProxy<IUserService>()) { proxy.Channel.CreateRoles(new RoleDataObjectList { model }); return RedirectToSuccess("添加账户角色成功!", "Roles", "Admin"); } }
public ActionResult EditRole(string id) { using (var proxy = new ServiceProxy<IUserService>()) { var model = proxy.Channel.GetRoleByKey(new Guid(id)); return View(model); } }
protected override Task <BaseResponse <Post> > GetStackData() { return(ServiceProxy.GetTopQuestionsByUserAndTag(_userId, PostSortBy.activity, _tag, _page)); }
protected override Task <BaseResponse <Post> > GetStackData() { return(ServiceProxy.GetQuestions(PostFilter.normal, PostSortBy.creation, _page, tag: _tag)); }
public ProductsController() { _passportService = ServiceProxy.Create <IDataService>( new Uri("fabric:/DataServiceApplication/DataService"), new ServicePartitionKey(0)); }
public ProductsController() { _catalogService = ServiceProxy.Create <IProductCatalogService>( new Uri("fabric:/ECommerce/ECommerce.ProductCatalog"), new Microsoft.ServiceFabric.Services.Client.ServicePartitionKey(0)); }
public ListingsController() { _listingsService = ServiceProxy.Create <IListingsService>(new Uri("fabric:/Ticketing/Ticketing.Listings.Service")); }
public CompanyProviders(IConfiguration configuration) { _configuration = configuration; serviceProxy = new ServiceProxy(_configuration); }
protected override System.Threading.Tasks.Task <BaseResponse <Timeline> > GetStackData() { return(ServiceProxy.GetUserTimeline(_userId, _page)); }
public PeopleController() { _namesProxy = ServiceProxy.Create <INameService>(new Uri("fabric:/SF.Listeners/SF.Listeners.People"), listenerName: "NameService"); _ageProxy = ServiceProxy.Create <IAgeService>(new Uri("fabric:/SF.Listeners/SF.Listeners.People"), listenerName: "AgeService"); }
public static IStatefulService GetStatefulServiceHandler(string appName, string serviceName, string partitionKey) { var serviceUri = $"fabric:/{appName}/{serviceName}"; return(ServiceProxy.Create <IStatefulService>(new Uri(serviceUri), new ServicePartitionKey(long.Parse(partitionKey)))); }
public ProductsController() { productCatalogService = ServiceProxy.Create <IProductCatalogService>(new Uri("fabric:/ECommerce/ECommerce.ProductCatalog"), new ServicePartitionKey(0)); }
public ValuesController() { _service = ServiceProxy.Create <ICustomerService>(new Uri("fabric:/Flipkart/Customers"), new Microsoft.ServiceFabric.Services.Client.ServicePartitionKey(0)); }
public ActionResult SalesOrder(string id) { using (ServiceProxy<IOrderService> proxy = new ServiceProxy<IOrderService>()) { var model = proxy.Channel.GetSalesOrder(new Guid(id)); return View(model); } }
public TServiceInterface Create <TServiceInterface>(Uri serviceUri, ServicePartitionKey partitionKey = null, TargetReplicaSelector targetReplicaSelector = TargetReplicaSelector.Default, string listenerName = null) where TServiceInterface : IService { return(ServiceProxy.Create <TServiceInterface>(serviceUri, partitionKey, targetReplicaSelector, listenerName)); }
public Task <string> OpenAsync(CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); // Connect to the BSManager Service and target just a single partition for now. bsManager = ServiceProxy.Create <IBSManager>(new Uri("fabric:/BSGateway/BSManagerService"), new ServicePartitionKey(1)); // Get the Port number from the service endpoint EndpointResourceDescription endpoint = context.CodePackageActivationContext.GetEndpoint("ServiceEndpoint"); listeningPort = endpoint.Port; string uriPrefix = $"{endpoint.Protocol}://+:{endpoint.Port}"; string nodeIPOrName = FabricRuntime.GetNodeContext().IPAddressOrFQDN; // Create the list of hostnames to bind to List <string> listHostnamesToBindTo = new List <string>(); listHostnamesToBindTo.Add(nodeIPOrName); // We will add the hostname to the list of names the service will listen on. // // 1) When deployed to the cluster, the kernel driver will connect to the hostname // to interact with the BSGateway (stateless) service. Aside from colocated connection, // we need to do this since attempt to connect to the FQDN of the cluster results in a bugcheck // way down in NT's Event-trace infrastructure. // // REVIEW: We should determine a better way (than binding hostname's IP addresses to service port) // to determine the address service uses on each node. // // 2) When developing the driver, it will connect to FQDN of the dev machine on which the service is running // since the driver is usually developed in a VM (different from where service is deployed). listHostnamesToBindTo.Add(Dns.GetHostName()); // Create the list to hold the tcpListener we create for IPV4 address bindings tcpListeners = new List <TcpListener>(); foreach (string hostname in listHostnamesToBindTo) { // Create a new Tcp listner listening on the specified port IPHostEntry hostEntry = Dns.GetHostEntry(hostname); Console.WriteLine("BSGatewayService: Processing hostname {0} (resolved to {1})", hostname, hostEntry.HostName); foreach (IPAddress address in hostEntry.AddressList) { // REVIEW: Support IPV6 as well. Bind to every IPV4 address // corresponding to the hostname. if (address.AddressFamily == AddressFamily.InterNetwork) { try { TcpListener tcpListener = new TcpListener(address, listeningPort); tcpListener.Start(); tcpListeners.Add(tcpListener); Console.WriteLine("BSGateway: Service is listening at {0}", address.ToString()); // Queue off a workitem in Threadpool that will process incoming requests ThreadPool.QueueUserWorkItem((state) => { this.ProcessTcpRequests(cancellationToken, tcpListener); }); } catch (Exception) { // REVIEW: Ignore any exceptions while starting a listening session. } } } } // REVIEW: Should we publish the URI of all the addresses we are listening on? // Return the Uri to be published by SF's naming service string publishUri = uriPrefix.Replace("+", FabricRuntime.GetNodeContext().IPAddressOrFQDN); return(Task.FromResult(publishUri)); }
public static ILocationViewer CreateLocationViewer() { return(ServiceProxy.Create <ILocationViewer>(LocationReporterServiceUrl, new ServicePartitionKey(0))); }
public ActionResult DeleteRole(string id) { using (var proxy = new ServiceProxy<IUserService>()) { proxy.Channel.DeleteRoles(new IDList { id }); return RedirectToSuccess("删除账户角色成功!", "Roles", "Admin"); } }
public AgentApprovalProviders(IConfiguration configuration) { _configuration = configuration; serviceProxy = new ServiceProxy(_configuration); }
public ActionResult SalesOrders() { using (var proxy = new ServiceProxy<IOrderService>()) { var model = proxy.Channel.GetAllSalesOrders(); return View(model); } }
private async Task PeriodicInventoryCheck(CancellationToken cancellationToken) { IReliableDictionary <InventoryItemId, InventoryItem> inventoryItems = await this.StateManager.GetOrAddAsync <IReliableDictionary <InventoryItemId, InventoryItem> >(InventoryItemDictionaryName); while (true) { cancellationToken.ThrowIfCancellationRequested(); IList <InventoryItem> items = new List <InventoryItem>(); using (ITransaction tx = this.StateManager.CreateTransaction()) { ServiceEventSource.Current.ServiceMessage(this, "Checking inventory stock for {0} items.", await inventoryItems.GetCountAsync(tx)); IAsyncEnumerator <KeyValuePair <InventoryItemId, InventoryItem> > enumerator = (await inventoryItems.CreateEnumerableAsync(tx)).GetAsyncEnumerator(); while (await enumerator.MoveNextAsync(cancellationToken)) { InventoryItem item = enumerator.Current.Value; //Check if stock is below restockThreshold and if the item is not already on reorder if ((item.AvailableStock <= item.RestockThreshold) && !item.OnReorder) { items.Add(enumerator.Current.Value); } } } foreach (InventoryItem item in items) { cancellationToken.ThrowIfCancellationRequested(); try { ServiceUriBuilder builder = new ServiceUriBuilder(RestockRequestManagerServiceName); IRestockRequestManager restockRequestManagerClient = ServiceProxy.Create <IRestockRequestManager>( builder.ToUri(), new ServicePartitionKey()); // we reduce the quantity passed in to RestockRequest to ensure we don't overorder RestockRequest newRequest = new RestockRequest(item.Id, (item.MaxStockThreshold - item.AvailableStock)); InventoryItem updatedItem = new InventoryItem( item.Description, item.Price, item.AvailableStock, item.RestockThreshold, item.MaxStockThreshold, item.Id, true); // TODO: this call needs to be idempotent in case we fail to update the InventoryItem after this completes. await restockRequestManagerClient.AddRestockRequestAsync(newRequest); // Write operations take an exclusive lock on an item, which means we can't do anything else with that item while the transaction is open. // If something blocks before the transaction is committed, the open transaction on the item will prevent all operations on it, including reads. // Once the transaction commits, the lock is released and other operations on the item can proceed. // Operations on the transaction all have timeouts to prevent deadlocking an item, // but we should do as little work inside the transaction as possible that is not related to the transaction itself. using (ITransaction tx = this.StateManager.CreateTransaction()) { await inventoryItems.TryUpdateAsync(tx, item.Id, updatedItem, item); await tx.CommitAsync(); } ServiceEventSource.Current.ServiceMessage( this, "Restock order placed. Item ID: {0}. Quantity: {1}", newRequest.ItemId, newRequest.Quantity); } catch (Exception e) { ServiceEventSource.Current.ServiceMessage(this, "Failed to place restock order for item {0}. {1}", item.Id, e.ToString()); } } await Task.Delay(TimeSpan.FromSeconds(30), cancellationToken); } }
protected override System.Threading.Tasks.Task <BaseResponse <Comment> > GetStackData() { return(ServiceProxy.GetUserMentions(_user.user_id, _page)); }
private void btnOK_Click(object sender, EventArgs e) { errorProvider.Clear(); var hasError = false; if (string.IsNullOrEmpty(txtOldPassword.Text)) { errorProvider.SetError(txtOldPassword, Resources.OriginalPasswordRequired); hasError = true; } if (string.IsNullOrEmpty(txtNewPassword.Text)) { errorProvider.SetError(txtNewPassword, Resources.NewPasswordRequired); hasError = true; } if (string.IsNullOrEmpty(txtConfirmPassword.Text)) { errorProvider.SetError(txtConfirmPassword, Resources.ConfirmPasswordRequired); hasError = true; } if (string.Compare(txtNewPassword.Text, txtConfirmPassword.Text, StringComparison.InvariantCulture) != 0) { errorProvider.SetError(txtConfirmPassword, Resources.IncorrectConfirmPassword); hasError = true; } if (hasError) { this.DialogResult = DialogResult.None; } else { oldPassword = txtOldPassword.Text; newPassword = txtNewPassword.Text; var encodedOldPassword = Convert.ToBase64String( Encoding.ASCII.GetBytes(Crypto.ComputeHash(oldPassword, this.clientCredential.UserName))); var encodedNewPassword = Convert.ToBase64String( Encoding.ASCII.GetBytes(Crypto.ComputeHash(newPassword, this.clientCredential.UserName))); using (var proxy = new ServiceProxy(this.clientCredential)) { try { txtConfirmPassword.Enabled = false; txtNewPassword.Enabled = false; txtOldPassword.Enabled = false; btnOK.Enabled = false; var result = proxy.PostAsJsonAsync( "api/users/password/change", new { clientCredential.UserName, EncodedOldPassword = encodedOldPassword, EncodedNewPassword = encodedNewPassword }).Result; switch (result.StatusCode) { case HttpStatusCode.OK: // Re-assign the new password to client credential clientCredential.Password = newPassword; MessageBox.Show( Resources.PasswordChangedSuccessfully, Resources.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); break; case HttpStatusCode.Forbidden: MessageBox.Show( Resources.IncorrectUserNamePassword, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.None; return; default: var message = result.Content.ReadAsStringAsync().Result; MessageBox.Show( message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.None; return; } } catch (Exception ex) { FrmExceptionDialog.ShowException(ex); this.DialogResult = DialogResult.None; } finally { txtConfirmPassword.Enabled = true; txtNewPassword.Enabled = true; txtOldPassword.Enabled = true; btnOK.Enabled = true; } } } }
public ActionResult DeleteCategory(string id) { using (var proxy = new ServiceProxy<IProductService>()) { proxy.Channel.DeleteCategories(new IDList { id }); return RedirectToSuccess("删除商品分类成功!", "Categories", "Admin"); } }
/// <summary> /// Initializes a new instance of the <see cref="WebApiDataAccessProxy"/> class. /// </summary> /// <param name="credential">The client credential used for consuming the data access functionalities.</param> public WebApiDataAccessProxy(ClientCredential credential) : base(credential) { this.serviceProxy = new ServiceProxy(credential); }
protected override System.Threading.Tasks.Task <BaseResponse <Comment> > GetStackData() { return(ServiceProxy.GetQuestionComments(_post.question_id, PostSortBy.creation, _page)); }
protected override Task <BaseResponse <Post> > GetStackData() { return(ServiceProxy.GetQuestions(_postFilter, _postSortBy, _page)); }
protected override void Load(ContainerBuilder builder) { // IMetricsListener builder.Register( c => this.metricsConfig.Enabled ? new MetricsListener(this.metricsConfig.ListenerConfig, c.Resolve <IMetricsProvider>()) : new NullMetricsListener() as IMetricsListener) .As <IMetricsListener>() .SingleInstance(); // IMetricsProvider builder.Register( c => this.metricsConfig.Enabled ? new MetricsProvider(MetricsConstants.EdgeHubMetricPrefix, this.iothubHostName, this.edgeDeviceId, this.metricsConfig.HistogramMaxAge) : new NullMetricsProvider() as IMetricsProvider) .As <IMetricsProvider>() .SingleInstance(); // ISignatureProvider builder.Register( c => { ISignatureProvider signatureProvider = this.edgeHubConnectionString.Map( cs => { IotHubConnectionStringBuilder csBuilder = IotHubConnectionStringBuilder.Create(cs); return(new SharedAccessKeySignatureProvider(csBuilder.SharedAccessKey) as ISignatureProvider); }) .GetOrElse( () => { string edgeHubGenerationId = this.edgeHubGenerationId.Expect(() => new InvalidOperationException("Generation ID missing")); string workloadUri = this.workloadUri.Expect(() => new InvalidOperationException("workloadUri is missing")); string workloadApiVersion = this.workloadApiVersion.Expect(() => new InvalidOperationException("workloadUri version is missing")); return(new HttpHsmSignatureProvider(this.edgeHubModuleId, edgeHubGenerationId, workloadUri, workloadApiVersion, Constants.WorkloadApiVersion) as ISignatureProvider); }); return(signatureProvider); }) .As <ISignatureProvider>() .SingleInstance(); // Detect system environment builder.Register(c => new SystemEnvironment()) .As <ISystemEnvironment>() .SingleInstance(); // DataBase options builder .Register(c => new RocksDbOptionsProvider( c.Resolve <ISystemEnvironment>(), this.optimizeForPerformance, this.storageMaxTotalWalSize, this.storageMaxManifestFileSize, this.storageMaxOpenFiles, this.storageLogLevel)) .As <IRocksDbOptionsProvider>() .SingleInstance(); if (!this.usePersistentStorage && this.useBackupAndRestore) { // Backup and restore serialization builder.Register(c => new ProtoBufDataBackupRestore()) .As <IDataBackupRestore>() .SingleInstance(); } // IStorageSpaceChecker builder.Register( c => { IStorageSpaceChecker spaceChecker = !this.usePersistentStorage ? new MemorySpaceChecker(() => 0L) as IStorageSpaceChecker : new NullStorageSpaceChecker(); return(spaceChecker); }) .As <IStorageSpaceChecker>() .SingleInstance(); // IDbStoreProvider builder.Register( async c => { var loggerFactory = c.Resolve <ILoggerFactory>(); ILogger logger = loggerFactory.CreateLogger(typeof(RoutingModule)); if (this.usePersistentStorage) { // Create partitions for messages and twins var partitionsList = new List <string> { Core.Constants.MessageStorePartitionKey, Core.Constants.TwinStorePartitionKey, Core.Constants.CheckpointStorePartitionKey }; try { IDbStoreProvider dbStoreProvider = DbStoreProvider.Create( c.Resolve <IRocksDbOptionsProvider>(), this.storagePath, partitionsList); logger.LogInformation($"Created persistent store at {this.storagePath}"); return(dbStoreProvider); } catch (Exception ex) when(!ex.IsFatal()) { logger.LogError(ex, "Error creating RocksDB store. Falling back to in-memory store."); IDbStoreProvider dbStoreProvider = await this.BuildInMemoryDbStoreProvider(c); return(dbStoreProvider); } } else { logger.LogInformation($"Using in-memory store"); IDbStoreProvider dbStoreProvider = await this.BuildInMemoryDbStoreProvider(c); return(dbStoreProvider); } }) .As <Task <IDbStoreProvider> >() .SingleInstance(); // Task<Option<IEncryptionProvider>> builder.Register( async c => { Option <IEncryptionProvider> encryptionProviderOption = await this.workloadUri .Map( async uri => { var encryptionProvider = await EncryptionProvider.CreateAsync( this.storagePath, new Uri(uri), this.workloadApiVersion.Expect(() => new InvalidOperationException("Missing workload API version")), Constants.WorkloadApiVersion, this.edgeHubModuleId, this.edgeHubGenerationId.Expect(() => new InvalidOperationException("Missing generation ID")), Constants.InitializationVectorFileName) as IEncryptionProvider; return(Option.Some(encryptionProvider)); }) .GetOrElse(() => Task.FromResult(Option.None <IEncryptionProvider>())); return(encryptionProviderOption); }) .As <Task <Option <IEncryptionProvider> > >() .SingleInstance(); // Task<IStoreProvider> builder.Register(async c => { var dbStoreProvider = await c.Resolve <Task <IDbStoreProvider> >(); IStoreProvider storeProvider = new StoreProvider(dbStoreProvider); return(storeProvider); }) .As <Task <IStoreProvider> >() .SingleInstance(); // Task<IMetadataStore> builder.Register( async c => { var storeProvider = await c.Resolve <Task <IStoreProvider> >(); IKeyValueStore <string, string> entityStore = storeProvider.GetEntityStore <string, string>("ProductInfo", "MetadataStore"); IMetadataStore metadataStore = new MetadataStore(entityStore, this.productInfo); return(metadataStore); }) .As <Task <IMetadataStore> >() .SingleInstance(); // ITokenProvider builder.Register(c => new ClientTokenProvider(c.Resolve <ISignatureProvider>(), this.iothubHostName, this.edgeDeviceId, this.edgeHubModuleId, TimeSpan.FromHours(1))) .Named <ITokenProvider>("EdgeHubClientAuthTokenProvider") .SingleInstance(); // ITokenProvider builder.Register( c => { string deviceId = WebUtility.UrlEncode(this.edgeDeviceId); string moduleId = WebUtility.UrlEncode(this.edgeHubModuleId); return(new ClientTokenProvider(c.Resolve <ISignatureProvider>(), this.iothubHostName, deviceId, moduleId, TimeSpan.FromHours(1))); }) .Named <ITokenProvider>("EdgeHubServiceAuthTokenProvider") .SingleInstance(); builder.Register( c => { var loggerFactory = c.Resolve <ILoggerFactory>(); var logger = loggerFactory.CreateLogger <RoutingModule>(); return(Proxy.Parse(this.proxy, logger)); }) .As <Option <IWebProxy> >() .SingleInstance(); // IServiceIdentityHierarchy builder.Register <IServiceIdentityHierarchy>( c => { if (this.nestedEdgeEnabled) { return(new ServiceIdentityTree(this.edgeDeviceId)); } else { return(new ServiceIdentityDictionary(this.edgeDeviceId)); } }) .As <IServiceIdentityHierarchy>() .SingleInstance(); // Task<IDeviceScopeIdentitiesCache> builder.Register( async c => { IDeviceScopeIdentitiesCache deviceScopeIdentitiesCache; if (this.authenticationMode == AuthenticationMode.CloudAndScope || this.authenticationMode == AuthenticationMode.Scope) { var edgeHubTokenProvider = c.ResolveNamed <ITokenProvider>("EdgeHubServiceAuthTokenProvider"); var proxy = c.Resolve <Option <IWebProxy> >(); IServiceIdentityHierarchy serviceIdentityHierarchy = c.Resolve <IServiceIdentityHierarchy>(); string hostName = this.gatewayHostName.GetOrElse(this.iothubHostName); IDeviceScopeApiClientProvider securityScopesApiClientProvider = new DeviceScopeApiClientProvider(hostName, this.edgeDeviceId, this.edgeHubModuleId, 10, edgeHubTokenProvider, serviceIdentityHierarchy, proxy); IServiceProxy serviceProxy = new ServiceProxy(securityScopesApiClientProvider, this.nestedEdgeEnabled); IKeyValueStore <string, string> encryptedStore = await GetEncryptedStore(c, "DeviceScopeCache"); deviceScopeIdentitiesCache = await DeviceScopeIdentitiesCache.Create(serviceIdentityHierarchy, serviceProxy, encryptedStore, this.scopeCacheRefreshRate, this.scopeCacheRefreshDelay); } else { deviceScopeIdentitiesCache = new NullDeviceScopeIdentitiesCache(); } return(deviceScopeIdentitiesCache); }) .As <Task <IDeviceScopeIdentitiesCache> >() .AutoActivate() .SingleInstance(); // IRegistryApiClient builder.Register( c => { string upstreamHostname = this.gatewayHostName.GetOrElse(this.iothubHostName); var proxy = c.Resolve <Option <IWebProxy> >(); var edgeHubTokenProvider = c.ResolveNamed <ITokenProvider>("EdgeHubServiceAuthTokenProvider"); return(new RegistryOnBehalfOfApiClient(upstreamHostname, proxy, edgeHubTokenProvider)); }) .As <IRegistryOnBehalfOfApiClient>() .SingleInstance(); // Task<ICredentialsCache> builder.Register( async c => { ICredentialsCache underlyingCredentialsCache; if (this.persistTokens) { IKeyValueStore <string, string> encryptedStore = await GetEncryptedStore(c, "CredentialsCache"); return(new PersistedTokenCredentialsCache(encryptedStore)); } else { underlyingCredentialsCache = new NullCredentialsCache(); } ICredentialsCache credentialsCache; if (this.nestedEdgeEnabled) { credentialsCache = new NestedCredentialsCache(underlyingCredentialsCache); } else { credentialsCache = new CredentialsCache(underlyingCredentialsCache); } return(credentialsCache); }) .As <Task <ICredentialsCache> >() .SingleInstance(); // Task<IAuthenticator> builder.Register( async c => { IAuthenticator tokenAuthenticator; IAuthenticator certificateAuthenticator; IDeviceScopeIdentitiesCache deviceScopeIdentitiesCache; var credentialsCacheTask = c.Resolve <Task <ICredentialsCache> >(); // by default regardless of how the authenticationMode, X.509 certificate validation will always be scoped deviceScopeIdentitiesCache = await c.Resolve <Task <IDeviceScopeIdentitiesCache> >(); certificateAuthenticator = new DeviceScopeCertificateAuthenticator(deviceScopeIdentitiesCache, new NullAuthenticator(), this.trustBundle, true, this.nestedEdgeEnabled); switch (this.authenticationMode) { case AuthenticationMode.Cloud: tokenAuthenticator = await this.GetCloudTokenAuthenticator(c); break; case AuthenticationMode.Scope: tokenAuthenticator = new DeviceScopeTokenAuthenticator(deviceScopeIdentitiesCache, this.iothubHostName, this.edgeDeviceHostName, new NullAuthenticator(), true, true, this.nestedEdgeEnabled); break; default: IAuthenticator cloudTokenAuthenticator = await this.GetCloudTokenAuthenticator(c); tokenAuthenticator = new DeviceScopeTokenAuthenticator(deviceScopeIdentitiesCache, this.iothubHostName, this.edgeDeviceHostName, cloudTokenAuthenticator, true, true, this.nestedEdgeEnabled); break; } ICredentialsCache credentialsCache = await credentialsCacheTask; return(new Authenticator(tokenAuthenticator, certificateAuthenticator, credentialsCache) as IAuthenticator); }) .As <Task <IAuthenticator> >() .SingleInstance(); // IClientCredentialsFactory builder.Register(c => new ClientCredentialsFactory(c.Resolve <IIdentityProvider>(), this.productInfo)) .As <IClientCredentialsFactory>() .SingleInstance(); // IClientCredentials "EdgeHubCredentials" builder.Register( c => { var identityFactory = c.Resolve <IClientCredentialsFactory>(); IClientCredentials edgeHubCredentials = this.edgeHubConnectionString.Map(cs => identityFactory.GetWithConnectionString(cs)).GetOrElse( () => identityFactory.GetWithIotEdged(this.edgeDeviceId, this.edgeHubModuleId)); return(edgeHubCredentials); }) .Named <IClientCredentials>("EdgeHubCredentials") .SingleInstance(); // ServiceIdentity "EdgeHubIdentity" builder.Register( c => { return(new ServiceIdentity( this.edgeDeviceId, this.edgeHubModuleId, deviceScope: null, parentScopes: new List <string>(), this.edgeHubGenerationId.GetOrElse("0"), capabilities: new List <string>(), new ServiceAuthentication(ServiceAuthenticationType.None), ServiceIdentityStatus.Enabled)); }) .Named <ServiceIdentity>("EdgeHubIdentity") .SingleInstance(); // ConnectionReauthenticator builder.Register( async c => { var edgeHubCredentials = c.ResolveNamed <IClientCredentials>("EdgeHubCredentials"); var connectionManagerTask = c.Resolve <Task <IConnectionManager> >(); var authenticatorTask = c.Resolve <Task <IAuthenticator> >(); var credentialsCacheTask = c.Resolve <Task <ICredentialsCache> >(); var deviceScopeIdentitiesCacheTask = c.Resolve <Task <IDeviceScopeIdentitiesCache> >(); var deviceConnectivityManager = c.Resolve <IDeviceConnectivityManager>(); IConnectionManager connectionManager = await connectionManagerTask; IAuthenticator authenticator = await authenticatorTask; ICredentialsCache credentialsCache = await credentialsCacheTask; IDeviceScopeIdentitiesCache deviceScopeIdentitiesCache = await deviceScopeIdentitiesCacheTask; var connectionReauthenticator = new ConnectionReauthenticator( connectionManager, authenticator, credentialsCache, deviceScopeIdentitiesCache, TimeSpan.FromMinutes(5), edgeHubCredentials.Identity, deviceConnectivityManager); return(connectionReauthenticator); }) .As <Task <ConnectionReauthenticator> >() .SingleInstance(); base.Load(builder); }
private IProductCatalogService GetProductCatalogService() { return(ServiceProxy.Create <IProductCatalogService>( new Uri("fabric:/Belatrix/Belatrix.ProductCatalog"), new ServicePartitionKey(0))); }
public TestController(ServiceProxy <IExampleServiceState> serviceProxy) { _proxy = serviceProxy; }
public ActionResult EnableUserAccount(string id) { using (var proxy = new ServiceProxy<IUserService>()) { proxy.Channel.EnableUser(new UserDataObject { ID = id }); return RedirectToAction("UserAccounts"); } }
public ActionResult SalesOrders() { using (ServiceProxy<IOrderService> proxy = new ServiceProxy<IOrderService>()) { var model = proxy.Channel.GetSalesOrdersForUser(this.UserID); return View(model); } }
public ActionResult DeleteUserAccount(string id) { using (var proxy = new ServiceProxy<IUserService>()) { proxy.Channel.DeleteUsers(new UserDataObjectList { new UserDataObject { ID = id } }); return RedirectToSuccess("删除用户账户成功!", "UserAccounts", "Admin"); } }
protected override Task <BaseResponse <Post> > GetStackData() { return(ServiceProxy.GetFavoritesForUser(_userId, PostSortBy.votes, _page)); }
public ActionResult Roles() { using (var proxy = new ServiceProxy<IUserService>()) { var model = proxy.Channel.GetRoles(); return View(model); } }
private void btnOK_Click(object sender, EventArgs e) { errorProvider.Clear(); this.DialogResult = DialogResult.OK; if (string.IsNullOrEmpty(txtUserName.Text)) { errorProvider.SetError(txtUserName, Resources.UserNameRequired); txtUserName.Focus(); this.DialogResult = DialogResult.None; return; } if (string.IsNullOrEmpty(txtPassword.Text)) { errorProvider.SetError(txtPassword, Resources.PasswordRequired); txtPassword.Focus(); this.DialogResult = DialogResult.None; return; } if (string.IsNullOrEmpty(txtConfirm.Text)) { errorProvider.SetError(txtConfirm, Resources.ConfirmPasswordRequired); txtConfirm.Focus(); this.DialogResult = DialogResult.None; return; } if (string.Compare(txtPassword.Text, txtConfirm.Text, StringComparison.InvariantCultureIgnoreCase) != 0) { errorProvider.SetError(txtConfirm, Resources.IncorrectConfirmPassword); txtConfirm.Focus(); this.DialogResult = DialogResult.None; return; } if (string.IsNullOrEmpty(txtEmail.Text)) { errorProvider.SetError(txtEmail, Resources.EmailRequired); txtEmail.Focus(); this.DialogResult = DialogResult.None; return; } var regex = new Regex(Constants.EmailAddressFormatPattern); if (!regex.IsMatch(txtEmail.Text)) { errorProvider.SetError(txtEmail, Resources.InvalidEmailAddress); txtEmail.Focus(); this.DialogResult = DialogResult.None; return; } if (string.IsNullOrEmpty(txtServer.Text)) { errorProvider.SetError(txtServer, Resources.ServerRequired); txtServer.Focus(); this.DialogResult = DialogResult.None; return; } try { txtUserName.Enabled = false; txtPassword.Enabled = false; txtConfirm.Enabled = false; txtEmail.Enabled = false; txtServer.Enabled = false; btnOK.Enabled = false; using ( var proxy = new ServiceProxy( new ClientCredential { UserName = Crypto.ProxyUserName, Password = Crypto.ProxyUserPassword, ServerUri = txtServer.Text.Trim() })) { var result = proxy.PutAsJsonAsync( "api/users/create", new { UserName = txtUserName.Text.Trim(), Password = Convert.ToBase64String( Encoding.ASCII.GetBytes( Crypto.ComputeHash(txtPassword.Text.Trim(), txtUserName.Text.Trim()))), Email = txtEmail.Text.Trim() }).Result; // Here we cannot use the async/await feature, since // the dialog will be closed even if we set the DialogResult to None. if (result.IsSuccessStatusCode) { this.UserName = txtUserName.Text.Trim(); this.Password = txtPassword.Text.Trim(); this.ServerUri = txtServer.Text.Trim(); MessageBox.Show( Resources.CreateAccountSuccessful, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { dynamic details = JsonConvert.DeserializeObject(result.Content.ReadAsStringAsync().Result); if (details != null) { MessageBox.Show( details.ExceptionMessage.ToString(), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Register failed!", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } this.DialogResult = DialogResult.None; } } } catch (Exception ex) { FrmExceptionDialog.ShowException(ex); this.DialogResult = DialogResult.None; } finally { txtUserName.Enabled = true; txtPassword.Enabled = true; txtConfirm.Enabled = true; txtEmail.Enabled = true; txtServer.Enabled = true; btnOK.Enabled = true; } }
protected override void Load(ContainerBuilder builder) { // ISignatureProvider builder.Register( c => { ISignatureProvider signatureProvider = this.edgeHubConnectionString.Map( cs => { IotHubConnectionStringBuilder csBuilder = IotHubConnectionStringBuilder.Create(cs); return(new SharedAccessKeySignatureProvider(csBuilder.SharedAccessKey) as ISignatureProvider); }) .GetOrElse( () => { string edgeHubGenerationId = this.edgeHubGenerationId.Expect(() => new InvalidOperationException("Generation ID missing")); string workloadUri = this.workloadUri.Expect(() => new InvalidOperationException("workloadUri is missing")); return(new HttpHsmSignatureProvider(this.edgeHubModuleId, edgeHubGenerationId, workloadUri, Service.Constants.WorkloadApiVersion) as ISignatureProvider); }); return(signatureProvider); }) .As <ISignatureProvider>() .SingleInstance(); // Detect system environment builder.Register(c => new SystemEnvironment()) .As <ISystemEnvironment>() .SingleInstance(); // DataBase options builder.Register(c => new Storage.RocksDb.RocksDbOptionsProvider(c.Resolve <ISystemEnvironment>(), this.optimizeForPerformance)) .As <Storage.RocksDb.IRocksDbOptionsProvider>() .SingleInstance(); // IDbStoreProvider builder.Register( c => { var loggerFactory = c.Resolve <ILoggerFactory>(); ILogger logger = loggerFactory.CreateLogger(typeof(RoutingModule)); if (this.usePersistentStorage) { // Create partitions for messages and twins var partitionsList = new List <string> { Constants.MessageStorePartitionKey, Constants.TwinStorePartitionKey, Core.Constants.CheckpointStorePartitionKey }; try { IDbStoreProvider dbStoreprovider = Storage.RocksDb.DbStoreProvider.Create(c.Resolve <Storage.RocksDb.IRocksDbOptionsProvider>(), this.storagePath, partitionsList); logger.LogInformation($"Created persistent store at {this.storagePath}"); return(dbStoreprovider); } catch (Exception ex) when(!ExceptionEx.IsFatal(ex)) { logger.LogError(ex, "Error creating RocksDB store. Falling back to in-memory store."); return(new InMemoryDbStoreProvider()); } } else { logger.LogInformation($"Using in-memory store"); return(new InMemoryDbStoreProvider()); } }) .As <IDbStoreProvider>() .SingleInstance(); // Task<Option<IEncryptionProvider>> builder.Register( async c => { Option <IEncryptionProvider> encryptionProviderOption = await this.workloadUri .Map( async uri => { var encryptionProvider = await EncryptionProvider.CreateAsync( this.storagePath, new Uri(uri), Service.Constants.WorkloadApiVersion, this.edgeHubModuleId, this.edgeHubGenerationId.Expect(() => new InvalidOperationException("Missing generation ID")), Service.Constants.InitializationVectorFileName) as IEncryptionProvider; return(Option.Some(encryptionProvider)); }) .GetOrElse(() => Task.FromResult(Option.None <IEncryptionProvider>())); return(encryptionProviderOption); }) .As <Task <Option <IEncryptionProvider> > >() .SingleInstance(); // IStoreProvider builder.Register(c => new StoreProvider(c.Resolve <IDbStoreProvider>())) .As <IStoreProvider>() .SingleInstance(); // ITokenProvider builder.Register(c => new ClientTokenProvider(c.Resolve <ISignatureProvider>(), this.iothubHostName, this.edgeDeviceId, this.edgeHubModuleId, TimeSpan.FromHours(1))) .Named <ITokenProvider>("EdgeHubClientAuthTokenProvider") .SingleInstance(); // ITokenProvider builder.Register(c => { string deviceId = WebUtility.UrlEncode(this.edgeDeviceId); string moduleId = WebUtility.UrlEncode(this.edgeHubModuleId); return(new ClientTokenProvider(c.Resolve <ISignatureProvider>(), this.iothubHostName, deviceId, moduleId, TimeSpan.FromHours(1))); }) .Named <ITokenProvider>("EdgeHubServiceAuthTokenProvider") .SingleInstance(); // Task<IDeviceScopeIdentitiesCache> builder.Register( async c => { IDeviceScopeIdentitiesCache deviceScopeIdentitiesCache; if (this.authenticationMode == AuthenticationMode.CloudAndScope || this.authenticationMode == AuthenticationMode.Scope) { var edgeHubTokenProvider = c.ResolveNamed <ITokenProvider>("EdgeHubServiceAuthTokenProvider"); IDeviceScopeApiClient securityScopesApiClient = new DeviceScopeApiClient(this.iothubHostName, this.edgeDeviceId, this.edgeHubModuleId, 10, edgeHubTokenProvider); IServiceProxy serviceProxy = new ServiceProxy(securityScopesApiClient); IKeyValueStore <string, string> encryptedStore = await GetEncryptedStore(c, "DeviceScopeCache"); deviceScopeIdentitiesCache = await DeviceScopeIdentitiesCache.Create(serviceProxy, encryptedStore, this.scopeCacheRefreshRate); } else { deviceScopeIdentitiesCache = new NullDeviceScopeIdentitiesCache(); } return(deviceScopeIdentitiesCache); }) .As <Task <IDeviceScopeIdentitiesCache> >() .AutoActivate() .SingleInstance(); // Task<ICredentialsCache> builder.Register(async c => { ICredentialsCache underlyingCredentialsCache; if (this.persistTokens) { IKeyValueStore <string, string> encryptedStore = await GetEncryptedStore(c, "CredentialsCache"); return(new PersistedTokenCredentialsCache(encryptedStore)); } else { underlyingCredentialsCache = new NullCredentialsCache(); } ICredentialsCache credentialsCache = new CredentialsCache(underlyingCredentialsCache); return(credentialsCache); }) .As <Task <ICredentialsCache> >() .SingleInstance(); // Task<IAuthenticator> builder.Register(async c => { IAuthenticator tokenAuthenticator; IAuthenticator certificateAuthenticator; IDeviceScopeIdentitiesCache deviceScopeIdentitiesCache; var credentialsCacheTask = c.Resolve <Task <ICredentialsCache> >(); // by default regardless of how the authenticationMode, X.509 certificate validation will always be scoped deviceScopeIdentitiesCache = await c.Resolve <Task <IDeviceScopeIdentitiesCache> >(); certificateAuthenticator = new DeviceScopeCertificateAuthenticator(deviceScopeIdentitiesCache, new NullAuthenticator(), this.trustBundle, true); switch (this.authenticationMode) { case AuthenticationMode.Cloud: tokenAuthenticator = await this.GetCloudTokenAuthenticator(c); break; case AuthenticationMode.Scope: tokenAuthenticator = new DeviceScopeTokenAuthenticator(deviceScopeIdentitiesCache, this.iothubHostName, this.edgeDeviceHostName, new NullAuthenticator(), true, true); break; default: IAuthenticator cloudTokenAuthenticator = await this.GetCloudTokenAuthenticator(c); tokenAuthenticator = new DeviceScopeTokenAuthenticator(deviceScopeIdentitiesCache, this.iothubHostName, this.edgeDeviceHostName, cloudTokenAuthenticator, true, true); break; } ICredentialsCache credentialsCache = await credentialsCacheTask; return(new Authenticator(tokenAuthenticator, certificateAuthenticator, this.edgeDeviceId, credentialsCache) as IAuthenticator); }) .As <Task <IAuthenticator> >() .SingleInstance(); // IClientCredentialsFactory builder.Register(c => new ClientCredentialsFactory(c.Resolve <IIdentityProvider>(), this.productInfo)) .As <IClientCredentialsFactory>() .SingleInstance(); // ConnectionReauthenticator builder.Register(async c => { var edgeHubCredentials = c.ResolveNamed <IClientCredentials>("EdgeHubCredentials"); var connectionManagerTask = c.Resolve <Task <IConnectionManager> >(); var authenticatorTask = c.Resolve <Task <IAuthenticator> >(); var credentialsCacheTask = c.Resolve <Task <ICredentialsCache> >(); var deviceScopeIdentitiesCacheTask = c.Resolve <Task <IDeviceScopeIdentitiesCache> >(); var deviceConnectivityManager = c.Resolve <IDeviceConnectivityManager>(); IConnectionManager connectionManager = await connectionManagerTask; IAuthenticator authenticator = await authenticatorTask; ICredentialsCache credentialsCache = await credentialsCacheTask; IDeviceScopeIdentitiesCache deviceScopeIdentitiesCache = await deviceScopeIdentitiesCacheTask; var connectionReauthenticator = new ConnectionReauthenticator( connectionManager, authenticator, credentialsCache, deviceScopeIdentitiesCache, TimeSpan.FromMinutes(5), edgeHubCredentials.Identity, deviceConnectivityManager); return(connectionReauthenticator); }) .As <Task <ConnectionReauthenticator> >() .SingleInstance(); base.Load(builder); }
internal void BuildObjectGraph(Action shutdown) { const int FIVE_SECONDS = 5000; const int THIRTY_SECONDS = 30000; logger = new Logger(); systemInfo = new SystemInfo(); InitializeConfiguration(); InitializeLogging(); InitializeText(); var args = Environment.GetCommandLineArgs(); var messageBox = new MessageBoxFactory(text); var nativeMethods = new NativeMethods(); var uiFactory = new UserInterfaceFactory(text); var desktopFactory = new DesktopFactory(ModuleLogger(nameof(DesktopFactory))); var explorerShell = new ExplorerShell(ModuleLogger(nameof(ExplorerShell)), nativeMethods); var fileSystem = new FileSystem(); var processFactory = new ProcessFactory(ModuleLogger(nameof(ProcessFactory))); var proxyFactory = new ProxyFactory(new ProxyObjectFactory(), ModuleLogger(nameof(ProxyFactory))); var runtimeHost = new RuntimeHost(appConfig.RuntimeAddress, new HostObjectFactory(), ModuleLogger(nameof(RuntimeHost)), FIVE_SECONDS); var runtimeWindow = uiFactory.CreateRuntimeWindow(appConfig); var server = new ServerProxy(appConfig, ModuleLogger(nameof(ServerProxy))); var serviceProxy = new ServiceProxy(appConfig.ServiceAddress, new ProxyObjectFactory(), ModuleLogger(nameof(ServiceProxy)), Interlocutor.Runtime); var sessionContext = new SessionContext(); var splashScreen = uiFactory.CreateSplashScreen(appConfig); var userInfo = new UserInfo(ModuleLogger(nameof(UserInfo))); var vmDetector = new VirtualMachineDetector(ModuleLogger(nameof(VirtualMachineDetector)), systemInfo); var bootstrapOperations = new Queue <IOperation>(); var sessionOperations = new Queue <IRepeatableOperation>(); bootstrapOperations.Enqueue(new I18nOperation(logger, text)); bootstrapOperations.Enqueue(new CommunicationHostOperation(runtimeHost, logger)); sessionOperations.Enqueue(new SessionInitializationOperation(configuration, fileSystem, logger, runtimeHost, sessionContext)); sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new FileSystem(), new HashAlgorithm(), logger, sessionContext)); sessionOperations.Enqueue(new ServerOperation(args, configuration, fileSystem, logger, sessionContext, server)); sessionOperations.Enqueue(new VirtualMachineOperation(vmDetector, logger, sessionContext)); sessionOperations.Enqueue(new ServiceOperation(logger, runtimeHost, serviceProxy, sessionContext, THIRTY_SECONDS, userInfo)); sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS)); sessionOperations.Enqueue(new KioskModeOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext)); sessionOperations.Enqueue(new ClientOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS)); sessionOperations.Enqueue(new SessionActivationOperation(logger, sessionContext)); var bootstrapSequence = new OperationSequence(logger, bootstrapOperations); var sessionSequence = new RepeatableOperationSequence(logger, sessionOperations); RuntimeController = new RuntimeController( appConfig, logger, messageBox, bootstrapSequence, sessionSequence, runtimeHost, runtimeWindow, serviceProxy, sessionContext, shutdown, splashScreen, text, uiFactory); }
public GroupsController() { this.service = ServiceProxy.Create <IGroupsService>(new Uri(Constants.GROUPS_SERVICE_URI)); }
static void UpdateU9LogProxy(U9Context context,EntityResult result,long svID) { ServiceProxy svProxy = new ServiceProxy(); U9ProxyLogger logger = new U9ProxyLogger(); logger.ID = svID; logger.Result = result; svProxy.Do(context, logger); }
public async void ExecuteRefreshCommand(object param) { var data = await Task.Run(() => ServiceProxy.GetAvaivableGames().ToList()); Games = new ObservableCollection <OneWayReference.Game>(data); }