Example #1
0
        public ExecutionResult Execute(IExecutionContext executionContext, Keys key)
        {
            var state = CommandState.Handled;

            if (executionContext.Stack.Count > 0 && executionContext.Stack.Last() == Keys.D && key == Keys.D)
            {
                try
                {
                    Dte.ExecuteCommand("Edit.Delete");
                }
                catch (Exception e) { }

                executionContext = executionContext.Clear();
            }
            else if (key == Keys.D)
            {
                executionContext = executionContext.Add(key).With(delayedExecutable: this);
            }
            else
            {
                executionContext = executionContext.Clear();
                state            = CommandState.Cleared;
            }

            return(new ExecutionResult(executionContext, state));
        }
        public void ShowWorkItem(int id)
        {
            try
            {
                DocumentService          doc   = Dte.GetObject("Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.DocumentService") as DocumentService;
                TfsTeamProjectCollection col   = (TfsTeamProjectCollection)Repository.Instance.TfsBridgeProvider.TfsTeamProjectCollection;
                IWorkItemDocument        wiDoc = doc.GetWorkItem(col, id, this);


                try
                {
                    if (!wiDoc.IsLoaded)
                    {
                        wiDoc.Load();
                    }
                    doc.ShowWorkItem(wiDoc);
                }
                finally
                {
                    wiDoc.Release(this);
                }
            }
            catch (Exception ex)
            {
                SimpleLogger.Log(ex, true);
            }
        }
Example #3
0
        private void ImprimirInformacionRelevanteDocumento(Dte dte)
        {
            Console.WriteLine("Documento creado");
            Console.WriteLine("------------------");
            Console.WriteLine("Tipo: {0}", dte.Tipo);
            Console.WriteLine("ID: {0}", dte.Id);
            Console.WriteLine("Serie: {0}", dte.Serie);
            Console.WriteLine("Numero: {0}", dte.Numero);
            Console.WriteLine("Archivo XML URI: {0}", dte.ArchivoXmlUri);
            Console.WriteLine();
            Console.WriteLine("Datos adicionales");
            Console.WriteLine("------------------");
            foreach (var datoAdicional in dte.DatosAdicionales)
            {
                Console.WriteLine("{0} ({1}) : {2}", datoAdicional.Nombre, datoAdicional.Visible.Value ? "visible" : "no visible", datoAdicional.Valor);
            }

            if (dte.DatosAnulacion != null)
            {
                Console.WriteLine();
                Console.WriteLine("Datos de Anulacion");
                Console.WriteLine("------------------");
                {
                    Console.WriteLine("ArchivoXmlUri (anulacion): {0}", dte.DatosAnulacion.ArchivoXmlUri);
                    Console.WriteLine("Fecha (anulacion): {0}", dte.DatosAnulacion.FechaAnulacion);
                    Console.WriteLine("Motivo (anulacion): {0}", dte.DatosAnulacion.MotivoAnulacion);
                }
            }
        }
Example #4
0
        public void SimpleUndoRedo()
        {
            ExecuteMigrateDiagramNodesTest(
                "SimpleUndoRedo",
                (artifact, commandProcessorContext) =>
            {
                var baseType =
                    (ConceptualEntityType)
                    CreateEntityTypeCommand.CreateEntityTypeAndEntitySetWithDefaultNames(commandProcessorContext);
                var derivedType = CreateEntityTypeCommand.CreateDerivedEntityType(
                    commandProcessorContext, "SubType", baseType, true);

                Dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), "Edit.Undo");
                Assert.IsTrue(!artifact.ConceptualModel.EntityTypes().Any(et => et.LocalName.Value == derivedType.LocalName.Value));

                Dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), "Edit.Undo");
                Assert.IsTrue(!artifact.ConceptualModel.EntityTypes().Any(et => et.LocalName.Value == baseType.LocalName.Value));

                Dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), "Edit.Redo");
                Dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), "Edit.Redo");

                Assert.IsNotNull(
                    artifact.ConceptualModel.EntityTypes().SingleOrDefault(et => et.LocalName.Value == baseType.LocalName.Value));

                // Verify that derived type and inheritance are recreated.
                derivedType =
                    (ConceptualEntityType)
                    artifact.ConceptualModel.EntityTypes().SingleOrDefault(et => et.LocalName.Value == derivedType.LocalName.Value);
                Assert.IsNotNull(derivedType);
                Assert.AreEqual(baseType.LocalName.Value, derivedType.BaseType.Target.LocalName.Value);
            });
        }
