public ActionResult <string> Get(string channelId, string resourceId, string instance) { try { // Just because .NET is some weird kind of monster and doesn't like to play well with URLs... Thanks Microsoft // Note WebUtility outputs stuff in a CORRECT fashion while HttpUtility is NOT suitable for case sensitive systems channelId = WebUtility.UrlDecode(channelId); resourceId = WebUtility.UrlDecode(resourceId); instance = WebUtility.UrlDecode(instance); // Check if the request was created by the current instance if (KeySync.instance.Equals(instance)) { // Sync all the calendars KeySync.runCal(); } // Clean up the current channel, it's not valid else { GService.service.Channels.Stop(KeySync.deleteChannel(channelId, resourceId)).Execute(); } } catch (Exception e) { ControlRoom.SendErrorMessage("Google Sync error", e.Message); } return(instance); }
private void Sync(KeySync ks) { ValueSyc vs; if (!_req.TryRemove(ks, out vs)) { throw new Exception("attemping to sync non-existing request"); } vs.done.Set(); }
public void Put(DatastoreKey datastoreKey, T value) { var ks = new KeySync { op = PutKey, k = datastoreKey, value = value }; ValueSyc vs; if (!Sync(ks, out vs)) { _child.Put(datastoreKey, value); Sync(ks); } }
public void Delete(DatastoreKey datastoreKey) { var ks = new KeySync { op = DeleteKey, k = datastoreKey }; ValueSyc vs; if (!Sync(ks, out vs)) { _child.Delete(datastoreKey); Sync(ks); } }
public T Get(DatastoreKey datastoreKey) { var ks = new KeySync { op = GetKey, k = datastoreKey }; ValueSyc vs; if (!Sync(ks, out vs)) { vs.value = _child.Get(datastoreKey); Sync(ks); } return((T)vs.value); }
private bool Sync(KeySync ks, out ValueSyc vs) { if (!_req.TryGetValue(ks, out vs)) { vs = new ValueSyc(done: new ManualResetEvent(false)); _req.TryAdd(ks, vs); return(false); } else { vs.done.Set(); return(true); } }
public bool Has(DatastoreKey datastoreKey) { var ks = new KeySync { op = HasKey, k = datastoreKey }; ValueSyc vs; if (!Sync(ks, out vs)) { vs.value = _child.Has(datastoreKey); Sync(ks); } return((bool)vs.value); }