原創|使用教程|編輯:龔雪|2020-06-23 09:59:22.397|閱讀 615 次
概述:從v18.2版本開始,DevExpress Winforms可以使用Google日歷進行新的Scheduler同步,本文主要為大家介紹此功能。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
下載DevExpress v20.1完整版 DevExpress v20.1漢化資源獲取
DevExpress Winforms Controls 內置140多個UI控件和庫,完美構建流暢、美觀且易于使用的應用程序。想要體驗?點擊下載>>
從v18.2版本開始,DevExpress Winforms可以使用Google日歷進行新的Scheduler同步,本文主要為大家介紹此功能。
要同步Scheduler和Google Calendars Appointments(在Google文檔中,這些稱為Events),您需要一個DXGoogleCalendarSync組件。 單擊Add DX Google Calendar Synchronizer Smart Tag鏈接時,Scheduler會自動添加它,該組件需要幾個NuGet軟件包。
DXGoogleCalendarSync在Scheduler存儲(支持SchedulerDataStorage及其先前的SchedulerStorage)與選定的Google日歷之間傳輸數據,可以將存儲同時綁定到任何受支持的數據源。
您不僅限于導入或導出數據,同步是一個雙向過程,可同時處理兩個任務。
DXGoogleCalendarSync組件可以正確識別和同步Scheduler支持的所有Appointment類型:常規Appointment和定期Appointment、all-day events、假期等,該組件唯一無法自動同步的內容類型是顏色信息:Appointment標簽和狀態不轉換默認為事件顏色。狀態是唯一的Appointment屬性,沒有匹配的事件屬性(Google事件僅提供兩個“statuses” - Busy和Free),您可以通過處理某些組件事件來手動將標簽與事件顏色同步(請參見此)。
第二個限制是DXGoogleCalendarSync一次只能使用一個日歷,而Google日歷用戶可以預訂多個不同的日歷:個人日歷、工作日歷、假期日歷、家庭日歷、同事之間共享的公司日歷等,當然,您可以輕松地檢索日歷列表,并實現一個UI在運行時在它們之間進行切換。
顯示運行中的同步組件。
要管理Google Calendar Events,您需要訪問Google Calendar API。 請單擊Google文檔中,然后按照步驟13b下載您自己的credentials.json文件,這應該包含在您的項目中,GitHub示例對此文件使用名稱。
組件上需要設置三個核心屬性:
gcSyncComponent.Storage = schedulerStorage;
... GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, new String[] { CalendarService.Scope.Calendar }, "user", CancellationToken.None, new FileDataStore(credPath, true));
然后可以實例化CalendarService(在示例的中)。
... gcSyncComponent.CalendarService = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = this.credential, ApplicationName = "GoogleCalendarSyncSample" }); ...
CalendarList calendarList; string activeCalendarId; async Task UpdateCalendarListUI() { var listRequest = this.service.CalendarList.List(); this.calendarList = await listRequest.ExecuteAsync(); this.ricbCalendarList.Items.Clear(); foreach (CalendarListEntry item in this.calendarList.Items) this.ricbCalendarList.Items.Add(item.Summary); if (!String.IsNullOrEmpty(this.activeCalendarId)) { var itemToSelect = this.calendarList.Items.FirstOrDefault( x => x.Id == this.activeCalendarId); this.gcSyncComponent.CalendarId = this.activeCalendarId; if (this.ricbCalendarList.Items.Contains(itemToSelect.Summary)) this.beiCalendarList.EditValue = itemToSelect.Summary; else this.activeCalendarId = String.Empty; } }
一切設置完成后,可以隨時在DXGoogleCalendarSync組件上調用Synchronize或SynchronizeAsync來觸發同步進程。首次啟動時,默認的網絡瀏覽器將顯示一個頁面,要求您登錄要用于同步的Google帳戶。
除了上述基本設置外,DXGoogleCalendarSync組件還提供其他功能,包括:
有關Google日歷同步功能的完整文檔,請訪問。
中國區首發 · DevExpress v20.1新版發布會報名開啟,名額有限先到先得哦~
DevExpress技術交流群2:775869749 歡迎一起進群討論
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都網