Example #5
0
        public void ExecuteCommand(string commandName, string commandArgs = "", int timeout = 25000)
        {
            Task task = Task.Factory.StartNew(() => {
                Console.WriteLine("Executing command {0} {1}", commandName, commandArgs);
                Dte.ExecuteCommand(commandName, commandArgs);
                Console.WriteLine("Successfully executed command {0} {1}", commandName, commandArgs);
            });

            bool timedOut = false;

            try {
                timedOut = !task.Wait(timeout);
            } catch (AggregateException ae) {
                foreach (var ex in ae.InnerExceptions)
                {
                    Console.WriteLine(ex.ToString());
                }
                ExceptionDispatchInfo.Capture(ae.InnerException).Throw();
            }

            if (timedOut)
            {
                string msg = String.Format("Command {0} failed to execute in specified timeout", commandName);
                Console.WriteLine(msg);
                DumpVS();
                Assert.Fail(msg);
            }
        }
        protected override void OnCreate()
        {
            base.OnCreate();

            try
            {
                _tracer.WriteLine(Resources.IntroMessage);

                var view = _compositionHost.GetExportedValue <VsixShellView>();
                view.Loaded     += View_Loaded;
                view.DataContext = _compositionHost.GetExportedValue <VsixShellViewModel>();
                // ReSharper disable once PossibleNullReferenceException
                view.Resources.MergedDictionaries.Add(DataTemplateManager.CreateDynamicDataTemplates(_compositionHost.Container));

                var executingAssembly = Assembly.GetExecutingAssembly();
                var folder            = Path.GetDirectoryName(executingAssembly.Location);

                _tracer.WriteLine(Resources.AssemblyLocation, folder);
                _tracer.WriteLine(Resources.Version, new AssemblyName(executingAssembly.FullName).Version);

                EventManager.RegisterClassHandler(typeof(VsixShellView), ButtonBase.ClickEvent, new RoutedEventHandler(Navigate_Click));

                // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
                // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
                // the object returned by the Content property.
                Content = view;

                Dte.SetFontSize(view);
            }
            catch (Exception ex)
            {
                _tracer.TraceError("MyToolWindow OnCreate failed: " + ex);
                MessageBox.Show(string.Format(CultureInfo.CurrentCulture, Resources.ExtensionLoadingError, ex.Message));
            }
        }
Example #7
0
        public NewProjectDialog FileNewProject()
        {
            ThreadPool.QueueUserWorkItem(x => Dte.ExecuteCommand("File.NewProject"));
            IntPtr dialog = WaitForDialog();

            return(new NewProjectDialog(AutomationElement.FromHandle(dialog)));
        }
        public void AddRelatedItemsTest()
        {
            var shapeColor = Color.Cyan;

            ChangeEntityTypesFillColorTest(
                "AddRelatedItems",
                shapeColor,
                (artifact, commandProcessorContext) =>
            {
                var diagram = CreateDiagramCommand.CreateDiagramWithDefaultName(commandProcessorContext);
                var docData = GetDocData(commandProcessorContext.EditingContext);
                docData.OpenDiagram(diagram.Id.Value);

                CreateEntityTypeShapeCommand.CreateEntityTypeShapeAndConnectorsInDiagram(
                    commandProcessorContext,
                    diagram,
                    (ConceptualEntityType)artifact.ConceptualModel.EntityTypes().Single(et => et.LocalName.Value == "author"),
                    shapeColor, false);

                var entityDesignerDiagram = docData.GetEntityDesignerDiagram(diagram.Id.Value);
                var author = entityDesignerDiagram.GetShape("author");
                Assert.IsNotNull(author, "Could not get DSL entity type shape instance of 'author'.");

                entityDesignerDiagram.SelectDiagramItems(new[] { author });
                Dte.ExecuteCommand("OtherContextMenus.MicrosoftDataEntityDesignContext.IncludeRelated");

                var titleauthor = entityDesignerDiagram.GetShape("titleauthor");
                Assert.IsNotNull(titleauthor, "Could not get DSL entity type shape instance of 'titleauthor'.");

                Assert.AreEqual(shapeColor, author.FillColor);
                Assert.AreEqual(shapeColor, titleauthor.FillColor);
            });
        }
