Ejemplo n.º 1
0
        private bool ProcessWsdlWizardRequest(bool roundtrip)
        {
            if (!ValidateItemAndProject())
            {
                return(false);
            }

            string currentDir     = selectedItem.Directory;
            string projectRootDir = selectedItem.ParentProject.ProjectDirectory;
            string metdataFile    = selectedItem.FileName;

            WsdlWizardForm wizard = null;

            try
            {
                wizard = (roundtrip) ? new WsdlWizardForm(metdataFile, true) : new WsdlWizardForm(metdataFile);

                wizard.WsdlLocation          = currentDir;
                wizard.DefaultPathForImports = "";
                wizard.ProjectRootDirectory  = projectRootDir;
                wizard.ShowDialog();

                if (wizard.DialogResult == DialogResult.OK)
                {
                    if (wizard.WsdlLocation.Length > 0)
                    {
                        string wsdlFile = wizard.WsdlLocation;

                        if (!roundtrip)
                        {
                            currentProject.AddFile(wsdlFile);
                        }

                        if (wizard.OpenCodeGenDialog)
                        {
                            ProcessCodeGenerationRequest(wsdlFile);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,
                                "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                if (wizard != null)
                {
                    wizard.Close();
                }
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// xsd生成wsdl
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void XsdCommandInvoke(object sender, EventArgs e)
        {
            var items = ProjectHelpers.GetSelectedItemPaths(_dte);

            if (items.Count() == 1 &&
                (items.ElementAt(0).ToLower().EndsWith(".xsd", StringComparison.OrdinalIgnoreCase)))
            {
                var _file         = items.ElementAt(0);
                var fileInfo      = new FileInfo(_file);
                var folder        = fileInfo.Directory?.FullName;
                var project       = ProjectHelpers.GetActiveProject().FullName;
                var projectInfo   = new FileInfo(project);
                var folderproject = projectInfo.Directory?.FullName;
                if (!string.IsNullOrEmpty(folder))
                {
                    WsdlWizardForm wizard = null;
                    try
                    {
                        wizard = new WsdlWizardForm(_file);
                        wizard.WsdlLocation          = folder;
                        wizard.DefaultPathForImports = "";
                        wizard.ProjectRootDirectory  = folderproject;
                        wizard.ShowDialog();

                        string wsdlFile = "";
                        if (wizard.DialogResult == DialogResult.OK)
                        {
                            if (wizard.WsdlLocation.Length > 0)
                            {
                                wsdlFile = wizard.WsdlLocation;
                                ProjectHelpers.AddFileToActiveProject(wsdlFile);
                                //ProcessCodeGenerationRequest(wsdlFile);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ProjectHelpers.AddError(_package, ex.ToString());
                        MessageBox.Show(ex.Message, "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        if (wizard != null)
                        {
                            wizard.Close();
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private bool ProcessWsdlWizardRequest(bool roundtrip)
        {
            VisualStudioSelectedItem selectedItem = this.VisualStudio.SelectedItem;

            if (selectedItem == null)
            {
                MessageBox.Show("No selected item.",
                                "Web Services Contract-First WSDL Wizard", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                return(true);
            }

            if (!selectedItem.HasProject)
            {
                MessageBox.Show("Cannot create a WSDL contract for items outside of a project.",
                                "Web Services Contract-First WSDL Wizard", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);

                return(true);
            }

            string currentDir     = selectedItem.Directory;
            string projectRootDir = selectedItem.ParentProject.ProjectDirectory;
            string metdataFile    = selectedItem.FileName;

            WsdlWizardForm wizard = null;

            try
            {
                wizard = roundtrip ? new WsdlWizardForm(metdataFile, true) : new WsdlWizardForm(metdataFile);
                wizard.WsdlLocation          = currentDir;
                wizard.DefaultPathForImports = "";
                wizard.ProjectRootDirectory  = projectRootDir;
                wizard.ShowDialog();

                if (wizard.DialogResult == DialogResult.OK)
                {
                    if (wizard.WsdlLocation.Length > 0)
                    {
                        var wsdlFile = wizard.WsdlLocation;

                        if (!roundtrip)
                        {
                            AddFileToCurrentProject(wsdlFile);
                        }

                        if (wizard.OpenCodeGenDialog)
                        {
                            ProcessCodeGenerationRequest(wsdlFile);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,
                                "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                wizard?.Close();
                return(false);
            }

            return(true);
        }