Esempio n. 1
0
        /// <summary>
        /// Receive all streams in the account.
        /// </summary>
        private void UpdateStreamList(object sender, RoutedEventArgs e)
        {
            if (RestApi == null && ApiToken == null)
            {
                Status.AddError("Not logged in");
                return;
            }

            Task.Run(() => SpeckleStreamManager.GetStreams(RestApi, ApiToken)).ContinueWith(res =>
            {
                Application.Current.Dispatcher.BeginInvoke(
                    DispatcherPriority.Background,
                    new Action(() =>
                {
                    List <Tuple <string, string> > streams = res.Result;
                    if (streams != null)
                    {
                        streams.Reverse();
                        StreamList.Items.Clear();
                        foreach (Tuple <string, string> t in streams)
                        {
                            StreamList.Items.Add(t);
                        }
                    }
                }
                               ));
            });
        }
Esempio n. 2
0
        private void SenderStreams_CloneStreams(object sender, RoutedEventArgs e)
        {
            if (RestApi == null && ApiToken == null)
            {
                Status.AddError("Not logged in");
                return;
            }

            var cell = SenderStreams.CurrentCell.Item;

            if (cell.GetType() == typeof(Tuple <string, string>))
            {
                string streamID = (cell as Tuple <string, string>).Item2;

                Task.Run(() => SpeckleStreamManager.CloneStream(RestApi, ApiToken, streamID)).ContinueWith(res =>
                {
                    Application.Current.Dispatcher.BeginInvoke(
                        DispatcherPriority.Background,
                        new Action(() =>
                    {
                        try
                        {
                            Status.AddMessage("Cloned to: " + res.Result);
                        }
                        catch { Status.AddError("Could not clone " + streamID); }
                    }
                                   ));
                });
            }
        }
        public override List <StreamState> GetStreamsInFile()
        {
            List <string> strings = SpeckleStreamManager.GetSpeckleStreams();

            return(strings.Select(s => JsonConvert.DeserializeObject <StreamState>(s)).ToList());
        }
 public override void PersistAndUpdateStreamInFile(StreamState state)
 {
     SpeckleStreamManager.UpdateSpeckleStream(state.Stream.id, JsonConvert.SerializeObject(state));
 }
 public override void RemoveStreamFromFile(string streamId)
 {
     SpeckleStreamManager.RemoveSpeckleStream(streamId);
 }
 public override void AddNewStream(StreamState state)
 {
     SpeckleStreamManager.AddSpeckleStream(state.Stream.id, JsonConvert.SerializeObject(state));
 }