Exemple #1
0
 protected override void InternalRefresh()
 {
     Dataphoria.ExecuteScript("System.RefreshLibraries();");
     base.InternalRefresh();
     RefreshCurrent();
     RefreshRegistered();
 }
Exemple #2
0
 private void FTextArea_HelpRequested(object sender, HelpEventArgs args)
 {
     if (_textEdit.ActiveTextAreaControl.SelectionManager.HasSomethingSelected)
     {
         Dataphoria.InvokeHelp(_textEdit.ActiveTextAreaControl.SelectionManager.SelectedText);
     }
     else
     {
         string word = "";
         // the next 7 lines added/modified to overcome bug in FindWordStart
         // runtime error if Caret is at end of document
         int caretOffset = _textEdit.ActiveTextAreaControl.Caret.Offset;
         int textLength  = _textEdit.Document.TextLength;
         if (textLength > 0)
         {
             if (caretOffset == textLength)
             {
                 caretOffset--;
             }
             int first = TextEdit.FindWordStart(_textEdit.Document, caretOffset);
             int last  = TextEdit.FindWordEnd(_textEdit.Document, caretOffset);
             word = _textEdit.Document.GetText(first, last - first);
         }
         if (word.Trim().Length == 0)
         {
             Dataphoria.InvokeHelp(DesignerID);
         }
         else
         {
             Dataphoria.InvokeHelp(word);
         }
     }
 }
        private string FindUniqueDocumentName(string libraryName, string documentName)
        {
            if (!Dataphoria.DocumentExists(libraryName, documentName))
            {
                return(documentName);
            }

            int count = 1;

            int numIndex = documentName.Length - 1;

            while ((numIndex >= 0) && Char.IsNumber(documentName, numIndex))
            {
                numIndex--;
            }
            if (numIndex < (documentName.Length - 1))
            {
                count        = Int32.Parse(documentName.Substring(numIndex + 1));
                documentName = documentName.Substring(0, numIndex + 1);
            }

            string name;

            do
            {
                name = documentName + count.ToString();
                count++;
            }  while (Dataphoria.DocumentExists(libraryName, name));

            return(name);
        }
Exemple #4
0
        protected override void InternalReconcileChildren()
        {
            ArrayList items = new ArrayList(Nodes.Count);

            foreach (TreeNode node in Nodes)
            {
                items.Add(node);
            }
            Dataphoria.Execute(GetChildExpression(), GetParams(), ARow =>
            {
                TreeNode node = FindByKey(ARow);
                if (node != null)
                {
                    items.Remove(node);
                    ReconcileNode((BaseNode)node, ARow);
                }
                else
                {
                    AddNode(CreateChildNode(ARow));
                }
            });
            foreach (TreeNode node in items)
            {
                Nodes.Remove(node);
            }
        }
Exemple #5
0
        protected virtual INode GetNewDesignNode()
        {
            var form = (IWindowsFormInterface)FrontendSession.CreateForm();

            Dataphoria.AddDesignerForm(form, this);
            return(form);
        }
Exemple #6
0
        private void OpenRegisterScriptClicked(object sender, EventArgs args)
        {
            DesignerInfo         info   = Dataphoria.GetDefaultDesigner("d4");
            DocumentDesignBuffer buffer = new DocumentDesignBuffer(Dataphoria, LibraryName, "Register");

            Dataphoria.OpenDesigner(info, buffer);
        }
Exemple #7
0
 private void SetAsCurrentClicked(object sender, EventArgs args)
 {
     if (Registered && !Current)
     {
         Dataphoria.ExecuteScript(String.Format("System.SetLibrary('{0}');", _libraryName));
         ((LibraryListNode)Parent).RefreshCurrent();
     }
 }
Exemple #8
0
        /// <remarks>
        ///		Note that this method should not be confused with Form.Close().
        ///		Be sure to deal with a compile-time instance of type IDesigner
        ///		to invoke this method.
        ///	</remarks>
        void IDesigner.Show()
        {
            UpdateTitle();
            Dataphoria.AttachForm(this);

            // HACK: Don't know why, but for some reason, setting the MDIParent of this form collapses the nodes tree.
            FNodesTree.ExpandAll();
        }
Exemple #9
0
        public void RefreshCurrent()
        {
            string currentLibrary = Dataphoria.GetCurrentLibraryName();

            foreach (LibraryNode node in Nodes)
            {
                node.Current = node.LibraryName == currentLibrary;
            }
        }
