Beispiel #1
0
        public string ToString(MdxScriptCommandDisplayOption displayOption)
        {
            string helper;
            string ret = "";

            switch (displayOption)
            {
            case MdxScriptCommandDisplayOption.Original:
                ret = _text;
                break;

            case MdxScriptCommandDisplayOption.Original_Trimmed:
                ret = _text.Trim();
                break;

            case MdxScriptCommandDisplayOption.NoComments:
                ret = MdxScriptHelper.StripComments(_text);
                break;

            case MdxScriptCommandDisplayOption.NoComments_Trimmed:
                ret = MdxScriptHelper.StripComments(_text).Trim();
                break;

            case MdxScriptCommandDisplayOption.SingleLine:
                helper = this.ToString(MdxScriptCommandDisplayOption.NoComments_Trimmed);
                ret    = Regex.Replace(helper, "(\r\n|\r|\n)", "");
                break;

            case MdxScriptCommandDisplayOption.SingleLine_Indented:
                helper = this.ToString(MdxScriptCommandDisplayOption.SingleLine);
                ret    = new string(' ', 4 * this._nestingLevel) + this.ToString(MdxScriptCommandDisplayOption.SingleLine);
                break;

            case MdxScriptCommandDisplayOption.Console:
                helper = this.ToString(MdxScriptCommandDisplayOption.SingleLine);
                ret    = string.Format("{0,5} | {1,10:#,0} ms  |  {2}", CommandNumber, Duration, helper.SafeLeft(50));
                break;

            default:
                return("");
            }

            return(ret);
        }
Beispiel #2
0
        public static MdxScriptCommandType ParseCommandType(string command)
        {
            string helper = MdxScriptHelper.StripComments(command).ToUpper().Trim();

            if (helper.StartsWith("CALCULATE"))
            {
                return(MdxScriptCommandType.CALCULATE);
            }
            else if (helper.StartsWith("CLEAR CALCULATIONS"))
            {
                return(MdxScriptCommandType.CLEAR_CALCULATIONS);
            }
            else if (helper.StartsWith("ALTER"))
            {
                return(MdxScriptCommandType.ALTER_CUBE);
            }
            else if (helper.StartsWith("SCOPE"))
            {
                return(MdxScriptCommandType.SCOPE);
            }
            else if (helper.StartsWith("END SCOPE"))
            {
                return(MdxScriptCommandType.END_SCOPE);
            }
            else if (helper.StartsWith("THIS"))
            {
                return(MdxScriptCommandType.THIS_ASSIGNMENT);
            }
            else if (helper.StartsWith("("))    // ([Dim].[Hier].&[Key1]) = 1;
            {
                return(MdxScriptCommandType.DIRECT_ASSIGNMENT);
            }
            else if (helper.StartsWith("["))    // [Dim].[Hier].&[Key1] = 1;
            {
                return(MdxScriptCommandType.DIRECT_ASSIGNMENT);
            }
            else if (helper.StartsWith("CREATE MEMBER"))
            {
                return(MdxScriptCommandType.CREATE_MEMBER);
            }
            else if (helper.StartsWith("CREATE CELL CALCULATION"))
            {
                return(MdxScriptCommandType.CELL_CALCULATION);
            }
            else if (helper.StartsWith("CREATE"))
            {
                return(MdxScriptCommandType.CREATE_SET);
            }
            else if (helper.StartsWith("FREEZE"))
            {
                return(MdxScriptCommandType.FREEZE);
            }
            else if (helper.StartsWith("FORMAT_STRING"))
            {
                return(MdxScriptCommandType.FORMATTING);
            }
            else if (helper.StartsWith("FORE_COLOR"))
            {
                return(MdxScriptCommandType.FORMATTING);
            }
            else if (helper.StartsWith("BACK_COLOR"))
            {
                return(MdxScriptCommandType.FORMATTING);
            }
            else
            {
                return(MdxScriptCommandType.Other);
            }
        }