Rename
Rename
Explore posts from servers
CDCloudflare Developers
Created by Rename on 4/15/2025 in #general-help
Issue with CloudFlare response
Hi guys, I have a page where I can filter a list of results. the website is hosted on IIS. my query parameters are like so:
?contractOption=All&occurrenceRule=&occurrenceType=&selectedName=&startDate=10%2f03%2f2025&startDateMax=14%2f03%2f2025
?contractOption=All&occurrenceRule=&occurrenceType=&selectedName=&startDate=10%2f03%2f2025&startDateMax=14%2f03%2f2025
the issue is, if I search for any dates where startDateMax is less than the 14th of March, the response is correct. if I search anything from the date of 14th march or later on, without the other parameters changed, I get the error
Cloudflare encountered an error processing this request: Bad Gateway
Cloudflare encountered an error processing this request: Bad Gateway
with status 502. so the URL for the correct response would be this:
?contractOption=All&occurrenceRule=&occurrenceType=&selectedName=&startDate=10%2f03%2f2025&startDateMax=13%2f03%2f2025
?contractOption=All&occurrenceRule=&occurrenceType=&selectedName=&startDate=10%2f03%2f2025&startDateMax=13%2f03%2f2025
I believe this is an issue with CloudFlare because: I connecting with Remote Desktop to the server, accessed the same URLs from the website's local IP (bypassing CloudFlare) and the pages load correctly. I also see no errors in my IIS logs or Event Viewer. and if i check in CF > Analytics & Logs > HTTP Traffic and I find those calls, the Edge status codes are all
200 OK
200 OK
, same thing with the Origin Status code. any ideas? and thank you in advance
54 replies
CC#
Created by Rename on 2/3/2025 in #help
Converting Legacy App to .Net 8
Hi, we've got a legacy app in .Net 4.6 Framework. it currently uses MSharp (which is not that known) framework, and I have been converting it to .Net 8 using clean-architecture as best as I can so far. One thing that bothers me is loading entity navigation data (with EF 8). The way the project is currenctly set up, as a simplified example is: StaffMembers table, WeekShifts table - contains weekStart date, shift1 - shift7 IDs. Contracts table - contract data, staffMemberId, rotationId Rotations table - has data regarding a weekly pattern for setting default shifts if none set manually. - current legacy backend setup: StaffMember class contains all DB columns as fields/properties. it also contains multiple methods such as: GetShift(Datetime date) this method basically checks 1. the WeekShifts table to find the shift, 2. If none found, get latest contract, set and return the default shift based on contract's rotation. The issue: Now what if I want to get all staff who have a shift on a particular date, I'd have to load all those staffs' WeekShifts navigation property, the contracts, and each contract's (or latest) rotation data. This method is used A LOT. if i keep it in StaffMember class, I'll have to find a way to always load that related data otherwise the methid would return null, if no WeekShifts or contract is loaded for example. loading that data everytime before I make a .GetShift() call doesn't seem like a good solution to me since it gets messy. Having a separate service for StaffMemberService.GetShift() method that loads all neccessary data doesn't seem that good of an idea if I have to load multiple staff. (I'd have to create overload methods in case I need more than 1 staff so that I dont make a DB call for each staff). what about other methods that also call staffMember's GetShift method
50 replies
CC#
Created by Rename on 10/8/2024 in #help
How to setup shared/common data in a web app
I've been working on a legacy project with .NET Framework 4.6. there is a Shift class and initially it had this code in its Shift entity class:
public static Shift None => Database.Find<Shift>(s => s.Department == null && s.IsNone);

public static Shift DayOff => Database.Find<Shift>(s => s.Department == null && s.IsDayOff);
public static Shift None => Database.Find<Shift>(s => s.Department == null && s.IsNone);

public static Shift DayOff => Database.Find<Shift>(s => s.Department == null && s.IsDayOff);
now I'm updating everything to .NET 8 and trying to use clean architecture, I'm using Entity Framewokr 8. It does not make sense to use direct DB calls in the entity class, these Shifts are all saved in the DB and could be edited anytime but the None and DayOff shifts are used very often. an example is GetShift() method for a staff which has something like this:
public Shift GetShift(DateTime date)
{

var contract = GetContract(date);
if (contract == null)
return Shift.None;
...
}
public Shift GetShift(DateTime date)
{

var contract = GetContract(date);
if (contract == null)
return Shift.None;
...
}
I'm a bit lost on what would be the best way to set this up. I could pass those shifts to the GetShift method from a service but I'm wondering if there's a better solution, this GetShift method is used in a lot of .Where clauses also.
33 replies
CC#
Created by Rename on 6/13/2024 in #help
"Duplicate property" Entity Framework 8 Error
I've got this error popping up on OnModelCreating method:
System.InvalidOperationException: 'The property or navigation 'Rotation' cannot be added to the 'AlternativeShift' type because a property or navigation with the same name already exists on the 'AlternativeShift' type.'
System.InvalidOperationException: 'The property or navigation 'Rotation' cannot be added to the 'AlternativeShift' type because a property or navigation with the same name already exists on the 'AlternativeShift' type.'
this is how I'm setting up AlternativeShift there:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

modelBuilder.Entity<AlternativeShift>(entity =>
{
entity.HasKey(e => e.Id)
.HasName("PK__Alternat__3214EC068342A05F")
.IsClustered(false);

entity.HasIndex(e => e.Rotation, "IX_AlternativeShifts->Rotation");

entity.HasIndex(e => e.Shift, "IX_AlternativeShifts->Shift");

entity.HasIndex(e => new { e.Rotation, e.Shift, e.Weekday }, "UQ_RotaShiftWeekday").IsUnique();

entity.Property(e => e.Id).ValueGeneratedNever();

entity.HasOne(d => d.Rotation).WithMany(p => p.AlternativeShifts)
.HasForeignKey(d => d.RotationId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_AlternativeShift.Rotation");

entity.HasOne(d => d.Shift).WithMany(p => p.AlternativeShifts)
.HasForeignKey(d => d.ShiftId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_AlternativeShift.Shift");

entity.HasOne(d => d.Weekday).WithMany(p => p.AlternativeShifts)
.HasForeignKey(d => d.WeekdayId)
.HasConstraintName("FK__Alternati__Weekd__1352D76D");
});
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

modelBuilder.Entity<AlternativeShift>(entity =>
{
entity.HasKey(e => e.Id)
.HasName("PK__Alternat__3214EC068342A05F")
.IsClustered(false);

entity.HasIndex(e => e.Rotation, "IX_AlternativeShifts->Rotation");

entity.HasIndex(e => e.Shift, "IX_AlternativeShifts->Shift");

entity.HasIndex(e => new { e.Rotation, e.Shift, e.Weekday }, "UQ_RotaShiftWeekday").IsUnique();

entity.Property(e => e.Id).ValueGeneratedNever();

entity.HasOne(d => d.Rotation).WithMany(p => p.AlternativeShifts)
.HasForeignKey(d => d.RotationId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_AlternativeShift.Rotation");

entity.HasOne(d => d.Shift).WithMany(p => p.AlternativeShifts)
.HasForeignKey(d => d.ShiftId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_AlternativeShift.Shift");

entity.HasOne(d => d.Weekday).WithMany(p => p.AlternativeShifts)
.HasForeignKey(d => d.WeekdayId)
.HasConstraintName("FK__Alternati__Weekd__1352D76D");
});
10 replies