Example #9
0
        protected override void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                try {
                    InteractiveWindow.CloseAll(this);
                } catch (Exception ex) {
                    Console.WriteLine("Error while closing all interactive windows");
                    Console.WriteLine(ex);
                }

                if (_deletePerformanceSessions)
                {
                    try {
                        dynamic profiling = Dte.GetObject("PythonProfiling");

                        for (dynamic session = profiling.GetSession(1);
                             session != null;
                             session = profiling.GetSession(1))
                        {
                            profiling.RemoveSession(session, true);
                        }
                    } catch (Exception ex) {
                        Console.WriteLine("Error while cleaning up profiling sessions");
                        Console.WriteLine(ex);
                    }
                }
            }
            base.Dispose(disposing);
        }
Example #10
0
        private Dte ConstruirDteSencillo()
        {
            var dte = new Dte();

            dte.Receptor = new Receptor()
            {
                Id        = "CF",
                Nombre    = "Distribuidora XYZ",
                Direccion = new DireccionEntidad()
                {
                    Direccion    = "2a CALLE 3-51 ZONA 9 GUATEMALA",
                    Departamento = "Guatemala",
                    Municipio    = "Guatemala",
                    Pais         = Pais.GT,
                    CodigoPostal = "01009"
                }
            };

            dte.Items = new List <Item>();
            dte.Items.Add(new Item()
            {
                Descripcion    = "Bocina BX-456",
                PrecioUnitario = 1500
            });

            return(dte);
        }
Example #11
0
        public IntPtr OpenDialogWithDteExecuteCommand(string commandName, string commandArgs = "")
        {
            Task task = Task.Factory.StartNew(() => {
                Dte.ExecuteCommand(commandName, commandArgs);
                Console.WriteLine("Successfully executed command {0} {1}", commandName, commandArgs);
            });

            IntPtr dialog = IntPtr.Zero;

            try {
                dialog = WaitForDialog(task);
            } finally {
                if (dialog == IntPtr.Zero)
                {
                    if (task.IsFaulted && task.Exception != null)
                    {
                        Assert.Fail("Unexpected Exception - VSTestContext.DTE.ExecuteCommand({0},{1}){2}{3}",
                                    commandName, commandArgs, Environment.NewLine, task.Exception.ToString());
                    }
                    Assert.Fail("Task failed - VSTestContext.DTE.ExecuteCommand({0},{1})",
                                commandName, commandArgs);
                }
            }
            return(dialog);
        }
