Example #1
0
        public static void InitializeListeners()
        {
            _dte = ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE2;

            //register for F5 hit event and start previewing if selected document is jsreport
            _debugCommandEvent = _dte.Events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 295];
            _debugCommandEvent.BeforeExecute +=
                (string guid, int id, object @in, object @out, ref bool @default) =>
            {
                if (_dte.ActiveDocument != null && _dte.ActiveDocument.FullName.Contains(".jsrep") &&
                    !_dte.ActiveDocument.FullName.Contains(".png") &&
                    !_dte.ActiveDocument.FullName.Contains(".json"))
                {
                    @default = true;
                    DoPreviewActiveItem().Wait();
                }
            };

            //new project item should clear schemas cache, so new jsrep.json is visible in combo
            _cteateProjectItemEvent = _dte.Events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 220];
            _cteateProjectItemEvent.AfterExecute += (string guid, int id, object @in, object @out) =>
            {
                ReportingServerManagerAdapter.ClearCache();

                foreach (Window window in _dte.Windows)
                {
                    var jsrepEditorPane = window.Object as JsRepEditorPane;

                    if (jsrepEditorPane != null)
                    {
                        jsrepEditorPane.MarkRerfeshRequired();
                    }
                }
            };

            //saving ReportingStartup.cs should restart current server manager
            _documentEvents = _dte.Events.DocumentEvents;
            _documentEvents.DocumentSaved += async document =>
            {
                if (document.FullName.ToLower().Contains("reportingstartup"))
                {
                    lock (_locker)
                    {
                        if (_configReloadInProgress)
                        {
                            return;
                        }

                        _configReloadInProgress = true;
                    }

                    try
                    {
                        Trace.TraceInformation("Reloading because of reportingstartup");
                        await ReportingServerManagerAdapter.StopAsync();

                        foreach (Window window in _dte.Windows)
                        {
                            var jsrepEditorPane = window.Object as JsRepEditorPane;

                            if (jsrepEditorPane != null)
                            {
                                jsrepEditorPane.MarkRerfeshRequired();
                            }
                        }
                    }
                    finally
                    {
                        _configReloadInProgress = false;
                        Trace.TraceInformation("Reloading done");
                    }
                }
            };

            ReportingServerManagerAdapter = new ReportingServerManagerAdapter(_dte);
        }
Example #2
0
        public static void InitializeListeners()
        {
            _dte = ServiceProvider.GlobalProvider.GetService(typeof (DTE)) as DTE2;

            //register for F5 hit event and start previewing if selected document is jsreport
            _debugCommandEvent = _dte.Events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 295];
            _debugCommandEvent.BeforeExecute +=
                (string guid, int id, object @in, object @out, ref bool @default) =>
                {
                    if (_dte.ActiveDocument != null && _dte.ActiveDocument.FullName.Contains(".jsrep") && 
                        !_dte.ActiveDocument.FullName.Contains(".png") &&
                        !_dte.ActiveDocument.FullName.Contains(".json"))
                    {
                        @default = true;
                        DoPreviewActiveItem().Wait();
                    }
                };

            //new project item should clear schemas cache, so new jsrep.json is visible in combo
            _cteateProjectItemEvent = _dte.Events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 220];
            _cteateProjectItemEvent.AfterExecute += (string guid, int id, object @in, object @out) =>
            {
                ReportingServerManagerAdapter.ClearCache();

                foreach (Window window in _dte.Windows)
                {
                    var jsrepEditorPane = window.Object as JsRepEditorPane;

                    if (jsrepEditorPane != null)
                        jsrepEditorPane.MarkRerfeshRequired();
                }
            };

            //saving ReportingStartup.cs should restart current server manager
            _documentEvents = _dte.Events.DocumentEvents;
            _documentEvents.DocumentSaved += async document =>
            {
                if (document.FullName.ToLower().Contains("reportingstartup"))
                {
                    lock (_locker)
                    {
                        if (_configReloadInProgress)
                            return;

                        _configReloadInProgress = true;
                    }

                    try
                    {
                        Trace.TraceInformation("Reloading because of reportingstartup");
                        await ReportingServerManagerAdapter.StopAsync();

                        foreach (Window window in _dte.Windows)
                        {
                            var jsrepEditorPane = window.Object as JsRepEditorPane;

                            if (jsrepEditorPane != null)
                                 jsrepEditorPane.MarkRerfeshRequired();
                        }
                    }
                    finally
                    {
                        _configReloadInProgress = false;
                        Trace.TraceInformation("Reloading done");
                    }
                }
            };

            ReportingServerManagerAdapter = new ReportingServerManagerAdapter(_dte);
        }