/// <summary> /// Fills the list of entities /// </summary> private void FillEntities() { // Displays entities if (entityCache == null) { MessageBox.Show(this, "You are not connected to an organization, so it is not possible to display a list of entities\n\nPlease use menu \"More actions\" to load entities and web resources", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); Close(); } foreach (var emd in entityCache) { if (emd.DisplayName.UserLocalizedLabel != null) { var item = new ListViewItem { Text = emd.DisplayName.UserLocalizedLabel.Label, Tag = emd }; ListViewDelegates.AddItem(lvSelectedEntities, item); } } // Enables controls ListViewDelegates.Sort(lvSelectedEntities); ListViewDelegates.SetEnableState(lvSelectedEntities, true); CommonDelegates.SetEnableState(btnCancel, true); CommonDelegates.SetEnableState(btnValidate, true); }
private void FillImageList() { ListViewDelegates.ClearItems(lstWebResources); if (webResourcesImageCache == null || webResourcesImageCache.Count == 0) { webResourcesImageCache = new List <Entity>(); QueryExpression qe = new QueryExpression("webresource"); ConditionExpression ce = new ConditionExpression(); ce.AttributeName = "webresourcetype"; if (requestedType == (int)WebResourceType.Image) { ce.Operator = ConditionOperator.In; ce.Values.AddRange(5, 6, 7); } else { ce.Operator = ConditionOperator.Equal; ce.Values.Add(requestedType); } qe.Criteria.AddCondition(ce); qe.ColumnSet.AllColumns = true; EntityCollection ec = service.RetrieveMultiple(qe); foreach (Entity webresource in ec.Entities) { webResourcesImageCache.Add(webresource); } } foreach (Entity webresource in webResourcesImageCache) { if (requestedType == 11 && webresource.GetAttributeValue <OptionSetValue>("webresourcetype").Value == 11 || requestedType != 11 && webresource.GetAttributeValue <OptionSetValue>("webresourcetype").Value != 11) { ListViewItem item = new ListViewItem(webresource.Contains("displayname") ? webresource["displayname"].ToString() : "N/A"); item.SubItems.Add(webresource["name"].ToString()); item.Tag = webresource; ListViewDelegates.AddItem(lstWebResources, item); } } ListViewDelegates.Sort(lstWebResources); ListViewDelegates.SetEnableState(lstWebResources, true); CommonDelegates.SetEnableState(btnWebResourcePickerCancel, true); CommonDelegates.SetEnableState(btnWebResourcePickerValidate, true); CommonDelegates.SetEnableState(btnNewResource, true); CommonDelegates.SetEnableState(btnRefresh, true); }
/// <summary> /// Fills the list of entities /// </summary> private void FillEntities() { // Checks the application cache and load it if needed //if (entityCache == null || entityCache.Count == 0) //{ // entityCache = new List<EntityMetadata>(); // var request = new RetrieveAllEntitiesRequest // { // EntityFilters = EntityFilters.Entity // }; // var response = (RetrieveAllEntitiesResponse)SiteMapEditor.service.Execute(request); // foreach (var emd in response.EntityMetadata) // { // SiteMapEditor.entityCache.Add(emd); // } //} // Displays entities foreach (var emd in entityCache) { if ((emd.IsCustomizable.Value || emd.IsManaged.Value == false) && emd.DisplayName.UserLocalizedLabel != null) { var item = new ListViewItem { Text = emd.DisplayName.UserLocalizedLabel.Label, Tag = emd }; ListViewDelegates.AddItem(lvSelectedEntities, item); } } // Enables controls ListViewDelegates.Sort(lvSelectedEntities); ListViewDelegates.SetEnableState(lvSelectedEntities, true); CommonDelegates.SetEnableState(btnCancel, true); CommonDelegates.SetEnableState(btnValidate, true); }
/// <summary> /// Initializes a new instance of class WebResourcePicker /// </summary> /// <param name="type">Type of web resource to select</param> public WebResourcePicker(WebResourceType type, List <Entity> webResourcesImageCache, List <Entity> webResourcesHtmlCache, IOrganizationService service) { InitializeComponent(); this.webResourcesImageCache = webResourcesImageCache; this.webResourcesHtmlCache = webResourcesHtmlCache; this.service = service; requestedType = (int)type; // Disables controls ListViewDelegates.SetEnableState(lstWebResources, false); CommonDelegates.SetEnableState(btnWebResourcePickerCancel, false); CommonDelegates.SetEnableState(btnWebResourcePickerValidate, false); CommonDelegates.SetEnableState(btnNewResource, false); // Run work var worker = new BackgroundWorker(); worker.DoWork += worker_DoWork; worker.RunWorkerCompleted += worker_RunWorkerCompleted; worker.RunWorkerAsync(); }