Esempio n. 1
0
 public static void ColumnsSync(NestSync NestSync, Action<NestSync> Callback, Decimal TwitterAccountID)
 {
     ThreadPool.QueueUserWorkItem((WaitCallback) (x =>
       {
     NestSync.LastSynced = App.AppState.Accounts[TwitterAccountID].Settings.SyncLastUpdate;
     IRestResponse local_0 = CoreServices.Instance.RestService.InvokeRESTService("https://api.tothenest.org/1/", "columns/sync", (IDictionary<string, string>) null, "POST", CoreServices.Instance.RestService.SerializeJson((object) NestSync, true), (IDictionary<string, string>) NestService.SetupHeaders(TwitterAccountID), "", "");
     if (local_0.StatusCode != HttpStatusCode.OK)
       return;
     Callback(CoreServices.Instance.RestService.DeserializeJson<NestSync>(local_0.Content));
       }));
 }
Esempio n. 2
0
 private void NestUpdate(NestSync sync)
 {
     if (!App.AppState.Accounts[this.TwitterAccountID].Settings.SyncColumns || sync == null)
         return;
     if (sync.Add != null && sync.Add.Count > 0)
     {
         foreach (NestColumn nestColumn in (IEnumerable)sync.Add)
         {
             NestColumn column = nestColumn;
             IEnumerable<TweetListViewModel> source = Enumerable.Where<TweetListViewModel>((IEnumerable<TweetListViewModel>)this.ColumnsToShow, (Func<TweetListViewModel, int, bool>)((x, r) => x.NestColumnID == column.Id || x.TweetListName == column.Name && x.TwitterTerm == (string.IsNullOrEmpty(column.Value) ? string.Empty : column.Value) && x.TweetType == (TweetListType)column.Type));
             if (Enumerable.Count<TweetListViewModel>(source) == 0)
             {
                 TweetListViewModel tweetListViewModel = new TweetListViewModel(Guid.Empty, (TweetListType)column.Type, this.TwitterAccountID, new MetroTwitColumn(), column.Name, string.Empty, column.Value, new Decimal?(), false, (MetroTwitStatusBase)null, (Decimal)column.LastReadId);
                 tweetListViewModel.ChangetoSavedColumn();
                 this.ColumnsToShow.Add(tweetListViewModel);
                 this.SetAddButtonsEnabled(tweetListViewModel.TweetType, false);
                 System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)-1), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.ColumnsToShow))), new object[0]);
             }
             else
                 Enumerable.First<TweetListViewModel>(source).NestColumnID = column.Id;
         }
     }
     if (sync.Edit != null && sync.Edit.Count > 0)
     {
         foreach (NestColumn nestColumn in (IEnumerable)sync.Edit)
         {
             NestColumn column = nestColumn;
             IEnumerable<TweetListViewModel> source = Enumerable.Where<TweetListViewModel>((IEnumerable<TweetListViewModel>)this.ColumnsToShow, (Func<TweetListViewModel, int, bool>)((x, r) => x.NestColumnID == column.Id));
             if (Enumerable.Count<TweetListViewModel>(source) > 0)
             {
                 foreach (TweetListViewModel tweetListViewModel in source)
                 {
                     TweetListViewModel MTColumn = tweetListViewModel;
                     if (!string.IsNullOrEmpty(column.Name))
                         Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => MTColumn.TweetListName = column.Name), DispatcherPriority.ContextIdle, new object[0]);
                     if (!string.IsNullOrEmpty(column.Value))
                         Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => MTColumn.TwitterTerm = column.Value), DispatcherPriority.ContextIdle, new object[0]);
                     if (column.LastReadId > 0L && (Decimal)column.LastReadId > MTColumn.CurrentTweetID)
                         Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() =>
                         {
                             MTColumn.CurrentTweetID = (Decimal)column.LastReadId;
                             MTColumn.UpdateReadTweets(new Decimal?());
                         }), DispatcherPriority.ContextIdle, new object[0]);
                 }
             }
             else
             {
                 IEnumerable<TweetListViewModel> possiblecolumns = Enumerable.Where<TweetListViewModel>((IEnumerable<TweetListViewModel>)this.ColumnsToShow, (Func<TweetListViewModel, int, bool>)((x, r) => x.TweetListName == column.Name && x.TwitterTerm == (string.IsNullOrEmpty(column.Value) ? string.Empty : column.Value) && x.TweetType == (TweetListType)column.Type));
                 if (Enumerable.Count<TweetListViewModel>(possiblecolumns) > 0)
                     Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => Enumerable.First<TweetListViewModel>(possiblecolumns).NestColumnID = column.Id), DispatcherPriority.ContextIdle, new object[0]);
             }
         }
     }
     if (sync.Remove != null && sync.Remove.Count > 0)
     {
         foreach (NestColumn nestColumn in (IEnumerable)sync.Remove)
         {
             NestColumn column = nestColumn;
             foreach (TweetListViewModel tweetListViewModel in Enumerable.ToArray<TweetListViewModel>(Enumerable.Where<TweetListViewModel>((IEnumerable<TweetListViewModel>)this.ColumnsToShow, (Func<TweetListViewModel, int, bool>)((x, r) => x.NestColumnID == column.Id))))
             {
                 TweetListViewModel MTColumn = tweetListViewModel;
                 Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => this.RemoveColumn(new GenericMessage<TweetListViewModel>(MTColumn), false)), DispatcherPriority.ContextIdle, new object[0]);
             }
         }
     }
     if (sync.Add.Count == 0 && sync.Edit.Count == 0 && sync.Edit.Count == 0 && Enumerable.Count<TweetListViewModel>(Enumerable.Where<TweetListViewModel>((IEnumerable<TweetListViewModel>)this.ColumnsToShow, (Func<TweetListViewModel, bool>)(x => x.NestColumnID == 0))) == this.ColumnsToShow.Count)
     {
         NestSync NestSync = new NestSync();
         NestSync.Add = (IList)new ArrayList();
         foreach (TweetListViewModel tweetListViewModel in (Collection<TweetListViewModel>)this.ColumnsToShow)
             NestSync.Add.Add((object)new NestColumn()
             {
                 Name = tweetListViewModel.TweetListName,
                 Value = tweetListViewModel.TwitterTerm,
                 Type = (int)tweetListViewModel.TweetType,
                 LastReadId = (long)tweetListViewModel.CurrentTweetID,
                 Date = DateTime.UtcNow.ToUniversalTime()
             });
         NestService.ColumnsSync(NestSync, (Action<NestSync>)(r => this.NestUpdate(r)), this.TwitterAccountID);
     }
     else
     {
         App.AppState.Accounts[this.TwitterAccountID].Settings.SyncLastUpdate = new DateTime?(DateTime.UtcNow.ToUniversalTime());
         foreach (TweetListViewModel tweetListViewModel in Enumerable.Where<TweetListViewModel>((IEnumerable<TweetListViewModel>)this.ColumnsToShow, (Func<TweetListViewModel, bool>)(x => x.NestColumnID == 0)))
         {
             TweetListViewModel overriddencolumn = tweetListViewModel;
             Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => this.RemoveColumn(new GenericMessage<TweetListViewModel>(overriddencolumn), false)), DispatcherPriority.ContextIdle, new object[0]);
         }
     }
 }