原創(chuàng)|使用教程|編輯:龔雪|2020-06-23 09:59:22.397|閱讀 615 次
概述:從v18.2版本開始,DevExpress Winforms可以使用Google日歷進行新的Scheduler同步,本文主要為大家介紹此功能。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
下載DevExpress v20.1完整版 DevExpress v20.1漢化資源獲取
DevExpress Winforms Controls 內(nèi)置140多個UI控件和庫,完美構(gòu)建流暢、美觀且易于使用的應(yīng)用程序。想要體驗?點擊下載>>
從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日歷之間傳輸數(shù)據(jù),可以將存儲同時綁定到任何受支持的數(shù)據(jù)源。
您不僅限于導(dǎo)入或?qū)С鰯?shù)據(jù),同步是一個雙向過程,可同時處理兩個任務(wù)。
DXGoogleCalendarSync組件可以正確識別和同步Scheduler支持的所有Appointment類型:常規(guī)Appointment和定期Appointment、all-day events、假期等,該組件唯一無法自動同步的內(nèi)容類型是顏色信息:Appointment標簽和狀態(tài)不轉(zhuǎn)換默認為事件顏色。狀態(tài)是唯一的Appointment屬性,沒有匹配的事件屬性(Google事件僅提供兩個“statuses” - Busy和Free),您可以通過處理某些組件事件來手動將標簽與事件顏色同步(請參見此)。
第二個限制是DXGoogleCalendarSync一次只能使用一個日歷,而Google日歷用戶可以預(yù)訂多個不同的日歷:個人日歷、工作日歷、假期日歷、家庭日歷、同事之間共享的公司日歷等,當(dāng)然,您可以輕松地檢索日歷列表,并實現(xiàn)一個UI在運行時在它們之間進行切換。
顯示運行中的同步組件。
要管理Google Calendar Events,您需要訪問Google Calendar API。 請單擊Google文檔中,然后按照步驟13b下載您自己的credentials.json文件,這應(yīng)該包含在您的項目中,GitHub示例對此文件使用名稱。
組件上需要設(shè)置三個核心屬性:
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; } }
一切設(shè)置完成后,可以隨時在DXGoogleCalendarSync組件上調(diào)用Synchronize或SynchronizeAsync來觸發(fā)同步進程。首次啟動時,默認的網(wǎng)絡(luò)瀏覽器將顯示一個頁面,要求您登錄要用于同步的Google帳戶。
除了上述基本設(shè)置外,DXGoogleCalendarSync組件還提供其他功能,包括:
有關(guān)Google日歷同步功能的完整文檔,請訪問。
中國區(qū)首發(fā) · DevExpress v20.1新版發(fā)布會報名開啟,名額有限先到先得哦~
DevExpress技術(shù)交流群2:775869749 歡迎一起進群討論
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都網(wǎng)