Example #12
0
        public ActionResult DeleteConfirmed(int id)
        {
            Dte dte = db.Dtes.Find(id);

            db.Dtes.Remove(dte);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #13
0
        public ExecutionResult Execute(IExecutionContext executionContext, Keys key)
        {
            try
            {
                Dte.ExecuteCommand("Edit.Paste");
            } catch (Exception e) { }

            return(new ExecutionResult(executionContext.Clear(), CommandState.Handled));
        }
Example #14
0
        private async Task ShowButtons()
        {
            var speed = 25U;
            await Dte.FadeTo(1, speed);

            await Chck.FadeTo(1, speed);

            await Dir.FadeTo(1, speed);
        }
Example #15
0
        private async Task HideButtons()
        {
            var speed = 25U;
            await Dte.FadeTo(0, speed);

            await Chck.FadeTo(0, speed);

            await Dir.FadeTo(0, speed);
        }
Example #16
0
        private static void HandleDtoUpdate(Document document, INativeTypesHandler typesHandler,
                                            OutputWindowWriter outputWindowWriter)
        {
            string fullPath = document.ProjectItem.GetFullPath();

            outputWindowWriter.ShowOutputPane(document.DTE);
            outputWindowWriter.Show();
            outputWindowWriter.WriteLine(
                "--- Updating ServiceStack Reference '" +
                fullPath.Substring(fullPath.LastIndexOf("\\", StringComparison.Ordinal) + 1) +
                "' ---");
            var    existingGeneratedCode = File.ReadAllLines(fullPath).Join(Environment.NewLine);
            string baseUrl;

            if (!typesHandler.TryExtractBaseUrl(existingGeneratedCode, out baseUrl))
            {
                outputWindowWriter.WriteLine("Failed to update ServiceStack Reference: Unabled to find BaseUrl");
                return;
            }
            try
            {
                var    options     = typesHandler.ParseComments(existingGeneratedCode);
                string updatedCode = typesHandler.GetUpdatedCode(baseUrl, options);

                //Can't work out another way that ensures UI is updated.
                //Overwriting the file inconsistently prompts the user that file has changed.
                //Sometimes old code persists even though file has changed.
                document.Close();
                using (var streamWriter = File.CreateText(fullPath))
                {
                    streamWriter.Write(updatedCode);
                    streamWriter.Flush();
                }
                try
                {
                    bool optOutOfStats = Dte.GetOptOutStatsSetting();
                    if (!optOutOfStats)
                    {
                        var langName = typesHandler.RelativeTypesUrl.Substring(6);
                        Analytics.SubmitAnonymousUpdateReferenceUsage(langName);
                    }
                }
                catch (Exception)
                {
                    // Ignore errors
                }
                //HACK to ensure new file is loaded
                Task.Run(() => { document.DTE.ItemOperations.OpenFile(fullPath); });
            }
            catch (Exception e)
            {
                outputWindowWriter.WriteLine("Failed to update ServiceStack Reference: Unhandled error - " + e.Message);
            }

            outputWindowWriter.WriteLine("--- Update ServiceStack Reference Complete ---");
        }
 void FormatDocument()
 {
     try
     {
         Dte.ExecuteCommand("Edit.FormatDocument", string.Empty);
     }
     catch (COMException)
     {
     }
 }
Example #18
0
 public ExecutionResult Execute(IExecutionContext executionContext, Keys key)
 {
     try
     {
         Dte.ExecuteCommand("Edit.Copy");
     }
     catch (Exception e) { }
     executionContext = executionContext.Clear().With(mode: InputMode.Normal);
     return(new ExecutionResult(executionContext, CommandState.Handled));
 }
Example #19
0
 public ActionResult Edit([Bind(Include = "dte_id,dte_tipo_dte,dte_folio,dte_emisor,dte_receptor,dte_emisor_razonsocial,dte_receptor_razonsocial,dte_fecha_emision,dte_fecha_recepcion,dte_monto_total,dte_sii_estado,dte_sii_estado_desc,dte_tipo_distribucion,dte_acuse,dte_estado_comercial,dte_ws_descargado,dte_resp_cliente_cod,dte_resp_cliente_desc,dte_distribucion_cod,dte_distribucion_desc,dte_comercial_cod,dte_comercial_desc,dte_acuse_cod,dte_acuse_est,dte_url_custodia,dte_tipo_ingreso,dte_fch_venc,dte_vlr_codigo,dte_mnt_neto,dte_mnt_exe,dte_tasa_iva,dte_iva,dte_saldo_anterior,dte_vlr_pagar")] Dte dte)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dte).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dte));
 }
 public void Quit()
 {
     try
     {
         Dte.Quit();
     }
     catch (Exception) { Console.WriteLine("Ocorreu um erro ao finalizar o DTE mas o processamento prossegue"); }
     // Ultimate solution
     KillInstance();
 }
 void RemoveAndSort()
 {
     try
     {
         Dte.ExecuteCommand("Edit.RemoveAndSort", string.Empty);
     }
     catch (COMException)
     {
     }
 }
        private void ContentWrapper_Loaded(object sender, RoutedEventArgs e)
        {
            _compositionHost.GetExportedValue <ResourceViewModel>().Reload();

            var view = _compositionHost.GetExportedValue <VsixShellView>();

            _contentWrapper.Content = view;

            Dte.SetFontSize(view);
        }
 public void TrackChangeset(int id)
 {
     try
     {
         var ext = Dte.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
         ext.BranchVisualizer.TrackChangeset(id);
     }
     catch (Exception)
     {
     }
 }
 public void ShowChangeset(int id)
 {
     try
     {
         var ext = Dte.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
         ext.ViewChangesetDetails(id);
     }
     catch (Exception)
     {
     }
 }
