コード例 #1
0
 public void RefreshSolutionList()
 {
     asyncWorkQueue.EnqueueBackgroundWork(
         AlBackgroundWorkerFactory.NewWorker(RefreshSolutionListInner, RefreshSolutionListCompleted)
         .WithViewModel(solutionPackagerControl.toolViewModel)
         .WithMessage(solutionPackagerControl, Resources.REFRESHING_SOLUTION_LIST));
 }
コード例 #2
0
 public void DownloadCoreTools(string nuGetFeed)
 {
     backgroundWorkHandler.EnqueueBackgroundWork(
         AlBackgroundWorkerFactory.NewAsyncWorker(DownloadCoreToolsAsync, nuGetFeed, DownloadCoreToolsCompleted)
         .WithViewModel(toolViewModel)
         .WithMessage(solutionPackagerControl, Resources.DOWNLOADING_CORE_TOOLS));
 }
コード例 #3
0
 public void DownloadSolution(Parameters @params)
 {
     asyncWorkQueue.EnqueueBackgroundWork(
         AlBackgroundWorkerFactory.NewWorker(DownloadSolutionInner, @params, DownloadSolutionCompleted)
         .WithViewModel(solutionPackagerControl.toolViewModel)
         .WithMessage(solutionPackagerControl, string.Format(CultureInfo.InvariantCulture, Resources.DOWNLOADING_SOLUTION, @params.Solution.FriendlyName)));
 }
コード例 #4
0
 public void ManageSolution(Parameters @params)
 {
     backgroundWorkHandler.EnqueueBackgroundWork(
         AlBackgroundWorkerFactory.NewWorker <Parameters, string, object>(ExtractSolution, @params, ExtractSolutionProgress, ExtractSolutionCompleted)
         .WithViewModel(solutionPackagerControl.toolViewModel)
         .WithMessage(solutionPackagerControl, string.Format(CultureInfo.InvariantCulture, @params.Action == "Pack" ? Resources.PACKING_SOLUTION : Resources.EXTRACTING_SOLUTION, Path.GetFileName(@params.ZipFile))));
 }
コード例 #5
0
 public void DownloadCoreTools()
 {
     backgroundWorkHandler.EnqueueBackgroundWork(
         AlBackgroundWorkerFactory.NewAsyncWorker(DownloadCoreToolsAsync, DownloadCoreToolsEnded)
         .WithViewModel(myPlugin.pluginViewModel)
         .WithMessage(myPlugin, Resources.DOWNLOADING_CORE_TOOLS));
 }
コード例 #6
0
 public void GetRelationships(string entityName, TreeNodeAdv relationshipsNode, bool checkedState = false, HashSet <string> checkedRelationships = default(HashSet <string>))
 {
     backgroundWorkHandler.EnqueueBackgroundWork(
         AlBackgroundWorkerFactory.NewWorker(
             GetRelationships,
             new Tuple <string, TreeNodeAdv, bool, HashSet <string> >(entityName, relationshipsNode, checkedState, checkedRelationships),
             GetRelationships).WithViewModel(myPlugin.pluginViewModel)
         .WithMessage(myPlugin, string.Format(CultureInfo.CurrentCulture, Resources.GETTING_RELATIONSHIPS, entityName)));
 }
コード例 #7
0
        public void GetEntityList(bool selectAll = false)
        {
            var options = this.myPlugin.options;

            backgroundWorkHandler.EnqueueBackgroundWork(AlBackgroundWorkerFactory.NewWorker(
                                                            DoWork,
                                                            new Tuple <string, bool>((string.IsNullOrEmpty(options.CurrentOrganizationOptions.Output) ? "Test.cs" : Path.GetFullPath(options.CurrentOrganizationOptions.Output)) + ".alb", selectAll),
                                                            WorkEnded
                                                            ).WithViewModel(myPlugin.pluginViewModel)
                                                        .WithMessage(myPlugin, Resources.GETTING_ENTITY_LIST));
        }
