createFieldList() 공개 메소드

public createFieldList ( String tableName, String fields ) : QvxField[]
tableName String
fields String
리턴 QvxField[]
        public override QvxDataTable ExtractQuery(string query, List <QvxTable> qvxTables)
        {
            QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Notice, "Extracting Query");
            //Debugger.Launch();
            //NOTE: Where clause not yet supported
            String fields = "";

            String where = "";
            query        = query.Replace("\r\n", " ");
            try
            {
                Match match;
                if (query.ToUpper().Contains(" WHERE "))
                {
                    match = Regex.Match(query, @"SELECT\s+(?<fields>.+)\sFROM\s+(?<table>.+)\sWHERE\s+(?<where>.+)", RegexOptions.IgnoreCase);
                }
                else
                {
                    match = Regex.Match(query, @"SELECT\s+(?<fields>.+)\sFROM\s+(?<table>\w+)", RegexOptions.IgnoreCase);
                }
                if (!match.Success)
                {
                    QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Error, string.Format("ExtractQueryAndTransmitTableHeader() - QvxPleaseSendReplyException({0}, \"Invalid query: {1}\")", QvxResult.QVX_SYNTAX_ERROR, query));
                }
                //Establish Table Name
                fields = match.Groups["fields"].Value;
                fields = fields.Trim();
                if (match.Groups["where"] != null)
                {
                    where = match.Groups["where"].Value;
                    where = where.Trim();
                }
                liveTable = match.Groups["table"].Value;
            }
            catch (Exception ex)
            {
                QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Error, ex.Message);
            }
            if (!String.IsNullOrEmpty(liveTable) && helper != null)
            {
                helper.SetActiveTable(liveTable, where);
                //Create QvxTable based on fields in Select statement
                MTables = new List <QvxTable>();
                QvxTable qT = new QvxTable {
                    TableName = liveTable, Fields = helper.createFieldList(liveTable, fields), GetRows = GetData
                };
                MTables.Add(qT);
                return(new QvxDataTable(qT));
            }
            return(null);

            //return table
        }
예제 #2
0
        public override QvxDataTable ExtractQuery(string query, List <QvxTable> qvxTables)
        {
            QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Notice, "Extracting Query");
            //Debugger.Launch();
            //NOTE: Where clause not yet supported
            String fields = "";

            String where = "";
            Int16 limit;

            query = query.Replace("\r\n", " ").Replace("\n", " ");
            try
            {
                Match match;
                match = Regex.Match(query, @"(?:select\s(?<fields>[^\/\r\n]*))\s(?:from\s(?<table>[^\/\r\n\s]+))\s*(?:where\s(?<where>[^\r\n\s]*))?(?:\s*)(?:limit\s(?<limit>[^\/\r\n\s]*))?(?:\s*)(?<cache>cache)?", RegexOptions.IgnoreCase);

                if (!match.Success)
                {
                    QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Error, string.Format("ExtractQueryAndTransmitTableHeader() - QvxPleaseSendReplyException({0}, \"Invalid query: {1}\")", QvxResult.QVX_SYNTAX_ERROR, query));
                }
                //Establish Table Name
                fields = match.Groups["fields"].Value;
                fields = fields.Trim();
                if (match.Groups["where"] != null)
                {
                    where = match.Groups["where"].Value;
                    where = where.Trim();
                }
                if (match.Groups["limit"] != null)
                {
                    try
                    {
                        limit = Int16.Parse(match.Groups["limit"].Value);
                        helper.pageInfo.LoadLimit = limit;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                liveTable = match.Groups["table"].Value;
                if (match.Groups["cache"].Value.ToLower() == "cache")
                {
                    helper.addTableToCacheList(liveTable);
                }
            }
            catch (Exception ex)
            {
                QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Error, ex.Message);
            }
            if (!String.IsNullOrEmpty(liveTable) && helper != null)
            {
                helper.SetActiveTable(liveTable, where);
                //Create QvxTable based on fields in Select statement
                MTables = new List <QvxTable>();
                QvxTable qT = new QvxTable {
                    TableName = liveTable, Fields = helper.createFieldList(liveTable, fields), GetRows = GetData
                };
                MTables.Add(qT);
                return(new QvxDataTable(qT));
            }
            return(null);

            //return table
        }