예제 #1
0
 public void ProcessRow(PubSubSQL.Client client)
 {
     dirtyFlag = true;
     string id = client.GetValue("id");
     List<Cell> row = null;
     switch (client.Action)
     {
         case "select":
         case "add":
         case "insert":
             // add row
             row = new List<Cell>(columns.Count);
             // for select operations columns are always in the same order
             foreach(string col in columns)
             {
                 row.Add(new Cell(client.GetValue(col)));
             }
             rows.Add(row);
             if (!string.IsNullOrEmpty(id))
             {
                 idsToRows[id] = row;
             }
             break;
         case "update":
             if (idsToRows.TryGetValue(id, out row))
             {
                 foreach (string col in client.Columns)
                 {
                     int ordinal = columnOrdinals[col];
                     // auto expand row
                     for (int i = row.Count; i <= ordinal; i++)
                     {
                         row.Add(new Cell(string.Empty));
                     }
                     row[ordinal].Value = client.GetValue(col);
                     row[ordinal].LastUpdated = DateTime.Now.Ticks;
                 }
             }
             break;
         case "delete":
         case "remove":
             if (idsToRows.TryGetValue(id, out row))
             {
                 idsToRows.Remove(id);
                 rows.Remove(row);
             }
             break;
     }
 }
예제 #2
0
 public void SyncColumns(PubSubSQL.Client client)
 {
     foreach (string col in client.Columns)
     {
         if (!columnOrdinals.ContainsKey(col))
         {
             int ordinal = columns.Count;
             columnOrdinals[col] = ordinal;
             columns.Add(col);
         }
     }
 }