Base solution for your next web application

Activities of "carelearning"

This workaround involves creating a static method in my module IndividualConstants class and adding a using statement in the view. I am not sure this is the optimal solution but it does work.

public class IndividualConstants
{
   public const string LocalizationSourceName = "Individual";

   public static ILocalizableString Ls(string name) => new LocalizableString(name, LocalizationSourceName);
   public static string L(string name) => Ls(name).Localize();
}
@using Individuals
<div>
    <form class="form-validation" name="createIndividualForm" novalidate role="form">
        <div class="modal-header">
            <h4 class="modal-title">@IndividualConstants.L(IndividualConstants.IndividualCreate)</h4>
        </div>
        <div class="modal-body">
            <div class="form-group">
                <label for="Name" class="control-label bold">@L("Name")</label>
 
Answer

Thank you very much your reply!

We have implemented the code you posted and it works great!

Thank you again for your hard work.

careLearning-Bill

Answer

Do you know yet if the Angular2 version will be developed to work with Angular CLI (<a class="postlink" href="http://cli.angular.io">http://cli.angular.io</a>)? Thank you for the hard work. We are excited about the AspNet Core and Angular2 versions!

Here is the webapi controller:

namespace MyCompanyName.AbpZeroTemplate.Web.Controllers.api
{
    using Abp.WebApi.Controllers;
    using Departments;
    using Departments.Dto;
    using Domain;
    using Models.Dto;
    using System;
    using System.Collections.Generic;
    using System.Web.Http;

    public class DepartmentController : AbpApiController
    {

        public DepartmentController()
        {

        }

        [HttpGet]
        public IHttpActionResult Get()
        {
           var departments;
        //retrieve data and pass it on--this works
            return Json(departments);           
        }


//This fails with a 500 error:
        [HttpDelete]
        public void Delete(DeleteItem item)
        {
            if (!String.IsNullOrWhiteSpace(item.key))
                _departmentAppService.Delete(item.key);
        }

    }
}

We tried the [FromBody] attribute and received the same result.

Thanks

Thank you for your reply. We could not recreate the problem you described above in an empty MVC5/WebAPI project with only the DevExteme widgets added. To be clear, we are not directly using

abp.services.app.department.delete(1);

to invoke our DepartmentAppService. Instead we created a wrapper DepartmentApiController that proxies the requests to the DepartmentAppService because it appears that DevExpress' dxDataGrid.DataSource requires it.

Upon further investigation we discovered an issue using mediaformatters. We found a possible solution by adding FormUrlEncodedMediaTypeFormatter and JQueryMvcFormUrlEncodedFormatter in the PostInitialize Method of the DxAbpWebApiModule class.

To illustrate this case, we have a simple project using: Asp.Net Boilerplate project with DevExpress dxDataGrid and dxButtons. You can find it here: git clone [http://git.carelearning.com/dxabp.git])

You can see the issue if you comment out this method:

public override void PostInitialize()
        {
            base.PostInitialize();

            Configuration.Modules.AbpWebApi().HttpConfiguration.Formatters.Add(new FormUrlEncodedMediaTypeFormatter());
            Configuration.Modules.AbpWebApi().HttpConfiguration.Formatters.Add(new JQueryMvcFormUrlEncodedFormatter());
        }

And then try to delete a department:

  • Check a department
  • Click Delete button
  • Click Done button

Is this approach advisable? Do you know of a better approach? We see that at aspnetboilerplate/src/Abp.Web.Api/WebApi/AbpWebApiModule.cs you are clearing all formatters except JSON. Therefore we are not sure if adding formatters will cause other problems.

Thank you. The project is intentionally only Asp.Net Boilerplate so as not to make anything public. I am sorry for not specifying that earlier. Thanks again for all your hard work.

Thank you for your reply. Here are the steps we used to resolve the issue we had:

  • We changed AbpDbContext to AbpZeroTenantDbContext<Role, User>
  • Added DefaultDbContext attribute to AbpZeroHostDbContext<Tenant, Role, User>
  • Seeded AbpLanguages with 1 record for English
  • Stopped seeding AbpUsers in the host context and instead created AbpUser for each TenantDbContext
  • MSDTC service was configured on DB Server and local dev machine and firewall rules had to be set

Thank you again for your help and effort.

@ismcagdas

Sorry for the tardy reply and the long explanatory post to follow.

To illustrate the problem I created a File->New Project->ASP.NET Web Application (.NET Framework)

  • Authentication: No Authentication
  • MVC: include
  • Web API: include

Working Branch git clone <a class="postlink" href="http://git.carelearning.com/dxabp.git">http://git.carelearning.com/dxabp.git</a> example -b working

When I build and run the Example project from the working branch; I select click "Upload", a DevExpress FileUploader widget, and navigate to an included sample file located at the [cloned-project-dir]\assets\departments.csv. This in return executes the controller's Upload method shown below.

[HttpPost]
        public ActionResult Upload()
        {
            var file = Request.Files[0];
            if (file == null ||
                file.ContentLength == 0)
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            var content = _departmentAppService.Upload(file.InputStream);
            return Content(content);
        }

Here is the DepartmentAppService Upload method which uses Gembox.Spreadsheet and Json.Net.

public string Upload(Stream stream)
        {
            SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

            var workbook = ExcelFile.Load(stream, LoadOptions.CsvDefault);
            var worksheet = workbook.Worksheets.ActiveWorksheet;
           
           // TODO optimize
            var dataTable = worksheet.CreateDataTable(new CreateDataTableOptions()
            {
                ColumnHeaders = true
            });

            return JsonConvert.SerializeObject(dataTable, new DataSetConverter());
        }

When I breakpoint and debug I see the expected Json content string.

Broken Branch git clone <a class="postlink" href="http://git.carelearning.com/dxabp.git">http://git.carelearning.com/dxabp.git</a> example -b broken

To prevent licensing issues when sharing this example code; yesterday I created a brand new Asp.Net Boilerplate project. I created a Custom controller with single Index view. I then transplanted the code from the Working project, slightly altering the code to use the idomatic Abp code and the suggested inheritance hierarchy. I also had to disable the CSRF/XSS protection according to this post.

After building and setting Web as the Startup Project I run update-database -verbose -projectname EntityFramework to bootstrap the required database. The project uses (localdb) for the data source in the connection string.

When running and selecting the same test file at[cloned-project-dir]\assets\departments.csv. The Upload method now throws the aforementioned ReadTimeout not supported exception (see attached screenshot, ReadTimeout_Exception.png).

When searching the forums another user experienced this issue with Kendo Upload Widget. We tried the presented solution of adding MethodInvocationValidator.IgnoredTypesForRecursiveValidation.AddIfNotContains(typeof(HttpPostedFileWrapper)); in the Global.aspx code-behind in our real AbpZero project and it did not work. I also tried adding this code to this example project, however it would not compile. I left it in but commented out.

Thank you for your time and an outstanding library.

-Chris

After scouring the Git repository's comment messages, I determined we had some out-of-date NuGet packages. I eventually updated all the packages except for EntityFramework.DynamicFilters. Next, I added the missing Changed_Code_MaxLength_Of_OrganizationUnit migration. Finally, I built and ran and the exception went away. I push the changes the broken branch of the example repo.

I replicated the changes in our real project and after fixing several changes like; Clock.SupportsMultipleTimezone from a method to a property, renaming IdentityFrameworkClaimsAbpSession to ClaimsAbpSession and updating the CustomDtoMapper's CreateMappingsInternal method. I built and ran and the exception is gone.

-Chris

Hello,

Thank you for your response. We do not use the ChatMessage and Friendship tables. They are not referenced anywhere in our code. We do not get this error until we include the javascript files in our layout. When we drop the tables and try to add a migration, it does not find find these tables to add. To use signalR in abpZero template, are these tables required? Is there some sort of dependenct injection requirement? We can manually create a migration instead of adding the table manually through SQL. Is that what you mean?

For more background, our Tenent DB Context File looks like this:

namespace MyCompanyName.AbpZeroTemplate.EntityFramework
{
//    using statments;

    public class AbpZeroTemplateTenantDbContext : AbpZeroTenantDbContext<Role, User>
    {
        public virtual IDbSet<Department> Departments { get; set; }
        public virtual IDbSet<Enrollment> Enrollments { get; set; }

        public AbpZeroTemplateTenantDbContext() : base("Tenant")
        {
            
        }

        public AbpZeroTemplateTenantDbContext(string nameOrConnectionString)
            : base(nameOrConnectionString)
        {

        }

        /* This constructor is used in tests to pass a fake/mock connection.
         */
        public AbpZeroTemplateTenantDbContext(DbConnection dbConnection)
            : base(dbConnection, true)
        {

        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Configurations.Add(new DepartmentConfiguration());
            modelBuilder.Configurations.Add(new EnrollmentConfiguration());
        }
    }
}

and the error we are getting is attached.

Thank you again for your help.

Showing 1 to 10 of 65 entries