Exemplo n.º 1
0
        /// <summary>
        /// Opens the testing environment window. When closed the execution proceeds. The testing does not affect the data state of the execution.
        /// </summary>
        /// <param name="view">A view object.</param>
        /// <param name="title">A title that will appear in the window.</param>
        /// <param name="option">An option that specifies whether the testing environment window should open, should open and execute, or should be skipped.</param>
        public static View Test(this View view, string title, TestingOption option = TestingOption.OpenAndExecute)
        {
            return(PublicInvoker.Call <View>(Assembly.GetCallingAssembly(), (ca) =>
            {
                var connectable = Reader.GetConnectable(ca, (Chainer)view);
                if (!Admin.IsTestingEnvironmentOff(ca) && option != TestingOption.Skip)
                {
                    using (var form = new TestingForm(connectable, option, title))
                    {
                        form.ShowDialog();
                    }
                }

                return view;
            }));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Opens the testing environment window. When closed the execution proceeds. The testing does not affect the data state of the execution.
        /// </summary>
        /// <param name="prev">A predecessor object.</param>
        /// <param name="option">An option that specifies whether the testing environment window should open, should open and execute, or should be skipped.</param>
        public static Connectable Test(this IGo prev, TestingOption option = TestingOption.OpenAndExecute)
        {
            return(PublicInvoker.Call <Connectable>(Assembly.GetCallingAssembly(), (ca) =>
            {
                var connectable = Reader.GetConnectable(ca, (Chainer)prev);
                if (!Admin.IsTestingEnvironmentOff(ca) && option != TestingOption.Skip)
                {
                    using (var form = new TestingForm(connectable, option, null))
                    {
                        form.ShowDialog();
                    }
                }

                return connectable;
            }));
        }
Exemplo n.º 3
0
        internal TestingForm(Connectable connectable, TestingOption option, string title)
        {
            try
            {
                _connectable = connectable;                     // store connectable object which may be used after the testing, for the execution
                _body        = connectable.Executable.Body;     // store body
                InitializeComponent();

                _offToolTip = new ToolTip();
                _offToolTip.SetToolTip(_off, "Close and set Testing Environment OFF.");
                _interruptToolTip = new ToolTip();
                _interruptToolTip.SetToolTip(_interrupt, "Interrupt the execution of the Testing Environment");

                _params = new Dictionary <string, TVP>();

                this.ShowIcon    = false;
                Text             = String.Format("{0} | {1}", Wall.Text.Free.QtTesting, ParseConnString());
                _statusRows.Text = null;

                var name = ((IName)_connectable).Name;
                if (title != null)
                {
                    _name.Text       = title;
                    _statusName.Text = title;
                }
                else if (name != null)
                {
                    _name.Text       = name;
                    _statusName.Text = (name == Wall.Text.NotAvailable) ? null : name;
                }
                else
                {
                    _name.Text       = Wall.Text.NotAvailable;
                    _statusName.Text = null;
                }

                _sql.Text = _connectable.Body;

                _tranCodeInfo = new TransactionCodeInfo(_connectable.Body);

                // if compilable object is a stored procedure, show extra message
                if (_connectable.Executable.Compilable.CompilableType == Compilable.ObjectType.StoredProc)
                {
                    ShowMessage(Wall.Text.Free.StoredProcTestMessage);
                }

                _sqlContextMenu = new ContextMenuStrip();
                ToolStripMenuItem menuItem = new ToolStripMenuItem(Wall.Text.Free.RestoreSQL,
                                                                   Properties.Resources.restore,
                                                                   (o, e) =>
                {
                    _sql.ThreadSafeInvoke(new Action(() => _sql.Text = _body));
                });
                _sqlContextMenu.Items.Add(menuItem);
                _sql.ContextMenuStrip = _sqlContextMenu;

                AddEventHandlers();
                ShowParameterGrid();

                // clear loader cache
                //   note:
                //     We clear cache in order to remove all mapped loaders that contain graph objects (associations)
                //     that cannot be shown in the grid. Otherwise the grid does not show the correct data.
                Cache.Loaders.Clear();

                this.Load += (o, e) =>
                {
                    try
                    {
                        if (option == TestingOption.OpenAndExecute)
                        {
                            Run();
                        }
                    }
                    catch (Exception ex)
                    {
                        ShowException(ex);
                    }
                };
            }
            catch (System.Exception ex)
            {
                throw ClrException(ex);
            }
        }
Exemplo n.º 4
0
        private static DbTable <T> _Test <T>(Assembly ca, DbTable <T> node, string title, TestingOption option)
            where T : DbRow
        {
            if (Admin.IsTestingEnvironmentOff(ca) || option == TestingOption.Skip)
            {
                return(node);
            }

            // handle reusability - !
            var node2 = node.RootWithBrokenChain ?? node.Root;

            Chainer query;

            if (node2.IsPureSubject())
            {
                query = new SelectChainer((ISemantic)node2, new Column[] { }, false).Top(Admin.TestSelectTopRows);
            }
            else
            {
                query = new SelectChainer((ISemantic)node2, new Column[] { }, false);
            }

            var connectable = Reader.GetConnectable(ca, query);

            using (var form = new TestingForm(connectable, option, title))
            {
                form.ShowDialog();
            }

            node2.Recover();

            return(node);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Opens the testing environment window. When closed the execution proceeds. The testing does not affect the data state of the execution.
 /// </summary>
 /// <typeparam name="T">The type of a subject node.</typeparam>
 /// <param name="node">A semantic sentence.</param>
 /// <param name="title">A title that will appear in the window.</param>
 /// <param name="option">An option that specifies whether the testing environment window should open, should open and execute, or should be skipped.</param>
 public static DbTable <T> Test <T>(this DbTable <T> node, string title, TestingOption option = TestingOption.OpenAndExecute)
     where T : DbRow
 {
     node.CheckNullAndThrow(Text.Free.Sentence, Text.Method.Test);
     return(_Test(Assembly.GetCallingAssembly(), node, title, option));
 }