public async Task <IActionResult> Index() { var context = CreateDomainContext(); var threadDomain = DomainProvider.GetService <EntityDomainService <Thread> >(); IEntityEditModel <Thread> threadResult; try { threadResult = await threadDomain.ExecuteAsync <IEntityEditModel <Thread> >(context, "Detail"); ViewBag.Thread = threadResult.Item; } catch (ArgumentException ex) { return(NotFound()); } catch (EntityNotFoundException ex) { return(NotFound()); } var postDomain = DomainProvider.GetService <EntityDomainService <Post> >(); IEntityViewModel <Post> postResult = await postDomain.ExecuteAsync <IEntityViewModel <Post> >(context, "List"); return(View(postResult)); }
public Task <TResult> ExecuteAsync <TDomainService, TResult>(IDomainContext context, string method) where TDomainService : IDomainService { var domain = DomainProvider.GetService <TDomainService>(); return(domain.ExecuteAsync <TResult>(context, method)); }
public async Task <IActionResult> SignUp(string username) { if (User.Identity.IsAuthenticated) { return(StatusCode(200)); } var memberDomain = DomainProvider.GetService <MemberDomainService>(); var context = CreateDomainContext(); try { await memberDomain.ExecuteAsync(context, "SignUp"); } catch (DomainServiceException ex) { if (ex.InnerException is ArgumentException) { return(StatusCode(401, ex.InnerException.Message)); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } return(StatusCode(200)); }
public async Task <IActionResult> Create() { var context = CreateDomainContext(); var forumDomain = DomainProvider.GetService <EntityDomainService <Entity.Forum> >(); IEntityEditModel <Entity.Forum> forumResult; try { forumResult = await forumDomain.ExecuteAsync <IEntityEditModel <Entity.Forum> >(context, "Detail"); ViewBag.Forum = forumResult.Item; } catch (ArgumentException ex) { return(NotFound()); } catch (EntityNotFoundException ex) { return(NotFound()); } var threadDomain = DomainProvider.GetService <EntityDomainService <Thread> >(); IEntityEditModel <Thread> threadResult = await threadDomain.ExecuteAsync <IEntityEditModel <Thread> >(context, "Create"); threadResult.Item.Forum = forumResult.Item; return(View(threadResult)); }
public virtual async Task <IActionResult> PostDelete() { var context = GetPostDeleteDomainContext(); var domain = DomainProvider.GetService <ForumDomainService>(); try { await domain.ExecuteDeletePost(context); return(Ok()); } catch (DomainServiceException ex) { if (ex.InnerException is KeyNotFoundException) { return(NotFound()); } else if (ex.InnerException is ArgumentException || ex.InnerException is ArgumentNullException || ex.InnerException is ArgumentOutOfRangeException) { return(BadRequest(ex.InnerException.Message)); } else if (ex.InnerException is UnauthorizedAccessException) { return(Unauthorized()); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } }
public virtual async Task <IActionResult> Thread() { var context = GetThreadDomainContext(); var domain = DomainProvider.GetService <ForumDomainService>(); try { var thread = await domain.ExecuteGetThread(context); ViewBag.Thread = thread; } catch (DomainServiceException ex) { if (ex.InnerException is KeyNotFoundException) { return(NotFound()); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } var result = await domain.ExecuteListPosts(context); return(View(result)); }
/// <summary> /// Starts the thread service. /// </summary> public void Start() { log.Debug("IdentityManagement service Start called"); // Instantiate the server domain // The domain will be created the first time the // server is run EnterpriseDomain enterpriseDomain = new EnterpriseDomain(true); if (enterpriseDomain != null) { // Valid enterprise domain - start the external // identity sync service Simias.IdentitySynchronization.Service.Start(); if (userProvider == null) { LoadIdentityProvider(); } // Register with the domain provider service. if (authProvider == null) { authProvider = new Simias.Identity.Authentication(); DomainProvider.RegisterProvider(this.authProvider); } } }
private void lstView_Click(object sender, EventArgs e) { Application.DoEvents(); try { lstNetworkDevices.Items.Clear(); lstIPAddress.DataSource = null; lstStorage.Items.Clear(); lstSoftware.Items.Clear(); SelectedMachineName = lstView.SelectedItems[0].SubItems[1].Text; if (DomainProvider.GetInstance().IsDomainAdministrator || Dns.GetHostName() == SelectedMachineName) { InitCursor(); GetListofSofwares(); PopulateNetworkDevices(); FillStorage(); ResetCursor(); } else { MessageBox.Show("Please login as domain admin to see other system details"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async Task <IActionResult> Create() { var context = CreateDomainContext(); var forumDomain = DomainProvider.GetService <EntityDomainService <Entity.Forum> >(); IEntityEditModel <Entity.Forum> forumResult; try { forumResult = await forumDomain.ExecuteAsync <IEntityEditModel <Entity.Forum> >(context, "Detail"); ViewBag.Forum = forumResult.Item; } catch (DomainServiceException ex) { if (ex.InnerException is ArgumentException) { return(StatusCode(400, ex.InnerException.Message)); } else if (ex.InnerException is EntityNotFoundException) { return(NotFound()); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } var threadDomain = DomainProvider.GetService <EntityDomainService <Thread> >(); IEntityEditModel <Thread> threadResult = await threadDomain.ExecuteAsync <IEntityEditModel <Thread> >(context, "Create"); threadResult.Item.Forum = forumResult.Item; return(View(threadResult)); }
private void FindFirstEnumerateAll(string domainID) { string context; Member[] memberList; int total; bool moreEntries = DomainProvider.FindFirstDomainMembers( domainID, MemberCount + 1, out context, out memberList, out total); if (moreEntries) { throw new ApplicationException("More entries returned."); } if (memberList == null) { throw new ApplicationException("No member list returned."); } if (memberList.Length != total) { throw new ApplicationException("Not all entries returned in list."); } if (total != MemberCount) { throw new ApplicationException("Total entries is incorrect."); } CheckMemberOrder(memberList); DomainProvider.FindCloseDomainMembers(domainID, context); }
public async Task <IActionResult> Index() { var context = CreateDomainContext(); var threadDomain = DomainProvider.GetService <EntityDomainService <Thread> >(); IEntityEditModel <Thread> threadResult; try { threadResult = await threadDomain.ExecuteAsync <IEntityEditModel <Thread> >(context, "Detail"); ViewBag.Thread = threadResult.Item; } catch (DomainServiceException ex) { if (ex.InnerException is ArgumentException) { return(StatusCode(400, ex.InnerException.Message)); } else if (ex.InnerException is EntityNotFoundException) { return(NotFound()); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } var postDomain = DomainProvider.GetService <EntityDomainService <Post> >(); IEntityViewModel <Post> postResult = await postDomain.ExecuteAsync <IEntityViewModel <Post> >(context, "List"); return(View(postResult)); }
/// <summary> /// Stops the service from executing. /// </summary> public void Stop() { log.Debug("Stop called"); Simias.Server.Catalog.StopCatalogService(); Simias.IdentitySync.Service.Stop(); if (syncProvider != null) { IdentitySync.Service.Unregister(syncProvider); syncProvider = null; } if (authProvider != null) { DomainProvider.Unregister(authProvider); authProvider = null; } if (userProvider != null) { User.UnregisterProvider(userProvider); userProvider = null; } }
public ActionResult Scan() { var loggedInUser = User.Identity.Name.Split('\\')[1]; var domain = DomainProvider.GetInstance().EnumerateDomains(loggedInUser); var machines = NetworkProvider.GetInstance().DomainNetworkComputers(domain.FirstOrDefault()); return(View(machines)); }
public async Task <IActionResult> Index() { var context = CreateDomainContext(); context.ValueProvider.SetValue("size", 1000); var domain = DomainProvider.GetService <EntityDomainService <Entity.Forum> >(); var result = await domain.ExecuteAsync <IEntityViewModel <Entity.Forum> >(context, "List"); return(View(result)); }
public virtual async Task <IActionResult> Board() { var context = GetBoardDomainContext(); { var domain = DomainProvider.GetService <ForumDomainService>(); var result = await domain.ExecuteListForums(context); return(View(result)); } }
private void PopulateDomain() { var loggedinUser = WindowsIdentity.GetCurrent().Name.Split('\\')[1]; var domains = DomainProvider.GetInstance().EnumerateDomains(loggedinUser); lblDomain.Text = string.Format("Domain({0})", domains.Count); lstDomain.DataSource = domains; SelectedDomain = domains.FirstOrDefault(); }
internal SettingCollection(DomainProvider owner) { this.owner = owner; this.configUri = new Uri(owner.RootUri, configUriRaletive); foreach (var item in this.items.Values) { item.Owner = this; } loadCache(); loadSettingsDic(); }
protected virtual void ConfigureServices(IServiceCollection services) { services.AddSingleton <IAuthenticationProvider, MockAuthenticationProvider>(); services.AddSingleton <IDomainServiceAccessor, DomainServiceAccessor>(); services.AddSingleton <IDomainServiceProvider, DomainProvider>(t => { var provider = new DomainProvider(t); ConfigureDomainService(provider); return(provider); }); }
internal SettingCollection(DomainProvider domain) { owner = domain; configUri = new Uri(domain.RootUri, configUriRaletive); foreach (var item in items.Values) { item.Owner = this; } loadCache(); _LoadSettingsDic(); }
/// <summary> /// Initializes a new instance of the object. /// </summary> /// <param name="domainID">Identifier of the domain that the user belongs to.</param> private ClientUpgrade(string domainID) { // Set the web state when authentication is really required... WebState ws = new WebState(domainID, domainID); // Get the address of the host service. hostAddress = DomainProvider.ResolveLocation(domainID).ToString(); // Setup the url to the server. service = new ClientUpdate(); service.Url = hostAddress + "/ClientUpdate.asmx"; ws.InitializeWebClient(service, domainID); }
public async Task <IActionResult> Reply() { var context = CreateDomainContext(); var threadDomain = DomainProvider.GetService <EntityDomainService <Thread> >(); IEntityEditModel <Thread> threadResult; try { threadResult = await threadDomain.ExecuteAsync <IEntityEditModel <Thread> >(context, "Detail"); return(View(threadResult.Item)); } catch (EntityNotFoundException ex) { return(NotFound()); } }
private void SetHostAddress(string domainID) { // Get the current address for this domain. Uri currentAddress = DomainProvider.ResolveLocation(domainID); if (currentAddress != null) { UriBuilder ub = new UriBuilder(currentAddress); ub.Host = "mylocalhost"; DomainProvider.SetHostLocation(domainID, ub.Uri); } currentAddress = DomainProvider.ResolveLocation(domainID); if ((currentAddress == null) || (currentAddress.Host != "mylocalhost")) { throw new ApplicationException("Did not set host address."); } }
/// <summary> /// Starts the thread service. /// </summary> public void Start() { log.Debug("Start called"); //Thread.Sleep( 30 * 1000 ); // Instantiate the server domain // The domain will be created the first time the // server is run EnterpriseDomain enterpriseDomain = new EnterpriseDomain(true); if (enterpriseDomain != null) { new Simias.Host.HostProvider(enterpriseDomain.GetServerDomain(false)); //new Simias.Host.HostProvider( new EnterpriseDomain( false ).GetServerDomain( false ) ); if (Simias.Service.Manager.LdapServiceEnabled == false) { // Valid enterprise domain - start the external // identity sync service Simias.IdentitySync.Service.Start(); } if (userProvider == null) { LoadIdentityProvider(); } if (Simias.Service.Manager.LdapServiceEnabled == false) { // Register with the domain provider service. if (authProvider == null) { authProvider = new Simias.Server.Authentication(); DomainProvider.RegisterProvider(this.authProvider); } } Simias.Server.Catalog.StartCatalogService(); ExtractMemberPoliciesOnMaster(); CheckStoreAndLoadRA(); CheckServerForChageMasterError(); } }
public async Task <IActionResult> SignIn(string username) { if (User.Identity.IsAuthenticated) { return(StatusCode(200)); } var memberDomain = DomainProvider.GetService <MemberDomainService>(); var context = CreateDomainContext(); try { await memberDomain.ExecuteAsync(context, "SignIn"); } catch (UnauthorizedAccessException ex) { return(StatusCode(401, ex.Message)); } return(StatusCode(200)); }
public async Task <IActionResult> SignOut() { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Home")); } var memberDomain = DomainProvider.GetService <MemberDomainService>(); var context = CreateDomainContext(); await memberDomain.ExecuteAsync(context, "SignOut"); if (Request.Query["returnUrl"].Count > 0) { return(Redirect(Request.Query["returnUrl"][0])); } else { return(RedirectToAction("Index", "Home")); } }
public async Task <IActionResult> Create() { var context = CreateDomainContext(); var domain = DomainProvider.GetService <EntityDomainService <Post> >(); try { var model = await domain.ExecuteAsync <IEntityUpdateModel <Post> >(context, "Update"); return(RedirectToAction("Index", "Thread", new { id = model.Result.Thread.Index })); } catch (ArgumentNullException ex) { return(StatusCode(400, ex.Message)); } catch (Exception ex) { throw ex; } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); services.AddSession(); services.AddMvc(options => { options.AddComBoostMvcDataOptions(); }); services.AddComBoostMvcAuthentication <ComBoostAuthenticationSessionHandler>(); services.AddScoped <DbContext, DataContext>(serviceProvider => new DataContext(new DbContextOptionsBuilder <DataContext>().UseInMemoryDatabase("Test") .Options)); services.AddScoped <IDatabaseContext, DatabaseContext>(); services.AddScoped <ISecurityProvider, ForumSecurityProvider>(); services.AddScoped <IAuthenticationProvider, ComBoostAuthenticationProvider>(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <IDomainServiceAccessor, DomainServiceAccessor>(); services.AddSingleton <IActionContextAccessor, ActionContextAccessor>(); services.AddSingleton <ICacheProvider, MemoryCacheProvider>(); services.AddSingleton <ISerializerProvider, JsonSerializerProvider>(); services.AddScoped <IStorageProvider, PhysicalStorageProvider>(t => { return(new PhysicalStorageProvider(PhysicalStorageOptions.CreateDefault(_Env.ContentRootPath + System.IO.Path.DirectorySeparatorChar + "Uploads"))); }); services.AddSingleton <IDomainServiceProvider, DomainProvider>(t => { var provider = new DomainProvider(t); provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(EntitySearchExtension <>)); provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(EntityPagerExtension <>)); provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(EntityPasswordExtension <>)); provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(ImageExtension <>)); provider.AddForumExtensions(); provider.AddGlobalFilter <AliasFilter>(); return(provider); }); EntityDescriptor.InitMetadata(typeof(Board).Assembly); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMemoryCache(); services.AddSession(); services.AddMvc(options => { options.AddComBoostMvcDataOptions(); }); services.AddComBoostMvcAuthentication <ComBoostAuthenticationCookieHandler>(); services.AddScoped <DbContext, DataContext>(serviceProvider => new DataContext(new DbContextOptionsBuilder <DataContext>().UseInMemoryDatabase("Test") //new DataContext(new DbContextOptionsBuilder<DataContext>().UseSqlServer(Configuration.GetConnectionString("DataContext")) .Options)); services.AddScoped <IDatabaseContext, DatabaseContext>(); services.AddScoped <ISecurityProvider, ForumSecurityProvider>(); services.AddScoped <IAuthenticationProvider, ComBoostAuthenticationProvider>(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <IDomainServiceAccessor, DomainServiceAccessor>(); services.AddSingleton <IActionContextAccessor, ActionContextAccessor>(); services.AddSingleton <ICacheProvider, MemoryCacheProvider>(); services.AddSingleton <ISerializerProvider, AspNetCore.JsonSerializerProvider>(); services.AddScoped <IStorageProvider, PhysicalStorageProvider>(t => { return(new PhysicalStorageProvider(PhysicalStorageOptions.CreateDefault(_Env.ContentRootPath + System.IO.Path.DirectorySeparatorChar + "Uploads"))); }); services.AddSingleton <IDomainServiceProvider, DomainProvider>(t => { var provider = new DomainProvider(t); provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(EntitySearchExtension <>)); provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(EntityPagerExtension <>)); provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(EntityPasswordExtension <>)); provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(ImageExtension <>)); provider.AddForumExtensions(); return(provider); }); }
private Domain CreateDomain() { // Create a new domain Domain domain = new Domain( store, "DomainServerAddressTest", Guid.NewGuid().ToString(), "Test domain", SyncRoles.Slave, Domain.ConfigurationType.ClientServer); domain.SetType(domain, "Enterprise"); Member member = new Member("Test Owner", Guid.NewGuid().ToString(), Access.Rights.Admin); member.IsOwner = true; domain.Commit(new Node[] { domain, member }); // Set a default host address. DomainProvider.SetHostLocation(domain.ID, new Uri("http://localhost/simias10")); return(domain); }
public async Task <IActionResult> Create() { var context = CreateDomainContext(); var domain = DomainProvider.GetService <EntityDomainService <Post> >(); try { var model = await domain.ExecuteAsync <IEntityUpdateModel <Post> >(context, "Update"); return(RedirectToAction("Index", "Thread", new { id = model.Result.Thread.Index })); } catch (DomainServiceException ex) { if (ex.InnerException is ArgumentNullException) { return(StatusCode(404, ex.InnerException.Message)); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } }