Exemplo n.º 1
0
        private void TsbPublishAllClick(object sender, EventArgs e)
        {
            tsbPublishEntity.Enabled = false;
            tsbPublishAll.Enabled    = false;
            tsbSaveViews.Enabled     = false;
            tsbLoadEntities.Enabled  = false;

            WorkAsync("Publishing all customizations...",
                      evt =>
            {
                var pubRequest = new PublishAllXmlRequest();
                Service.Execute(pubRequest);
            },
                      evt =>
            {
                if (evt.Error != null)
                {
                    string errorMessage = CrmExceptionHelper.GetErrorMessage(evt.Error, false);
                    MessageBox.Show(this, errorMessage, "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }

                tsbPublishEntity.Enabled = true;
                tsbPublishAll.Enabled    = true;
                tsbSaveViews.Enabled     = true;
                tsbLoadEntities.Enabled  = true;
            });
        }
Exemplo n.º 2
0
        private void LoadEntities()
        {
            txtSearchEntity.Text = string.Empty;
            lvEntities.Items.Clear();
            gbEntities.Enabled       = false;
            tsbPublishEntity.Enabled = false;
            tsbPublishAll.Enabled    = false;
            tsbSaveViews.Enabled     = false;

            lvSourceViews.Items.Clear();
            lvTargetViews.Items.Clear();
            lvSourceViewLayoutPreview.Columns.Clear();

            WorkAsync(new WorkAsyncInfo
            {
                Message = "Loading entities...",
                Work    = (bw, e) =>
                {
                    e.Result = MetadataHelper.RetrieveEntities(Service);
                },
                PostWorkCallBack = e =>
                {
                    if (e.Error != null)
                    {
                        string errorMessage = CrmExceptionHelper.GetErrorMessage(e.Error, true);
                        CommonDelegates.DisplayMessageBox(ParentForm, errorMessage, "Error", MessageBoxButtons.OK,
                                                          MessageBoxIcon.Error);
                    }
                    else
                    {
                        entitiesCache = (List <EntityMetadata>)e.Result;
                        lvEntities.Items.Clear();
                        var list = new List <ListViewItem>();
                        foreach (EntityMetadata emd in (List <EntityMetadata>)e.Result)
                        {
                            var item = new ListViewItem {
                                Text = emd.DisplayName.UserLocalizedLabel.Label, Tag = emd.LogicalName
                            };
                            item.SubItems.Add(emd.LogicalName);
                            list.Add(item);
                        }

                        this.listViewItemsCache = list.ToArray();
                        lvEntities.Items.AddRange(listViewItemsCache);

                        gbEntities.Enabled       = true;
                        tsbPublishEntity.Enabled = true;
                        tsbPublishAll.Enabled    = true;
                        tsbSaveViews.Enabled     = true;
                    }
                }
            });
        }
Exemplo n.º 3
0
        private void TsbPublishEntityClick(object sender, EventArgs e)
        {
            if (lvEntities.SelectedItems.Count > 0)
            {
                tsbPublishEntity.Enabled = false;
                tsbPublishAll.Enabled    = false;
                tsbSaveViews.Enabled     = false;
                tsbLoadEntities.Enabled  = false;

                WorkAsync(new WorkAsyncInfo
                {
                    Message       = "Publishing entity...",
                    AsyncArgument = lvEntities.SelectedItems[0].Tag,
                    Work          = (bw, evt) =>
                    {
                        var pubRequest          = new PublishXmlRequest();
                        pubRequest.ParameterXml = string.Format(@"<importexportxml>
                                                           <entities>
                                                              <entity>{0}</entity>
                                                           </entities>
                                                           <nodes/><securityroles/><settings/><workflows/>
                                                        </importexportxml>",
                                                                evt.Argument);

                        Service.Execute(pubRequest);
                    },
                    PostWorkCallBack = evt =>
                    {
                        if (evt.Error != null)
                        {
                            string errorMessage = CrmExceptionHelper.GetErrorMessage(evt.Error, false);
                            MessageBox.Show(this, errorMessage, "Error", MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
                        }

                        tsbPublishEntity.Enabled = true;
                        tsbPublishAll.Enabled    = true;
                        tsbSaveViews.Enabled     = true;
                        tsbLoadEntities.Enabled  = true;
                    }
                });
            }
        }