コード例 #1
0
        private void findUnusedWebResourcesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var nodes = new List<TreeNode>();
            TreeViewHelper.GetNodes(nodes, tvWebResources, false);

            WorkAsync("Starting analysis...",
                (bw, evt) =>
                {
                    var localNodes = (List<TreeNode>)evt.Argument;

                    var unusedWebResources = new List<Entity>();
                    int i = 1;
                    foreach (TreeNode node in localNodes)
                    {
                        var wr = ((WebResource)node.Tag).WebResourceEntity;

                        bw.ReportProgress((i * 100) / nodes.Count, "Analyzing web resource " + wr["name"] + "...");

                        if (!wrManager.HasDependencies(wr.Id))
                        {
                            unusedWebResources.Add(wr);
                        }
                        i++;
                    }

                    evt.Result = unusedWebResources;
                },
                evt =>
                {
                    var dialog = new UnusedWebResourcesListDialog((List<Entity>)evt.Result, Service);
                    dialog.ShowInTaskbar = true;
                    dialog.StartPosition = FormStartPosition.CenterParent;
                    dialog.ShowDialog(this);
                },
                evt => SetWorkingMessage(string.Format("{0}% - {1}", evt.ProgressPercentage, evt.UserState)),
                nodes);
        }
コード例 #2
0
        private void TsmiFindUnusedWebResourcesClick(object sender, EventArgs e)
        {
            var allresources = webresourceTreeView1.GetAllResources();
            WorkAsync(new WorkAsyncInfo("Starting analysis...", (bw, evt) =>
            {
                var resources = (List<WebResource>)evt.Argument;

                var unusedWebResources = new List<Entity>();
                int i = 1;
                foreach (var resource in resources)
                {
                    var wr = resource.Entity;

                    bw.ReportProgress((i * 100) / resources.Count, "Analyzing web resource " + wr["name"] + "...");

                    wrManager = new AppCode.WebResourceManager(Service);
                    if (!wrManager.HasDependencies(wr.Id))
                    {
                        unusedWebResources.Add(wr);
                    }
                    i++;
                }

                evt.Result = unusedWebResources;
            })
            {
                AsyncArgument = allresources,
                ProgressChanged = evt => SetWorkingMessage(string.Format("{0}% - {1}", evt.ProgressPercentage, evt.UserState)),
                PostWorkCallBack = evt =>
                {
                    var dialog = new UnusedWebResourcesListDialog((List<Entity>)evt.Result, Service);
                    dialog.ShowInTaskbar = true;
                    dialog.StartPosition = FormStartPosition.CenterParent;
                    dialog.ShowDialog(this);
                }
            });
        }