/// <summary> /// Helper method for loading the portal items /// </summary> /// <param name="bw"></param> private void LoadPortalItems(BackgroundWorker bw, bool isLegacyPortal) { portalItems = new List <EditablePortalItem>(); bw.ReportProgress(0, "Loading Web pages..."); portalItems.AddRange(WebPage.GetItems(Service)); bw.ReportProgress(0, "Loading Entity forms..."); portalItems.AddRange(EntityForm.GetItems(Service, ref isLegacyPortal)); bw.ReportProgress(0, "Loading Entity lists..."); portalItems.AddRange(EntityList.GetItems(Service, ref isLegacyPortal)); bw.ReportProgress(0, "Loading Web templates..."); portalItems.AddRange(WebTemplate.GetItems(Service, ref isLegacyPortal)); bw.ReportProgress(0, "Loading Web files..."); portalItems.AddRange(WebFile.GetItems(Service)); bw.ReportProgress(0, "Loading Web form steps..."); portalItems.AddRange(WebFormStep.GetItems(Service)); bw.ReportProgress(0, "Loading Content Snippets..."); portalItems.AddRange(ContentSnippet.GetItems(Service, ref isLegacyPortal)); if (!isLegacyPortal) { bw.ReportProgress(0, "Loading Portal languages..."); ctvf.Languages = Service.RetrieveMultiple(new QueryExpression("adx_websitelanguage") { ColumnSet = new ColumnSet(true) }).Entities.ToList(); } }
private void LoadItems() { ctv.Enabled = false; WorkAsync(new WorkAsyncInfo { Message = "Loading portal items...", Work = (bw, e) => { portalItems = new List <EditablePortalItem>(); bw.ReportProgress(0, "Loading Web pages..."); portalItems.AddRange(WebPage.GetItems(Service)); bw.ReportProgress(0, "Loading Entity forms..."); portalItems.AddRange(EntityForm.GetItems(Service, ref isLegacyPortal)); bw.ReportProgress(0, "Loading Entity lists..."); portalItems.AddRange(EntityList.GetItems(Service, ref isLegacyPortal)); bw.ReportProgress(0, "Loading Web templates..."); portalItems.AddRange(WebTemplate.GetItems(Service, ref isLegacyPortal)); bw.ReportProgress(0, "Loading Web files..."); portalItems.AddRange(WebFile.GetItems(Service)); bw.ReportProgress(0, "Loading Web form steps..."); portalItems.AddRange(WebFormStep.GetItems(Service)); bw.ReportProgress(0, "Loading Content Snippets..."); portalItems.AddRange(ContentSnippet.GetItems(Service, ref isLegacyPortal)); portalItems.SelectMany(p => p.Items).ToList().ForEach(i => i.StateChanged += CodeItem_StateChanged); }, ProgressChanged = e => { SetWorkingMessage(e.UserState.ToString()); }, PostWorkCallBack = e => { if (e.Error != null) { if (((FaultException <OrganizationServiceFault>)e.Error).Detail.ErrorCode == -2147217149) { MessageBox.Show(e.Error.ToString()); var message = "Unable to load code items: Please ensure you are targeting an organization linked to a Microsoft Portal (not a legacy Adxstudio one)"; MessageBox.Show(this, message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); LogError(message); } else { MessageBox.Show(this, $"An error occured while loading code items: {e.Error.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); LogError($"An error occured while loading code items: {e.Error.ToString()}"); } } ctv.DisplayCodeItems(portalItems, isLegacyPortal); ctv.Enabled = true; } }); }