コード例 #1
0
        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();
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 protected bool IsParticipant(Activity activity)
 {
     return activity.Participants.Count(p => p.Id == CurrentUser.Id) == 1;
 }
コード例 #4
0
 protected bool IsOwner(Activity activity)
 {
     return activity.Owner.Id == CurrentUser.Id;
 }
コード例 #5
0
 public override void ActivityNetAdded(Activity act)
 {
     HandleActivity(act);
     base.ActivityNetAdded(act);
 }
コード例 #6
0
 public void AddActivity(Activity activity)
 {
     Rest.Post(BaseUrl + "Activities/", activity, _connection.ConnectionId);
 }
コード例 #7
0
 /// <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);
 }
コード例 #8
0
        /// <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);
            });
        }
コード例 #9
0
 /// <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");
 }
コード例 #10
0
 public virtual void ActivityNetSwitched(Activity act)
 {
     if (ActivitySwitched != null)
         ActivitySwitched(this, new ActivityEventArgs(act));
 }
コード例 #11
0
 public virtual void ActivityNetChanged(Activity act)
 {
     if (ActivityChanged != null)
         ActivityChanged(this, new ActivityEventArgs(act));
 }
コード例 #12
0
ファイル: Activity.cs プロジェクト: madebysoren/NooSphere
 public bool Equals(Activity act)
 {
     return Id == act.Id;
 }
コード例 #13
0
 public ActivityEventArgs(Activity activity)
 {
    Activity = activity;
 }
コード例 #14
0
        public void UpdateActivity(Activity activity)
        {
            Task.Factory.StartNew(
                delegate
                {

                        Rest.Put(BaseUrl + "Activities/" + activity.Id, activity,
                                 _connection.ConnectionId);
                        Console.WriteLine("UPDATE TO CLOUD========================");
                    });
        }
コード例 #15
0
        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;
        }
コード例 #16
0
 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");
 }
コード例 #17
0
        /// <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);
        }
コード例 #18
0
        /// <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);
        }
コード例 #19
0
 /// <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);
             });
 }
コード例 #20
0
        /// <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");
        }
コード例 #21
0
 /// <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));
 }
コード例 #22
0
 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;
     }
 }