public void Show(Activity act, int offset) { activity = act; Left = offset; Top = taskbar.Height + 5; txtActivity.Text = act.Name; txtInfo.Text = act.Id.ToString(); Show(); }
private void PutParticipantsOnSubscription(Activity activity) { // Add subscription for participants foreach (var connectionId in activity.Participants.Where(p => p.Id != CurrentUserId). SelectMany(participant => DeviceRegistry.ConnectionIds(participant.Id))) Notifier.Subscribe(connectionId, activity.Id); }
protected bool IsParticipant(Activity activity) { return activity.Participants.Count(p => p.Id == CurrentUser.Id) == 1; }
protected bool IsOwner(Activity activity) { return activity.Owner.Id == CurrentUser.Id; }
public override void ActivityNetAdded(Activity act) { HandleActivity(act); base.ActivityNetAdded(act); }
public void AddActivity(Activity activity) { Rest.Post(BaseUrl + "Activities/", activity, _connection.ConnectionId); }
/// <summary> /// Adds a participant to an activity /// </summary> /// <param name="a">Activity</param> /// <param name="u">Participant</param> /// <param name="deviceId"> </param> public void AddParticipant(Activity a, User u, string deviceId) { if (_useCloud && _connectionActive) _activityCloudConnector.AddParticipant(a.Id, u.Id); ParticipantStore.Participants.Add(u.Id, u); Console.WriteLine("ActivityManager: Added participant {0} to activity {1}", u.Name, a.Name); }
/// <summary> /// Adds an activity to the cloud /// </summary> /// <param name="act">The activity that needs to be added to the cloud</param> /// <param name="deviceId"> </param> public void AddActivity(Activity act, string deviceId) { Task.Factory.StartNew( delegate { //Set the path of newly added activity _fileServer.IntializePath(act.Id); if (!_useCloud) { //Publish the activity ActivityStore.Activities.Add(act.Id, act); _publisher.Publish(ActivityEvent.ActivityAdded.ToString(), act); Console.WriteLine("ActivityManager: Published {0}: {1}", EventType.ActivityEvents, ActivityEvent.ActivityAdded); } if (_connectionActive && _useCloud) _activityCloudConnector.AddActivity(act); }); }
/// <summary> /// Sends an "add activity" request to the activity manager /// </summary> /// <param name="act">The activity that needs to be included in the request</param> /// <remarks> /// Before we can use the activity, the client needs to wait for the manager /// to publish the activity back to us, so the transaction is confirmed /// </remarks> public void AddActivity(Activity act) { //If we are connected to a manager, post an activityAdd request with the //given activity if (_connected) { //The activity manager is expecting a tuple={activity,deviceId} Rest.Post(ServiceAddress + Url.Activities, new { act, deviceId = _connectionId }); } else //Throw an error if we are not connected throw new Exception( "ActivityClient: Not connected to service. Call connect() method or check address"); }
public virtual void ActivityNetSwitched(Activity act) { if (ActivitySwitched != null) ActivitySwitched(this, new ActivityEventArgs(act)); }
public virtual void ActivityNetChanged(Activity act) { if (ActivityChanged != null) ActivityChanged(this, new ActivityEventArgs(act)); }
public bool Equals(Activity act) { return Id == act.Id; }
public ActivityEventArgs(Activity activity) { Activity = activity; }
public void UpdateActivity(Activity activity) { Task.Factory.StartNew( delegate { Rest.Put(BaseUrl + "Activities/" + activity.Id, activity, _connection.ConnectionId); Console.WriteLine("UPDATE TO CLOUD========================"); }); }
private JObject ReturnObject(Activity activity) { var result = JObject.FromObject(activity); var storage = _activityStorage.Get(activity.Id); foreach (var node in storage.Properties()) { if (result[node.Name] == null) result.Add(node.Name, node.Value); else result[node.Name] = node.Value; } result.Remove("History"); result.Remove("IsHistory"); return result; }
public void SwitchActivity(Activity activity) { if (_connected) Rest.Post(ServiceAddress + Url.Activities + "/" + activity.Id, _connectionId); else throw new Exception( "ActivityClient: Not connected to service. Call connect() method or check address"); }
/// <summary> /// Adds an activity to the manager that is pushed from the cloud /// </summary> /// <param name="act"></param> private void AddActivityFromCloud(Activity act) { //If the id is in the store -> activity was uploaded by this system if (ActivityStore.Activities.ContainsKey(act.Id)) return; //Initialize the activity _fileServer.IntializePath(act.Id); //Add activity to the store ActivityStore.Activities.Add(act.Id, act); //Publish activity added _publisher.Publish(ActivityEvent.ActivityAdded.ToString(), act); }
/// <summary> /// Handles activities that are published by the activity manager /// </summary> /// <param name="act">The activity that is published by the activity manager</param> private void HandleActivity(Activity act) { //In case there are resources, initialize the file server _fileStore.IntializePath(act.Id); //Add the activity to a local buffer _activityBuffer.AddOrUpdate(act.Id, act,(key, oldValue)=> act); }
/// <summary> /// Updates an activity in the cloud /// </summary> /// <param name="act">The activity that needs to be updated</param> /// <param name="deviceId"> </param> public void UpdateActivity(Activity act, string deviceId) { Task.Factory.StartNew( delegate { //Publish the activityChangedEvent to local system ActivityStore.Activities[act.Id] = act; _publisher.Publish(ActivityEvent.ActivityChanged.ToString(), act); Console.WriteLine("ActivityManager: Published {0}: {1}", EventType.ActivityEvents, ActivityEvent.ActivityChanged); if (_connectionActive) _activityCloudConnector.UpdateActivity(act); }); }
/// <summary> /// Sends an "Update activity" request to the activity manager /// </summary> /// <param name="act">The activity that needs to be included in the request</param> public void UpdateActivity(Activity act) { if (_connected) Rest.Put(ServiceAddress + Url.Activities, new {act, deviceId = _connectionId}); else throw new Exception( "ActivityClient: Not connected to service. Call connect() method or check address"); }
/// <summary> /// Removes an participant from an activity /// </summary> /// <param name="a">Activity</param> /// <param name="id">Id that represents the participant</param> /// <param name="deviceId"> </param> public void RemoveParticipant(Activity a, string id, string deviceId) { if (_useCloud && _connectionActive) _activityCloudConnector.RemoveParticipant(a.Id, new Guid(id)); Console.WriteLine("ActivityManager: Removed participant {0} to activity {1}", ParticipantStore.Participants[new Guid(id)], a.Name); ParticipantStore.Participants.Remove(new Guid(id)); }
public void Sync(SyncType type, Activity activity, Guid connectionId, Activity oldActivity = null) { switch (type) { case SyncType.Added: foreach (var r in activity.Resources) Notifier.NotifyGroup(connectionId, NotificationType.FileUpload, r); break; case SyncType.Removed: foreach (var r in activity.Resources) Notifier.NotifyGroup(connectionId, NotificationType.FileDelete, r); break; case SyncType.Updated: if(oldActivity != null) foreach (var r in activity.Resources) { var oldR = oldActivity.Resources.SingleOrDefault(r2 => r2.Id == r.Id); if (oldR == null || r.LastWriteTime.ToUniversalTime() > oldR.LastWriteTime.ToUniversalTime()) Notifier.NotifyGroup(connectionId, NotificationType.FileUpload, r); } break; } }