How to disable transactions in ABP Framework? - abp

I want to turn off the transaction in my ABP project.
Is there any way to turn off transactions?

To completely disable the DB transactions, you can add the following code in the ConfigureServices() method of EntityFrameworkCore project.
Configure<Volo.Abp.Uow.AbpUnitOfWorkDefaultOptions>(options =>
{
options.TransactionBehavior = Volo.Abp.Uow.UnitOfWorkTransactionBehavior.Disabled;
});

Related

How to save AbpEntityChanges data in database of the entity table?

I want to use entity change functionality and enabled it from .Application section
but it's not working.
When I download github repo and check in .NetCore EntityFramwork IEntityHistoryHelper class. but this using in commonDBContext but object not created.
Can you please explain how to resolve dependency or user IEntityHistoryHelper in application.
Your ABP Framework version.= 7.3.0.0
Your User Interface type (Angular/MVC/React... etc.) if the issue is related to a specific UI = MVC
Your database provider(EF Core/MongoDB)=EF Core

IdentityServer4 QuickStart Register Issue

I have ASP.NET Core application with IdentityServer4 using ASP.NET Core Identity (based on excellent quickstart).
http://docs.identityserver.io/en/release/quickstarts/6_aspnet_identity.html
In the walkthrough blog they talk about navigating to localhost:5000/Account/Register to create a new user in the Identity db.
When i navigate to that url i get a white page. Furthermore I don't have a Register.cshmtl page or a Register route or anything with the term Register in it.
Did i get the wrong branch? because i am on the release and using core 2.0
I'm new at this and apologize if i'm missing something obvious.
I have run the dotnet ef command but can't see a db anywhere I look - like in sql express or LocalDb.
I am running the Identity server project out of vs17 on port 5000
If i run the MvcClient project I see the home page with the Secure link. If i click that i am directed to the IS4 instance but alice nor bob login will work. (invalid us/pw).
And i can see in the logs that alice and bob users are not being created in-memory
You probably got this by now, but it might interest someone else.
The Quickstart UI repository is not a direct implementation of the tutorials in the IdentityServer4 docs. If you follow the docs, you will first create a new ASP.NET Core MVC application with Individual User Accounts authentication, and that template will create the registration page.
I think your problem is about routing. With scaffolding Identity and specifying routing Your problem will be resolved.
To maintain full control of the Identity UI, run the Identity
scaffolder and select Override all files.
replace
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
with
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
.AddRazorPagesOptions(options =>
{
options.AllowAreas = true;
options.Conventions.AuthorizeAreaFolder("Identity", "/Account/Manage");
options.Conventions.AuthorizeAreaPage("Identity", "/Account/Logout");
});
services.ConfigureApplicationCookie(options =>
{
options.LoginPath = $"/Identity/Account/Login";
options.LogoutPath = $"/Identity/Account/Logout";
options.AccessDeniedPath = $"/Identity/Account/AccessDenied";
});
// using Microsoft.AspNetCore.Identity.UI.Services;
services.AddSingleton<IEmailSender, EmailSender>();
Now you can access to Register account page:
http://localhost:5000/Identity/Account/Register
You also can also change default route like what you want (localhost:5000/Account/Register) for this purpose check this post

Connecting Backbone.js with CouchDB when hosting in Apache or IIS

