翻譯|使用教程|編輯:龔雪|2023-07-26 10:54:11.207|閱讀 103 次
概述:本文將介紹在使用DevExpress WinForms Scheduler組件時(shí)如何實(shí)現(xiàn)與Office 365的雙向同步,歡迎下載相關(guān)組件體驗(yàn)!
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
隨著DevExpress WinForms最近的更新,用戶可以無縫同步DevExpress WinForms Scheduler與Office 365事件/日程的數(shù)據(jù)。您可以將用戶日程從WinForms Scheduler中導(dǎo)出到Office 365日歷,或?qū)ffice 365事件/日程導(dǎo)入到Scheduler控件。在同步錢修改用戶事件/日程,將用戶日程與Microsoft 365日歷合并,解決合并沖突,并將更改保存到數(shù)據(jù)庫中。
DevExpress WinForms 擁有180+組件和UI庫,能為Windows Forms平臺創(chuàng)建具有影響力的業(yè)務(wù)解決方案。DevExpress WinForms能完美構(gòu)建流暢、美觀且易于使用的應(yīng)用程序,無論是Office風(fēng)格的界面,還是分析處理大批量的業(yè)務(wù)數(shù)據(jù),它都能輕松勝任!
DevExpress技術(shù)交流群8:523159565 歡迎一起進(jìn)群討論
安裝以下依賴庫(NuGet包):
將WinForms Scheduler控件放到窗體上,打開其智能標(biāo)簽菜單并選擇"Sync with Microsoft 365 Calendar",這將創(chuàng)建DXOutlook365Sync組件。
如果您需要在應(yīng)用程序和Microsoft Office 365日歷同步之后保存對數(shù)據(jù)庫的更改,DXOutlook365Sync組件需要五個(gè)特定字段(在您的數(shù)據(jù)源中)來存儲(chǔ)Microsoft 365事件的唯一標(biāo)識符并記錄用戶事件/約會(huì)的最后修改日期。
DataTable source = new DataTable(); source.Columns.AddRange(new DataColumn[] { new DataColumn("Subject", typeof(string)), new DataColumn("Description", typeof(string)), new DataColumn("Start", typeof(DateTime)), new DataColumn("End", typeof(DateTime)), // Special data fields. new DataColumn("Outlook365CalendarId", typeof(string)), new DataColumn("Outlook365EventId", typeof(string)), new DataColumn("Outlook365EventUniqId", typeof(string)), new DataColumn("Outlook365LastChangedUTC", typeof(DateTime)), new DataColumn("SchedulerLastChangedUTC", typeof(DateTime)) });
定義到這些字段的自定義映射,來完成數(shù)據(jù)源設(shè)置。
// Defines custom mappings. schedulerDataStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("outlook365_calendar_id", "Outlook365CalendarId")); schedulerDataStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("outlook365_event_id", "Outlook365EventId")); schedulerDataStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("outlook365_event_ICalUId", "Outlook365EventUniqId")); schedulerDataStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("outlook365_lastChangedUTC", "Outlook365LastChangedUTC")); schedulerDataStorage1.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("scheduler_lastChangedUTC", "SchedulerLastChangedUTC"));
在使用DXOutlook365Sync組件的API之前,必須初始化它,使用它的InitAsync()方法,此方法打開"Sign in to your account"窗口(需要登錄Microsoft Office 365)。
private async void initBarButtonItem_ItemClick(object sender, ItemClickEventArgs e) { await dxOutlook365Sync1.InitAsync(); }
DXOutlook365Sync組件可以將WinForms Scheduler控件中的用戶日程與所有(或特定)Office 365日歷中的事件同步,它的日歷集合包含與Office365日歷對應(yīng)的OutlookCalendarItem對象。
日歷具有OutlookCalendarItem.EnableSynchronization設(shè)置,該設(shè)置指定是否將其事件與WinForms Scheduler控件中的用戶日程同步。
使用ImportOutlookToSchedulerAsync(Boolean)方法將Office 365日歷中的事件導(dǎo)入到WinForms Scheduler控件中。
using DevExpress.XtraScheduler.Microsoft365Calendar; private async void importEventsButton_Click(object sender, EventArgs e) { // Checks whether the initialization of 'dxOutlook365Sync1' failed. if(!await InitOutlook365Sync(dxOutlook365Sync1)) return; // Displays the wait form. splashScreenManager1.ShowWaitForm(); // Imports Outlook 365 events to the Scheduler control. await dxOutlook365Sync1.ImportOutlookToSchedulerAsync(false); // Hides the wait form. splashScreenManager1.CloseWaitForm(); } private async Task<bool> InitOutlook365Sync(DXOutlook365Sync outlook365sync) { // Initializes the 'dxOutlook365Sync1' component. InitStatus status = await outlook365sync.InitAsync(); // Returns false and displays a message box if the initialization of 'dxOutlook365Sync1' failed. if(status == InitStatus.Error) { XtraMessageBox.Show("Initialization of DXOutlook365Sync failed.", "Error", MessageBoxButtons.OK); return false; } return true; }
使用ExportSchedulerToOutlookAsync(Boolean)方法從DevExpress Scheduler控件導(dǎo)出用戶日程到Office 365日歷。
以下事件允許您在同步之前自定義用戶日程或事件:
DXOutlook365Sync API允許您將用戶日程與Office 365事件合并,您可以合并所有事件/日程,也可以定義跳過某些事件/日程的規(guī)則(基于特定條件)。
同步API允許您根據(jù)需要輕松解決合并沖突。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都網(wǎng)