How to update abp db table names to MySql convention like "abp_user_role" - mysql

I'm trying to convert the ABP template project's DB table names to MySql convention like 'abp_user_role', but failed for AbpRoleBase, AbpTenantBase, AbpUserBase, others are all good.
Following are my code in DB Context:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
UpdateAbpTableNamesForMySqlConvention(modelBuilder);
modelBuilder.Entity<TestEntity>(entity =>
{
entity.HasKey(e => new { e.Id });
entity.ToTable("test_entity");
});
}
private void UpdateAbpTableNamesForMySqlConvention(ModelBuilder modelBuilder)
{
modelBuilder.Entity<AuditLog>(e => { e.ToTable("abp_audit_log"); });
modelBuilder.Entity<BackgroundJobInfo>(e => { e.ToTable("abp_background_job"); });
modelBuilder.Entity<Edition>(e => { e.ToTable("abp_edition"); });
modelBuilder.Entity<EntityChange>(e => { e.ToTable("abp_entity_change"); });
modelBuilder.Entity<EntityChangeSet>(e => { e.ToTable("abp_entity_change_set"); });
modelBuilder.Entity<EntityPropertyChange>(e => { e.ToTable("abp_entity_property_change"); });
modelBuilder.Entity<FeatureSetting>(e => { e.ToTable("abp_feature"); });
modelBuilder.Entity<ApplicationLanguage>(e => { e.ToTable("abp_language"); });
modelBuilder.Entity<ApplicationLanguageText>(e => { e.ToTable("abp_language_text"); });
modelBuilder.Entity<NotificationInfo>(e => { e.ToTable("abp_notification"); });
modelBuilder.Entity<NotificationSubscriptionInfo>(e => { e.ToTable("abp_notification_subscription"); });
modelBuilder.Entity<OrganizationUnit>(e => e.ToTable("abp_organization_unit"));
modelBuilder.Entity<PermissionSetting>(e => e.ToTable("abp_permission_setting"));
modelBuilder.Entity<RoleClaim>(e => e.ToTable("abp_role_claim"));
//modelBuilder.Entity<AbpRoleBase>(e => e.ToTable("abp_role"));
modelBuilder.Entity<Setting>(e => e.ToTable("abp_setting"));
modelBuilder.Entity<TenantNotificationInfo>(e => e.ToTable("abp_tenant_notification"));
//modelBuilder.Entity<AbpTenantBase>(e => e.ToTable("abp_tenant"));
modelBuilder.Entity<UserAccount>(e => e.ToTable("abp_user_account"));
modelBuilder.Entity<UserClaim>(e => e.ToTable("abp_user_claim"));
modelBuilder.Entity<UserLoginAttempt>(e => e.ToTable("abp_user_login_attempt"));
modelBuilder.Entity<UserLogin>(e => e.ToTable("abp_user_login"));
modelBuilder.Entity<UserNotificationInfo>(e => e.ToTable("abp_user_notification"));
modelBuilder.Entity<UserOrganizationUnit>(e => e.ToTable("abp_user_organization_unit"));
modelBuilder.Entity<UserRole>(e => e.ToTable("abp_user_role"));
//modelBuilder.Entity<AbpUserBase>(e => e.ToTable("abp_user"));
modelBuilder.Entity<UserToken>(e => e.ToTable("abp_user_token"));
}
Got Error:
The filter expression 'e => (Not(Convert(e, ISoftDelete).IsDeleted) OrElse (Convert(e, ISoftDelete).IsDeleted != value(Test.EntityFrameworkCore.TestDbContext).IsSoftDeleteFilterEnabled))' cannot be specified for entity type 'Tenant'. A filter may only be applied to the root entity type in a hierarchy.