I'm having trouble understanding how to connect Backbone.js with CouchDB cleanly if I am to serve the html and js files from Apache web server or IIS (not from node.js or couchApp).
Should I use a backbone.js CouchDB extension to abstract the requests? If so which ?
Should I connect Backbone.js connect directly to the CouchDB RESTful interface or should I use
an intermediate PHP layer (because I am familiar with PHP but and not Java or other server side setups) ? If so which ?
What is the best way to deal with the 'same origin policy' preventing me from interacting with the database ?
Basically I want a tidy way using backbone.js to GET json documents from a number of collections by id, an array of ids, or all ids.
Also from a second admin web interface I need to be able to update, create, and delete by id
I don't think you need any extension to work with CouchDB.
The main thing you need to do is set idAttribute to _id in all your model.
Also, I would advise you to put an intermediate layer between CouchDB and your client. Unless your use-case is very simple, you'll quickly want to transform your documents before sending them to your client. You can do that with PHP, Express and use CouchApp if you want to stick close to CouchDB.
If you want to bypass SOP cleanly, take a look at CORS, which is now supported by most browsers.
I'm not familiar with PHP, but here's how I do it with Express and felix-couchdb:
var couchdb = require('felix-couchdb'),
client = couchdb.createClient(config.port, config.host),
myDb = client.db('my_db');
// (... express boilerplate)
app.get('/resource/:resource_id', function (req, res) {
myDb.getDoc(req.params.resource_id, function (err, doc) {
if(err)
return res.send(err);
res.send(doc);
});
});
I have had very good luck with https://cloudant.com/blog/backbone-and-cloudant/

Meteor how to perform database migrations?

How do you perform database migrations with Meteor? With Ruby on Rails there is ActiveRecord::Migration. Is there an equivalent mechanism in Meteor?
For example, I make an app with some user data. I'm storing the data in Mongo using a JSON format. The app changes, and the JSON database schema needs to change. I can write a migration method to change the schema, however, I only want this to run if the server database is out of date.
There's nothing built in for this. What I've done myself for now is similar to how Rails works, but as part of startup instead of a separate task. First create a Meteor.Collection called Migrations, and then for each discrete migration, create a function under the server subdirectory that runs on startup. It should only run the migration if it hasn't run before, and it should flag the migration in the Migrations collection once its done.
// database migrations
Migrations = new Meteor.Collection('migrations');
Meteor.startup(function () {
if (!Migrations.findOne({name: "addFullName"})) {
Users.find().forEach(function (user) {
Users.update(user._id, {$set: {fullname: users.firstname + ' ' + users.lastname}});
});
Migrations.insert({name: "addFullName"});
}
});
You could extend this technique to support down migrations (look for the existence of a given migration and reverse it), enforce a sort order on the migrations, and split each migration into a separate file if you wanted.
It'd be interesting to think about a smart package for automating this.
As Aram pointed already in the comment, percolate:migrations package gives you what you need. Sample
Migrations.add({
version: 1,
name: 'Adds pants to some people in the db.',
up: function() {//code to migrate up to version 1}
down: function() {//code to migrate down to version 0}
});
Migrations.add({
version: 2,
name: 'Adds a hat to all people in the db who are wearing pants.',
up: function() {//code to migrate up to version 2}
down: function() {//code to migrate down to version 1}
});
I created a smart package for this use case.
See https://atmosphere.meteor.com/package/migrations

Grails: updating hibernate after externally loading data

I have a grails application. I'd like to load data into the underlying database with something external to grails, perl, specifically. I know I have to update the hibernate sequence after external data loading, otherwise on the next create object in grails, hibernate throws an exception; but is there anything else I need to update? Do I have to clear the hibernate cache, for instance? This would seem to be a very common issue, but there's no discussion of it in the grails docs. Thanks.
Found this
http://grails.1312388.n4.nabble.com/Accessing-the-2nd-level-cache-to-allow-it-to-be-cleared-via-a-controller-or-service-td1390985.html
Hibernate has APIs for this. You can get the query cache via sessionFactory.getQueryCache() and clear it using
sessionFactory.queryCache.clear()
You can access a cache for a domain classes using its full class name, e.g.
def cache = sessionFactory.getSecondLevelCacheRegion('com.foo.bar.Book')
and clear it via
sessionFactory.getSecondLevelCacheRegion('com.foo.bar.Book').clear()
You can also call evict() on the sessionFactory for an entire class
sessionFactory.evict(com.foo.bar.Book)
or for an individual instance
sessionFactory.evict(com.foo.bar.Book, 42)

Resources