public static async Task <List <Tweet> > Get() { try { var config = AppConfig.GetConfig(); var tweets = await config.TweetFunctionUrl .GetJsonAsync <List <Tweet> >(); return(tweets); } catch (Exception e) { DotNetRuLogger.Report(e); } return(new List <Tweet>()); }
public static async Task <List <ISocialPost> > GetBySubscriptionsAsync(List <string> communities) { try { var config = AppConfig.GetConfig(); var tweets = await config.SubscriptionTweetFunctionUrl.PostJsonAsync(communities) .ReceiveJson <List <Tweet> >(); return(tweets.Cast <ISocialPost>().ToList()); } catch (Exception e) { DotNetRuLogger.Report(e); } return(new List <ISocialPost>()); }
public static async Task <List <ISocialPost> > GetAsync() { try { var config = AppConfig.GetConfig(); var vkontaktePosts = await config.VkontakteFunctionUrl .GetJsonAsync <List <VkontaktePost> >(); return(vkontaktePosts.Cast <ISocialPost>().ToList()); } catch (Exception e) { DotNetRuLogger.Report(e); } return(new List <ISocialPost>()); }
public static async Task <List <ISocialPost> > GetBySubscriptionsAsync(IDictionary <string, byte> communities) { try { var config = AppConfig.GetConfig(); var vkontaktePosts = await config.SubscriptionVkontakteFunctionUrl.PostJsonAsync(communities) .ReceiveJson <List <VkontaktePost> >(); return(vkontaktePosts.Cast <ISocialPost>().ToList()); } catch (Exception e) { DotNetRuLogger.Report(e); } return(new List <ISocialPost>()); }
// Called whenever your app performs a background fetch public override void PerformFetch(UIApplication application, Action <UIBackgroundFetchResult> completionHandler) { // Do Background Fetch var downloadSuccessful = false; try { Forms.Init(); // need for dependency services } catch (Exception ex) { ex.Data["Method"] = "PerformFetch"; DotNetRuLogger.Report(ex); } // If you don't call this, your application will be terminated by the OS. // Allows OS to collect stats like data cost and power consumption var resultFlag = downloadSuccessful ? UIBackgroundFetchResult.NewData : UIBackgroundFetchResult.Failed; completionHandler(resultFlag); }
private bool ExecuteLoadNotifications(bool force = false) { if (this.IsBusy) { return(false); } try { this.IsBusy = true; } catch (Exception ex) { DotNetRuLogger.Report(ex); MessagingService.Current.SendMessage(MessageKeys.Error, ex); } finally { this.IsBusy = false; } return(true); }
private void ExecuteLoadSubscriptions() { if (this.IsBusy) { return; } try { this.IsBusy = true; UpdateSubscriptions(); } catch (Exception ex) { DotNetRuLogger.Report(ex); MessagingService.Current.SendMessage(MessageKeys.Error, ex); } finally { this.IsBusy = false; } }
public static async Task UpdateAudit() { try { DotNetRuLogger.TrackEvent("AuditUpdate. Started updating audit"); string currentCommitSha; using (var auditRealm = Realm.GetInstance("Audit.realm")) { var auditVersion = auditRealm.All <AuditVersion>().Single(); currentCommitSha = auditVersion.CommitHash; } DotNetRuLogger.TrackEvent("AuditUpdate. Current synchronization context: " + SynchronizationContext.Current); DotNetRuLogger.TrackEvent("AuditUpdate. Current version is: " + currentCommitSha); var client = new GitHubClient(new ProductHeaderValue("DotNetRu")); var reference = await client.Git.Reference.Get(DotNetRuAppRepositoryID, "heads/master"); var latestMasterCommitSha = reference.Object.Sha; DotNetRuLogger.TrackEvent("AuditUpdate. Latest version (master) is: " + latestMasterCommitSha); var contentUpdate = await client.Repository.Commit.Compare( DotNetRuAppRepositoryID, currentCommitSha, latestMasterCommitSha); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var httpClient = new HttpClient(); var streamTasks = contentUpdate.Files.Select( async file => new UpdatedFile { Filename = file.Filename, Content = await httpClient.GetByteArrayAsync(file.RawUrl) .ConfigureAwait(false) }); var fileContents = await Task.WhenAll(streamTasks); DotNetRuLogger.TrackEvent("AuditUpdate. Downloading files time: " + stopwatch.Elapsed.ToString("g")); var xmlFiles = fileContents.Where(x => x.Filename.EndsWith(".xml")).ToList(); using (var auditRealm = Realm.GetInstance("Audit.realm")) { using (var trans = auditRealm.BeginWrite()) { var mapper = GetAutoMapper(auditRealm); UpdateModels <SpeakerEntity>(mapper, auditRealm, xmlFiles, "speakers"); UpdateModels <FriendEntity>(mapper, auditRealm, xmlFiles, "friends"); UpdateModels <VenueEntity>(mapper, auditRealm, xmlFiles, "venues"); UpdateModels <TalkEntity>(mapper, auditRealm, xmlFiles, "talks"); UpdateModels <MeetupEntity>(mapper, auditRealm, xmlFiles, "meetups"); var speakerPhotos = fileContents.Where(x => x.Filename.EndsWith("avatar.jpg")); UpdateSpeakerAvatars(auditRealm, speakerPhotos); var auditVersion = auditRealm.All <AuditVersion>().Single(); auditVersion.CommitHash = latestMasterCommitSha; auditRealm.Add(auditVersion, update: true); trans.Commit(); } } stopwatch.Stop(); DotNetRuLogger.TrackEvent("AuditUpdate. Finished! Time: " + stopwatch.Elapsed.ToString("g")); } catch (Exception e) { DotNetRuLogger.Report(e, "AuditUpdate"); throw; } }