Exemplo n.º 1
0
 protected override void PrepareEditForm(Frontend.Client.Windows.IWindowsFormInterface form)
 {
     base.PrepareEditForm(form);
     if (Registered)
     {
         Frontend.Client.ITextBox textBox = ((Frontend.Client.ITextBox)form.FindNode("MainColumnMain.Name"));
         textBox.ReadOnly = true;
         textBox.Title    = textBox.Title + Strings.LibraryNode_CannotEditWhileRegistered;
     }
 }
Exemplo n.º 2
0
 public override void DragDrop(DragEventArgs args)
 {
     Frontend.Client.Windows.IWindowsFormInterface form = Dataphoria.FrontendSession.LoadForm(null, AddDocument(), new Frontend.Client.FormInterfaceHandler(SetInsertOpenState));
     try
     {
         DocumentData            document        = args.Data as DocumentData;
         Frontend.Client.ISource librariesSource = ((Frontend.Client.IFrame)form.FindNode("Frontend.ApplicationLibraries_ApplicationsFrame")).FrameInterfaceNode.MainSource;
         if (document != null)
         {
             form.MainSource["Main.ID"].AsString            = document.Node.DocumentName;
             form.MainSource["Main.Description"].AsString   = document.Node.DocumentName;
             form.MainSource["Main.StartDocument"].AsString = String.Format(".Frontend.Form('{0}', '{1}')", document.Node.LibraryName.Replace("'", "''"), document.Node.DocumentName.Replace("'", "''"));
             librariesSource.Insert();
             librariesSource["Main.Library_Name"].AsString = document.Node.LibraryName;
             librariesSource.Post();
         }
         else
         {
             TableData table = args.Data as TableData;
             if (table != null)
             {
                 form.MainSource["Main.ID"].AsString            = table.Node.ObjectName;
                 form.MainSource["Main.Description"].AsString   = table.Node.ObjectName;
                 form.MainSource["Main.StartDocument"].AsString = String.Format(".Frontend.Derive('{0}')", table.Node.ObjectName.Replace("'", "''"));
                 librariesSource.Insert();
                 librariesSource["Main.Library_Name"].AsString = ((SchemaListNode)table.Node.Parent).LibraryName;
                 librariesSource.Post();
             }
         }
         if (form.ShowModal(Frontend.Client.FormMode.Insert) != DialogResult.OK)
         {
             throw new AbortException();
         }
         BaseNode node = CreateChildNode(form.MainSource.DataView.ActiveRow);
         AddNode(node);
         TreeView.SelectedNode = node;
     }
     finally
     {
         form.HostNode.Dispose();
     }
 }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
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;
			}
		}
Exemplo n.º 5
0
        public static string Execute(DocumentExpression documentExpression)
        {
            IDataphoria dataphoria = Program.DataphoriaInstance;

            Frontend.Client.Windows.IWindowsFormInterface form = dataphoria.FrontendSession.LoadForm(null, ".Frontend.Form('Frontend', 'DocumentExpressionEditor')", new Frontend.Client.FormInterfaceHandler(SetEditOpenState));
            try
            {
                Frontend.Client.INotebook notebook = (Frontend.Client.INotebook)form.FindNode("Notebook");
                Frontend.Client.ISource   source   = form.MainSource;
                switch (documentExpression.Type)
                {
                case DocumentType.Document:
                    notebook.ActivePage = (Frontend.Client.INotebookPage)form.FindNode("nbpLoad");
                    source.DataView.Fields["Library_Name"].AsString  = documentExpression.DocumentArgs.LibraryName;
                    source.DataView.Fields["Document_Name"].AsString = documentExpression.DocumentArgs.DocumentName;
                    break;

                case DocumentType.Derive:
                    notebook.ActivePage = (Frontend.Client.INotebookPage)form.FindNode("nbpDerive");
                    form.MainSource.DataView["Query"].AsString      = documentExpression.DeriveArgs.Query;
                    form.MainSource.DataView["PageType"].AsString   = documentExpression.DeriveArgs.PageType;
                    form.MainSource.DataView["MKN"].AsString        = documentExpression.DeriveArgs.MasterKeyNames;
                    form.MainSource.DataView["DKN"].AsString        = documentExpression.DeriveArgs.DetailKeyNames;
                    form.MainSource.DataView["Elaborate"].AsBoolean = documentExpression.DeriveArgs.Elaborate;
                    break;

                default:
                    notebook.ActivePage = (Frontend.Client.INotebookPage)form.FindNode("nbpOther");
                    form.MainSource.DataView["Expression"].AsString = documentExpression.Expression;
                    break;
                }
                if (form.ShowModal(Frontend.Client.FormMode.Edit) != DialogResult.OK)
                {
                    throw new AbortException();
                }
                if ((notebook.ActivePage.Name) == "nbpLoad")
                {
                    documentExpression.Type = DocumentType.Document;
                    documentExpression.DocumentArgs.LibraryName  = form.MainSource.DataView["Library_Name"].AsString;
                    documentExpression.DocumentArgs.DocumentName = form.MainSource.DataView["Document_Name"].AsString;
                }
                else if ((notebook.ActivePage.Name) == "nbpDerive")
                {
                    documentExpression.Type                      = DocumentType.Derive;
                    documentExpression.DeriveArgs.Query          = form.MainSource.DataView["Query"].AsString;
                    documentExpression.DeriveArgs.PageType       = form.MainSource.DataView["PageType"].AsString;
                    documentExpression.DeriveArgs.MasterKeyNames = form.MainSource.DataView["MKN"].AsString;
                    documentExpression.DeriveArgs.DetailKeyNames = form.MainSource.DataView["DKN"].AsString;
                    documentExpression.DeriveArgs.Elaborate      = form.MainSource.DataView["Elaborate"].AsBoolean;
                }
                else if ((notebook.ActivePage.Name) == "nbpOther")
                {
                    documentExpression.Type       = DocumentType.Other;
                    documentExpression.Expression = form.MainSource.DataView["Expression"].AsString;
                }
                return(documentExpression.Expression);
            }
            finally
            {
                form.Dispose();
            }
        }