Exemple #10
0
        public override void Delete()
        {
            IDesigner designer = Dataphoria.GetDesigner(GetBuffer());

            if ((designer == null) || ((designer != null) && designer.CloseSafely()))
            {
                base.Delete();
            }
        }
Exemple #11
0
        private void ScriptChangesClicked(object sender, EventArgs args)
        {
            string catalogDirectory = FolderUtility.GetDirectory(String.Empty);

            using (Frontend.Client.Windows.StatusForm statusForm = new Frontend.Client.Windows.StatusForm(Strings.ComparingSchema))
            {
                Dataphoria.EvaluateAndEdit(String.Format(".System.ScriptLibraryChanges('{0}', '{1}')", catalogDirectory.Replace("'", "''"), LibraryName), "d4");
            }
        }
Exemple #12
0
 private void ViewLogClicked(object sender, EventArgs args)
 {
     using (Frontend.Client.Windows.IWindowsFormInterface form = (Frontend.Client.Windows.IWindowsFormInterface)Dataphoria.FrontendSession.CreateForm())
     {
         Dataphoria.FrontendSession.CreateHost().Load("Derive('System.ListLogs', 'List')", form);
         form.HostNode.Open();
         form.ShowModal(Frontend.Client.FormMode.None);
         Dataphoria.EvaluateAndEdit("ShowLog(" + form.MainSource["Sequence"].AsString + ")", "txt");
     }
 }
Exemple #13
0
 public void RefreshRegistered()
 {
     Dataphoria.Execute(GetChildExpression(), GetParams(), ARow =>
     {
         var node = FindByKey(ARow) as LibraryNode;
         if (node != null)
         {
             UpdateNode(node, ARow);
         }
     });
 }
Exemple #14
0
 /// <summary> Prepares (or re-prepares) the frontend session and the component palette </summary>
 private void PrepareSession()
 {
     if (_frontendSession == null)
     {
         _frontendSession = Dataphoria.GetLiveDesignableFrontendSession();
         _palettePanel.FrontendSession = this._frontendSession;
     }
     _frontendSession.SetFormDesigner();
     _palettePanel.ClearPalette();
     _palettePanel.LoadPalette();
 }
Exemple #15
0
        private void OpenClicked(object sender, EventArgs args)
        {
            IDesigner designer = Dataphoria.GetDesigner(GetBuffer());

            if (designer != null)
            {
                designer.Select();
            }
            else
            {
                OpenDesigner(Dataphoria.GetDefaultDesigner(_documentType));
            }
        }
 private void StartClicked(object sender, EventArgs args)
 {
     Frontend.Client.Windows.Session session = Dataphoria.GetLiveDesignableFrontendSession();
     try
     {
         session.StartCallback(session.SetApplication(_iD), null);
     }
     catch
     {
         session.Dispose();
         throw;
     }
     Dataphoria.RefreshLibraries();
 }
 private void StartClicked(object sender, EventArgs args)
 {
     Frontend.Client.Windows.Session session = Dataphoria.GetLiveDesignableFrontendSession();
     try
     {
         session.SetLibrary(LibraryName);
         session.StartCallback(GetDocumentExpression(), null);
     }
     catch
     {
         session.Dispose();
         throw;
     }
 }
Exemple #18
0
		protected void BrowseClicked(object sender, EventArgs args)
		{
			Frontend.Client.Windows.Session session = Dataphoria.GetLiveDesignableFrontendSession();
			try
			{
				session.SetFormDesigner();
				session.StartCallback(String.Format(".Frontend.Derive('{0}', 'Browse')", ObjectName), null);
			}
			catch
			{
				session.Dispose();
				throw;
			}
		}
Exemple #19
0
 private void UpdateReconciliationMode()
 {
     Dataphoria.ExecuteScript
     (
         String.Format
         (
             "alter device .{0} alter reconciliation {{ mode = {{ {1} }} }};",
             ObjectName,
             DAE.Language.D4.ReconcileMode.None |
             (LStartup.Checked ? DAE.Language.D4.ReconcileMode.Startup : DAE.Language.D4.ReconcileMode.None) |
             (LCommand.Checked ? DAE.Language.D4.ReconcileMode.Command : DAE.Language.D4.ReconcileMode.None) |
             (LAutomatic.Checked ? DAE.Language.D4.ReconcileMode.Automatic : DAE.Language.D4.ReconcileMode.None)
         )
     );
 }
 public void MoveFromDocument(string libraryName, string documentName)
 {
     Dataphoria.CheckDocumentOverwrite(LibraryName, documentName);
     Dataphoria.ExecuteScript
     (
         String.Format
         (
             ".Frontend.MoveDocument('{0}', '{1}', '{2}', '{3}');",
             DAE.Schema.Object.EnsureRooted(libraryName),
             DAE.Schema.Object.EnsureRooted(documentName),
             DAE.Schema.Object.EnsureRooted(LibraryName),
             documentName
         )
     );
     ReconcileChildren();
 }