Correct one:
private void UpdateAbpTableNamesForMySqlConvention(ModelBuilder modelBuilder)
{
modelBuilder.Entity<AuditLog>(e => { e.ToTable("abp_audit_log"); });
modelBuilder.Entity<BackgroundJobInfo>(e => { e.ToTable("abp_background_job"); });
modelBuilder.Entity<Edition>(e => { e.ToTable("abp_edition"); });
modelBuilder.Entity<EntityChange>(e => { e.ToTable("abp_entity_change"); });
modelBuilder.Entity<EntityChangeSet>(e => { e.ToTable("abp_entity_change_set"); });
modelBuilder.Entity<EntityPropertyChange>(e => { e.ToTable("abp_entity_property_change"); });
modelBuilder.Entity<FeatureSetting>(e => { e.ToTable("abp_feature"); });
modelBuilder.Entity<ApplicationLanguage>(e => { e.ToTable("abp_language"); });
modelBuilder.Entity<ApplicationLanguageText>(e => { e.ToTable("abp_language_text"); });
modelBuilder.Entity<NotificationInfo>(e => { e.ToTable("abp_notification"); });
modelBuilder.Entity<NotificationSubscriptionInfo>(e => { e.ToTable("abp_notification_subscription"); });
modelBuilder.Entity<OrganizationUnit>(e => e.ToTable("abp_organization_unit"));
modelBuilder.Entity<PermissionSetting>(e => e.ToTable("abp_permission_setting"));
modelBuilder.Entity<RoleClaim>(e => e.ToTable("abp_role_claim"));
modelBuilder.Entity<Role>(e => e.ToTable("abp_role"));
modelBuilder.Entity<Setting>(e => e.ToTable("abp_setting"));
modelBuilder.Entity<TenantNotificationInfo>(e => e.ToTable("abp_tenant_notification"));
modelBuilder.Entity<Tenant>(e => e.ToTable("abp_tenant"));
modelBuilder.Entity<UserAccount>(e => e.ToTable("abp_user_account"));
modelBuilder.Entity<UserClaim>(e => e.ToTable("abp_user_claim"));
modelBuilder.Entity<UserLoginAttempt>(e => e.ToTable("abp_user_login_attempt"));
modelBuilder.Entity<UserLogin>(e => e.ToTable("abp_user_login"));
modelBuilder.Entity<UserNotificationInfo>(e => e.ToTable("abp_user_notification"));
modelBuilder.Entity<UserOrganizationUnit>(e => e.ToTable("abp_user_organization_unit"));
modelBuilder.Entity<UserRole>(e => e.ToTable("abp_user_role"));
modelBuilder.Entity<User>(e => e.ToTable("abp_user"));
modelBuilder.Entity<UserToken>(e => e.ToTable("abp_user_token"));
}

Related

How do I write json value using variable in cypress

it ('check link', () => {
cy.visit(/)
var link1_value
var link2_value
var datasheet_value
cy.get('[class="classname"]').then(($link1) => {
if ($link1.find('[data-type="link1"]').length>0){
cy.get('[data-type="link1"]').invoke('text').as('link1')
cy.get('#link1').then((link1) => {
link1_value = 'Link1:' + link1
})
}
else {
link1_value= '0'
}
}) //there's another one like this for link2
cy.writeFile('txt.json', { link1: link1_value ,link2: link2_value })
})
The code above does not work because link1_value does not have any data. How should I add the value so that it will show in the json file?
To start with, wrap the cy.writeFile() in a .then().
it('check link', () => {
cy.visit('/')
let link1_value
let link2_value
let datasheet_value
cy.get('[class="classname"]').then(($link1) => {
if ($link1.find('[data-type="link1"]').length > 0) {
cy.get('[data-type="link1"]').invoke('text').as('link1')
cy.get('#link1').then((link1) => {
link1_value = 'Link1:' + link1
})
}
else {
link1_value = '0'
}
})
.then(() => { // delays the writeFile until after above code finishes
cy.writeFile('txt.json', { link1: link1_value, link2: link2_value })
})
})
You can also try with the cypress-if package
it('check link', () => {
cy.visit('/')
let link1_value
let link2_value
let datasheet_value
cy.get('[class="classname"]')
.find('[data-type="link1"]')
.if()
.then($link1 => link1_value = $link1.text())
.else()
.then(() => link1_value = '0')
.finally(() => {
cy.writeFile('txt.json', { link1: link1_value, link2: link2_value })
})
})
Without the variables (passing results down the chain)
it('check link', () => {
cy.visit('/')
cy.get('[class="classname"]')
.find('[data-type="link1"]')
.if()
.then($link1 => $link1.text())
.else()
.then(() => '0')
.finally(link1_value => {
cy.writeFile('txt.json', { link1: link1_value, link2: link2_value })
})
})
With the 2nd link
const getLink = (link) => {
return cy.get('[class="classname"]')
.find(`[data-type="${link}"]`) // backticks to insert "link" parameter
.if()
.then($link => $link.text())
.else()
.then(() => '0')
}
it('check link', () => {
cy.visit('/')
getLink('link1')
.then(link1_value => {
getLink('link2')
.then(link2_value => {
cy.writeFile('txt.json', {
link1: link1_value,
link2: link2_value
})
})
})
})

Why json file is created automatically after every event in database in my project

