I'm having a few issues getting a second context to a vended app database wired up properly (second context should not use code first). The specific error I am getting when attempting to run 'abp.services.app.vended.getAttributes()' is 'error detail not sent by server', with a response of '{"message":"An error has occurred."}'.
I've looked at the MultiContextDemo app, and think I have things wired up properly, but I am obviously missing something.
CSDataModule
[DependsOn(typeof(AbpZeroEntityFrameworkModule), typeof(CSCoreModule))]
public class CSDataModule : AbpModule
{
public override void PreInitialize()
{
Database.SetInitializer(new CreateDatabaseIfNotExists<CSDbContext>());
//web.config (or app.config for non-web projects) file should contain a connection string named "Default".
Configuration.DefaultNameOrConnectionString = "Default";
}
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
Database.SetInitializer<VendedDbContext>(null);
}
}
VendedDbContext
public class VendedDbContext : AbpDbContext
{
public VendedDbContext()
: base("Vended")
{
}
}
Attribute Class
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Abp.Domain.Entities;
namespace MCMT.CS.Vended
{
/// <summary>
/// A class which represents the Attribute table.
/// </summary>
[Table("Attribute")]
public class Attribute : Entity
{
[Key]
public virtual int AttributeID { get; set; }
public virtual int ResourceTypeID { get; set; }
public virtual string Name { get; set; }
public virtual int AttributeTypeID { get; set; }
public virtual int? SortOrder { get; set; }
public virtual string DefaultValue { get; set; }
public virtual byte? ResNameIndex { get; set; }
public virtual bool IsUnique { get; set; }
public virtual byte? RepNameIndex { get; set; }
public virtual string RepNameFormat { get; set; }
public virtual bool IsCertification { get; set; }
public virtual bool IsPublic { get; set; }
public virtual int? SpecialTypeID { get; set; }
public virtual bool ShowOnTimesheet { get; set; }
public virtual bool IsSelfServe { get; set; }
public virtual string CertType { get; set; }
public virtual int? CertWarnDays { get; set; }
public virtual int? CertExpireDays { get; set; }
public virtual string CertExpireValue { get; set; }
public virtual bool IsContact { get; set; }
public virtual int? CertValueOperator { get; set; }
public virtual bool CertIgnoreNull { get; set; }
public virtual bool CertForbidPunch { get; set; }
}
}
Vended App Service Interface
using System.Collections.Generic;
using Abp.Application.Services;
namespace MCMT.CS.Vended
{
public interface IVendedAppService : IApplicationService
{
List<Attribute> GetAttributes();
}
}
Vended App Service
using System.Collections.Generic;
using System.Linq;
using Abp.Auditing;
using Abp.Domain.Repositories;
namespace MCMT.CS.Vended
{
[DisableAuditing]
public class VendedAppService : CSAppServiceBase, IVendedAppService
{
private readonly IRepository<Attribute> _aRepository;
public VendedAppService(IRepository<Attribute> aRepository)
{
_aRepository = aRepository;
}
public List<Attribute> GetAttributes()
{
var attributes = _aRepository.GetAllList().ToList();
return attributes;
}
}
}
Any assistance would be appreciated.
Sorry for the simple question, but how does one change the default backend app from AngularJS to MPA.
Thanks, MPM
The app I am working on right now has two DbContext, and two controllers. The first controller (using the default DbContext) is logging to the audit log with no issue. The second controller (using the second DbContext) is not logging anything to the audit log.
Do you have any thoughts on possible causes?
I've created a unit test for creating a device object with a DeviceName, Site, and IsTraining bit. AutoMapper is throwing out the following error in the test. I'm not sure why my DTO and Domain object aren't able to map properly.
Result Message: AutoMapper.AutoMapperMappingException : Missing type map configuration or unsupported mapping.
Mapping types: DeviceEditDto -> Device MCMT.PatientCareReporting.Devices.Dto.DeviceEditDto -> MCMT.PatientCareReporting.Devices.Device
My test looks like so:
public class DeviceAppService_Create_Tests : DeviceAppServiceTestBase
{
[Fact]
public async Task Should_Create_Device()
{
LoginAsHostAdmin();
await CreateDeviceAndTestAsync("TESTDEVICE", "Rochester", false);
await CreateDeviceAndTestAsync("R5001011", "Austin", true);
}
private async Task CreateDeviceAndTestAsync(string deviceName, string site, bool isTraining)
{
//Act
await DeviceAppService.CreateOrUpdateDevice(
new CreateOrUpdateDeviceInput
{
Device = new DeviceEditDto
{
DeviceName = deviceName,
Site = site,
IsTraining = isTraining
}
});
//Assert
UsingDbContext(async context =>
{
//Get created device
var createdDevice = await context.Devices.FirstOrDefaultAsync(u => u.DeviceName == "TESTDEVICE");
createdDevice.ShouldNotBe(null);
//Check some properties
createdDevice.Site.ShouldBe("Rochester");
createdDevice.IsTraining.ShouldBe(false);
});
}
}
My domain object is as follows:
[Table("rntDevice")]
public class Device : FullAuditedEntity
{
public const int MaxDeviceNameLength = 10;
public const int MaxSiteLength = 32;
[Required]
[MaxLength(MaxDeviceNameLength)]
public virtual string DeviceName { get; set; }
[Required]
[MaxLength(MaxSiteLength)]
public virtual string Site { get; set; }
public virtual bool IsTraining { get; set; }
}
and the DTO object looks like so:
public class DeviceEditDto : IValidate
{
/// <summary>
/// Set null to create a new device. Set device's Id to update a device
/// </summary>
public long? Id { get; set; }
[Required]
[StringLength(Device.MaxDeviceNameLength)]
public string DeviceName { get; set; }
[Required]
[StringLength(Device.MaxSiteLength)]
public string Site { get; set; }
public bool IsTraining { get; set; }
}
Any thoughts I what I might have wired together incorrectly?
Halil,
I'm not certain I fully understand how to enable LDAP integration. I've Enabled LDAP in the CoreModule.cs as follows:
//Enable this line to create a multi-tenant application.
//Configuration.MultiTenancy.IsEnabled = true;
//Enable LDAP authentication (It can be enabled only if MultiTenancy is disabled!)
Configuration.Modules.ZeroLdap().Enable(typeof(AppLdapAuthenticationSource));
I'm not sure of the next steps? Do I need to drop in a LdapSettingProvider and LdapSettings class, then call Configuration.Settings.Providers.Add<LdapSettingProvider>?
Are changes needed in the AccountController to support LDAP.
Thanks for your assistance, MPM