public EntitySelectionHandler(MyPluginControl myPlugin, AlBackgroundWorkHandler backgroundWorkHandler, TreeViewAdv metadataTree, AttributeMetadataHandler attributeMetadataHandler, RelationshipMetadataHandler relationshipMetadataHandler)
 {
     this.myPlugin = myPlugin;
     this.backgroundWorkHandler       = backgroundWorkHandler;
     this.metadataTree                = metadataTree;
     this.attributeMetadataHandler    = attributeMetadataHandler;
     this.relationshipMetadataHandler = relationshipMetadataHandler;
 }
Exemple #2
0
 public MyPluginControl()
 {
     InitializeComponent();
     MyPluginFactory                = new Factories.MyPluginFactory();
     AttributeMetadataHandler       = MyPluginFactory.NewAttributeMetadataHandler(this);
     CoreToolsDownloader            = MyPluginFactory.NewCoreToolsDownloader(this);
     EntityGeneratorHandler         = MyPluginFactory.NewEntityGeneratorHandler(this, metadataTree);
     EntityMetadataHandler          = MyPluginFactory.NewEntityMetadataHandler(this, metadataTree);
     RelationshipMetadataHandler    = MyPluginFactory.NewRelationshipMetadataHandler(this);
     treeEventHandler               = new TreeViewAdvBeforeCheckEventHandler(this.MetadataTree_BeforeCheck);
     this.metadataTree.BeforeCheck += treeEventHandler;
 }
 public MyPluginControl()
 {
     InitializeComponent();
     MyPluginFactory                = new Factories.MyPluginFactory();
     AttributeMetadataHandler       = MyPluginFactory.NewAttributeMetadataHandler(this);
     CoreToolsDownloader            = MyPluginFactory.NewCoreToolsDownloader(this);
     EntityGeneratorHandler         = MyPluginFactory.NewEntityGeneratorHandler(this, metadataTree, txtOutput);
     EntityMetadataHandler          = MyPluginFactory.NewEntityMetadataHandler(this, metadataTree);
     RelationshipMetadataHandler    = MyPluginFactory.NewRelationshipMetadataHandler(this);
     pluginViewModel                = MyPluginFactory.NewPluginViewModel();
     treeEventHandler               = new TreeViewAdvBeforeCheckEventHandler(this.MetadataTree_BeforeCheck);
     this.metadataTree.BeforeCheck += treeEventHandler;
     btnGenerateEntities.Enabled    = pluginViewModel.Generate_Enabled;
     btnGetMetadata.Enabled         = pluginViewModel.ActiveConnection;
     DataBind();
 }
 public MyPluginControl()
 {
     InitializeComponent();
     MyPluginFactory                = Factories.MyPluginFactory.GetMyPluginFactory(this);
     pluginViewModel                = MyPluginFactory.NewPluginViewModel();
     BackgroundWorkHandler          = MyPluginFactory.NewBackgroundWorkHandler();
     AttributeMetadataHandler       = MyPluginFactory.NewAttributeMetadataHandler();
     CoreToolsDownloader            = MyPluginFactory.NewCoreToolsDownloader();
     EntityGeneratorHandler         = MyPluginFactory.NewEntityGeneratorHandler(metadataTree, txtOutput);
     RelationshipMetadataHandler    = MyPluginFactory.NewRelationshipMetadataHandler();
     EntitySelectionHandler         = MyPluginFactory.NewEntitySelectionHandler(metadataTree, AttributeMetadataHandler, RelationshipMetadataHandler);
     EntityMetadataHandler          = MyPluginFactory.NewEntityMetadataHandler(metadataTree, EntitySelectionHandler);
     treeEventHandler               = new TreeViewAdvBeforeCheckEventHandler(this.MetadataTree_BeforeCheck);
     this.metadataTree.BeforeCheck += treeEventHandler;
     btnGenerateEntities.Enabled    = pluginViewModel.Generate_Enabled;
     mnuSelectGenerated.Visible     = pluginViewModel.Generate_Enabled;
     mnuSelectNone.Visible          = pluginViewModel.Generate_Enabled;
     btnGetMetadata.Enabled         = pluginViewModel.ActiveConnection;
     mnuGetMetadata.Enabled         = pluginViewModel.ActiveConnection;
     mnuSelectAll.Enabled           = pluginViewModel.ActiveConnection;
     mnuCopyCommand.Enabled         = pluginViewModel.LaunchCommandEnabled;
     DataBind();
 }
        public void WorkEnded(Tuple <string, bool> input, Tuple <RetrieveAllEntitiesResponse, Dictionary <string, EntitySelection> > value, Exception exception)
        {
            try
            {
                if (exception != null)
                {
                    MessageBox.Show(exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (value != null)
                {
                    RetrieveAllEntitiesResponse result = value.Item1;
                    metadataTree.BackgroundImage = null;
                    metadataTree.Enabled         = true;
                    metadataTree.Nodes.Clear();
                    myPlugin.entityMetadatas = result.EntityMetadata;
                    foreach (var item in result.EntityMetadata.OrderBy(x => x.LogicalName))
                    {
                        if (item.DisplayName.LocalizedLabels.Count == 0)
                        {
                            continue;
                        }

                        TreeNodeAdv attributes = new TreeNodeAdv("Attributes")
                        {
                            ShowCheckBox        = true,
                            InteractiveCheckBox = true
                        };

                        TreeNodeAdv relationships = new TreeNodeAdv("Relationships")
                        {
                            ShowCheckBox        = true,
                            InteractiveCheckBox = true
                        };

                        TreeNodeAdv node = new TreeNodeAdv($"{item.LogicalName}: {item.DisplayName.LocalizedLabels[0].Label}",
                                                           new TreeNodeAdv[] { attributes, relationships })
                        {
                            ExpandedOnce        = true,
                            ShowCheckBox        = true,
                            InteractiveCheckBox = true,
                            Tag = item
                        };
                        metadataTree.Nodes.Add(node);
                        if (input.Item2)
                        {
                            AttributeMetadataHandler.CreateAttributeNodes(attributes, item, checkedState: true);
                            RelationshipMetadataHandler.CreateRelationshipNodes(relationships, item, checkedState: true);
                        }
                    }
                    if (!input.Item2)
                    {
                        entitySelectionHandler.SelectGenerated();
                    }

                    myPlugin.pluginViewModel.All_Metadata_Requested = input.Item2;
                    myPlugin.pluginViewModel.Generate_Enabled       = true;
                }
            }
#pragma warning disable CA1031 // We don't want our plugin to crash because of unhandled exceptions
            catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }