public NewsFeedIgnoreItemData GetIgnoreItemData() { NewsItem newsItem = this._newsItemWithInfo.NewsItem; List <VKClient.Common.Backend.DataObjects.Video> videoList1; if (newsItem == null) { videoList1 = (List <VKClient.Common.Backend.DataObjects.Video>)null; } else { VKList <VKClient.Common.Backend.DataObjects.Video> video = newsItem.video; videoList1 = video != null ? video.items : (List <VKClient.Common.Backend.DataObjects.Video>)null; } List <VKClient.Common.Backend.DataObjects.Video> videoList2 = videoList1; if (videoList2 == null || videoList2.Count <= 0) { return((NewsFeedIgnoreItemData)null); } VKClient.Common.Backend.DataObjects.Video video1 = videoList2[0]; long itemId = videoList2.Count == 1 ? video1.id : BaseFormatterHelper.GetLastMidnight((long)newsItem.date, false); return(new NewsFeedIgnoreItemData("video", video1.owner_id, itemId)); }
private string GetPhotoPhotoTagFeedText(NewsItem newsFeedItem, List <Group> groups, List <User> users) { User user = users.FirstOrDefault <User>((Func <User, bool>)(u => u.uid == newsFeedItem.source_id)); if (user != null) { bool flag = user.sex == 2; if (newsFeedItem.Photo_tags != null && newsFeedItem.Photo_tags.Count > 0) { string str1 = flag ? BaseResources.Photo_WasTaggedMale : BaseResources.Photo_WasTaggedFemale; string str2 = BaseFormatterHelper.FormatNumberOfSomething(newsFeedItem.PhotoTagsCount, BaseResources.Photo_OnOnePhotoFrm, BaseResources.Photo_OnFivePhotosFrm, BaseResources.Photo_OnFivePhotosFrm, true, null, false); string str3 = " "; string str4 = str2; return(str1 + str3 + str4); } if (newsFeedItem.Photos != null && newsFeedItem.Photos.Count > 0) { string str1 = flag ? BaseResources.Photo_AddedMale : BaseResources.Photo_AddedFemale; string str2 = BaseFormatterHelper.FormatNumberOfSomething(newsFeedItem.PhotosCount, BaseResources.Photo_OnePhotoAddedFrm, BaseResources.Photo_TwoFourPhotosAddedFrm, BaseResources.Photo_FivePhotosAddedFrm, true, null, false); string str3 = " "; string str4 = str2; return(str1 + str3 + str4); } } return(""); }
public string GenerateTitleIfNecessary(WallPost wallPost) { string str = ""; if (wallPost.attachments == null) { return(str); } if ((wallPost.attachments == null ? 0 : wallPost.attachments.Count <Attachment>((Func <Attachment, bool>)(a => a.photo != null))) > 0) { str = BaseFormatterHelper.FormatNumberOfSomething(wallPost.attachments.Count, BaseResources.OnePhotoFrm, BaseResources.TwoFourPhotosFrm, BaseResources.FivePhotosFrm, true, null, false); } List <Attachment> attachments1 = wallPost.attachments; Func <Attachment, bool> predicate1 = (Func <Attachment, bool>)(a => a.link != null); if (attachments1.Any <Attachment>(predicate1)) { str = BaseResources.Link; } List <Attachment> attachments2 = wallPost.attachments; Func <Attachment, bool> predicate2 = (Func <Attachment, bool>)(a => a.Page != null); if (attachments2.Any <Attachment>(predicate2)) { str = BaseResources.WikiPage; } return(str); }
protected override object VisitInternal(FunctionOperator theOperator) { string[] operands = new string[theOperator.Operands.Count]; for (int i = 0; i < theOperator.Operands.Count; ++i) { operands[i] = Process((CriteriaOperator)theOperator.Operands[i]); } string result = BaseFormatterHelper.DefaultFormatFunction(theOperator.OperatorType, operands); if (result != null) { return(result); } return(base.VisitInternal(theOperator)); }
protected override async void OnInvoke(ScheduledTask task) { Logger.Instance.Info(("Entering ScheduledAgent.OnInvoke, task.Name=" + task.Name) ?? "", new object[0]); try { AppGlobalStateManager.Current.Initialize(true); if (AppGlobalStateManager.Current.LoggedInUserId != 0L) { if (task.Name == "ExtensibilityTaskAgent") { await SocialDataManager.Instance.ProcessSocialOperationsQueue(); this.NotifyComplete(); } else { SecondaryTileManager.Instance.UpdateAllExistingTiles(delegate(bool resSecondary) { CountersService.Instance.GetCountersWithLastMessage(delegate(BackendResult <CountersWithMessageInfo, ResultCode> res) { if (res.ResultCode == ResultCode.Succeeded) { string content = ""; string content2 = ""; string content3 = ""; if (res.ResultData.LastMessage != null && BaseFormatterHelper.UnixTimeStampToDateTime((double)res.ResultData.LastMessage.date, true) > AppGlobalStateManager.Current.GlobalState.LastDeactivatedTime) { MessageHeaderFormatterHelper.FormatForTileIntoThreeStrings(res.ResultData.LastMessage, res.ResultData.User, out content, out content2, out content3); } int messages = res.ResultData.Counters.messages; TileManager.Instance.SetContentAndCount(content, content2, content3, messages, delegate { base.NotifyComplete(); }); return; } base.NotifyComplete(); }); }); } } } catch (Exception var_2_FE) { Logger.Instance.Error("ScheduledAgent.OnInvoke failed", var_2_FE); this.NotifyComplete(); } }
public static IEnumerable <PhoneItem> GetPhones(UserData profileData) { List <PhoneItem> phoneItemList = new List <PhoneItem>(); User user = profileData.user; if (!string.IsNullOrEmpty(user.mobile_phone)) { List <string> phoneNumbers = BaseFormatterHelper.ParsePhoneNumbers(user.mobile_phone); phoneItemList.AddRange((IEnumerable <PhoneItem>)Enumerable.Select <string, PhoneItem>(phoneNumbers, (Func <string, PhoneItem>)(phoneNumber => new PhoneItem(CommonResources.ProfilePage_Info_MobilePhone, phoneNumber)))); } if (!string.IsNullOrEmpty(user.home_phone)) { List <string> phoneNumbers = BaseFormatterHelper.ParsePhoneNumbers(user.home_phone); phoneItemList.AddRange((IEnumerable <PhoneItem>)Enumerable.Select <string, PhoneItem>(phoneNumbers, (Func <string, PhoneItem>)(phoneNumber => new PhoneItem(CommonResources.ProfilePage_Info_AlternativePhone, phoneNumber)))); } return((IEnumerable <PhoneItem>)phoneItemList); }
private static string GetAttachmentsDesc(Message message) { string str = ""; if (message.attachments != null && message.attachments.Count > 0) { Attachment firstAttachment = message.attachments.First <Attachment>(); int number = message.attachments.Count <Attachment>((Func <Attachment, bool>)(a => a.type == firstAttachment.type)); string lowerInvariant = firstAttachment.type.ToLowerInvariant(); if (!(lowerInvariant == "photo")) { if (!(lowerInvariant == "video")) { if (!(lowerInvariant == "audio")) { if (!(lowerInvariant == "doc")) { if (lowerInvariant == "wall") { str = BaseResources.WallPost; } } else { str = BaseFormatterHelper.FormatNumberOfSomething(number, BaseResources.OneDocFrm, BaseResources.TwoFourDocsFrm, BaseResources.FiveDocsFrm, true, null, false); } } else { str = BaseFormatterHelper.FormatNumberOfSomething(number, BaseResources.OneAudioFrm, BaseResources.TwoFourAudiosFrm, BaseResources.FiveAudiosFrm, true, null, false); } } else { str = BaseFormatterHelper.FormatNumberOfSomething(number, BaseResources.OneVideoFrm, BaseResources.TwoFourVideosFrm, BaseResources.FiveVideosFrm, true, null, false); } } else { str = BaseFormatterHelper.FormatNumberOfSomething(number, BaseResources.OnePhotoFrm, BaseResources.TwoFourPhotosFrm, BaseResources.FivePhotosFrm, true, null, false); } } return(str); }
public NewsFeedIgnoreItemData GetIgnoreItemData() { NewsItem newsItem = this._newsPost.NewsItem; string postType = newsItem.post_type; string type = ""; long sourceId = newsItem.source_id; long itemId = 0; if (postType == "photo" || postType == "photo_tag" || postType == "wall_photo") { if (!(postType == "photo") && !(postType == "wall_photo")) { if (postType == "photo_tag") { type = "tag"; } } else { type = "photo"; } Photo photo = this._photo; itemId = photo != null ? photo.id : BaseFormatterHelper.GetLastMidnight((long)newsItem.date, false); } else if (postType == "video") { type = "video"; VKClient.Common.Backend.DataObjects.Video video = this._video; itemId = video != null ? video.id : BaseFormatterHelper.GetLastMidnight((long)newsItem.date, false); } if (!string.IsNullOrEmpty(type) && sourceId != 0L && itemId != 0L) { return(new NewsFeedIgnoreItemData(type, sourceId, itemId)); } return(null); }
private async Task SetContactProperties(StoredContact contact, User user, User originalUser = null) { if (contact != null) { contact.RemoteId = ContactsManager.GetRemoteId(user); contact.GivenName = user.first_name; contact.FamilyName = user.last_name; if (!string.IsNullOrWhiteSpace(user.photo_max) && !user.photo_max.EndsWith(".gif")) { Stream responseStreamAsync = await HttpExtensions.TryGetResponseStreamAsync(user.photo_max); if (responseStreamAsync == null) { throw new Exception("failed to download contact pic " + user.photo_max); } await contact.SetDisplayPictureAsync(responseStreamAsync.AsInputStream()); } IDictionary <string, object> propertiesAsync = await contact.GetPropertiesAsync(); if (!string.IsNullOrWhiteSpace(user.site)) { propertiesAsync[KnownContactProperties.Url] = (object)user.site; } if (!string.IsNullOrWhiteSpace(user.mobile_phone) && this.IsPhoneNumber(user.mobile_phone)) { List <string> phoneNumbers = BaseFormatterHelper.ParsePhoneNumbers(user.mobile_phone); if (phoneNumbers.Count >= 1) { propertiesAsync[KnownContactProperties.MobileTelephone] = (object)phoneNumbers[0]; } if (phoneNumbers.Count >= 2) { propertiesAsync[KnownContactProperties.AlternateMobileTelephone] = (object)phoneNumbers[1]; } } if (!string.IsNullOrWhiteSpace(user.home_phone) && this.IsPhoneNumber(user.home_phone)) { List <string> phoneNumbers = BaseFormatterHelper.ParsePhoneNumbers(user.home_phone); if (phoneNumbers.Count >= 1) { propertiesAsync[KnownContactProperties.Telephone] = (object)phoneNumbers[0]; } if (phoneNumbers.Count >= 2) { propertiesAsync[KnownContactProperties.AlternateTelephone] = (object)phoneNumbers[1]; } } DateTime dateTime; if (!string.IsNullOrWhiteSpace(user.bdate) && ContactsManager.TryParseDateTimeFromString(user.bdate, out dateTime)) { TimeSpan timeSpan = DateTime.Now - DateTime.UtcNow; dateTime = dateTime.Add(timeSpan); DateTimeOffset dateTimeOffset = new DateTimeOffset(dateTime.Year, dateTime.Month, dateTime.Day, 0, 0, 0, 0, TimeSpan.Zero); propertiesAsync[KnownContactProperties.Birthdate] = (object)new DateTimeOffset(dateTime); } } if (originalUser == null) { return; } originalUser.first_name = user.first_name; originalUser.last_name = user.last_name; originalUser.site = user.site; originalUser.mobile_phone = user.mobile_phone; originalUser.home_phone = user.home_phone; originalUser.photo_max = user.photo_max; originalUser.bdate = user.bdate; }
public static DateTime UnixTimeStampToDateTime(double unixTimeStamp, bool includeTimeDiff = true) { return(BaseFormatterHelper.UnixTimeStampToDateTime(unixTimeStamp, includeTimeDiff)); }
public static string FormatNumberOfSomething(int number, string oneSomethingFrm, string twoSomethingFrm, string fiveSomethingFrm, bool includeNumberInResult = true, string additionalFormatParam = null, bool includeZero = false) { return(BaseFormatterHelper.FormatNumberOfSomething(number, oneSomethingFrm, twoSomethingFrm, fiveSomethingFrm, includeNumberInResult, additionalFormatParam, includeZero)); }
private async Task SetContactProperties(StoredContact contact, User user, User originalUser = null) { if (contact != null) { contact.RemoteId = (ContactsManager.GetRemoteId(user)); contact.GivenName = (user.first_name); contact.FamilyName = (user.last_name); if (!string.IsNullOrWhiteSpace(user.photo_max) && !user.photo_max.EndsWith(".gif")) { Stream stream = await HttpExtensions.TryGetResponseStreamAsync(user.photo_max); if (stream == null) { throw new Exception("failed to download contact pic " + user.photo_max); } await contact.SetDisplayPictureAsync(stream.AsInputStream()); } IDictionary <string, object> dictionary = await contact.GetPropertiesAsync(); if (!string.IsNullOrWhiteSpace(user.site)) { dictionary[KnownContactProperties.Url] = user.site; } if (!string.IsNullOrWhiteSpace(user.mobile_phone) && this.IsPhoneNumber(user.mobile_phone)) { List <string> var_6_262 = BaseFormatterHelper.ParsePhoneNumbers(user.mobile_phone); if (var_6_262.Count >= 1) { dictionary[KnownContactProperties.MobileTelephone] = var_6_262[0]; } if (var_6_262.Count >= 2) { dictionary[KnownContactProperties.AlternateMobileTelephone] = var_6_262[1]; } } if (!string.IsNullOrWhiteSpace(user.home_phone) && this.IsPhoneNumber(user.home_phone)) { List <string> var_7_2D8 = BaseFormatterHelper.ParsePhoneNumbers(user.home_phone); if (var_7_2D8.Count >= 1) { dictionary[KnownContactProperties.Telephone] = var_7_2D8[0]; } if (var_7_2D8.Count >= 2) { dictionary[KnownContactProperties.AlternateTelephone] = var_7_2D8[1]; } } DateTime var_8; if (!string.IsNullOrWhiteSpace(user.bdate) && ContactsManager.TryParseDateTimeFromString(user.bdate, out var_8)) { var_8 = var_8.Add(DateTime.Now - DateTime.UtcNow); new DateTimeOffset(var_8.Year, var_8.Month, var_8.Day, 0, 0, 0, 0, TimeSpan.Zero); dictionary[KnownContactProperties.Birthdate] = new DateTimeOffset(var_8); } } if (originalUser != null) { originalUser.first_name = user.first_name; originalUser.last_name = user.last_name; originalUser.site = user.site; originalUser.mobile_phone = user.mobile_phone; originalUser.home_phone = user.home_phone; originalUser.photo_max = user.photo_max; originalUser.bdate = user.bdate; } }
string ICriteriaVisitor <string> .Visit(UnaryOperator theOperator) { return(BaseFormatterHelper.DefaultFormatUnary(theOperator.OperatorType, Process(theOperator.Operand))); }