1 Commits

Author SHA1 Message Date
Burak Kaan Köse
aba7539e7d Replaced DateTimeOffset usage in the calendar. 2025-05-20 21:08:19 +02:00
10 changed files with 51 additions and 284 deletions

View File

@@ -142,5 +142,7 @@ public partial class AccountManagementViewModel : AccountManagementPageViewModel
}; };
var synchronizationResponse = await WinoServerConnectionManager.GetResponseAsync<CalendarSynchronizationResult, NewCalendarSynchronizationRequested>(new NewCalendarSynchronizationRequested(synchronizationOptions, SynchronizationSource.Client)); var synchronizationResponse = await WinoServerConnectionManager.GetResponseAsync<CalendarSynchronizationResult, NewCalendarSynchronizationRequested>(new NewCalendarSynchronizationRequested(synchronizationOptions, SynchronizationSource.Client));
accountCreationDialog.Complete(cancel: false);
} }
} }

View File

@@ -237,20 +237,20 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel,
{ {
var durationSeconds = (QuickEventEndTime - QuickEventStartTime).TotalSeconds; var durationSeconds = (QuickEventEndTime - QuickEventStartTime).TotalSeconds;
var testCalendarItem = new CalendarItem //var testCalendarItem = new CalendarItem
{ //{
CalendarId = SelectedQuickEventAccountCalendar.Id, // CalendarId = SelectedQuickEventAccountCalendar.Id,
StartDate = QuickEventStartTime, // StartDate = QuickEventStartTime,
DurationInSeconds = durationSeconds, // DurationInSeconds = durationSeconds,
CreatedAt = DateTime.UtcNow, // CreatedAt = DateTime.UtcNow,
Description = string.Empty, // Description = string.Empty,
Location = Location, // Location = Location,
Title = EventName, // Title = EventName,
Id = Guid.NewGuid() // Id = Guid.NewGuid()
}; //};
IsQuickEventDialogOpen = false; //IsQuickEventDialogOpen = false;
await _calendarService.CreateNewCalendarItemAsync(testCalendarItem, null); //await _calendarService.CreateNewCalendarItemAsync(testCalendarItem, null);
// TODO: Create the request with the synchronizer. // TODO: Create the request with the synchronizer.
} }

View File

@@ -17,11 +17,11 @@ public partial class CalendarItemViewModel : ObservableObject, ICalendarItem, IC
public IAccountCalendar AssignedCalendar => CalendarItem.AssignedCalendar; public IAccountCalendar AssignedCalendar => CalendarItem.AssignedCalendar;
public DateTime StartDate { get => CalendarItem.StartDate; set => CalendarItem.StartDate = value; } public DateTime StartDate => CalendarItem.StartDate;
public DateTime EndDate => CalendarItem.EndDate; public DateTime EndDate => CalendarItem.EndDate;
public double DurationInSeconds { get => CalendarItem.DurationInSeconds; set => CalendarItem.DurationInSeconds = value; } public double DurationInSeconds => CalendarItem.DurationInSeconds;
public ITimePeriod Period => CalendarItem.Period; public ITimePeriod Period => CalendarItem.Period;

View File

