private void ReceiveTimeline() { if (User == null || User.TwitterUser == null) { return; } IsStandby = false; Task.Factory.StartNew(() => { try { var acc = AccountStorage.GetRandom(a => a.Followings.Contains(this.User.TwitterUser.NumericId), true); var tweets = InjectionPoint.UnfoldTimeline(i => acc.GetUserTimeline(userId: this.User.TwitterUser.NumericId, count: 100, includeRts: true, page: i), 100, 5); if (tweets != null) { tweets.ForEach(t => TweetStorage.Register(t)); } } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.TwitterError, "ユーザータイムラインを受信できませんでした: @" + this.User.TwitterUser.ScreenName, ReceiveTimeline); } finally { IsStandby = true; } }); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RetainInstance = true; ((MainActivity)Activity).SetTitle("Settings"); AccountStorage.SetContext(this.Activity); // Create your fragment here AddPreferencesFromResource(Resource.Layout.Settings); Preference pf = FindPreference("login_preference"); pf.Summary = "Logged in as : " + AccountStorage.UserId; pf.PreferenceClick += (sender, args) => { try { System.Diagnostics.Debug.WriteLine("We are about to logout"); AccountStorage.ClearStorage(); System.Diagnostics.Debug.WriteLine("Main Activity is :" + Activity == null); System.Diagnostics.Debug.WriteLine("Items in the backstack :" + Activity.FragmentManager.BackStackEntryCount); System.Diagnostics.Debug.WriteLine("Main Activity is :" + Activity == null); Activity.FragmentManager.PopBackStack(null, PopBackStackFlags.Inclusive); System.Diagnostics.Debug.WriteLine("Items in the backstack 2 :" + Activity.FragmentManager.BackStackEntryCount); ((MainActivity)(Activity)).SetDrawerState(false); ((MainActivity)(Activity)).SwitchToFragment(MainActivity.FragmentTypes.Login); } catch (System.Exception e) { System.Diagnostics.Debug.WriteLine("We encountered an error :" + e.Message); } }; }
public async Task <IActionResult> BuyItem(int accountId, int itemId) { if (accountId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var itemFromDb = await _cRUDRepo.GetOneWithCondition <Item>(item => item.Id == itemId); if (itemFromDb == null) { return(NotFound()); } var buy = new AccountStorage() { AccountId = accountId, ItemId = itemId, PurchasedDate = DateTime.Now }; _cRUDRepo.Create(buy); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Error on buying")); }
public async Task DropboxMigrationAsync(int accountId) { AccountStorage entity = await _dbContext.AccountStorages.FindAsync(accountId, (int)StorageType.Dropbox); if (entity is null) { return; } DropboxJson dbxJson = JsonConvert.DeserializeObject <DropboxJson>(entity.JsonData); using var dbx = new DropboxClient(dbxJson.JwtToken); var files = await dbx.Files.ListFolderAsync(string.Empty); dbxJson.Cursor = files.Cursor; await UpdateDbxJsonData(accountId, dbxJson); await _dbContext.SaveChangesAsync(); if (_env.IsDevelopment()) { _backgroundTaskQueue.EnqueueAsync(ct => UpdateSongsDBX(accountId, files.Entries, dbxJson.JwtToken)); } else { await UpdateSongsDBX(accountId, files.Entries, dbxJson.JwtToken); } }
internal void NotifyNewTweetReceived(TimelineListCoreViewModel timelineListCoreViewModel, TimelineChild.TweetViewModel tweetViewModel) { if (AccountStorage.Contains(tweetViewModel.Status.User.ScreenName) || !this.IsAlive) { return; } // 正直謎設定だし、スタックトップTLの新着を伝えるってあんまり直感的じゃないから // 設定じゃなくて固定にしてよかったかもしれない if (Setting.Instance.NotificationProperty.NotifyStackTopTimeline ? this.CurrentForegroundTimeline.CoreViewModel == timelineListCoreViewModel : this.BaseTimeline.CoreViewModel == timelineListCoreViewModel) { // NewTweetsCountはプロパティが良きに計らってくれるので // _人人人人人人人人人人人人人人人_ // > インクリしていってね!!!< //  ̄YYYYYYYYYYYYYYY ̄ this.NewTweetsCount++; if (this.TabProperty.IsNotifyEnabled) { if (String.IsNullOrEmpty(this.TabProperty.NotifySoundPath)) { NotificationCore.QueueNotify(tweetViewModel); } else { NotificationCore.QueueNotify(tweetViewModel, this.TabProperty.NotifySoundPath); } } } }
private void UpdateList() { if (!AccountStorage.Contains(_selectedScreenName)) { return; } var acc = AccountStorage.Get(_selectedScreenName); IsListLoading = true; Task.Factory.StartNew(() => { try { var lists = acc.GetFollowingListsAll(_selectedScreenName); if (lists != null) { lists.ForEach(l => acc.RegisterFollowingList(l)); } RaisePropertyChanged(() => ListItems); } catch { this.Messenger.Raise(new InformationMessage("リスト情報を取得できません。", "リストロードエラー", System.Windows.MessageBoxImage.Error, "WarningMessage")); } finally { IsListLoading = false; } }); }
public bool Match(string haystack, string needle) { if (needle == "*") { return(AccountStorage.Contains(haystack)); } else { bool startsWith = false; bool endsWith = false; if (needle.StartsWith("\\/")) { // 先頭のスラッシュエスケープを削除 needle = needle.Substring(1); } if (needle.StartsWith("^")) { startsWith = true; needle = needle.Substring(1); } else if (needle.StartsWith("\\^")) { needle = needle.Substring(1); } if (needle.EndsWith("$")) { if (needle.EndsWith("\\$")) { needle = needle.Substring(0, needle.Length - 2) + "$"; } else { endsWith = true; needle = needle.Substring(0, needle.Length - 1); } } var unescaped = needle.UnescapeFromQuery(); if (startsWith && endsWith) { // complete return(haystack.Equals(needle, StringComparison.CurrentCultureIgnoreCase)); } else if (startsWith) { return(haystack.StartsWith(needle, StringComparison.CurrentCultureIgnoreCase)); } else if (endsWith) { return(haystack.EndsWith(needle, StringComparison.CurrentCultureIgnoreCase)); } else { return(haystack.IndexOf(needle, StringComparison.CurrentCultureIgnoreCase) >= 0); } } }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RetainInstance = true; _mActivity.SetTitle("Process Dashboard"); AccountStorage.SetContext(this.Activity); }
private static IEnumerable <AccountInfo> GetAccountInfos(string argument) { if (argument == null) { return(new AccountInfo[0]); } return(argument.Split(',').Select(s => AccountStorage.Get(s.Trim())) .Where(i => i != null) .Distinct()); }
private async static Task <LogOnIdentity> LogOnIdentityFromUserAsync(EmailAddress emailAddress, Passphrase passphrase) { AccountStorage store = new AccountStorage(New <LogOnIdentity, IAccountService>(new LogOnIdentity(emailAddress, passphrase))); if (await store.IsIdentityValidAsync()) { return(new LogOnIdentity(await store.AllKeyPairsAsync(), passphrase)); } return(LogOnIdentity.Empty); }
public static bool IsMuted(TwitterStatusBase status) { var tweet = status as TwitterStatus; return((Setting.Instance.TimelineFilteringProperty.MuteFilterCluster != null && Setting.Instance.TimelineFilteringProperty.MuteFilterCluster.Filter(status) && !AccountStorage.Contains(status.User.ScreenName)) || IsMuted(status.User) || (tweet != null && tweet.RetweetedOriginal != null && IsMuted(tweet.RetweetedOriginal.User))); }
public Startup( ILogger logger, AccountStorage accountStorage, XmlConfigurationProvider <RealmServerConfiguration> configurationProvider, TcpServer tcpServer) { this.logger = logger; this.accountStorage = accountStorage; this.configurationProvider = configurationProvider; this.tcpServer = tcpServer; }
public async Task <bool> SaveTokensToStorageAsync() { if (Account == null) { return(false); } await AccountStorage.SaveAsync(Account); return(true); }
private OwnershipType CheckOwnership(string courseId) // need to check for user id { try { Account _user = AccountStorage.GetAccount("0"); //temporarily 0 return(_user.CheckOwnership(courseId)); } catch (IndexOutOfRangeException) { return(OwnershipType.None); } }
public async Task TestSimpleCreateAsymmetricKeysStore() { FakeDataStore.AddFolder(@"C:\Temp"); IDataContainer workFolder = New <IDataContainer>(@"C:\Temp"); AccountStorage store = new AccountStorage(new LocalAccountService(new LogOnIdentity(EmailAddress.Parse(@"*****@*****.**"), new Passphrase("secret")), workFolder)); UserKeyPair userKeyPair = new UserKeyPair(EmailAddress.Parse("*****@*****.**"), 512); await store.ImportAsync(userKeyPair); Assert.That((await store.AllKeyPairsAsync()).First().KeyPair.PrivateKey, Is.Not.Null); Assert.That((await store.AllKeyPairsAsync()).First().KeyPair.PublicKey, Is.Not.Null); }
public static async Task <ManageAccountViewModel> CreateAsync(AccountStorage accountStorage) { ManageAccountViewModel vm = new ManageAccountViewModel(); vm._accountStorage = accountStorage; await vm.InitializePropertyValuesAsync(); BindPropertyChangedEvents(); SubscribeToModelEvents(); return(vm); }
private async Task <object> CreateAccountAction() { if (String.IsNullOrEmpty(UserEmail)) { return(null); } AccountStorage accountStorage = new AccountStorage(New <LogOnIdentity, IAccountService>(new LogOnIdentity(EmailAddress.Parse(UserEmail), new Passphrase(PasswordText)))); UserKeyPair userKeys = new UserKeyPair(EmailAddress.Parse(UserEmail), New <INow>().Utc, New <KeyPairService>().New()); await accountStorage.ImportAsync(userKeys); return(null); }
public static async Task <ManageAccountDialog> CreateAsync(Form parent) { ManageAccountDialog mad = new ManageAccountDialog(); mad.InitializeStyle(parent); AccountStorage userKeyPairs = new AccountStorage(New <LogOnIdentity, IAccountService>(Resolve.KnownIdentities.DefaultEncryptionIdentity)); mad._viewModel = await ManageAccountViewModel.CreateAsync(userKeyPairs); mad._viewModel.BindPropertyChanged <IEnumerable <AccountProperties> >(nameof(ManageAccountViewModel.AccountProperties), mad.ListAccountEmails); return(mad); }
public async Task <IActionResult> UseItem(int accountId, int itemId) { if (accountId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var accountFromDb = await _repo.GetAccountDetail(accountId); if (accountFromDb == null) { return(Unauthorized()); } var itemFromDb = await _cRUDRepo.GetOneWithCondition <Item>(item => item.Id == itemId); if (itemFromDb == null) { return(NotFound()); } AccountStorage item = new AccountStorage(); switch (itemFromDb.ItemName.ToLower()) { case "x2 exp": item = await _cRUDRepo.GetOneWithConditionTracking <AccountStorage>(store => store.Item.ItemName.ToLower().Equals("x2 exp")); break; case "x2 point": item = await _cRUDRepo.GetOneWithConditionTracking <AccountStorage>(store => store.Item.ItemName.ToLower().Equals("x2 point")); break; case "keep active": item = await _cRUDRepo.GetOneWithConditionTracking <AccountStorage>(store => store.Item.ItemName.ToLower().Equals("keep active")); break; default: break; } item.IsUsing = true; item.UseDate = DateTime.Now; item.OverDate = DateTime.Now.AddMinutes(item.Item.Usage); if (await _repo.SaveAll()) { return(Ok()); } return(StatusCode(500)); }
public async Task RegisterGoogleDriveAsync(int accountID, string token) { AccountStorage entity = new AccountStorage() { AccountID = accountID, StorageID = (int)StorageType.GoogleDrive }; string entityJson = JsonConvert.SerializeObject(token); entity.JsonData = entityJson; await _dbContext.AccountStorages.AddAsync(entity); await SaveAsync(); }
public async Task RegisterDropboxAsync(int accountId, DropboxJson json) { AccountStorage entity = new AccountStorage() { AccountID = accountId, StorageID = (int)StorageType.Dropbox }; string entityJson = JsonConvert.SerializeObject(json); entity.JsonData = entityJson; await _dbContext.AccountStorages.AddAsync(entity); await _dbContext.SaveChangesAsync(); }
static void Main(string[] args) { IdGenerator idGenerator = new IdGenerator(); AccountStorage accountStorage = new AccountStorage(); Bank newBank = new Bank(accountStorage, idGenerator); string myId = newBank.CreateNewAccount("Vadim", "Makarchik"); newBank.AddCash(myId, Currency.USD, new GoldCash(new BonusCalculator(0.05, 0.03))); newBank.Replenish(myId, Currency.USD, 10000.0); newBank.Deposit(myId, Currency.USD, 50.0); Console.WriteLine(newBank.GetAccountInfo(myId)); Console.ReadLine(); }
//Delete a timelog entry public async Task <Service.Interface.DeleteRoot> DeleteTimeLog(string timeLogId) { try { return(await base.DeleteTimeLog(dataset, timeLogId)); } catch (Exception ex) { if (ex.Message.Contains("401")) { AccountStorage.ClearPassword(); AppDelegate del = UIApplication.SharedApplication.Delegate as AppDelegate; del.BindLoginViewController(); } throw ex; } }
public static bool IsMentionOfMe(TwitterStatusBase status) { var tweet = status as TwitterStatus; // DMではなくて、リツイートでもないことを確認する if (tweet != null && tweet.RetweetedOriginal == null) { // リツイートステータス以外で、自分への返信を探す var matches = RegularExpressions.AtRegex.Matches(status.Text); if (matches.Count > 0 && matches.Cast <Match>().Select(m => m.Value) .Where(s => AccountStorage.Contains(s)).FirstOrDefault() != null) { return(true); } } return(false); }
private AccountInfo FallbackAccount(AccountInfo original, AccountInfo current) { if (!PostOffice.IsAccountUnderControlled(current)) { return(current); } var fallback = AccountStorage.Get(current.AccountProperty.FallbackAccount); if (fallback == null || fallback == original) { return(current); } else { return(FallbackAccount(original, fallback)); } }
/// <summary> /// アプリケーション開始時に呼び出される。 /// </summary> private void Application_Startup(object sender, StartupEventArgs e) { _accountStorage = new FileAccountStorage(); _accountManager = new AccountManager(_accountStorage); _windowManager = new WindowManagerImpl(); try { _accountManager.LoadAccounts(); } catch (AccountStorageException) { _windowManager.ShowError(null, Messages.FailedToLoadAccounts); } _windowManager.ShowMainWindow(_accountManager); }
// Get list of tasks public async Task <List <DTO.Task> > GetTasks(string projectId) { try { return(await base.GetTasks(dataset, projectId)); } catch (Exception ex) { if (ex.Message.Contains("401")) { AccountStorage.ClearPassword(); AppDelegate del = UIApplication.SharedApplication.Delegate as AppDelegate; del.BindLoginViewController(); } throw ex; } }
// Update a particular task public async Task <DTO.Task> UpdateATask(string taskId, double?estimatedTime, DateTime?completionDate, bool markTaskIncomplete) { try { return(await base.UpdateATask(dataset, taskId, estimatedTime, completionDate, markTaskIncomplete)); } catch (Exception ex) { if (ex.Message.Contains("401")) { AccountStorage.ClearPassword(); AppDelegate del = UIApplication.SharedApplication.Delegate as AppDelegate; del.BindLoginViewController(); } throw ex; } }
//Update an existing timelog entry public async Task <TimeLogEntry> UpdateTimeLog(string timeLogId, string comment, DateTime?startDate, string taskId, double?loggedTime, double?interruptTime, bool open) { try { return(await base.UpdateTimeLog(dataset, timeLogId, comment, startDate, taskId, loggedTime, interruptTime, open)); } catch (Exception ex) { if (ex.Message.Contains("401")) { AccountStorage.ClearPassword(); AppDelegate del = UIApplication.SharedApplication.Delegate as AppDelegate; del.BindLoginViewController(); } throw ex; } }
// Get Time Log entries with optional parameters. // Optional parameters should be specified as null // only dataset is required public async Task <List <TimeLogEntry> > GetTimeLogs(int?maxResults, DateTime?startDateFrom, DateTime?startDateTo, string taskId, string projectId) { try { return(await base.GetTimeLogs(dataset, maxResults, startDateFrom, startDateTo, taskId, projectId)); } catch (Exception ex) { if (ex.Message.Contains("401")) { AccountStorage.ClearPassword(); AppDelegate del = UIApplication.SharedApplication.Delegate as AppDelegate; del.BindLoginViewController(); } throw ex; } }