Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "sumitshah"

We have a owners module in our application and need to perform CRUD operations for some field in this module. For this we have created owner appservice. We are injecting IOwnerRepository and using the same for the CRUD operations. This IOwnerRepository is inheriting from IOwnerRepository: IRepository<Owner, int>

Below is the code snippet we are using for the insert and update. In this code we are wanting to use the CheckErrors function which logs the error using log4net as well as throws a user friendly message(Similar to what is used in the UserAppService)

public async Task CreateOrEdit(CreateOrEditOwnerDto input)
    {
        try
        {
            ValidateOwners(input);
            if (input.Id == null)
            {
                var owner = ObjectMapper.Map&lt;Owner&gt;(input);
                await _customOwnerRepository.InsertAsync(owner);
            }
            else
            {
                var updateOwner = _customOwnerRepository.Get(input.Id.GetValueOrDefault());
                ObjectMapper.Map(input, updateOwner);
                CurrentUnitOfWork.SaveChanges();
            }
        }
        catch(Exception ex)
        {
            throw new UserFriendlyException(ex.Message);
        }
    }

unfortunately we are unable to use the CheckErrors function(as used in the UserAppService) cause the return type is not Task<IdentityResult>. Could you please let us know how can this be achieved in one shot without explicitly logging and throwing error.

Also, please let us know if we are correct on the below points:

  1. Exception handling is already implemented in the framework
  2. log4net is setup and we have a log4net configuration file
  3. if any error occurs in the backend, the same is automatically logged using log4net if the correct level is set in the config file
  4. There is not explicit logging code required

How can CheckErrors be implemented in all our AppServices

Thank you for the quick response.

We are not using abp tables, we are using our applications legacy tables, so the columns names are not the same, altough am sure we can set data annotations in our dto's to match the names.

Abp column names: CreationTime - datetime CreatorUserId - bigint LastModificationTime - datetime? LastModifierUserId - bigint

Legacy tables: dCreatedDate - datetime cCreatedBy - varchar(25) dModifiedDate - datetime cModifiedBy - varchar(25)

Also, the data types are differeing and the inbuild interfaces are having CreatorUserID but in our case we need to store the UserName in the legacy tables so the inbuild interfaces would not suffice to our requirement.

Could you please suggest a different approach.

We are using Angular and .net core, aspnetzero framework.

For all the CRUD operations Insert/ Update we are using ObjectMapper to map the entity with the dto All the insert/ update dto's are exact replica of their respective entities(which are created using the RAD tool based on their SQL tables)

Now, there are 4 common columns in all the SQL tables and also the entities and we have created the same in the dto's as well. The 4 columns are:

  • cCreatedBy
  • dCreatedDate
  • cModifiedBy
  • dModifiedDate

We need to update the first 2 columns during a create operation and the remaining 2 when we update a record. There are 2 different ways we have tried to implement this:

  1. Set the date and user in the backend during save public async Task CreateOrEdit(CreateOrEditOwnerDto input) { try { ValidateOwners(input); if (input.Id == null) { var owner = ObjectMapper.Map<Owner>(input); owner.cCreatedBy = _mySession.IDMSUserName; owner.dCreatedDate = DateTime.Now; await _customOwnerRepository.InsertAsync(owner); } else { var updateOwner = _customOwnerRepository.Get(input.Id.GetValueOrDefault()); input.cModifiedBy = _mySession.IDMSUserName; input.dModifiedDate = DateTime.Now; ObjectMapper.Map(input, updateOwner); CurrentUnitOfWork.SaveChanges(); } } catch(Exception ex) { throw new UserFriendlyException(ex.Message); } }
  2. By passing the user and date from the Angular app in the dto.

We have explored the UserAppService code where we are inheriting AbpUser class and this internally inherits multiple interface which are setting the user and datetime. But all of this is in aspnetzero core dll and we are unable to use the same.

Could you please let us know the right way to implement this without writing redundant code.

Thank you, we were able to successfully disable the job

Owner Entity

namespace Infogroup.IDMS.Owners
{
    [Table("tblOwner")]
    public class Owner : Entity 
    {

        [Required]
        public virtual string cCode { get; set; }

        [Required]
        public virtual string cCompany { get; set; }

        [Required]
        public virtual string cAddress1 { get; set; }

        [Required]
        public virtual string cAddress2 { get; set; }

        [Required]
        public virtual string cCity { get; set; }

        [Required]
        public virtual string cState { get; set; }

        [Required]
        public virtual string cZip { get; set; }

        [Required]
        public virtual string cPhone { get; set; }

        [Required]
        public virtual string cFax { get; set; }

        [Required]
        public virtual string cNotes { get; set; }

        [Required]
        public virtual bool iIsActive { get; set; }

        [Required]
        public virtual DateTime dCreatedDate { get; set; }