Exemplo n.º 6
0
        private void LoadToggleClicked(object sender, EventArgs args)
        {
            Dataphoria.Warnings.ClearErrors(Dataphoria);
            if (!Registered)
            {
                try
                {
                    DAE.IServerCursor cursor =
                        Dataphoria.OpenCursor
                        (
                            String.Format
                            (
                                @"
									select 
										RequiredLibraries('{0}') 
											group by {{ Library_Name }}
											add {{ Max(Level) Level }}
											where not exists (System.LoadedLibraries where Name = Library_Name) 
											order by {{ Level desc }};
								"                                ,
                                _libraryName
                            )
                        );
                    try
                    {
                        using (DAE.Runtime.Data.IRow row = cursor.Plan.RequestRow())
                        {
                            while (cursor.Next())
                            {
                                cursor.Select(row);
                                try
                                {
                                    Dataphoria.ExecuteScript(String.Format("RegisterLibrary('{0}', false);", (string)row["Library_Name"]));
                                }
                                catch (Exception exception)
                                {
                                    Dataphoria.Warnings.AppendError(Dataphoria, exception, false);
                                }
                            }
                        }
                    }
                    finally
                    {
                        Dataphoria.CloseCursor(cursor);
                    }

                    try
                    {
                        Dataphoria.ExecuteScript(String.Format("RegisterLibrary('{0}', false);", _libraryName));
                    }
                    catch (Exception exception)
                    {
                        Dataphoria.Warnings.AppendError(Dataphoria, exception, false);
                    }
                }
                finally
                {
                    ((LibraryListNode)Parent).RefreshRegistered();
                }
                ((LibraryListNode)Parent).RefreshCurrent();
            }
            else
            {
                try
                {
                    using (Frontend.Client.Windows.IWindowsFormInterface form = (Frontend.Client.Windows.IWindowsFormInterface)Dataphoria.FrontendSession.CreateForm())
                    {
                        Dataphoria.FrontendSession.CreateHost().Load(".Frontend.Form('Frontend', 'UnloadLibrary')", form);
                        form.MainSource.Filter = GetFilter();
                        form.HostNode.Open();
                        if (form.ShowModal(Frontend.Client.FormMode.Query) != DialogResult.OK)
                        {
                            throw new AbortException();
                        }
                        DAE.Client.DataView view = ((Frontend.Client.ISource)form.FindNode("Dependencies")).DataView;
                        view.First();
                        foreach (DAE.Runtime.Data.Row row in view)
                        {
                            try
                            {
                                Dataphoria.ExecuteScript(String.Format("UnregisterLibrary('{0}', false);", (string)row["Library_Name"]));
                            }
                            catch (Exception exception)
                            {
                                Dataphoria.Warnings.AppendError(Dataphoria, exception, false);
                            }
                        }
                    }

                    try
                    {
                        Dataphoria.ExecuteScript(String.Format("UnregisterLibrary('{0}', false);", _libraryName));
                    }
                    catch (Exception exception)
                    {
                        Dataphoria.Warnings.AppendError(Dataphoria, exception, false);
                    }
                    _canLoad = true;
                }
                finally
                {
                    ((LibraryListNode)Parent).RefreshCurrent();
                    ((LibraryListNode)Parent).RefreshRegistered();
                }
            }
        }