@@ -17,24 +17,23 @@ public class CalendarItem : ICalendarItem
public string Description { get; set; } public string Description { get; set; }
public string Location { get; set; } public string Location { get; set; }
public DateTime StartDate { get; set; } public string StartTimeOffset { get; set; }
public string EndTimeOffset { get; set; }
public DateTime EndDate public DateTimeOffset StartDateTimeOffset => DateTimeOffset.Parse(StartTimeOffset);
{ public DateTimeOffset EndDateTimeOffsete => DateTimeOffset.Parse(EndTimeOffset);
get
{
return StartDate.AddSeconds(DurationInSeconds);
}
}
public TimeSpan StartDateOffset { get; set; } public DateTime StartDate => StartDateTimeOffset.DateTime;//TimeZoneInfo.ConvertTime(StartDateTimeOffset, TimeZoneInfo.Local).DateTime;
public TimeSpan EndDateOffset { get; set; } public DateTime EndDate => EndDateTimeOffsete.DateTime;// TimeZoneInfo.ConvertTime(, TimeZoneInfo.Local).DateTime;
private ITimePeriod _period; private ITimePeriod _period;
public ITimePeriod Period public ITimePeriod Period
{ {
get get
{ {
// Period must be loaded by user's current UI culture based on StartDateTimeOffset and EndDateTimeOffset
// Get the time zone corresponding to the current culture
_period ??= new TimeRange(StartDate, EndDate); _period ??= new TimeRange(StartDate, EndDate);
return _period; return _period;
@@ -94,7 +93,7 @@ public class CalendarItem : ICalendarItem
} }
} }
public double DurationInSeconds { get; set; } public double DurationInSeconds => Period.Duration.TotalSeconds;
public string Recurrence { get; set; } public string Recurrence { get; set; }
public string OrganizerDisplayName { get; set; } public string OrganizerDisplayName { get; set; }
@@ -144,7 +143,7 @@ public class CalendarItem : ICalendarItem
/// </summary> /// </summary>
public Guid EventTrackingId => IsOccurrence ? RecurringCalendarItemId.Value : Id; public Guid EventTrackingId => IsOccurrence ? RecurringCalendarItemId.Value : Id;
public CalendarItem CreateRecurrence(DateTime startDate, double durationInSeconds) public CalendarItem CreateRecurrence(DateTimeOffset startDateOffset, DateTimeOffset endDateOffset)
{ {
// Create a copy with the new start date and duration // Create a copy with the new start date and duration
@@ -154,8 +153,8 @@ public class CalendarItem : ICalendarItem
Title = Title, Title = Title,
Description = Description, Description = Description,
Location = Location, Location = Location,
StartDate = startDate, StartTimeOffset = startDateOffset.ToString("o"),
DurationInSeconds = durationInSeconds, EndTimeOffset = endDateOffset.ToString("o"),
Recurrence = Recurrence, Recurrence = Recurrence,
OrganizerDisplayName = OrganizerDisplayName, OrganizerDisplayName = OrganizerDisplayName,
OrganizerEmail = OrganizerEmail, OrganizerEmail = OrganizerEmail,
@@ -168,8 +167,6 @@ public class CalendarItem : ICalendarItem
Status = Status, Status = Status,
CustomEventColorHex = CustomEventColorHex, CustomEventColorHex = CustomEventColorHex,
HtmlLink = HtmlLink, HtmlLink = HtmlLink,
StartDateOffset = StartDateOffset,
EndDateOffset = EndDateOffset,
RemoteEventId = RemoteEventId, RemoteEventId = RemoteEventId,
IsHidden = IsHidden, IsHidden = IsHidden,
IsLocked = IsLocked, IsLocked = IsLocked,

View File

@@ -8,9 +8,9 @@ public interface ICalendarItem
string Title { get; } string Title { get; }
Guid Id { get; } Guid Id { get; }
IAccountCalendar AssignedCalendar { get; } IAccountCalendar AssignedCalendar { get; }
DateTime StartDate { get; set; } DateTime StartDate { get; }
DateTime EndDate { get; } DateTime EndDate { get; }
double DurationInSeconds { get; set; } double DurationInSeconds { get; }
ITimePeriod Period { get; } ITimePeriod Period { get; }
bool IsAllDayEvent { get; } bool IsAllDayEvent { get; }

View File

@@ -5,7 +5,6 @@ using System.Threading.Tasks;
using Microsoft.Graphics.Canvas; using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Printing; using Microsoft.Graphics.Canvas.Printing;
using Windows.Data.Pdf; using Windows.Data.Pdf;
using Windows.Graphics.Display;
using Windows.Graphics.Printing; using Windows.Graphics.Printing;
using Windows.Graphics.Printing.OptionDetails; using Windows.Graphics.Printing.OptionDetails;
using Windows.Storage.Streams; using Windows.Storage.Streams;
@@ -136,11 +135,6 @@ public class PrintService : IPrintService
private async void OnDocumentTaskOptionsChanged(CanvasPrintDocument sender, CanvasPrintTaskOptionsChangedEventArgs args) private async void OnDocumentTaskOptionsChanged(CanvasPrintDocument sender, CanvasPrintTaskOptionsChangedEventArgs args)
{ {
System.Diagnostics.Debug.WriteLine("[PrintService] OnDocumentTaskOptionsChanged starting...");
DisplayInformation di = DisplayInformation.GetForCurrentView();
System.Diagnostics.Debug.WriteLine($"[PrintService] DisplayInformation.RawPixelsPerViewPixel: {di.RawPixelsPerViewPixel}");
System.Diagnostics.Debug.WriteLine($"[PrintService] DisplayInformation.LogicalDpi: {di.LogicalDpi}");
var deferral = args.GetDeferral(); var deferral = args.GetDeferral();
try try
@@ -148,10 +142,6 @@ public class PrintService : IPrintService
await LoadPDFPageBitmapsAsync(sender); await LoadPDFPageBitmapsAsync(sender);
var pageDesc = args.PrintTaskOptions.GetPageDescription(1); var pageDesc = args.PrintTaskOptions.GetPageDescription(1);
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.PageSize.Width (DIPs): {pageDesc.PageSize.Width}");
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.PageSize.Height (DIPs): {pageDesc.PageSize.Height}");
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.DpiX: {pageDesc.DpiX}");
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.DpiY: {pageDesc.DpiY}");
var newPageSize = pageDesc.PageSize.ToVector2(); var newPageSize = pageDesc.PageSize.ToVector2();
if (pageSize == newPageSize && pageCount != -1) if (pageSize == newPageSize && pageCount != -1)
@@ -186,10 +176,6 @@ public class PrintService : IPrintService
// Calculate the page count // Calculate the page count
bitmapCount = bitmaps.Count; bitmapCount = bitmaps.Count;
pageCount = (int)Math.Ceiling(bitmapCount / (double)bitmapsPerPage); pageCount = (int)Math.Ceiling(bitmapCount / (double)bitmapsPerPage);
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated columns: {columns}");
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated rows: {rows}");
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated bitmapsPerPage: {bitmapsPerPage}");
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated pageCount: {pageCount}");
sender.SetPageCount((uint)pageCount); sender.SetPageCount((uint)pageCount);
// Set the preview page to the one that has the item that was currently displayed in the last preview // Set the preview page to the one that has the item that was currently displayed in the last preview
@@ -199,31 +185,11 @@ public class PrintService : IPrintService
{ {
deferral.Complete(); deferral.Complete();
} }
System.Diagnostics.Debug.WriteLine("[PrintService] OnDocumentTaskOptionsChanged finished.");
} }
private async Task LoadPDFPageBitmapsAsync(CanvasPrintDocument sender) private async Task LoadPDFPageBitmapsAsync(CanvasPrintDocument sender)
{ {
System.Diagnostics.Debug.WriteLine("[PrintService] LoadPDFPageBitmapsAsync starting...");
DisplayInformation displayInfo = DisplayInformation.GetForCurrentView();
float rawPixelsPerViewPixel = (float)displayInfo.RawPixelsPerViewPixel;
if (rawPixelsPerViewPixel == 0)
{
System.Diagnostics.Debug.WriteLine($"[PrintService] Warning: RawPixelsPerViewPixel was 0, defaulting to 1.0f");
rawPixelsPerViewPixel = 1.0f; // Sanity check
}
System.Diagnostics.Debug.WriteLine($"[PrintService] DisplayInformation.RawPixelsPerViewPixel: {rawPixelsPerViewPixel}");
System.Diagnostics.Debug.WriteLine($"[PrintService] DisplayInformation.LogicalDpi: {displayInfo.LogicalDpi}");
float printerDpi = sender.Dpi;
if (printerDpi == 0)
{
System.Diagnostics.Debug.WriteLine($"[PrintService] Warning: sender.Dpi (printerDpi) was 0, defaulting to 96.0f");
printerDpi = 96.0f; // Sanity check
}
System.Diagnostics.Debug.WriteLine($"[PrintService] sender.Dpi (CanvasPrintDocument.Dpi, used as PrinterDPI): {printerDpi}");
ClearBitmaps(); ClearBitmaps();
bitmaps ??= new List<CanvasBitmap>(); bitmaps ??= new List<CanvasBitmap>();
@@ -231,40 +197,11 @@ public class PrintService : IPrintService
for (int i = 0; i < pdfDocument.PageCount; i++) for (int i = 0; i < pdfDocument.PageCount; i++)
{ {
var page = pdfDocument.GetPage((uint)i); var page = pdfDocument.GetPage((uint)i);
System.Diagnostics.Debug.WriteLine($"[PrintService] Processing page.Index: {page.Index}"); var stream = new InMemoryRandomAccessStream();
System.Diagnostics.Debug.WriteLine($"[PrintService] page.Dimensions.MediaBox.Width (PDF points): {page.Dimensions.MediaBox.Width}"); await page.RenderToStreamAsync(stream);
System.Diagnostics.Debug.WriteLine($"[PrintService] page.Dimensions.MediaBox.Height (PDF points): {page.Dimensions.MediaBox.Height}");
double pageWidthInPoints = page.Dimensions.MediaBox.Width;
double pageHeightInPoints = page.Dimensions.MediaBox.Height;
double pageWidthInInches = pageWidthInPoints / 72.0;
double pageHeightInInches = pageHeightInPoints / 72.0;
// Calculate the desired pixel dimensions of the bitmap based on printer DPI
uint targetPixelWidth = (uint)(pageWidthInInches * printerDpi);
uint targetPixelHeight = (uint)(pageHeightInInches * printerDpi);
// Calculate DestinationWidth/Height for PdfPageRenderOptions in DIPs
PdfPageRenderOptions options = new PdfPageRenderOptions();
options.DestinationWidth = (uint)(targetPixelWidth / rawPixelsPerViewPixel);
options.DestinationHeight = (uint)(targetPixelHeight / rawPixelsPerViewPixel);
System.Diagnostics.Debug.WriteLine($"[PrintService] Page {i}, Calculated PdfPageRenderOptions.DestinationWidth (DIPs): {options.DestinationWidth}, DestinationHeight (DIPs): {options.DestinationHeight}");
System.Diagnostics.Debug.WriteLine($"[PrintService] Page {i}, TargetPixelWidth: {targetPixelWidth}, TargetPixelHeight: {targetPixelHeight}");
using (var stream = new InMemoryRandomAccessStream())
{
await page.RenderToStreamAsync(stream, options); // Use the options
var bitmap = await CanvasBitmap.LoadAsync(sender, stream); var bitmap = await CanvasBitmap.LoadAsync(sender, stream);
System.Diagnostics.Debug.WriteLine($"[PrintService] bitmap.SizeInPixels.Width: {bitmap.SizeInPixels.Width}");
System.Diagnostics.Debug.WriteLine($"[PrintService] bitmap.SizeInPixels.Height: {bitmap.SizeInPixels.Height}");
System.Diagnostics.Debug.WriteLine($"[PrintService] bitmap.Dpi: {bitmap.Dpi}");
bitmaps.Add(bitmap); bitmaps.Add(bitmap);
} }
}
largestBitmap = Vector2.Zero; largestBitmap = Vector2.Zero;
@@ -273,7 +210,6 @@ public class PrintService : IPrintService
largestBitmap.X = Math.Max(largestBitmap.X, (float)bitmap.Size.Width); largestBitmap.X = Math.Max(largestBitmap.X, (float)bitmap.Size.Width);
largestBitmap.Y = Math.Max(largestBitmap.Y, (float)bitmap.Size.Height); largestBitmap.Y = Math.Max(largestBitmap.Y, (float)bitmap.Size.Height);
} }
System.Diagnostics.Debug.WriteLine("[PrintService] LoadPDFPageBitmapsAsync finished.");
} }
@@ -326,153 +262,4 @@ public class PrintService : IPrintService
} }
} }
} }
// --- START SIMULATION CODE ---
private async Task RunSimulationAsync(float simulatedRawPixelsPerViewPixel, string callingMethodName)
{
// --- Simulate LoadPDFPageBitmapsAsync ---
System.Diagnostics.Debug.WriteLine($"[PrintService] SIMULATING from {callingMethodName} for {simulatedRawPixelsPerViewPixel}");
System.Diagnostics.Debug.WriteLine("[PrintService] LoadPDFPageBitmapsAsync starting...");
// Mock DisplayInformation
float actualRawPixelsPerViewPixel = simulatedRawPixelsPerViewPixel; // Override
if (actualRawPixelsPerViewPixel == 0)
{
System.Diagnostics.Debug.WriteLine($"[PrintService] Warning: actualRawPixelsPerViewPixel was 0, defaulting to 1.0f");
actualRawPixelsPerViewPixel = 1.0f; // Sanity check
}
System.Diagnostics.Debug.WriteLine($"[PrintService] DisplayInformation.RawPixelsPerViewPixel: {actualRawPixelsPerViewPixel}");
// LogicalDpi is not directly used in calculations we are testing, so we can use a placeholder.
System.Diagnostics.Debug.WriteLine($"[PrintService] DisplayInformation.LogicalDpi: 96.0f (Simulated)");
// Mock CanvasPrintDocument sender for DPI
float printerDpi = 300.0f; // As per subtask
System.Diagnostics.Debug.WriteLine($"[PrintService] sender.Dpi (CanvasPrintDocument.Dpi, used as PrinterDPI): {printerDpi}");
// Clear any previous simulation state for bitmaps
// In a real scenario, ClearBitmaps() would be called. Here we just reset relevant fields.
this.bitmaps.Clear(); // Assuming 'bitmaps' is the List<CanvasBitmap>
this.largestBitmap = Vector2.Zero;
// Simulate pdfDocument.PageCount = 1 and loop once
int simulatedPageCount = 1;
for (int i = 0; i < simulatedPageCount; i++)
{
// Mock PdfPage
uint pageIndex = (uint)i;
double pageWidthInPoints = 612.0; // Letter size
double pageHeightInPoints = 792.0; // Letter size
System.Diagnostics.Debug.WriteLine($"[PrintService] Processing page.Index: {pageIndex}");
System.Diagnostics.Debug.WriteLine($"[PrintService] page.Dimensions.MediaBox.Width (PDF points): {pageWidthInPoints}");
System.Diagnostics.Debug.WriteLine($"[PrintService] page.Dimensions.MediaBox.Height (PDF points): {pageHeightInPoints}");
double pageWidthInInches = pageWidthInPoints / 72.0;
double pageHeightInInches = pageHeightInPoints / 72.0;
uint targetPixelWidth = (uint)(pageWidthInInches * printerDpi);
uint targetPixelHeight = (uint)(pageHeightInInches * printerDpi);
PdfPageRenderOptions options = new PdfPageRenderOptions();
options.DestinationWidth = (uint)(targetPixelWidth / actualRawPixelsPerViewPixel);
options.DestinationHeight = (uint)(targetPixelHeight / actualRawPixelsPerViewPixel);
System.Diagnostics.Debug.WriteLine($"[PrintService] Page {i}, Calculated PdfPageRenderOptions.DestinationWidth (DIPs): {options.DestinationWidth}, DestinationHeight (DIPs): {options.DestinationHeight}");
System.Diagnostics.Debug.WriteLine($"[PrintService] Page {i}, TargetPixelWidth: {targetPixelWidth}, TargetPixelHeight: {targetPixelHeight}");
// Mock CanvasBitmap properties (as we can't actually render)
uint mockBitmapSizeInPixelsWidth = targetPixelWidth;
uint mockBitmapSizeInPixelsHeight = targetPixelHeight;
float mockBitmapDpi = printerDpi;
System.Diagnostics.Debug.WriteLine($"[PrintService] bitmap.SizeInPixels.Width: {mockBitmapSizeInPixelsWidth} (Simulated)");
System.Diagnostics.Debug.WriteLine($"[PrintService] bitmap.SizeInPixels.Height: {mockBitmapSizeInPixelsHeight} (Simulated)");
System.Diagnostics.Debug.WriteLine($"[PrintService] bitmap.Dpi: {mockBitmapDpi} (Simulated)");
// Simulate adding to bitmaps list and tracking largest
// We don't add a real CanvasBitmap, just update what's needed for OnDocumentTaskOptionsChanged
this.largestBitmap.X = Math.Max(this.largestBitmap.X, mockBitmapSizeInPixelsWidth);
this.largestBitmap.Y = Math.Max(this.largestBitmap.Y, mockBitmapSizeInPixelsHeight);
// bitmaps.Add(null); // Not adding real bitmaps
}
this.bitmapCount = simulatedPageCount; // Set based on simulation
System.Diagnostics.Debug.WriteLine("[PrintService] LoadPDFPageBitmapsAsync finished.");
// --- Simulate OnDocumentTaskOptionsChanged ---
System.Diagnostics.Debug.WriteLine("[PrintService] OnDocumentTaskOptionsChanged starting...");
// DisplayInformation logs already done in LoadPDFPageBitmapsAsync simulation part
// Mock PageDescription (from PrintTaskOptions)
// For Letter paper (8.5x11 inches) at 300 DPI:
// Pixel size = (8.5*300) x (11*300) = 2550 x 3300 pixels
// DIP size = (PixelSize / rawPixelsPerViewPixel)
float pageDescPageSizeWidth = (2550.0f / actualRawPixelsPerViewPixel);
float pageDescPageSizeHeight = (3300.0f / actualRawPixelsPerViewPixel);
float pageDescDpiX = 300.0f;
float pageDescDpiY = 300.0f;
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.PageSize.Width (DIPs): {pageDescPageSizeWidth} (Simulated)");
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.PageSize.Height (DIPs): {pageDescPageSizeHeight} (Simulated)");
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.DpiX: {pageDescDpiX} (Simulated)");
System.Diagnostics.Debug.WriteLine($"[PrintService] pageDesc.DpiY: {pageDescDpiY} (Simulated)");
this.pageSize = new Vector2(pageDescPageSizeWidth, pageDescPageSizeHeight);
// sender.InvalidatePreview(); // Cannot call
// Calculate the new layout
var printablePageSize = this.pageSize * 0.9f; // Assuming default behavior
this.imagePadding = new Vector2(64, 64); // Default from class
this.cellSize = this.largestBitmap + this.imagePadding;
var cellsPerPage = printablePageSize / this.cellSize;
this.columns = Math.Max(1, (int)Math.Floor(cellsPerPage.X));
this.rows = Math.Max(1, (int)Math.Floor(cellsPerPage.Y));
this.bitmapsPerPage = this.columns * this.rows;
this.pageCount = (int)Math.Ceiling(this.bitmapCount / (double)this.bitmapsPerPage);
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated columns: {this.columns}");
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated rows: {this.rows}");
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated bitmapsPerPage: {this.bitmapsPerPage}");
System.Diagnostics.Debug.WriteLine($"[PrintService] Calculated pageCount: {this.pageCount}");
// sender.SetPageCount((uint)this.pageCount); // Cannot call
System.Diagnostics.Debug.WriteLine("[PrintService] OnDocumentTaskOptionsChanged finished.");
System.Diagnostics.Debug.WriteLine($"[PrintService] SIMULATION END for {simulatedRawPixelsPerViewPixel}");
System.Diagnostics.Debug.WriteLine("---"); // Separator
}
public async Task SimulatePrintScalingAsync()
{
// Temporarily store and clear global state that might interfere
var originalBitmaps = new List<CanvasBitmap>(this.bitmaps);
var originalLargestBitmap = this.largestBitmap;
var originalPageSize = this.pageSize;
var originalCellSize = this.cellSize;
int originalBitmapCount = this.bitmapCount;
int originalColumns = this.columns;
int originalRows = this.rows;
int originalBitmapsPerPage = this.bitmapsPerPage;
int originalPageCount = this.pageCount;
await RunSimulationAsync(1.0f, nameof(SimulatePrintScalingAsync));
await RunSimulationAsync(1.25f, nameof(SimulatePrintScalingAsync));
await RunSimulationAsync(1.5f, nameof(SimulatePrintScalingAsync));
// Restore original state if necessary, though for this task it's just about logs
this.bitmaps = originalBitmaps;
this.largestBitmap = originalLargestBitmap;
this.pageSize = originalPageSize;
this.cellSize = originalCellSize;
this.bitmapCount = originalBitmapCount;
this.columns = originalColumns;
this.rows = originalRows;
this.bitmapsPerPage = originalBitmapsPerPage;
this.pageCount = originalPageCount;
}
// --- END SIMULATION CODE ---
} }

