Exemplo n.º 1
0
    public QueryDataset GetQueryResult(string id, int startLines, int numLines)
    {
      int i = 1, k = numLines;
      QueryDataset queryDataset = null, ret = null;
      
      if (id == "")
        throw new Exception("Empty ID");
      if (m_ResultCache.ContainsKey(id))
      {
        queryDataset = m_ResultCache[id];
      }
      
      ret = new QueryDataset(queryDataset.GetColumnTypes(), queryDataset.GetColumnNames());

      if (startLines < queryDataset.count)
      {
        foreach(var row in queryDataset)
        {
          if ((i == startLines) && (k > 0))
          {
            ret.AddRow(row.Key, row.Value);
            k--;
          }
          if (k == 0)
            break;
          i++;
        }
      }
      return ret;
    }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor for initialization 
        /// </summary>
        public RestAPI()
        {
            // Logger.LogWrite(EskimoDBLogLevel.Verbose, "Creating");
            DependencyInjection di = DependencyInjection.GetInstance();

            mockRootServer = (IRootServer)di.CreateObject("root", new object[]{
                this,new WSDualHttpBinding(),"http://localhost:8080/root"});
            mockAuthServer = (IAuthServer)di.CreateObject("auth", new object[]{
                null,new BasicHttpBinding(),"http://149.119.196.45:8080/IComm"});

            m_PutDataSetCalled = false;
            m_PutQueryInfoCalled = false;
            m_QueryResult = new QueryResult(0, null, null);
            m_id = null;
            m_QueryDataset = new QueryDataset(new System.Collections.Generic.List<Type>(), new System.Collections.Generic.List<string>());
            m_lines = 0;

            m_IterateToTheEnd = 0;
            m_CallGetResult = true;
            m_startLine = 0;
            m_RowsPerTime = 5;
            m_IterateIndex = 0;
            m_FinalLines = 0;
            m_Table = new Tables();

        }
Exemplo n.º 3
0
 public bool AddResultEntry(string id, QueryDataset queryDataSet)
 {
   try
   {
     m_ResultCache.Add(id, queryDataSet);
   }
   catch
   {
     return false;
   }
   return true;
 }
Exemplo n.º 4
0
 /*
  * PutDataset implements the contract ITableServerCallback. 
  * It is responsible for getting the QueryDataSet from the tableserver
  * and storing on the rootserver.
  * @param QueryData is the dataset received from the tableserver
  * @param DataId is a unique id received from the tableserver for the specific request
  * @returns none
  */
 public void PutDataset(QueryDataset QueryData, string DataId)
 {
   try
   {
     ResultStorage resultStorage = ResultStorage.Instance;
     if (!resultStorage.AddResultEntry(DataId, QueryData))
     {
       throw new Exception("Result not added in storage.");
     }
   }
   catch (Exception ex)
   {
     Console.WriteLine(ex.Message);
   }
 }
Exemplo n.º 5
0
    /// <summary>
    /// Constructor for initialization 
    /// </summary>
    public ClientAPI()
    {
      Logger.LogWrite("Initializing client api");

      m_PutDataSetCalled = false;
      m_PutQueryInfoCalled = false;
      m_QueryResult = new QueryResult(0, null, null);
      m_id = null;
      m_QueryDataset = new QueryDataset(new System.Collections.Generic.List<Type>(), new System.Collections.Generic.List<string>());
      m_lines = 0;

      m_IterateToTheEnd = 0;
      m_CallGetResult = true;
      m_startLine = 0;
      m_RowsPerTime = 5;
      m_IterateIndex = 0;
      m_FinalLines = 0;
      m_Table = new Tables();

    }
Exemplo n.º 6
0
 /// <summary>
 /// Implement the callback function PutDataset()
 /// </summary>
 /// <param name="result"></param>
 /// <param name="id"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public void PutDataset(QueryResult result, string id, QueryDataset data)
 {
   m_QueryResult = result;
   m_id = id;
   m_QueryDataset = data;
   m_PutDataSetCalled = true;
   return;
 }
 public void PutDataset(QueryResult result, string id, QueryDataset data)
 {
   Console.WriteLine("Mock root server PutDataset callback called.");
   Console.WriteLine("Query Result: " + result.GetMessage());
 }
Exemplo n.º 8
0
 public void PutDataset(QueryResult result, string id, QueryDataset data)
 {
   Console.WriteLine("IRootServerCallback - Put dataset called ");
 }
Exemplo n.º 9
0
 //----< test stub >-------------
 static void Main()
 {
   List<Type> colTypes = new List<Type>(new Type[]{typeof(int),typeof(string),typeof(DateTime)});
   List<string> colNames = new List<string>(new string[]{"GroupId","Name","JoinDate"});
   QueryDataset table = new QueryDataset(colTypes,colNames);
   List<object> entry = new List<object>();
   entry.Add(1);
   entry.Add("David");
   entry.Add(new DateTime(2010,6,3));
   table.AddRow(1, entry);
   entry.Clear();
   entry.Add(3);
   entry.Add("Mary");
   entry.Add(new DateTime(2011, 10, 12));
   table.AddRow(2, entry);
   foreach (var name in table.GetColumnNames())
     Console.Write(name + "  ");
   Console.WriteLine();
   foreach (var row in table)
   {
     foreach (var field in row.Value)
       Console.Write(field + "  ");
     Console.WriteLine();
   }
   Console.ReadKey();
 }
Exemplo n.º 10
0
    /// <summary>
    /// Used to create a Mock dataset with values 
    /// </summary>
    /// <returns> QueryDataset object </returns>
    public QueryDataset MockDataSet()
    {
      List<Type> colTypes = new List<Type>(new Type[] { typeof(int), typeof(string), typeof(DateTime) });
      List<string> colNames = new List<string>(new string[] { "GroupId", "Name", "JoinDate" });
      QueryDataset table = new QueryDataset(colTypes, colNames);

      List<object> entry = new List<object>();
      entry.Add(1);
      entry.Add("David");
      entry.Add(new DateTime(2010, 6, 3));
      table.AddRow(1, entry);

      entry.Clear();
      entry.Add(3);
      entry.Add("Mary");
      entry.Add(new DateTime(2011, 10, 12));
      table.AddRow(2, entry);

      entry.Clear();
      entry.Add(5);
      entry.Add("Harry");
      entry.Add(new DateTime(2011, 7, 4));
      table.AddRow(3, entry);

      entry.Clear();
      entry.Add(7);
      entry.Add("Peter");
      entry.Add(new DateTime(2011, 3, 18));
      table.AddRow(4, entry);

      entry.Clear();
      entry.Add(9);
      entry.Add("Kate");
      entry.Add(new DateTime(2011, 12, 18));
      table.AddRow(5, entry);

      return table;
    }