Example #25
0
 public ExecutionResult Execute(IExecutionContext executionContext, Keys key)
 {
     try
     {
         Dte.ExecuteCommand("View.Open");
         Dte.ExecuteCommand("Window.NewHorizontalTabGroup");
     }
     catch (Exception e) { }
     executionContext = executionContext.Clear().With(mode: InputMode.Normal);
     return(new ExecutionResult(executionContext, CommandState.Handled));
 }
        protected bool OpenSolutionWithPath(string solutionFile)
        {
            Assert.IsTrue(File.Exists(solutionFile), $"No Solution file at path: {solutionFile}");

            using (var waiting = new WaitUntil())
            {
                Dte.Events.SolutionEvents.Opened += () => waiting.Finish();

                Dte.ExecuteCommand("File.OpenProject", $"\"{solutionFile}\"");
            }
            return(true);
        }
Example #27
0
        public void MoveCurrentFileToProject(string projectName)
        {
            ThreadPool.QueueUserWorkItem((x) => Dte.ExecuteCommand("file.ProjectPickerMoveInto"));
            IntPtr dialog = WaitForDialog();

            var chooseDialog = new ChooseLocationDialog(dialog);

            chooseDialog.FindProject(projectName);
            chooseDialog.ClickOK();

            WaitForDialogDismissed();
        }
 public void TrackWorkItem(int id)
 {
     try
     {
         var ext = Dte.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
         ext.BranchVisualizer.TrackWorkItem(id);
     }
     catch (Exception ex)
     {
         SimpleLogger.Log(ex, true);
     }
 }
        public void GoToLine(string filePath, int line)
        {
            JoinableTaskFactory.RunAsync(async() =>
            {
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                var window     = Dte.OpenFile(Constants.vsViewKindPrimary, filePath);
                window.Visible = true;

                ((TextSelection)window.Document.Selection).GotoLine(line, true);
            });
        }
        private void ChangeEntityTypesFillColorTest(
            string projectName, Color fillColor, Action <EntityDesignArtifact, CommandProcessorContext> runTest)
        {
            var modelPath = Path.Combine(TestContext.DeploymentDirectory, @"TestData\Model\v3\PubSimple.edmx");

            UITestRunner.Execute(TestContext.TestName,
                                 () =>
            {
                EntityDesignArtifact entityDesignArtifact = null;
                Project project = null;
                try
                {
                    project = Dte.CreateProject(
                        TestContext.TestRunDirectory,
                        projectName,
                        DteExtensions.ProjectKind.Executable,
                        DteExtensions.ProjectLanguage.CSharp);

                    var projectItem = Dte.AddExistingItem(modelPath, project);
                    Dte.OpenFile(projectItem.FileNames[0]);

                    entityDesignArtifact =
                        (EntityDesignArtifact) new EFArtifactHelper(EFArtifactHelper.GetEntityDesignModelManager(ServiceProvider))
                        .GetNewOrExistingArtifact(TestUtils.FileName2Uri(projectItem.FileNames[0]));

                    var editingContext =
                        _package.DocumentFrameMgr.EditingContextManager.GetNewOrExistingContext(entityDesignArtifact.Uri);
                    var commandProcessorContext = new CommandProcessorContext(
                        editingContext, "DiagramTest", "DiagramTestTxn", entityDesignArtifact);

                    foreach (var ets in entityDesignArtifact.DesignerInfo.Diagrams.FirstDiagram.EntityTypeShapes)
                    {
                        CommandProcessor.InvokeSingleCommand(
                            commandProcessorContext, new UpdateDefaultableValueCommand <Color>(ets.FillColor, fillColor));
                    }

                    runTest(entityDesignArtifact, commandProcessorContext);
                }
                finally
                {
                    if (entityDesignArtifact != null)
                    {
                        entityDesignArtifact.Dispose();
                    }

                    if (project != null)
                    {
                        Dte.CloseSolution(false);
                    }
                }
            });
        }