Exemple #21
0
        public void SaveAsFile()
        {
            FileDesignBuffer buffer;
            FileDesignBuffer current = _buffer as FileDesignBuffer;

            if (current != null)
            {
                buffer = current.PromptForBuffer(_designer);
            }
            else
            {
                buffer = Dataphoria.PromptForFileBuffer(_designer, String.Empty);
            }
            ValidateBuffer(buffer);
            Save(buffer);
        }
        public void CopyFromDocument(string libraryName, string documentName)
        {
            string newDocumentName = FindUniqueDocumentName(LibraryName, documentName);

            Dataphoria.ExecuteScript
            (
                String.Format
                (
                    ".Frontend.CopyDocument('{0}', '{1}', '{2}', '{3}');",
                    DAE.Schema.Object.EnsureRooted(libraryName),
                    DAE.Schema.Object.EnsureRooted(documentName),
                    DAE.Schema.Object.EnsureRooted(LibraryName),
                    newDocumentName
                )
            );
            ReconcileChildren();
        }
 private void ExecuteClicked(object sender, EventArgs args)
 {
     using
     (
         DAE.Runtime.Data.IScalar script =
             Dataphoria.FrontendSession.Pipe.RequestDocument
             (
                 String.Format
                 (
                     ".Frontend.Load('{0}', '{1}')",
                     DAE.Schema.Object.EnsureRooted(LibraryName),
                     DAE.Schema.Object.EnsureRooted(DocumentName)
                 )
             )
     )
     {
         Dataphoria.ExecuteScript(script.AsString);
     }
 }
Exemple #24
0
        public void SaveAsDocument()
        {
            DocumentDesignBuffer buffer;
            DocumentDesignBuffer current = _buffer as DocumentDesignBuffer;

            if (current != null)
            {
                buffer = current.PromptForBuffer(_designer);
            }
            else
            {
                buffer = Dataphoria.PromptForDocumentBuffer(_designer, Dataphoria.GetCurrentLibraryName(), String.Empty);
            }
            ValidateBuffer(buffer);
            Save(buffer);
            if (AfterSaveAsDocument != null)
            {
                AfterSaveAsDocument(this, buffer);
            }
        }
Exemple #25
0
        protected virtual void Drop()
        {
            // Confirm the deletion
            Frontend.Client.Windows.IWindowsFormInterface form =
                Dataphoria.FrontendSession.LoadForm
                (
                    null,
                    ".Frontend.Form('Frontend', 'DropDependents')"
                );
            try
            {
                Frontend.Client.ISource source = (Frontend.Client.ISource)form.FindNode("Dependents");
                source.Expression =
                    String.Format
                    (
                        @"	
							DependentObjects('{0}')
								over {{ Level, Sequence, Object_Description }}
								rename {{ Object_Description Description }}
								order by {{ Level desc, Sequence }}
						"                        ,
                        ObjectName
                    );
                source.Enabled = true;
                if (form.ShowModal(Frontend.Client.FormMode.Query) != DialogResult.OK)
                {
                    throw new AbortException();
                }
            }
            finally
            {
                form.HostNode.Dispose();
            }

            // Emit and execute the drop script
            using (DAE.Runtime.Data.Scalar script = (DAE.Runtime.Data.Scalar)Dataphoria.EvaluateQuery(GetScriptDropExpression()))
                Dataphoria.ExecuteScript(script.AsString);

            ParentList.Refresh();
        }