コード例 #8
0
 public void GenerateEntities(Options options)
 {
     output.ResetText();
     backgroundWorkHandler.EnqueueBackgroundWork(
         AlBackgroundWorkerFactory.NewWorker <Options, string, string>(
             GenerateEntitiesInner,
             options,
             Progress,
             GenerateEntitiesEnd
             ).WithMessage(myPlugin, Resources.GENERATING_ENTITIES));
 }
コード例 #9
0
        internal void SelectGenerated()
        {
            var options = this.myPlugin.options;

            backgroundWorkHandler.EnqueueBackgroundWork(
                AlBackgroundWorkerFactory.NewWorker(
                    Deserialize,
                    (string.IsNullOrEmpty(options.CurrentOrganizationOptions.Output) ? "Test.cs" : Path.GetFullPath(options.CurrentOrganizationOptions.Output)) + ".alb",
                    SelectEntities).WithViewModel(myPlugin.pluginViewModel)
                .WithMessage(myPlugin, Resources.SELECTING_GENERATED));
        }
コード例 #10
0
        public void ImportSolution(Parameters @params)
        {
            var fileInfo = new FileInfo(@params.CustomizationFile);

            if (@params.PreferManaged)
            {
                fileInfo = new FileInfo(fileInfo.FullName.Substring(0, fileInfo.FullName.Length - fileInfo.Extension.Length) + "_managed" + fileInfo.Extension);
                @params.CustomizationFile = fileInfo.FullName;
            }
            asyncWorkQueue.EnqueueBackgroundWork(
                AlBackgroundWorkerFactory.NewWorker(ImportSolutionInner, @params, ImportSolutionStarted)
                .WithViewModel(toolViewModel)
                .WithMessage(solutionPackagerControl, string.Format(CultureInfo.InvariantCulture, Resources.IMPORT_SOLUTION, fileInfo.Name)));
        }
