Example #1
0
        public void Initialize(Bot ChatBot, User ChatUser, string FieldName)
        {
            this.Word = FieldName;
            SQLWord sqlWord       = this;
            SQLWord sqlWordParent = null;

            while (sqlWord.Word != null && sqlWord.Word != string.Empty)
            {
                try
                {
                    string fieldDesc = AIMLWhatIs(sqlWord.Word, ChatBot, ChatUser);
                    string fieldType = AIMLWhatTypeIs(sqlWord.Word, ChatBot, ChatUser);

                    if (IsNumber(FieldName, ChatBot, ChatUser))
                    {
                        fieldType = "NUMBER";
                    }
                    else if (IsMonth(FieldName, ChatBot, ChatUser))
                    {
                        fieldType = "MONTH";
                    }


                    switch (fieldDesc)
                    {
                    case "UNKNOWN":
                        sqlWord.Definition = null;
                        break;

                    default:
                        sqlWord.Definition = fieldDesc;
                        break;
                    }
                    ;

                    switch (fieldType)
                    {
                    case "NUMBER":
                        sqlWord.WordType = EWordType.Number;
                        break;

                    case "TABLE":
                        sqlWord.WordType = EWordType.Table;
                        break;

                    case "FIELD":
                        sqlWord.WordType = EWordType.Field;
                        break;

                    case "VALUE":
                        sqlWord.WordType = EWordType.Value;
                        break;

                    case "FUNCTION":
                        sqlWord.WordType = EWordType.Function;
                        break;

                    case "DATE":
                        sqlWord.WordType = EWordType.Date;
                        break;

                    case "DATE PERIOD":
                        sqlWord.WordType = EWordType.Date;
                        break;

                    case "MONTH":
                        sqlWord.WordType = EWordType.Month;
                        break;

                    case "DATE AFFIX":
                        sqlWord.WordType = EWordType.DateAffix;
                        break;

                    case "UNKNOWN":
                    default:
                        sqlWord.WordType = EWordType.Unknown;
                        break;
                    }
                    ;

                    string[]        sqlTables = null;
                    string[]        sqlFields = null;
                    SQLBot_Function function  = null;

                    if (IsTableName(sqlWord.Word, out sqlTables) && sqlTables.Length > 0)
                    {
                        SQLTable = sqlTables[0];
                    }

                    if (IsFieldName(sqlWord.Word, out sqlFields, out sqlTables))
                    {
                        if (sqlFields.Length > 0)
                        {
                            SQLColumn = sqlFields[0];
                        }
                        if (sqlTables.Length > 0)
                        {
                            SQLTable = sqlTables[0];
                        }

                        if (SQLTable != null && SQLColumn != null)
                        {
                            SQLColumn = string.Format("{0}.{1}", SQLTable, SQLColumn);
                        }
                    }

                    if (IsFunctionName(sqlWord.Word, ChatBot, ChatUser, out function))
                    {
                        SQLFunction = new SQLFunction(function);
                    }
                }
                catch (Exception)
                { }
                finally
                {   // Tutaj jest źle!
                    if (sqlWordParent != null)
                    {
                        sqlWordParent.Child = sqlWord;
                    }

                    sqlWord.Parent = sqlWordParent;

                    sqlWordParent = sqlWord;
                    sqlWord       = new SQLWord();
                    sqlWord.Word  = sqlWordParent.Definition;

                    /*
                     * sqlWord.Parent = sqlWordParent;
                     * sqlWordParent = sqlWord;
                     * sqlWord = new SQLWord();
                     * sqlWord.Word = sqlWordParent.Definition;
                     *
                     * sqlWordParent.Child = sqlWord;
                     */
                }
            }
            ;

            sqlWordParent.Child = null;
        }
Example #2
0
        public void Initialize(Bot ChatBot, User ChatUser, string FieldName)
        {
            this.Word = FieldName;
            SQLWord sqlWord = this;
            SQLWord sqlWordParent = null;

            while (sqlWord.Word != null && sqlWord.Word != string.Empty)
            {
                try
                {
                    string fieldDesc = AIMLWhatIs(sqlWord.Word, ChatBot, ChatUser);
                    string fieldType = AIMLWhatTypeIs(sqlWord.Word, ChatBot, ChatUser);

                    if (IsNumber(FieldName, ChatBot, ChatUser))
                    {
                        fieldType = "NUMBER";
                    }
                    else if (IsMonth(FieldName, ChatBot, ChatUser))
                    {
                        fieldType = "MONTH";
                    }

                    switch (fieldDesc)
                    {
                        case "UNKNOWN":
                            sqlWord.Definition = null;
                            break;
                        default:
                            sqlWord.Definition = fieldDesc;
                            break;
                    };

                    switch (fieldType)
                    {
                        case "NUMBER":
                            sqlWord.WordType = EWordType.Number;
                            break;
                        case "TABLE":
                            sqlWord.WordType = EWordType.Table;
                            break;
                        case "FIELD":
                            sqlWord.WordType = EWordType.Field;
                            break;
                        case "VALUE":
                            sqlWord.WordType = EWordType.Value;
                            break;
                        case "FUNCTION":
                            sqlWord.WordType = EWordType.Function;
                            break;
                        case "DATE":
                            sqlWord.WordType = EWordType.Date;
                            break;
                        case "DATE PERIOD":
                            sqlWord.WordType = EWordType.Date;
                            break;
                        case "MONTH":
                            sqlWord.WordType = EWordType.Month;
                            break;
                        case "DATE AFFIX":
                            sqlWord.WordType = EWordType.DateAffix;
                            break;
                        case "UNKNOWN":
                        default:
                            sqlWord.WordType = EWordType.Unknown;
                            break;
                    };

                    string[] sqlTables = null;
                    string[] sqlFields = null;
                    SQLBot_Function function = null;

                    if (IsTableName(sqlWord.Word, out sqlTables) && sqlTables.Length > 0)
                        SQLTable = sqlTables[0];

                    if (IsFieldName(sqlWord.Word, out sqlFields, out sqlTables))
                    {
                        if(sqlFields.Length > 0)
                            SQLColumn = sqlFields[0];
                        if (sqlTables.Length > 0)
                            SQLTable = sqlTables[0];

                        if(SQLTable != null && SQLColumn !=null)
                        {
                            SQLColumn = string.Format("{0}.{1}", SQLTable, SQLColumn);
                        }
                    }

                    if(IsFunctionName(sqlWord.Word, ChatBot, ChatUser, out function))
                    {
                        SQLFunction = new SQLFunction(function);
                    }
                }
                catch(Exception)
                { }
                finally
                {   // Tutaj jest źle!
                    if(sqlWordParent != null)
                    {
                        sqlWordParent.Child = sqlWord;
                    }

                    sqlWord.Parent = sqlWordParent;

                    sqlWordParent = sqlWord;
                    sqlWord = new SQLWord();
                    sqlWord.Word = sqlWordParent.Definition;

                    /*
                    sqlWord.Parent = sqlWordParent;
                    sqlWordParent = sqlWord;
                    sqlWord = new SQLWord();
                    sqlWord.Word = sqlWordParent.Definition;

                    sqlWordParent.Child = sqlWord;
                    */
                }
            };

            sqlWordParent.Child = null;
        }