Exemple #26
0
        public void Analyze()
        {
            PrepareForExecute();

            string plan;
            var    errors = new ErrorList();

            try
            {
                using (var statusForm = new StatusForm(Strings.ProcessingQuery))
                {
                    DateTime startTime = DateTime.Now;
                    try
                    {
                        var paramsValue = new DataParams();
                        paramsValue.Add(DataParam.Create(Dataphoria.UtilityProcess, "AQuery", GetTextToExecute()));
                        plan = ((DAE.Runtime.Data.Scalar)Dataphoria.EvaluateQuery("ShowPlan(AQuery)", paramsValue)).AsString;
                    }
                    finally
                    {
                        TimeSpan elapsed = DateTime.Now - startTime;
                        _executionTimeStatus.Text = elapsed.ToString();
                    }
                }
            }
            catch (Exception exception)
            {
                errors.Add(exception);
                ProcessErrors(errors);
                SetStatus(Strings.ScriptAnalyzeFailed);
                return;
            }

            SetStatus(Strings.ScriptAnalyzeSuccessful);

            var analyzer = (Analyzer.Analyzer)Dataphoria.OpenDesigner(Dataphoria.GetDefaultDesigner("pla"), null);

            analyzer.LoadPlan(plan);
        }
        public void CopyFromFiles(Array fileList)
        {
            FileStream           stream;
            DocumentDesignBuffer buffer;

            foreach (string fileName in fileList)
            {
                buffer = new DocumentDesignBuffer(Dataphoria, LibraryName, Path.GetFileNameWithoutExtension(fileName));
                Dataphoria.CheckDocumentOverwrite(buffer.LibraryName, buffer.DocumentName);
                buffer.DocumentType = Program.DocumentTypeFromFileName(fileName);
                stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                try
                {
                    buffer.SaveBinaryData(stream);
                }
                finally
                {
                    stream.Close();
                }
            }
            ReconcileChildren();
        }
Exemple #28
0
        private void OpenWithClicked(object sender, EventArgs args)
        {
            DesignerInfo info     = Dataphoria.ChooseDesigner(_documentType);
            IDesigner    designer = Dataphoria.GetDesigner(GetBuffer());

            if (designer != null)
            {
                if (designer.DesignerID != info.ID)
                {
                    if
                    (
                        (
                            MessageBox.Show
                            (
                                Strings.OtherDesignerOpen,
                                Strings.OtherDesignerOpenTitle,
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button1
                            ) == DialogResult.Yes
                        ) &&
                        designer.CloseSafely()
                    )
                    {
                        OpenDesigner(info);
                    }
                }
                else
                {
                    designer.Select();
                }
            }
            else
            {
                OpenDesigner(info);
            }
        }
Exemple #29
0
		protected void DeriveClicked(object sender, EventArgs args)
		{
			Frontend.Client.Windows.Session session = Dataphoria.GetLiveDesignableFrontendSession();
			try
			{
				session.SetFormDesigner();
				Frontend.Client.Windows.IWindowsFormInterface form = session.LoadForm(null, ".Frontend.Form('.Frontend', 'DerivedFormLauncher')");
				try
				{
					((Frontend.Client.ISource)form.FindNode("Main")).DataView.Fields["Query"].AsString = ObjectName;
					form.Show();
				}
				catch
				{
					form.HostNode.Dispose();
					throw;
				}
			}
			catch
			{
				session.Dispose();
				throw;
			}
		}
Exemple #30
0
        private void Execute(ExportType exportType, string fileName)
        {
            // Make sure our server is connected...
            Dataphoria.EnsureServerConnection();

            using (var statusForm = new StatusForm(Strings.Exporting))
            {
                using (var connection = new DAEConnection())
                {
                    if (DesignerID == "SQL")
                    {
                        SwitchToSQL();
                    }
                    try
                    {
                        using (var adapter = new DAEDataAdapter(GetTextToExecute(), connection))
                        {
                            using (var dataSet = new DataSet())
                            {
                                var process =
                                    DataSession.ServerSession.StartProcess(new ProcessInfo(DataSession.ServerSession.SessionInfo));
                                try
                                {
                                    connection.Open(DataSession.Server, DataSession.ServerSession, process);
                                    try
                                    {
                                        switch (exportType)
                                        {
                                        case ExportType.Data:
                                            adapter.Fill(dataSet);
                                            dataSet.WriteXml(fileName, XmlWriteMode.IgnoreSchema);
                                            break;

                                        case ExportType.Schema:
                                            adapter.FillSchema(dataSet, SchemaType.Source);
                                            dataSet.WriteXmlSchema(fileName);
                                            break;

                                        default:
                                            adapter.Fill(dataSet);
                                            dataSet.WriteXml(fileName, XmlWriteMode.WriteSchema);
                                            break;
                                        }
                                    }
                                    finally
                                    {
                                        connection.Close();
                                    }
                                }
                                finally
                                {
                                    DataSession.ServerSession.StopProcess(process);
                                }
                            }
                        }
                    }
                    finally
                    {
                        if (DesignerID == "SQL")
                        {
                            SwitchFromSQL();
                        }
                    }
                }
            }
        }