        [Required]
        public virtual string cCreatedBy { get; set; }

        public virtual string cModifiedBy { get; set; }

        public virtual DateTime? dModifiedDate { get; set; }


        public virtual int DatabaseId { get; set; }

        [ForeignKey("DatabaseId")]
        public Database DatabaseFk { get; set; }
		
    }
}

CreateOrEditOwnerDto

namespace Infogroup.IDMS.Owners.Dtos
{
    public class CreateOrEditOwnerDto : EntityDto<int?>
    {

            public string cCode { get; set; }

            public string cCompany { get; set; }

            public string cAddress1 { get; set; }

            public string cAddress2 { get; set; }

            public string cCity { get; set; }

            public string cState { get; set; }

            public string cZip { get; set; }

            public string cPhone { get; set; }

            public string cFax { get; set; }

            public string cNotes { get; set; }

            public bool iIsActive { get; set; }

            public int DatabaseId { get; set; }

            public string cCreatedBy { get; set; }

            public string cModifiedBy { get; set; }

            public DateTime dCreatedDate { get; set; }
    }
}
Question

Hi,

We need to completely disable the background jobs in our project. we have tried :

Configuration.BackgroundJobs.IsJobExecutionEnabled = false;

in the WebCoreModule.cs, Core Project >> CoreModule.cs but checking the queries in the SQL profiler, the below query is getting fired almost every 2 seconds

exec sp_executesql N'SELECT TOP(@__p_1) [t].[Id], [t].[CreationTime], [t].[CreatorUserId], [t].[IsAbandoned], [t].[JobArgs], [t].[JobType], [t].[LastTryTime], [t].[NextTryTime], [t].[Priority], [t].[TryCount]
FROM [AbpBackgroundJobs] AS [t]
WHERE ([t].[IsAbandoned] = 0) AND ([t].[NextTryTime] <= @__Now_0)
ORDER BY [t].[Priority] DESC, [t].[TryCount], [t].[NextTryTime]',N'@__p_1 int,@__Now_0 datetime2(7)',@__p_1=1000,@__Now_0='2019-12-09 16:21:02.3694549'

could you please let us know how to completely stop these background jobs.

Hello,

For Angular-Core project currently 34-35 odd tables are getting created in the DB. Can we get any documentation as to what tables are used for what purpose.

We are in process of moving the developed application onto Production, so before that we want to sure what tables need to be pushed into prod sql db.

Also, once the tables are into production, how do we maintain the tables. Let me explain the below scenrio:

  1. We have a staging environment where we make a few changes to the abp tables from the UI and admin section. Rows get added to the particular abp tables
  2. Now when we want to push the changes to production, do we need to truncate the abp tables, generate a insert script from staging DB and execute the script onto Prod DB or there is some mechanism where we can simply append the rows od staging DB into Production DB.

Hello,

We have been using the RAD tool to generate entities and basic UI's and we are able to do that swiftly, Thank you!!!

While working on development of one of the functionalities, we need to develop something similar to "Import from Excel" functionality provided in the Users module(by default).

There is no any option for "Import from excel" in the RAD tool, altough there is an option "Create Excel Export Button".

How can we implement this functionality using the RAD tool so that the development time would get reduced. Is it something in the RAD tool with which this can be achieved.

Also, if this is not possible using the RAD tool, could you please explain how this can be achieved in aspnetzero. We have a excel sheet with fixed columns and we would want to apply validations as well as if all the validations pass, would want to upload the file and insert the records in a particular SQL table.

We have cached three entities using Entity Caching by referring the below documentation. https://aspnetboilerplate.com/Pages/Documents/Caching#entity-caching

We have to perform a linq on these cached enitites. Below is the linq perform using the repository.

var mailers = (from mailer in _mailerRepository.GetAll() join groupBroker in _groupBrokerRepository.GetAll() on mailer.BrokerID equals groupBroker.BrokerID join userGroup in _userGroupRepository.GetAll() on groupBroker.GroupID equals userGroup.GroupID where mailer.iIsActive && userGroup.UserId == _mySession.IDMSUserId && mailer.DatabaseID == input.DatabaseID && _offerRepository.GetAll().Any(offer => offer.MailerId == mailer.Id) orderby mailer.cCompany select mailer).Distinct();

We are not able to do the same with entity caching as EntityCacheBase class does have any method implemented which returns List<TCacheItem>. Could you please help us out and explain how can we implement this.

Thank you, but could you please explain how and where this needs to be implemented. If would be very helpful if you could share a code snippet for the implementation.

Also, say if I cache a 1000 rows of a SQL table and all the consequent requests are catered from the cache. Now, the admin adds 2 more rows to the table, when and how can we refresh the cache so that the end users always get the fresh data.

Showing 71 to 80 of 105 entries