Base solution for your next web application

Activities of "cosmic"

Question

Hi, is it possible to load settings from DB by the SettingManager in the Initialize section of the module? When are the settings loaded from DB?

I have defined custom setting manager in the PreInitialize section of the module

Configuration.Settings.Providers.Add<WebSettingProvider>();

In the Initialize section of the web module I have defined BundleConfig and I need the settings to be accessible in this class, but when I tested this, the result was no settings (see attached image). But if I try to load the settings e.g. in the MVC Controller, everything is OK.

Any ideas? Thank you.

Question

Hi, is there any way to define two unique menus in one module? I need two menus in my web application, one in the sidebar (MainMenu) and one in the top bar (TopMenu). Thank you for help.

I solved it. It was really simple, just one line of code to add a new menu

context.Manager.Menus.Add("TopMenu", new MenuDefinition("TopMenu", new FixedLocalizableString("Top menu")));

In your code is it exactly same as my solution, thank you for help.

Answer

It works in PostInitialize section. Thank you.

Hi, is it possible to use ABP XML localization source in DataAnnotations?

For example, with the Resource file it works:

[Required]
[Display(ResourceType = typeof(MyResource), Name = "Password")]
public string Password { get; set; }

But, is it possible to do with the XML file localization source defined in the ABP module as a DictionaryBasedLocalizationSource?

Question

Hi, I have this code in the MVC controller:

public async Task<ActionResult> Edit(long? id)
{
    if (id == null)
    {
        throw new UserFriendlyException("Bad request");
    }

    var output = await _userAppService.GetAsync(new GetUserInput(id.Value));

    if (output.User == null)
    {
        throw new UserFriendlyException(L("InvalidUser"));
    }

    return View(output.User.MapTo<UserEditViewModel>());
}

If the ID is not supplied, then it will throw an UserFriendlyException, this is correct. But, when I look into the log file, there is following exception:

2015-04-17 13:43:06.1042|ERROR|Default|Abp.UI.UserFriendlyException: Bad request
   at Controllers.UsersController.<Edit>d__f.MoveNext() in c:\...\Controllers\UsersController.cs:line 109
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(Task task)
   at System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)

It looks like a result of unhandled exception. I think, the UserFriendlyException (AbpException) is not handled correctly. In log file should be only first line, or am I wrong?

Answer

Yes, customErrors is set On. It was a first thing I changed.

Answer

Hi, I changed this method to "normal" sync method and I tested it again. But, the error is the same. I think this is not only problem of an async implementation, there may be a global problem (somewhere deeper in the ABP framework code) to catch exceptions right way.

I'm using Multi Page Application, not Angular, Durandal, etc. Please test this example and you should get the same result.

Thank you.

By the way, this framework is great, it saved me a lot of time, I appreciate all of your work, keep going...

Hi, maybe this will help you:

<a class="postlink" href="http://bitoftech.net/2014/08/25/asp-net-web-api-documentation-using-swagger/">http://bitoftech.net/2014/08/25/asp-net ... g-swagger/</a> <a class="postlink" href="http://www.strathweb.com/2014/04/opt-opt-asp-net-web-api-help-page/">http://www.strathweb.com/2014/04/opt-op ... help-page/</a>

I followed these manuals and the Swagger is fully functional for my Web API. It should work for you too.

Hi, I have this app service:

public ListResultOutput<RecordDto> GetAllFilter(Expression<Func<Record, bool>> predicate)
{
    var items = _recordRepository.GetAllList(predicate);

    return new ListResultOutput<RecordDto>
    {
        Items = items.MapTo<List<RecordDto>>()
    };
}

I tried call this service from JavaScript code, but it didn't work:

abp.services.app.record.getAllFilter(function(r){
    return r.recordType = 20;
}).done(function (data) {
    for (var i = 0; i < data.items.length; i++) {
        records.push([i, data.items[i].points]);
    }
});

How I can call this service from JavaScript code right way? Is it possible?

Showing 1 to 10 of 27 entries