Ejemplo n.º 1
0
        /// <summary>
        ///     Execute the command.
        /// </summary>
        public override void Execute()
        {
            string template =
                @"    public class $name$Command
        : CommandBase
    {
        public $name$Command()
            : base(""$desc$"")
        {
            //ShortcutKeys = Keys.Control | Keys.?;
			//SmallImage = ImageResource.?;
		}

        public override void Execute()
        {
			
        }
    }";

            string code = template
                          .Replace("$name$", "OI")
                          .Replace("$desc$", "a thing");

            var editor = Services.Container.Get <IQueryEditor>();

            editor.AllText = code;
            editor.SetSyntax("C#");

            HostWindow.DisplayDockedForm(editor as DockContent);
        }
        /// <summary>
        ///     Execute the command.
        /// </summary>
        public override void Execute()
        {
            var editor = Services.Resolve <IQueryEditor>();

            editor.FileName = null;
            HostWindow.DisplayDockedForm(editor as DockContent);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Execute the command.
        /// </summary>
        public override void Execute()
        {
            var editor = Services.Resolve <IEditor>("txt-editor");

            //var editor = Services.Resolve<IEditor>();
            editor.FileName = null;
            HostWindow.DisplayDockedForm(editor as DockContent);

            if (HostWindow.DatabaseInspector.DbSchema == null)
            {
                HostWindow.DatabaseInspector.LoadDatabaseDetails();
            }

            var dependencyWalker = new DbModelDependencyWalker(HostWindow.DatabaseInspector.DbSchema);
            var tables           = dependencyWalker.SortTablesByForeignKeyReferences();

            var sb = new StringBuilder();

            foreach (DbModelTable table in tables)
            {
                sb.AppendLine(table.FullName);
            }

            editor.AllText = sb.ToString();
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Execute the command.
        /// </summary>
        public override void Execute()
        {
            string  xmlFile = Utility.GetConnectionStringFilename();
            IEditor editor  = Services.Resolve <IFileEditorResolver>().ResolveEditorInstance(xmlFile);

            editor.FileName = xmlFile;
            editor.LoadFile();
            HostWindow.DisplayDockedForm(editor as DockContent);
        }
        /// <summary>Execute the command.</summary>
        public override void Execute()
        {
            string tableName = HostWindow.DatabaseInspector.RightClickedTableName;

            if (tableName != null)
            {
                IViewTable frm = Services.Resolve <IViewTable>();
                frm.TableName = tableName;
                HostWindow.DisplayDockedForm(frm as DockContent);
            }
        }
        /// <summary>Execute the command.</summary>
        public override void Execute()
        {
            IQueryEditor queryForm = HostWindow.Instance.ActiveMdiChild as IQueryEditor;

            if (queryForm != null)
            {
                string     tableName = queryForm.SelectedText;
                IViewTable frm       = Services.Resolve <IViewTable>();
                frm.TableName = tableName;
                HostWindow.DisplayDockedForm(frm as DockContent);
            }
        }
Ejemplo n.º 7
0
        /// <summary>Execute the command.</summary>
        public override void Execute()
        {
            NewFileForm newFileForm = Services.Resolve <NewFileForm>();

            DialogResult result = newFileForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                var editor = Services.Resolve <IEditor>(newFileForm.FileEditorDescriptor.EditorKeyName);
                editor.FileName = null;
                HostWindow.DisplayDockedForm(editor as DockContent);
            }
        }
Ejemplo n.º 8
0
        protected void RunExportSqlCe(string fileName)
        {
            string file      = Path.GetTempFileName() + ".sql";
            string conn      = Settings.ConnectionDefinition.ConnectionString.Replace(@"""", @"\""");
            string arguments = string.Format("\"{0}\" \"{1}\"", conn, file);

            var tool = new Process();

            tool.StartInfo.FileName               = fileName;
            tool.StartInfo.Arguments              = arguments;
            tool.StartInfo.UseShellExecute        = false;
            tool.StartInfo.RedirectStandardOutput = true;
            tool.StartInfo.RedirectStandardError  = true;

            if (tool.Start())
            {
                string output = tool.StandardOutput.ReadToEnd();
                string err    = tool.StandardError.ReadToEnd();

                if (!string.IsNullOrEmpty(err))
                {
                    output = "ERROR:" + Environment.NewLine + err + Environment.NewLine + output;
                }

                if (File.Exists(file))
                {
                    IEditor editor = Services.Resolve <IFileEditorResolver>().ResolveEditorInstance(file);
                    editor.FileName = file;
                    editor.LoadFile();
                    HostWindow.DisplayDockedForm(editor as DockContent);
                }
                else
                {
                    var sb = new StringBuilder();
                    sb.AppendLine("Error generating the output file.");
                    sb.AppendLine("Process Info:");
                    sb.AppendFormat("  File Name: {0}", tool.StartInfo.FileName);
                    sb.AppendLine();
                    sb.AppendFormat("  Arguments: {0}", tool.StartInfo.Arguments);
                    sb.AppendLine();
                    sb.AppendLine(output);
                    output = sb.ToString();
                }

                if (!string.IsNullOrEmpty(output))
                {
                    HostWindow.DisplaySimpleMessageBox(null, output, fileName + " Output");
                }
            }
        }
Ejemplo n.º 9
0
        public override void Execute()
        {
            if (!Enabled)
            {
                return;
            }

            var fileEditorResolver = Services.Resolve <IFileEditorResolver>();

            _mostRecentFilesService = Services.Resolve <IMostRecentFilesService>();
            string fileName = GetFilenameByIndex();

            var editor = fileEditorResolver.ResolveEditorInstance(fileName);

            editor.FileName = fileName;
            editor.LoadFile();
            HostWindow.DisplayDockedForm(editor as DockContent);
        }
Ejemplo n.º 10
0
        /// <summary>Execute the command.</summary>
        public override void Execute()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
            openFileDialog.Filter           = Settings.DefaultFileFilter;
            openFileDialog.CheckFileExists  = true;
            if (openFileDialog.ShowDialog(HostWindow.Instance) == DialogResult.OK)
            {
                // todo: check for file exist file in open windows;
                IFileEditorResolver resolver = Services.Resolve <IFileEditorResolver>();
                var     fileName             = openFileDialog.FileName;
                IEditor editor = resolver.ResolveEditorInstance(fileName);
                editor.FileName = fileName;
                editor.LoadFile();
                HostWindow.DisplayDockedForm(editor as DockContent);

                Services.Resolve <IMostRecentFilesService>().Register(fileName);
            }
        }
        public override void Execute()
        {
            // We will be using this a bit:
            var queueInspector = HostWindow.QueueInspector;

            // Get the "Format Name":
            var formatName = queueInspector.MessageQueueContext.FormatName;

            // Get an instance of "IMsmqQueueManager" for better access to the queues:
            var msmqQueueManager = Services.Resolve <IMsmqQueueManager>();

            // Set the path to the format name of the selected queue:
            msmqQueueManager.QueuePath = formatName;

            // Create an MSMQ List Command - a wrapper that peaks the message data on the queue:
            var listCommand = new MsmqListCommand();

            // By default the body of the message is not loaded, set "DisplayBody" to true and
            // this will be retrieved with the message:
            listCommand.DisplayBody = true;

            // Execute the list command, this *will* enumerate the messages in the queue:
            listCommand.Execute(msmqQueueManager);

            // Use the "Name" of the queue to lookup the preferred deserialiser (if any), the default
            // is "guess" (note that the format of the key used to lookup the Preferred Deserialiser
            // is "<machine>\<queue-name>", e.g. "server\private$\orders".
            var preferredDeserialiser = HostWindow.QueueInspector.GetPreferredDeserialiserForQueue(
                queueInspector.MessageQueueContext.Name);

            // Get an instance of the rendering service:
            var messageBodyRenderService = Services.Resolve <IMessageBodyRenderService>();

            // Store up the report:
            var sb = new StringBuilder();

            // Some basic report details:
            sb.Append("Server: ");
            sb.AppendLine(queueInspector.MessageQueueContext.MachineName);
            sb.Append("Queue:  ");
            sb.AppendLine(queueInspector.MessageQueueContext.QueueName);
            sb.Append("Count:  ");
            sb.AppendLine(listCommand.Result.Count.ToString());
            sb.AppendLine();
            sb.AppendLine("---");
            sb.AppendLine();

            // Grab the first message - render the contents
            foreach (Message message in listCommand.Result)
            {
                // We need the message data in byte format, convert the stream to bytes:
                byte[] bytes;
                using (var sr = new StreamReader(message.BodyStream, true))
                {
                    var length = (int)sr.BaseStream.Length;
                    bytes = new byte[length];
                    sr.BaseStream.Read(bytes, 0, length);
                }

                // Use the Render Service to change the message bytes into a string:
                var msg = messageBodyRenderService.Render(bytes, preferredDeserialiser, null);

                sb.Append("Arrived Time: ");
                sb.AppendLine(message.ArrivedTime.ToString("u"));
                sb.AppendLine("Message Body:");
                sb.AppendLine();
                sb.AppendLine(msg);
                sb.AppendLine();
                sb.AppendLine("---");
                sb.AppendLine();
            }

            // Get an instance of basic text editor:
            var editor = Services.Resolve <IEditor>("txt-editor");

            // Set "all the text" of the editor window the the generated report:
            editor.AllText = sb.ToString();

            // This command displays the editor window in the application:
            HostWindow.DisplayDockedForm(editor as DockContent);
        }