Base solution for your next web application

Activities of "winson"

Not only for ABP framework, but I just want to know is possable to make a entity for a table view in code first? or are there any ways can do that in ABP ?

thanks!!

I am using the default ICacheManager, so should be use MemoryCache, but how can I set the expire time for it? and what's the default expire time?

thanks!

I need to dynamic to generate the URL with URL route, because I need to handle the root or subfolder deployment issue, so I want to generate url like below:

UrlHelper url = new UrlHelper(HttpContext.Current.Request.RequestContext);

var menuUrl= url.RouteUrl(new { Controller = "Home", Action = "Index" });

new MenuItemDefinition(
                        "Home",
                        new FixedLocalizableString("Home"),
                        url: menuUrl,
                        icon: "fa fa-home",
UserRole.JOURNALIST
                        )

but it's can't get the HttpContext.Current.Request.RequestContext in NavigationProvider class, so any ideas?

Thanks!

hi, I want to do some auditlog for the field values changed with below:

foreach (var entry in ChangeTracker.Entries<FormDataDetail>().Where(a => a.State == EntityState.Modified))
{    
    if (entry.CurrentValues["FieldValue"].ToString() != entry.OriginalValues["FieldValue"].ToString())
    {
       //to do some auditlog
    }
}

but the problem is the OriginalValues always same with the current value, and after I review the ABP source code, I find the below code in update function:

public override TEntity Update(TEntity entity)
        {
            AttachIfNot(entity);
            Context.Entry(entity).State = EntityState.Modified;
            return entity;
        }

I think the problem is

Context.Entry(entity).State = EntityState.Modified;

for the detail, you can take a look this article.

so can we fix this issue?

for now, I have to get the OriginalValues from db again, like below:

var oldValue = entry.GetDatabaseValues().GetValue<string>("FieldValue");

thanks!

I have my own user table, just want to use the ABP Authorization feature and session, but don't want to implement the module-zero project, can I do that?

thanks!

I inherit IModificationAudited and ICreationAudited interface and create CreatorUserId and LastModifierUserId fields, but when I insert a record, I have set the value to these fields like below:

var item = new Item
{
    Active = true,
    Name = input.Name,
    Value = input.Value,
    CreationTime = DateTime.Now,
    LastModificationTime = DateTime.Now,
    CreatorUserId = 1, //TODO: for testing
    LastModifierUserId = 1
};

_itemRepository.Insert(item);

but this just can save the LastModifierUserId value, and the CreatorUserId is null, if the LastModifierUserId is null, when I do the update, I also can't update it:

var item = _itemRepository.Get(input.Id);
            
item.Name = input.Name;
item.Value = input.Value;
item.LastModificationTime = DateTime.Now;
item.LastModifierUserId = 1; //TODO: for testing

_itemRepository.Update(item);

after that, the LastModifierUserId is also null.

I have created the ForeignKey for these fields :

public long? LastModifierUserId { get; set; }

public long? CreatorUserId { get; set; }

[ForeignKey("CreatorUserId")]
public virtual AdminUser CreatorUser { get; set; }

[ForeignKey("LastModifierUserId")]
public virtual AdminUser LastModifierUser { get; set; }

I want to create the multiple pages project and not use angular script, so I want to call the app service directly in my controller, but I tried many ways and still failed, after I read the Dependency Injection , seems there is a way to resolve the service directly, but I still failed, below is my code:

app service:

private readonly IFormBuilderRepository _formBuilderRepository;

        public FormBuilderAppService(IFormBuilderRepository formBuilderRepository)
        {
            _formBuilderRepository = formBuilderRepository;
        }

in controller:

private readonly IIocResolver _iocResolver;

        public FormBuilderController(IIocResolver iocResolver)
        {
            _iocResolver = iocResolver;
        }

and in the action:

[HttpPost]
        [UnitOfWork]
        public JsonResult Index(FormBuilderInput formBuilder)
        {
            var _formBuilderAppService = _iocResolver.Resolve<IFormBuilderAppService>();
            _formBuilderAppService.Create(formBuilder);
            _iocResolver.Release(_formBuilderAppService);

            return Json(new { Name = formBuilder.Name });
        }

after run these code, I got the below error:

ABP The entity type FormBuilderModel is not part of the model for the current context.

I have no ideas :(

for example, I have an IAbcAppService and AppService class, but how can I call it in my controller? I don't know how to instantiate it

in my app service:

public class ABCAppService: IABCAppService
{
        private readonly IRepository<ABCModel> _abcRepository;

        public ABCAppService(IRepository<ABCModel> abcRepository)
        {
            _abcRepository = abcRepository;
        }
}

and in my controller:

public class ABCController : ABCControllerBase
{
        private readonly IABCAppService _abcAppService;

        public ABCController()
        {
        	//should I use this way? but it doesn't work :(
            _abcAppService = IocManager.Instance.Resolve<IABCAppService>();
        }
}

just don't know how to init the _abcAppService in controller.

Showing 1 to 8 of 8 entries