コード例 #11
0
        public void GetAttributes(string entityName, TreeNodeAdv attributesNode, bool checkedState = false, HashSet <string> checkedAttributes = default(HashSet <string>))
        {
            backgroundWorkHandler.EnqueueBackgroundWork(
                AlBackgroundWorkerFactory.NewWorker(
                    () => myPlugin.Service.Execute(
                        new RetrieveEntityRequest()
            {
                EntityFilters = EntityFilters.Attributes,
                LogicalName   = entityName
            }),
                    (value, exception) =>
            {
                try
                {
                    if (exception != null)
                    {
                        MessageBox.Show(exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    if (value is RetrieveEntityResponse result)
                    {
                        if (checkedAttributes == null)
                        {
                            checkedAttributes = new HashSet <string>();
                        }

                        var entityMetadata = myPlugin.entityMetadatas.FirstOrDefault(x => x.LogicalName == entityName);
                        typeof(EntityMetadata).GetProperty(nameof(entityMetadata.Attributes)).SetValue(entityMetadata, result.EntityMetadata.Attributes);
                        CreateAttributeNodes(attributesNode, result.EntityMetadata, checkedState, checkedAttributes);
                    }
                }
#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);
                }
            }
                    )
                .WithViewModel(myPlugin.pluginViewModel)
                .WithMessage(myPlugin, string.Format(CultureInfo.CurrentCulture, Resources.GETTING_ATTRIBUTES, entityName))
                );
        }
コード例 #12
0
        private void MetadataTree_BeforeCheck(object sender, TreeNodeAdvBeforeCheckEventArgs e)
        {
            if (e.Node.Tag as RelationshipMetadataBase != null)
            {
                if (!options.CoupledRelationships)
                {
                    return;
                }
                string entity1    = "";
                string entity2    = "";
                string schemaName = "";
                if (e.Node.Tag is OneToManyRelationshipMetadata oneToMany)
                {
                    entity1    = oneToMany.ReferencingEntity;
                    entity2    = oneToMany.ReferencedEntity;
                    schemaName = oneToMany.SchemaName;
                }
                else if (e.Node.Tag is ManyToManyRelationshipMetadata manyToMany)
                {
                    entity1    = manyToMany.Entity1LogicalName;
                    entity2    = manyToMany.Entity2LogicalName;
                    schemaName = manyToMany.SchemaName;
                }

                foreach (TreeNodeAdv entity in metadataTree.Nodes)
                {
                    var entityName = ((EntityMetadata)entity.Tag).LogicalName;
                    if (entityName == entity1 || entityName == entity2)
                    {
                        foreach (TreeNodeAdv item in entity.Nodes)
                        {
                            if (item.Text == "Relationships")
                            {
                                if (!item.ExpandedOnce)
                                {
                                    BackgroundWorkHandler.EnqueueBackgroundWork(
                                        AlBackgroundWorkerFactory.NewWorker <string, RetrieveEntityResponse>(
                                            work: RetrieveRelationships,
                                            argument: entityName,
                                            workFinished: (string argument, RetrieveEntityResponse value, Exception exception) =>
                                    {
                                        try
                                        {
                                            if (exception != null)
                                            {
                                                MessageBox.Show(exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                            }
                                            if (value is RetrieveEntityResponse result)
                                            {
                                                item.ExpandedOnce  = true;
                                                var entityMetadata = entityMetadatas.FirstOrDefault(x => x.LogicalName == entityName);
                                                entityMetadata.SetPrivateValue(x => x.ManyToManyRelationships, result.EntityMetadata.ManyToManyRelationships);
                                                entityMetadata.SetPrivateValue(x => x.OneToManyRelationships, result.EntityMetadata.OneToManyRelationships);
                                                entityMetadata.SetPrivateValue(x => x.ManyToOneRelationships, result.EntityMetadata.ManyToOneRelationships);

                                                foreach (var relationship in result.EntityMetadata.ManyToManyRelationships.Union <RelationshipMetadataBase>(
                                                             result.EntityMetadata.OneToManyRelationships).Union(
                                                             result.EntityMetadata.ManyToOneRelationships).OrderBy(x => x.SchemaName))
                                                {
                                                    TreeNodeAdv node = new TreeNodeAdv($"{relationship.SchemaName}")
                                                    {
                                                        ExpandedOnce = true,
                                                        ShowCheckBox = true,
                                                        Tag          = relationship
                                                    };
                                                    if (schemaName == relationship.SchemaName)
                                                    {
                                                        node.CheckState = e.NewCheckState;
                                                    }
                                                    item.Nodes.Add(node);
                                                }
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        }
                                    }).WithViewModel(pluginViewModel).WithMessage(this, string.Format(CultureInfo.CurrentCulture, Resources.GETTING_RELATIONSHIPS, entityName)));
                                }
                                else
                                {
                                    foreach (TreeNodeAdv relationship in item.Nodes)
                                    {
                                        if (relationship == e.Node)
                                        {
                                            continue;
                                        }
                                        if (((RelationshipMetadataBase)relationship.Tag).SchemaName == schemaName)
                                        {
                                            this.metadataTree.BeforeCheck -= treeEventHandler;
                                            relationship.CheckState        = e.NewCheckState;
                                            treeEventHandler = new TreeViewAdvBeforeCheckEventHandler(this.MetadataTree_BeforeCheck);
                                            this.metadataTree.BeforeCheck += treeEventHandler;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (e.Node.Text == "Attributes" && e.NewCheckState == CheckState.Checked && !e.Node.ExpandedOnce)
            {
                AttributeMetadataHandler.GetAttributes(((EntityMetadata)e.Node.Parent.Tag).LogicalName, e.Node, checkedState: true);
            }
            else if (e.Node.Text == "Relationships" && e.NewCheckState == CheckState.Checked && !e.Node.ExpandedOnce)
            {
                RelationshipMetadataHandler.GetRelationships(((EntityMetadata)e.Node.Parent.Tag).LogicalName, e.Node, checkedState: true);
            }
        }