View File

@@ -190,7 +190,7 @@ public static class GoogleIntegratorExtensions
return calendar; return calendar;
} }
public static DateTimeOffset? GetEventDateTimeOffset(EventDateTime calendarEvent) public static DateTimeOffset GetEventDateTimeOffset(EventDateTime calendarEvent)
{ {
if (calendarEvent != null) if (calendarEvent != null)
{ {
@@ -212,7 +212,7 @@ public static class GoogleIntegratorExtensions
} }
} }
return null; throw new Exception("Invalid date format in Google Calendar event date.");
} }
/// <summary> /// <summary>

View File

@@ -66,12 +66,6 @@ public class GmailChangeProcessor : DefaultChangeProcessor, IGmailChangeProcesso
var eventStartDateTimeOffset = GoogleIntegratorExtensions.GetEventDateTimeOffset(calendarEvent.Start); var eventStartDateTimeOffset = GoogleIntegratorExtensions.GetEventDateTimeOffset(calendarEvent.Start);
var eventEndDateTimeOffset = GoogleIntegratorExtensions.GetEventDateTimeOffset(calendarEvent.End); var eventEndDateTimeOffset = GoogleIntegratorExtensions.GetEventDateTimeOffset(calendarEvent.End);
double totalDurationInSeconds = 0;
if (eventStartDateTimeOffset != null && eventEndDateTimeOffset != null)
{
totalDurationInSeconds = (eventEndDateTimeOffset.Value - eventStartDateTimeOffset.Value).TotalSeconds;
}
CalendarItem calendarItem = null; CalendarItem calendarItem = null;
@@ -80,12 +74,6 @@ public class GmailChangeProcessor : DefaultChangeProcessor, IGmailChangeProcesso
// Exceptions of parent events might not have all the fields populated. // Exceptions of parent events might not have all the fields populated.
// We must use the parent event's data for fields that don't exists. // We must use the parent event's data for fields that don't exists.
// Update duration if it's not populated.
if (totalDurationInSeconds == 0)
{
totalDurationInSeconds = parentRecurringEvent.DurationInSeconds;
}
var organizerMail = GetOrganizerEmail(calendarEvent, organizerAccount); var organizerMail = GetOrganizerEmail(calendarEvent, organizerAccount);
var organizerName = GetOrganizerName(calendarEvent, organizerAccount); var organizerName = GetOrganizerName(calendarEvent, organizerAccount);
@@ -96,10 +84,8 @@ public class GmailChangeProcessor : DefaultChangeProcessor, IGmailChangeProcesso
CreatedAt = DateTimeOffset.UtcNow, CreatedAt = DateTimeOffset.UtcNow,
Description = calendarEvent.Description ?? parentRecurringEvent.Description, Description = calendarEvent.Description ?? parentRecurringEvent.Description,
Id = Guid.NewGuid(), Id = Guid.NewGuid(),
StartDate = eventStartDateTimeOffset.Value.DateTime, StartTimeOffset = eventStartDateTimeOffset.ToString("o"),
StartDateOffset = eventStartDateTimeOffset.Value.Offset, EndTimeOffset = eventEndDateTimeOffset.ToString("o"),
EndDateOffset = eventEndDateTimeOffset?.Offset ?? parentRecurringEvent.EndDateOffset,
DurationInSeconds = totalDurationInSeconds,
Location = string.IsNullOrEmpty(calendarEvent.Location) ? parentRecurringEvent.Location : calendarEvent.Location, Location = string.IsNullOrEmpty(calendarEvent.Location) ? parentRecurringEvent.Location : calendarEvent.Location,
// Leave it empty if it's not populated. // Leave it empty if it's not populated.
@@ -120,22 +106,14 @@ public class GmailChangeProcessor : DefaultChangeProcessor, IGmailChangeProcesso
// This is a parent event creation. // This is a parent event creation.
// Start-End dates are guaranteed to be populated. // Start-End dates are guaranteed to be populated.
if (eventStartDateTimeOffset == null || eventEndDateTimeOffset == null)
{
Log.Error("Failed to create parent event because either start or end date is not specified.");
return;
}
calendarItem = new CalendarItem() calendarItem = new CalendarItem()
{ {
CalendarId = assignedCalendar.Id, CalendarId = assignedCalendar.Id,
CreatedAt = DateTimeOffset.UtcNow, CreatedAt = DateTimeOffset.UtcNow,
Description = calendarEvent.Description, Description = calendarEvent.Description,
Id = Guid.NewGuid(), Id = Guid.NewGuid(),
StartDate = eventStartDateTimeOffset.Value.DateTime, StartTimeOffset = eventStartDateTimeOffset.ToString("o"),
StartDateOffset = eventStartDateTimeOffset.Value.Offset, EndTimeOffset = eventEndDateTimeOffset.ToString("o"),
EndDateOffset = eventEndDateTimeOffset.Value.Offset,
DurationInSeconds = totalDurationInSeconds,
Location = calendarEvent.Location, Location = calendarEvent.Location,
Recurrence = GoogleIntegratorExtensions.GetRecurrenceString(calendarEvent), Recurrence = GoogleIntegratorExtensions.GetRecurrenceString(calendarEvent),
Status = GetStatus(calendarEvent.Status), Status = GetStatus(calendarEvent.Status),

View File

@@ -61,18 +61,21 @@ public class OutlookChangeProcessor(IDatabaseService databaseService,
DateTimeOffset eventStartDateTimeOffset = OutlookIntegratorExtensions.GetDateTimeOffsetFromDateTimeTimeZone(calendarEvent.Start); DateTimeOffset eventStartDateTimeOffset = OutlookIntegratorExtensions.GetDateTimeOffsetFromDateTimeTimeZone(calendarEvent.Start);
DateTimeOffset eventEndDateTimeOffset = OutlookIntegratorExtensions.GetDateTimeOffsetFromDateTimeTimeZone(calendarEvent.End); DateTimeOffset eventEndDateTimeOffset = OutlookIntegratorExtensions.GetDateTimeOffsetFromDateTimeTimeZone(calendarEvent.End);
var durationInSeconds = (eventEndDateTimeOffset - eventStartDateTimeOffset).TotalSeconds;
savingItem.RemoteEventId = calendarEvent.Id; savingItem.RemoteEventId = calendarEvent.Id;
savingItem.StartDate = eventStartDateTimeOffset.DateTime; savingItem.StartTimeOffset = eventStartDateTimeOffset.ToString("O");
savingItem.StartDateOffset = eventStartDateTimeOffset.Offset; savingItem.EndTimeOffset = eventEndDateTimeOffset.ToString("O");
savingItem.EndDateOffset = eventEndDateTimeOffset.Offset;
savingItem.DurationInSeconds = durationInSeconds;
savingItem.Title = calendarEvent.Subject; savingItem.Title = calendarEvent.Subject;
savingItem.Description = calendarEvent.Body?.Content; savingItem.Description = calendarEvent.Body?.Content;
savingItem.Location = calendarEvent.Location?.DisplayName; savingItem.Location = calendarEvent.Location?.DisplayName;
if (savingItem.Title.Contains("Atatürk"))
{
}
if (calendarEvent.Type == EventType.Exception && !string.IsNullOrEmpty(calendarEvent.SeriesMasterId)) if (calendarEvent.Type == EventType.Exception && !string.IsNullOrEmpty(calendarEvent.SeriesMasterId))
{ {
// This is a recurring event exception. // This is a recurring event exception.

View File

@@ -160,7 +160,7 @@ public class CalendarService : BaseDatabaseService, ICalendarService
// There is no exception for the period. // There is no exception for the period.
// Change the instance StartDate and Duration. // Change the instance StartDate and Duration.
var recurrence = ev.CreateRecurrence(occurrence.Period.StartTime.Value, occurrence.Period.Duration.TotalSeconds); var recurrence = ev.CreateRecurrence(occurrence.Period.StartTime.Value, occurrence.Period.EndTime.Value);
result.Add(recurrence); result.Add(recurrence);
} }