Base solution for your next web application

Activities of "ajayak"

  • What is your product version? 9.1
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .NET Core

How can I get all tenantIds where Edition Feature is Enabled/Avaible with 1 DB Query?

Similar to getting all settings in 1 query:

var settings = await _settingRepository.GetAll().IgnoreQueryFilters()
                .Where(c => c.TenantId.HasValue)
                .Where(c => c.Name == "MyName")
                .Select(c => new { TenantId = c.TenantId.Value, Value = c.Value.ToBool() })
                .ToListAsync();

It takes ~25 mins to build Angular project on Azure. Is there some way to reduce this time?

.net core/ 9.1.0 / Angular

We are running our App in West Europe and France Central regions on Azure.

In 80% cases, downloading a file with FileDownloadService works perfectly well. In 20% cases, I get the following error in browser with white page:

{"result":"Requested file does not exist!","targetUrl":null,"success":true,"error":null,"unAuthorizedRequest":false,"__abp":true}

Hi,

I am using dynamic imports and it suddenly started giving errors on project upgrade. Certainly an angular thing, but someone else faced this issue?

Code:

{
    path: 'product-mapping',
    loadChildren: () => import('./product-mapping/product-mapping.module').then(c => c.ProductMappingModule)
},

Hi,

Background job has Timer.Period property which controls when to run the job. But also I have hangfire connected which has its own way of running jobs via CRON expression.

Here is an example:

// At 1:50 of every 7th day
RecurringJob.AddOrUpdate<ShipmentAddressLocationCoordinatesWorker>(job => job.Start(), "50 1 * * 0", TimeZoneInfo.Utc);

inside the ShipmentAddressLocationCoordinatesWorker constuctor:

Timer.Period = 1000 * 60 * 60 * 24 * 7; // 7 Days

The problem is, I have no idea when the job's DoWork function will be executed! I checked the logs and saw that this job never executed. Can someone help me on understanding how to correctly use Timer.Period property? :)

I have hosted AspNetCore app as Azure App service. I have done all the things right but production app still throws developer exceptions.

Code in Configure function:

if (env.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
}
else
{
    app.UseStatusCodePagesWithRedirects("~/Error?statusCode={0}");
    app.UseExceptionHandler("/Error");
}

Azure App Service Configuration: ASPNETCORE_ENVIRONMENT : Production

Also tried to delete environment variable on azure as it points to Production by default but still no luck

Hi,

We are using AspNetZero. What are the benefits over swithching to AbpCommercial? How much to change in code from 10000 foot overview :D

Also, Is AbpCommercial built on metronic?

Hi,

I have a background job where I fetch a setting value for each tenant. Is there a way by which I can fetch the setting value for all tenants in 1 query instead of foreach?

Current code:

var tenantIds = await _lRepository.GetAll().IgnoreQueryFilters()
    .Select(c => c.TenantId)
    .ToListAsync();
foreach (var tenantId in tenantIds)
{
    var myBoolFlag = await SettingManager.GetSettingValueForTenantAsync<bool>("Super Power", tenantId);
    if (!myBoolFlag) continue;

    // Other code
}

Hi,

Is there any way to authorize angular routes as we do for permissions?

For eg:

new AppMenuItem('OrganizationUnits', 'Pages.Administration.OrganizationUnits', 'flaticon-map', '/app/admin/organization-units'),

and

{ path: 'users', component: UsersComponent, data: { permission: 'Pages.Administration.Users' } },

Can I do this check based on edition feature?

My app deals with saving orders received from an external system. The order contains child items like line items, address, fulfillments, refunds > refund items etc.

Currently, I use an ugly looking code to detect what has changed in each entity by its External Id. Can someone recommend me a better way? :)

Following is a simplified entity model of Order

public class Order 
{
    public long Id { get; set; }
    public string ExternalOrderId { get; set; }
    public List<LineItem> LineItems { get; set; }
    public List<Fulfillment> Fulfillments { get; set; }
    public ShippingAddress ShippingAddress { get; set; }
    public List<Refund> Refunds { get; set; }
    public string FinancialStatus { get; set; }
    public string FulfillmentStatus { get; set; }
}

public class LineItem 
{
    public long Id { get; set; }
    public string ExternalLineItemId { get; set; }
    public string SKU { get; set; }
    public int Quantity { get; set; }
    public long OrderId { get; set; }
}

public class Fulfillment 
{
    public long Id { get; set; }
    public string ExternalFulfillmentId { get; set; }
    public string Status { get; set; }
    public string TrackingUrl { get; set; }
    public long OrderId { get; set; }
}

public class ShippingAddress 
{
    public long Id { get; set; }
    public string ExternalShippingAddressrId { get; set; }
    public string Addres { get; set; }
    public long OrderId { get; set; }
}

public class Refund 
{
    public long Id { get; set; }
    public string ExternalRefundId { get; set; }
    public List<RefundedItem> LineItems { get; set; }
    public string CancelledReason { get; set; }
    public long OrderId { get; set; }
}

public class RefundedItem 
{
    public long Id { get; set; }
    public string ExternalRefundedItemId { get; set; }
    public string SKU { get; set; }
    public int Quantity { get; set; }
}

My sample code:

private async Task ManageFulfillments(long orderId, Order order)
{
    if (order.Fulfillments == null || !order.Fulfillments.Any()) return;

    var newFulfillmentIds = order.Fulfillments.Select(c => c.ExternalFulfillmentId).ToList();
    var dbFulfillments = await _fulfillmentRepository.GetAll().IgnoreQueryFilters()
        .Where(c => c.OrderId == orderId)
        .Select(c => new { c.Id, c.ExternalFulfillmentId }).ToListAsync();
    var dbFulfillmentIds = dbFulfillments.Select(c => c.ExternalFulfillmentId).ToList();

    // Delete Fulfillments that are not present in new Fulfillments list
    var deletedFulfillments = dbFulfillmentIds.Except(newFulfillmentIds).ToList();
    if (deletedFulfillments.Any())
    {
        await _fulfillmentRepository.DeleteAsync(c =>
        deletedFulfillments.Contains(c.ExternalFulfillmentId) && c.ExternalOrderId == orderId);
    }

    // Update existing Fulfillments ids
    order.Fulfillments
        .Where(c => dbFulfillmentIds.Contains(c.ExternalFulfillmentId))
        .ToList()
        .ForEach(async c =>
        {
            c.Id = dbFulfillments.Where(p => p.ExternalFulfillmentId == c.ExternalFulfillmentId)
                .Select(p => p.Id).FirstOrDefault();
            await _fulfillmentRepository.UpdateAsync(c);
        });

    // New Fulfillments will automatically be added by EF
}

I have similar code in place to update other entites as well and I'm not proud of it!

Showing 11 to 20 of 93 entries