Exemple #1
0
        public static void Output(this object value, int lineNumber = -1)
        {
            if (Program.CommandLineMode)
            {
                Info(string.Format(lineNumber != -1 ? "Script output line #{0}: {1}" : "Script output: {1}", lineNumber, value));
                return;
            }

            if (ScriptOutputForm.DontShow)
            {
                return;
            }

            var caption = string.Format("Script output{0}", lineNumber > 0 ? " at line " + lineNumber : "");

            var isHourglass = Hourglass.Enabled;

            if (isHourglass)
            {
                Hourglass.Enabled = false;
            }
            ScriptOutputForm.ShowObject(value, caption);
            if (isHourglass)
            {
                Hourglass.Enabled = true;
            }
        }
Exemple #2
0
        public static void OutputErrors(IEnumerable <TabularNamedObject> items)
        {
            if (ScriptOutputForm.DontShow)
            {
                return;
            }

            var caption = string.Format("Objects with errors ({0})", items.Count());

            ScriptOutputForm.ShowObject(items, caption, true);
        }
        public static void Output(this object value, int lineNumber = -1)
        {
            // TODO: Make this output to the console, when running in command-line mode

            if (ScriptOutputForm.DontShow)
            {
                return;
            }

            var caption = string.Format("Script output{0}", lineNumber > 0 ? " at line " + lineNumber : "");

            var isHourglass = Hourglass.Enabled;

            if (isHourglass)
            {
                Hourglass.Enabled = false;
            }
            ScriptOutputForm.ShowObject(value, caption);
            if (isHourglass)
            {
                Hourglass.Enabled = true;
            }
        }
Exemple #4
0
        public static void ShowObject(object value, string caption, bool errorObjects = false)
        {
            if (DormantForm != null && DormantForm.Visible)
            {
                DormantForm.Close();
            }
            DormantForm = new ScriptOutputForm();

            DormantForm.Text       = caption;
            DormantForm.ShowErrors = errorObjects;
            if (DormantForm.ShowErrors)
            {
                DormantForm.chkDontShow.Visible           = false;
                DormantForm.DataListView.Width            = (DormantForm.Width * 3) / 5;
                DormantForm.DataListView.Columns[1].Name  = "Error";
                DormantForm.DataListView.Columns[1].Width = 500;
            }
            else
            {
                DormantForm.chkDontShow.Visible           = true;
                DormantForm.DataListView.Width            = DormantForm.Width / 2;
                DormantForm.DataListView.Columns[1].Name  = "Type";
                DormantForm.DataListView.Columns[1].Width = DormantForm.DataListView.Width - DormantForm.DataListView.Columns[0].Width - 5;
            }

            var testTabularObject = value as TabularObject;

            IEnumerable <ITabularNamedObject> testTabularCollection;

            if (value is IEnumerable <IDaxDependantObject> )
            {
                // Most IDaxDependantObjects are ITabularNamedObjects, with the exception of RLSFilterExpression.
                // So if we encounter an enumeration of IDaxDependantObjects lets convert it to an enumeration of
                // ITabularNamedObjects. If there are any RLSFilterExpressions in the enumeration, output their
                // corresponding roles instead.
                var v = (value as IEnumerable <IDaxDependantObject>);
                testTabularCollection = v.OfType <ITabularNamedObject>()
                                        .Concat(v.OfType <RLSFilterExpression>().Select(rls => rls.Role));
            }
            else
            {
                testTabularCollection = value as IEnumerable <ITabularNamedObject>;
            }
            var testDictionary = value as IDictionary;
            var testList       = value as IEnumerable <object>;

            if (value == null)
            {
                ShowString("(Null)");
            }
            else if (testTabularObject != null)
            {
                ShowTabularObject(testTabularObject);
            }
            else if (testTabularCollection != null)
            {
                ShowTabularObjectCollection(testTabularCollection);
            }
            else if (testDictionary != null)
            {
                ShowObjectDictionary(testDictionary);
            }
            else if (testList != null)
            {
                ShowObjectCollection(testList);
            }
            else
            {
                ShowString(value.ToString());
            }

            if (errorObjects)
            {
                DormantForm.Show();
                DormantForm.BringToFront();
                DormantForm.Activate();
            }
            else
            {
                if (DormantForm.Visible)
                {
                    DormantForm.Visible = false;
                }
                DormantForm.ShowDialog();
            }

            DontShow = DormantForm.chkDontShow.Checked;
        }
        public static void ShowObject(object value, string caption, bool errorObjects = false)
        {
            if (DormantForm != null && DormantForm.Visible)
            {
                DormantForm.Close();
            }
            DormantForm = new ScriptOutputForm();

            DormantForm.Text       = caption;
            DormantForm.ShowErrors = errorObjects;
            if (DormantForm.ShowErrors)
            {
                DormantForm.chkDontShow.Visible           = false;
                DormantForm.DataListView.Width            = (DormantForm.Width * 3) / 5;
                DormantForm.DataListView.Columns[1].Name  = "Error";
                DormantForm.DataListView.Columns[1].Width = 500;
            }
            else
            {
                DormantForm.chkDontShow.Visible           = true;
                DormantForm.DataListView.Width            = DormantForm.Width / 2;
                DormantForm.DataListView.Columns[1].Name  = "Type";
                DormantForm.DataListView.Columns[1].Width = DormantForm.DataListView.Width - DormantForm.DataListView.Columns[0].Width - 5;
            }

            var testTabularObject     = value as TabularObject;
            var testTabularCollection = value as IEnumerable <ITabularNamedObject>;
            var testDictionary        = value as IDictionary;
            var testList = value as IEnumerable <object>;

            if (value == null)
            {
                ShowString("(Null)");
            }
            else if (testTabularObject != null)
            {
                ShowTabularObject(testTabularObject);
            }
            else if (testTabularCollection != null)
            {
                ShowTabularObjectCollection(testTabularCollection);
            }
            else if (testDictionary != null)
            {
                ShowObjectDictionary(testDictionary);
            }
            else if (testList != null)
            {
                ShowObjectCollection(testList);
            }
            else
            {
                ShowString(value.ToString());
            }

            if (errorObjects)
            {
                DormantForm.Show();
                DormantForm.BringToFront();
                DormantForm.Activate();
            }
            else
            {
                if (DormantForm.Visible)
                {
                    DormantForm.Visible = false;
                }
                DormantForm.ShowDialog();
            }

            DontShow = DormantForm.chkDontShow.Checked;
        }