Esempio n. 1
0
        public TableResultPane AddTab(TableName tname, int top)
        {
            FileLink        link = FileLink.CreateLink(tname.FullPath);
            TableResultPane pane;

            if (panes.ContainsKey(link))
            {
                pane = (TableResultPane)panes[link];
                tabControl.SelectedItem = pane.TabItem;
                return(pane);
            }

            pane = new TableResultPane(this, tname, top)
            {
                Link = link
            };

            panes.Add(link, pane);

            TabItem newTab = new TabItem
            {
                Header  = NewLabelImage(pane, tname.Path, "Close_16x16.png"),
                Content = pane,
                ToolTip = link.ToString(),
            };

            pane.TabItem = newTab;
            tabControl.Items.Add(newTab);
            newTab.Focus();

            return(pane);
        }
Esempio n. 2
0
        public override int SelectData(SelectClause select, DataSet ds)
        {
            TableName tname = select.TableName;
            var       file  = fileLink.PathCombine(tname.DatabaseName.Name, tname.ShortName);

            file = string.Format("{0}.{1}", file, EXT);

            var link = FileLink.CreateLink(file, tname.Provider.UserId, tname.Provider.Password);

            if (!link.Exists)
            {
                throw new InvalidDataException($"table {tname.FormalName} data file \"{file}\" not exist");
            }

            link.ReadXml(ds);

            if (ds.Tables.Count > 0)
            {
                return(ds.Tables[0].Rows.Count);
            }
            else
            {
                return(-1);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// load cfg file from ftp site or web site
        /// </summary>
        /// <param name="val"></param>
        /// <param name="DS"></param>
        private static void include(VAL val, Memory DS)
        {
            if (val.Size != 1 || val[0].VALTYPE != VALTYPE.stringcon)
            {
                cerr.WriteLine("required 1 parameters on function include(file), file can be local disk file, hyperlink, and ftp link");
                return;
            }

            string url = (string)val[0];

            if (string.IsNullOrEmpty(url))
            {
                return;
            }

            var  link   = FileLink.CreateLink(url);
            bool exists = false;

            try
            {
                exists = link.Exists;
            }
            catch (Exception ex)
            {
                cerr.WriteLine($"configuration file {link} doesn't exist, {ex.Message}");
                return;
            }

            if (!exists)
            {
                cerr.WriteLine($"configuration file {link} doesn't exist");
                return;
            }

            string code = null;

            try
            {
                code = link.ReadAllText();
            }
            catch (Exception ex)
            {
                cerr.WriteLine($"failed to load configuration file {link}, {ex.Message}");
                return;
            }

            if (string.IsNullOrEmpty(code))
            {
                return;
            }

            try
            {
                Script.Execute(code, DS);
            }
            catch (Exception ex)
            {
                cerr.WriteLine($"configuration file format error in {link}, {ex.Message}");
            }
        }
Esempio n. 4
0
        public void New()
        {
            FileLink link = FileLink.CreateLink(untitled);

            link.TemporaryLink = true;

            Display(link);
        }
Esempio n. 5
0
        public FileDbConnectionProvider(string name, string connectionString, DbFileType fileType)
            : base(name, ConnectionProviderType.DbFile, new SimpleDbConnectionStringBuilder(connectionString))
        {
            this.DbFileType       = fileType;
            this.FileLink         = FileLink.CreateLink(DataSource, this.UserId, this.Password);
            this.FileLink.Options = ConnectionBuilder;

            this.DataFile = DbFile.Create(DbFileType, FileLink);
        }
Esempio n. 6
0
        public void Open()
        {
            var openFile = new Microsoft.Win32.OpenFileDialog
            {
                Filter = "Sql Script Files (*.sql)|*.sql|Text Files (*.txt)|*.txt|All Files (*.*)|*.*",
            };

            if (openFile.ShowDialog(this) == true)
            {
                FileLink link = FileLink.CreateLink(openFile.FileName);
                Display(link);
            }
        }
Esempio n. 7
0
        public void Save()
        {
            if (!Link.TemporaryLink)
            {
                try
                {
                    Link.Save(TextBox.GetAllText());
                    Tabs.Editor.ShowStatus("saved successfully");
                    IsDirty = false;
                }
                catch (Exception ex)
                {
                    Tabs.Editor.ShowStatus(ex.Message);
                }
                return;
            }

            var saveFile = new Microsoft.Win32.SaveFileDialog
            {
                Filter   = "Sql Script Files (*.sql)|*.sql|Text Files (*.txt)|*.txt|All Files (*.*)|*.*",
                FileName = Link.Url
            };

            if (saveFile.ShowDialog() == true)
            {
                TextRange documentTextRange = new TextRange(TextBox.Document.ContentStart, TextBox.Document.ContentEnd);

                // If this file exists, it's overwritten.
                using (FileStream fs = File.Create(saveFile.FileName))
                {
                    if (Path.GetExtension(saveFile.FileName).ToLower() == ".rtf")
                    {
                        documentTextRange.Save(fs, DataFormats.Rtf);
                    }
                    else
                    {
                        documentTextRange.Save(fs, DataFormats.Text);
                    }

                    Link    = FileLink.CreateLink(saveFile.FileName);
                    IsDirty = false;
                }
            }

            return;
        }
Esempio n. 8
0
        public SqlEditor(IConnectionConfiguration cfg, ConnectionProvider provider, string currentPath, FileLink link)
        {
            this.cfg = cfg;

            InitializeComponent(cfg);
            scriptTabControl.SelectionChanged += ScriptTabControl_SelectionChanged;
            this.provider = provider;

            if (link == null)
            {
                link = FileLink.CreateLink(untitled);
                link.TemporaryLink = true;
            }

            Display(link);

            treeView.ChangeNode(currentPath);
        }