Пример #1
0
 public SQLWord()
 {
     WordType         = EWordType.Unknown;
     Word             = "";
     Definition       = "";
     SQLColumn        = null;
     SQLTable         = null;
     Parent           = null;
     Child            = null;
     Number           = 0;
     CharBeforeNumber = ECharBeforeNumber.Unknown;
 }
Пример #2
0
        private bool hasValidParentTable()
        {
            SQLWord sqlWord = this;

            while (sqlWord != null && sqlWord.Parent != null)
            {
                if (sqlWord.isValidTable())
                {
                    this.SQLTable = sqlWord.SQLTable;
                    return(true);
                }
                else
                {
                    sqlWord = sqlWord.Parent;
                }
            }
            ;
            return(false);
        }
Пример #3
0
        public bool hasValidParentColumn()
        {
            SQLWord sqlWord = this;

            while (sqlWord != null && sqlWord.Parent != null)
            {
                if (sqlWord.isValidColumn())
                {
                    this.SQLColumn = sqlWord.SQLColumn;
                    if (sqlWord.SQLTable != null)
                    {
                        SQLColumn = string.Format("{0}.{1}", sqlWord.SQLTable, SQLColumn);
                    }
                    return(true);
                }
                else
                {
                    sqlWord = sqlWord.Parent;
                }
            }
            ;
            return(false);
        }
Пример #4
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;
        }
Пример #5
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;
        }