Hi guys. I'm trying to implement some functionality to my Abp Mvc 5.x MPA pplication like password reset email confirmation.
i was using these lines of code before reading that [https://github.com/aspnetboilerplate/module-zero/issues/50])
//var provider = new DpapiDataProtectionProvider("VapeKit");
//_userManager.UserTokenProvider = new DataProtectorTokenProvider<User, long>(provider.Create("ASP.NET Identity")) //{
//TokenLifespan = TimeSpan.FromHours(3)
//};
after reading solution installed Abp.Zero.Owin. to my Web Project. Added DependsOn(typeof(AbpZeroOwinModule)) to web module.
finally i add app.RegisterDataProtectionProvider(); to Owin Startup class.
So far so good everything seems works now but i want to set TokenLifespan = TimeSpan.FromHours(3). How to setup this one?
Thank you very much.
I've istalled Visual Studio yesterday. I'm practicing modular and plugin system. I've big troubleshot with creating module solution and/or projects.
There are 3 dfferent class library template in visual studio. I downloaded ModularTodoApp sample. Right clicked to one of the projects. Forexample Core project. And the clicked to Properties. It seems the project .Net Framework 4.6.1 class library. And project hierarchy i can see Dependencies node. But if i create .Net Framework 4.6.1 Class Lirary project there is no Dependencies node.
Well, i created Class Library (.Net Core) i can see Dependencies node but i the Properties windows project is ot .Net 4.6.1 but .NetCoreApp 1.1
I'm new .Net Core and ofcourse Abp Asp.NEt Core 1.x.
Is there any way to create module projects like TodoModule? Any template? Which class library i have to you for asp.net core?
Thank you.
I found a working "hack" to pass data to all views.
I created a service named ISettingService and implemented here.
public class SettingService : ApplicationService, ISettingService
{
public string GetTheme()
{
return SettingManager.GetSettingValue(IndexSettingProvider.CurrentTheme);
}
}
I inject ISettingService in ControllerBase.
public abstract class IndexControllerBase : AbpController
{
private readonly ISettingService _settingService;
protected IndexControllerBase(ISettingService settingService)
{
_settingService = settingService;
LocalizationSourceName = IndexConsts.LocalizationSourceName;
ViewBag.Theme = _settingService.GetTheme();
}
}
And in each controller i created their constructor
public class HomeController : IndexControllerBase
{
public HomeController(ISettingService settingService): base(settingService)
{
}
public ActionResult Index()
{
return View();
}
}
this way is works. But the ugly way i believe.
Can't we use AbpController.SettingManager in Constructor of ControllerBase?
protected IndexControllerBase()
{
LocalizationSourceName = IndexConsts.LocalizationSourceName;
ViewBag.Theme = SettingManager.GetSettingValue(IndexSettingProvider.CurrentTheme);
}
Returns "Object reference not set to an instance of an object."
I'm trying to pass current theme setting to all view via ViewBag.
this is the _Layout file in shared dir.
@{
Layout = ViewBag.Theme;
}
@RenderBody()
@RenderSection("styles", required: false)
@RenderSection("scripts", required: false)
I've an entity name Listing like below.
public class Listing : FullAuditedEntity<long, User>, IPassivable
{}
I'm studing EntityCaching here. <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Caching#entity-caching">http://www.aspnetboilerplate.com/Pages/ ... ty-caching</a>
I created these codes by respecting documentation.
public interface IListingCache : IEntityCache<ListingDto>
{
}
public class ListingCache : EntityCache<Listing, ListingDto>, IListingCache, ITransientDependency
{
public ListingCache(ICacheManager cacheManager, IRepository<Listing, long> repository)
: base(cacheManager, repository)
{
}
}
At coding time there are errors like below
Listings.Listing' cannot be used as type parameter 'TEntity' in the generic type or method 'EntityCache<TEntity, TCacheItem>'. There is no implicit reference conversion from Listings.Listing' to 'Abp.Domain.Entities.IEntity<int>'.
Listings.Listing, long>' to 'Abp.Domain.Repositories.IRepository<Listings.Listing, int>'
These errors dis appears if i change Entity id type to int from long. So, question is basic. Cant i use EntityCache with long type? Or should i use ICacheManager?
By the way im not familiar with these caching things. What is different between ICacheManager and EntityCache? Ty.
<cite>ismcagdas: </cite>
But in my opinion, don't do that, just query posts with creatorUserId=[someUserId],
Why? Is it about performance or something else?
Using FullAuditedEntity<long, User> provides Creator id. This is not actually a releationship. To store creator id if we use FullAuditedEntity we lost the Navigation in User entity. This confuses me.
Forexample:
public class Post : FullAuditedEntity<long, User> { .. }
We can access to Post's create Id. (Not name or others) Well, what if i want to get User's posts? There will be no Posts navigation in User entity. Do i have to query with creator id? Is this?
Last step is registering the filter in PreInitialize method of module (i did it in Core Module). And i set it true to fetch only Published = true entries.
First parameter is same unique name we defined before. Second parameter indicates whether this filter is enabled or disabled by default. After declaring such a parametric filter, we can use it by supplying it's value on runtime .
Configuration.UnitOfWork.RegisterFilter("PublishedFilter", true);
That true parameter means: only published entries will be fetch, right?
SoftDelete pattern is good. In normal query sofdeleted record doesnt fetch. What about the Published and UnPublished records?
I need something like this.
public enum ContentState
{
Published = 1,
UnPublished = 0
}
In normal query unpublished records has not to be fetched also. Do i have to modify core or can i extend the ABP?
In two days i'm trying to build Role View. In fuct working permissions is beats me. But i decide to try what can i do.
I reasearched JsTree and Mvc at google. And i found Recursive and FlasObject samples.
public class FlatObject
{
public string Id { get; set; }
public string ParentId { get; set; }
public string Data { get; set; }
public FlatObject(string name, string id, string parentId)
{
Data = name;
Id = id;
ParentId = parentId;
}
}
public class RecursiveObject
{
public string Data { get; set; }
public string Id { get; set; }
public FlatTreeAttribute Attr { get; set; }
public List<RecursiveObject> Children { get; set; }
}
public class FlatTreeAttribute
{
public string id;
public bool selected;
}
this is the create action of RoleController
public ActionResult Create()
{
var permissions = _permissionManager.GetAllPermissions(multiTenancySides: Abp.MultiTenancy.MultiTenancySides.Tenant);
List<FlatObject> flatObject = new List<FlatObject>();
foreach (var item in permissions)
{
if (item.Parent != null)
{
flatObject.Add(new FlatObject(item.Name, item.Name, item.Parent.Name));
}
else
{
flatObject.Add(new FlatObject(item.Name, item.Name, ""));
}
}
var recursiveObjects = FillRecursive(flatObject, "");
var viewModel = new CreateEditRoleViewModel
{
Permissions = recursiveObjects
};
return View(viewModel);
}
private static List<RecursiveObject> FillRecursive(List<FlatObject> flatObjects, string parentId)
{
List<RecursiveObject> recursiveObjects = new List<RecursiveObject>();
foreach (var item in flatObjects.Where(x => x.ParentId.Equals(parentId)))
{
recursiveObjects.Add(new RecursiveObject
{
Data = item.Data,
Id = item.Id,
Children = FillRecursive(flatObjects, item.Id)
});
}
return recursiveObjects;
}
and here is the ViewModel
public class CreateEditRoleViewModel
{
public RoleDto Role { get; set; }
//public IReadOnlyList<Permission> Permissions { get; set; }
public List<RecursiveObject> Permissions { get; set; }
}
Create View
<div id="data">
<ul>
@foreach (var item in Model.Permissions)
{
<li class="jstree-open">
@item.Data
<ul>
@foreach (var child in item.Children)
{
<li class="jstree-open">@child.Data</li>
}
</ul>
</li>
}
</ul>
</div>
and finally the java script
$(document).ready(function () {
$('#data').jstree({
"plugins": ["checkbox"]
});
$('#data').on("changed.jstree", function (e, data) {
if (data.selected.length) {
$(data.selected).each(function (idx) {
var node = data.instance.get_node(data.selected[idx]);
});
}
});
});
and the result.
Well, 1-) How can i get the selected roles for current user and reflect it to the jsTree. 2-) How can i handle the post values?