This is part of the generated json file: "EventType":"PlantimsDbContext","Environment":{"UserName":"m-shirzadeh","MachineName":"DESKTOP-RVSF8C4","DomainName":"IOECC"
my project sturtup:
services.Configure(options =>
{
options.CheckConsentNeeded = context => false;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddIdentity<AppUser, AppRole>()
.AddEntityFrameworkStores<PlantimsDbContext>()
.AddDefaultTokenProviders();
services
.AddMvc()
//.AddSessionStateTempDataProvider()
.AddNewtonsoftJson(op => op.SerializerSettings.ContractResolver = new DefaultContractResolver());
services.AddCors();
services.AddKendo();
services.AddDbContext<PlantimsDbContext>(options =>
options.UseSqlServer(
Environment.GetEnvironmentVariable("PlantimsCnn2")));
services.AddRouteAnalyzer();
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromDays(3);
});
services.AddAuthentication(options =>
{
}).AddCookie(options =>
{
options.LoginPath = "/login";
options.LogoutPath = "/logout";
});
services.Configure<FormOptions>(options =>
{
options.ValueCountLimit = int.MaxValue;
});
services.AddSignalR();
services.AddLogging(c => c.ClearProviders());
services.AddLogging(
builder =>
{
builder.AddFilter("Microsoft", LogLevel.Warning)
.AddFilter("System", LogLevel.Warning)
.AddFilter("NToastNotify", LogLevel.Warning)
.AddConsole();
});

DEVEXTREME Save all selected data in grid inside edit form to database

multiple select item in Edit form with grid
How to save the data included the selected item at grid using DEVEXTREME.
The condition now is i can show the grid but now i struggle on get all the data inside the grid to save it and bring it to database, including need to show it again when the user want to edit the data
Template:
#using (Html.DevExtreme().NamedTemplate("EmbeddedDataGridMultiple"))
{
#(Html.DevExtreme().DataGrid()
.ID("PrincipalGrid")
.DataSource(d => d.WebApi().Controller("MasterPrincipal").LoadAction("GetPrincipalData").Key("PrincipalId"))
.Columns(columns => {
columns.Add().DataField("Principal");
columns.Add().DataField("Description");
})
.HoverStateEnabled(true)
.Paging(p => p.PageSize(10))
.FilterRow(f => f.Visible(true))
.Scrolling(s => s.Mode(GridScrollingMode.Virtual))
.Height(345)
.Selection(s => s.Mode(SelectionMode.Multiple))
.SelectedRowKeys(new JS(#"component.option(""value"")"))
.OnSelectionChanged(#<text>
function(selectedItems) {
var keys = selectedItems.selectedRowKeys;
component.option("value", keys);
}
</text>)
)
}
Form
#(Html.DevExtreme().DataGrid<MasterGroupQuotaValidateModel>
()
.ID("gridData")
.ShowBorders(true)
.DataSource(d => d.Mvc().Controller("MasterGroupQuota")
.LoadAction("GetGroupQuota")
.Key("IdGroup")
.UpdateAction("UpdateMasterGroupQuota")
.DeleteAction("DeleteMasterGroupQuota")
.InsertAction("InsertMasterGroupQuota")
)
.RemoteOperations(true)
.Columns(columns =>
{
columns.AddFor(m => m.RowNumber).Caption("No").Width(70);
columns.AddFor(m => m.GroupQuotaId).Visible(false);
columns.AddFor(m => m.SitePlan)
.Lookup(lookup => lookup
.DataSource(d => d.WebApi().Controller("MasterSite").LoadAction("GetSitePlan").Key("SiteId"))
.DisplayExpr("SitePlan")
.ValueExpr("SiteId")
).ValidationRules(rules =>
{
rules.AddAsync().ValidationCallback("CheckGroupQuota").Message("This Site is already registered with the follwoing GroupQuota and Principal");
}); ;
columns.AddFor(m => m.Description).Caption("Group Quota").ValidationRules(rules =>
{
rules.AddAsync().ValidationCallback("CheckGroupQuota").Message("This Group Quota is already registered with the follwoing Site Plan and Principal");
});
columns.AddFor(m => m.Principal)
.Lookup(lookup => lookup
.DataSource(d => d.WebApi().Controller("MasterPrincipal").LoadAction("GetPrincipalData").Key("PrincipalId"))
.DisplayExpr("Principal")
.ValueExpr("PrincipalId")
).ValidationRules(rules =>
{
rules.AddAsync().ValidationCallback("CheckGroupQuota").Message("This Principal is already registered with the follwoing GroupQuota and Site Plan");
});
})
.Paging(paging => paging.PageSize(5))
.Pager(pager =>
{
pager.Visible(true);
pager.ShowPageSizeSelector(true);
pager.AllowedPageSizes(new JS("[5, 10, 'all']"));
pager.ShowInfo(true);
pager.ShowNavigationButtons(true);
})
.Sorting(sorting=> sorting.Mode(GridSortingMode.Single))
.FilterRow(f => f.Visible(true))
.HeaderFilter(f => f.Visible(true))
.AllowColumnReordering(true)
.ShowBorders(true)
.Grouping(grouping => grouping.AutoExpandAll(true))
.SearchPanel(searchPanel => searchPanel.Visible(true))
.GroupPanel(groupPanel => groupPanel.Visible(true))
.HoverStateEnabled(true)
.ShowRowLines(true)
.RowAlternationEnabled(true)
.Scrolling(scrolling => scrolling.RowRenderingMode(GridRowRenderingMode.Virtual))
.Selection(s => s.Mode(SelectionMode.Single))
.OnSelectionChanged("gridSelectionChanged")
.OnExporting("exporting")
.OnRowUpdating("RowUpdating")
.OnEditorPreparing("onEditorPreparing")
.OnSaved("setItemTreeToTextSaving")
.OnEditingStart(#<text>
function(e) {
GetKeyId(e.key)
}
</text>)
.Editing(e => e.Mode(GridEditMode.Popup)
.AllowUpdating(false)
.AllowAdding(false)
.AllowDeleting(false)
.UseIcons(true)
.Popup(p => p
.ShowTitle(true)
.Width(700)
.Height(525)
)
.Form(f => f.Items(items =>
{
items.AddGroup()
.Caption("Detail Group Quota")
.ColCount(2)
.ColSpan(2)
.Items(groupItems =>
{
groupItems.AddSimpleFor(m => m.GroupQuotaId).Visible(false);
groupItems.AddSimpleFor(m => m.SitePlan);
groupItems.AddSimpleFor(m => m.Description);
});
items.AddGroup()
.Caption("Principal")
.ColCount(2)
.ColSpan(2)
.Items(groupItems =>
{
groupItems.AddSimpleFor(m => m.Principal).Template(new TemplateName("EmbeddedDataGridMultiple")).ColSpan(2);
});
}))
)
)

node.js use promise to do database query with for loop

Why is the property players gone from the result of an async call?
let getTickets = (userId) => {
return new Promise((resolve, reject) => {
let sql = util.format('select ticketId,number from ticket_Numbers where userId="%s"', userId);
db.query(sql)
.then(data => { resolve(data.rows); })
.catch(err => { console.log(err.stack) });
});
}
let getSameTicketPlayers = (tickets) => {
for (let ticket of tickets) {
db.query(util.format('select userId,number from ticket_numbers where ticketId="%s"', ticket.ticketId))
.then((players) => { ticket.players = players.rows; });
}
return new Promise((resolve, reject) => {
resolve(tickets);
});
}
exports.myTickets = (userId, cb) => {
getTickets(userId).then(getSameTicketPlayers).then(tickets => {
console.log(tickets); //tickets has players property here
console.log(JSON.stringify(tickets)); // players property is gone, why?
cb(tickets);
});
}
Screenshot

How to pass object as parameter to kendo grid read method

I have kendo grid as follow.
#(Html.Kendo().Grid<ManualInputDetail>()
.Name("gManualInputDetail")
.Columns(columns =>
{
columns.Bound(c => c.Id).Hidden(true);
columns.Bound(c => c.Month).Title("Month");
columns.Bound(c => c.Value).Title("Value");
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Navigatable()
.Selectable(selectable =>
{
selectable.Mode(GridSelectionMode.Single);
selectable.Type(GridSelectionType.Row);
})
.Sortable(sortable =>
{
sortable.SortMode(GridSortMode.MultipleColumn);
})
.DataSource(dataSource => dataSource
.WebApi()
.Model(model => model.Id(p => p.Id))
.PageSize(12)
.Read(read => read.Url(Url.HttpRouteUrl("ActionApi", new { controller = "ManualInputDetails", action = "GetManualInputDetails" })).Data("getFilterData"))
)
.Pageable(p => p.Refresh(true))
)
using getFilterData function I want to pass object parameter to read method. getFilterData function as follow
function getFilterData() {
var header= {
SectorId: 1,
BrandId: 2,
LocationId: 1,
DataElementId:2
}
return {
header: header
};
}
GetManualInputDataElements method as follow
[ActionName("GetManualInputDetails")]
public DataSourceResult GetManualInputDetails([System.Web.Http.ModelBinding.ModelBinder(typeof(WebApiDataSourceRequestModelBinder))] DataSourceRequest request,ManualInputHeader header)
{
var model = new DataElementMgt().GetAll(header).Select(x => new DataElement()
{
Id = x.Id,
DataElementTypeId = x.DataElementTypeId,
Name = x.Name,
Descriptionn = x.Descriptionn
}).ToList().ToDataSourceResult(request);
return model;
}
In here header value always gives as null. What is the reason for that. Is any thing wrong? Please help..
change the getFilterData method to this
function getFilterData() {
var _header= {
SectorId: 1,
BrandId: 2,
LocationId: 1,
DataElementId:2
}
return {
header: _header
};
}
and it should work. dont use the same name for what you return and declare.