示例#1
0
    public void DeleteRows(Statement queryObj, IRootServerCallback callback)
    {
      DeleteRows deleteRows = (DeleteRows)queryObj;
      List<TernaryAssociative<string, string, string>> whereList = new List<TernaryAssociative<string, string, string>>();
      
      m_Request = new Request();
      m_Parameters = new Object[3];
      m_Parameters[0] = GetDatabaseName(m_token);
      m_Parameters[1] = deleteRows.GetTableName();

      if (deleteRows.GetWhereListFlag() == true)
      {
        List<WhereEntry> whereEntries = deleteRows.GetWhereList().GetSubWhereList().GetWhereEntryList();
        foreach (WhereEntry whereEntry in whereEntries)
        {
          TernaryAssociative<string, string, string> item = new TernaryAssociative<string, string, string>();
          item.First = whereEntry.GetColumnName();
          item.Second = whereEntry.GetComparisonOperatorType().ToString();

          if (whereEntry.GetColumnValue().GetColumnValueType() == ColValueType.STRING)
          {
            item.Third = whereEntry.GetColumnValue().GetStringColumnValue();
          }
          else if (whereEntry.GetColumnValue().GetColumnValueType() == ColValueType.INTEGER)
          {
            item.Third = whereEntry.GetColumnValue().GetIntColumnValue().ToString();
          }
          else if (whereEntry.GetColumnValue().GetColumnValueType() == ColValueType.DOUBLE)
          {
            item.Third = whereEntry.GetColumnValue().GetDoubleColumnValue().ToString();
          }
          whereList.Add(item);
        }
      }
      m_Parameters[2] = whereList;
      
      m_Request.SetCallingMethod("DeleteRow");
      m_Request.SetRequestType(RequestType.EXECUTE_QUERY);
      m_Request.SetRootServerCallback(callback);
      m_Request.SetMethodParameters(m_Parameters);
    }
示例#2
0
    public void SelectRow(Statement queryObj, IRootServerCallback callback)
    {
      SelectRows selectRows = (SelectRows)queryObj;
      List<TernaryAssociative<string, string, string>> whereList = new List<TernaryAssociative<string, string, string>>();
      List<KeyValuePair<string, string>> orderByColumns = new List<KeyValuePair<string, string>>();

      m_Request = new Request();
      m_Parameters = new Object[8];
      m_Parameters[0] = GetDatabaseName(m_token);
      m_Parameters[1] = selectRows.GetTableName();
      if(selectRows.GetSelectRowTableColList().GetSelectRowColumnType() == SelectRowColumnType.ALL_COLUMNS)
      {
        m_Parameters[2] = new List<string>();
        m_Parameters[3] = "";
      }
      else if (selectRows.GetSelectRowTableColList().GetSelectRowColumnType() == SelectRowColumnType.SPECIFIC_COLUMNS)
      {
        m_Parameters[2] = selectRows.GetSelectRowTableColList().GetTableColumnList().GetList();
        m_Parameters[3] = "";
      }
      else if (selectRows.GetSelectRowTableColList().GetSelectRowColumnType() == SelectRowColumnType.COUNT_ROWS)
      {
        m_Parameters[2] = new List<string>();
        if(selectRows.GetSelectRowTableColList().GetCountRows().GetCountAllRowsFlag() == true)
          m_Parameters[3] = "*";
        else
          m_Parameters[3] = selectRows.GetSelectRowTableColList().GetCountRows().GetColumnName();
      }
      if (selectRows.GetWhereListFlag() == true)
      {
        List<WhereEntry> whereEntries = selectRows.GetWhereList().GetSubWhereList().GetWhereEntryList();
        foreach (WhereEntry whereEntry in whereEntries)
        {
          TernaryAssociative<string, string, string> item = new TernaryAssociative<string, string, string>();
          item.First = whereEntry.GetColumnName();
          item.Second = whereEntry.GetComparisonOperatorType().ToString();

          if (whereEntry.GetColumnValue().GetColumnValueType() == ColValueType.STRING)
          {
            item.Third = whereEntry.GetColumnValue().GetStringColumnValue();
          }
          else if (whereEntry.GetColumnValue().GetColumnValueType() == ColValueType.INTEGER)
          {
            item.Third = whereEntry.GetColumnValue().GetIntColumnValue().ToString();
          }
          else if (whereEntry.GetColumnValue().GetColumnValueType() == ColValueType.DOUBLE)
          {
            item.Third = whereEntry.GetColumnValue().GetDoubleColumnValue().ToString();
          }
          whereList.Add(item);    
        }
      }
      m_Parameters[4] = whereList;
      if (selectRows.GetOrderByFlag() == true)
      {
        List<OrderByEntry> orderByEntries = selectRows.GetOrderByList().GetSubOrderBylist().GetOrderByEntryList();
        foreach (OrderByEntry orderByEntry in orderByEntries)
        {
          KeyValuePair<string, string> item = new KeyValuePair<string, string>(orderByEntry.GetColumnName(),orderByEntry.GetOrderByType());
          orderByColumns.Add(item);
        }
      }
      m_Parameters[5] = orderByColumns;
      if (selectRows.GetLimitRangeFlag() == true)
      {
        m_Parameters[6] = selectRows.GetLimitRange().GetStartIndex();
        m_Parameters[7] = selectRows.GetLimitRange().GetCount();
      }
      else
      {
        m_Parameters[6] = -1;
        m_Parameters[7] = -1;
      }
      
      m_Request.SetCallingMethod("SelectRow");
      m_Request.SetRequestType(RequestType.EXECUTE_QUERY);
      m_Request.SetRootServerCallback(callback);
      m_Request.SetMethodParameters(m_Parameters);
      
    }