/// <summary>
        /// Click event to post link on wall
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BtnpostLink_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                PostLink oPostLink = new PostLink();
                oPostLink.message     = "Testing Facebook C# SDK";
                oPostLink.link        = "http://facebooksdk.codeplex.com/";
                oPostLink.name        = "Facebook C# SDK";
                oPostLink.description = "The Facebook C# SDK helps .Net developers build web, desktop, Silverlight, and Windows Phone 7 applications that integrate with Facebook.";
                oPostLink.privacy     = PrivacyType.ALL_FRIENDS.ToString();
                oPostLink.picture     = "http://download.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=facebooksdk&DownloadId=170794&Build=17672";
                oPostLink.caption     = "http://facebooksdk.codeplex.com/";
                string strResult = await GlobalVariable.oTSGFacebookManager.PostLinkOnWall(oPostLink);

                if (string.IsNullOrEmpty(strResult))
                {
                    strResult = "Error Ocuured!";
                }
                MessageDialog SuccessMsg = new MessageDialog(strResult);
                await SuccessMsg.ShowAsync();
            }
            catch (Exception ex)
            {
                //MessageDialog ErrMsg = new MessageDialog("Error Ocuured!");
            }
        }
Beispiel #2
0
        //public void UserEntersQuestionDetails(string qDetl)
        //{
        //    GetDisplayedElement(_txtQuestionDetails, 500, 15000).SendKeys(qDetl);
        //}

        //public void EnterAQuestion(string qTitle, string qDetl)
        //{
        //    WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(50));
        //    wait.Until(ExpectedConditions.ElementToBeClickable(_txtQuestionTitle));
        //    QuestionTitleText.Clear();
        //    QuestionTitleText.SendKeys(qTitle);
        //    Thread.Sleep(2000);
        //   // Assert.IsTrue(QuestionDetailsText.Displayed);
        //   // driver.SwitchTo().Frame(driver.FindElement(_iFrameQuestion));
        //   // wait.Until(ExpectedConditions.ElementToBeClickable(_txtQuestionDetails));
        //    QuestionDetailsText.Click();
        //    QuestionDetailsText.SendKeys(qDetl);
        //    Thread.Sleep(2000);
        //}
        public void ClickOnPostLink()
        {
            if (PostLink.Displayed)
            {
                PostLink.Click();
            }

            else
            {
                throw new Exception("Element is not found or not clickable");
            }
        }
Beispiel #3
0
        public void MapEntityToModelList()
        {
            var      mapper = new DALPostLinkMapper();
            PostLink item   = new PostLink();

            item.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, 1);
            List <ApiPostLinkServerResponseModel> response = mapper.MapEntityToModel(new List <PostLink>()
            {
                { item }
            });

            response.Count.Should().Be(1);
        }
Beispiel #4
0
        public virtual PostLink MapBOToEF(
            BOPostLink bo)
        {
            PostLink efPostLink = new PostLink();

            efPostLink.SetProperties(
                bo.CreationDate,
                bo.Id,
                bo.LinkTypeId,
                bo.PostId,
                bo.RelatedPostId);
            return(efPostLink);
        }
Beispiel #5
0
        public virtual BOPostLink MapEFToBO(
            PostLink ef)
        {
            var bo = new BOPostLink();

            bo.SetProperties(
                ef.Id,
                ef.CreationDate,
                ef.LinkTypeId,
                ef.PostId,
                ef.RelatedPostId);
            return(bo);
        }
Beispiel #6
0
        public virtual async Task <ApiPostLinkServerResponseModel> Get(int id)
        {
            PostLink record = await this.PostLinkRepository.Get(id);

            if (record == null)
            {
                return(null);
            }
            else
            {
                return(this.DalPostLinkMapper.MapEntityToModel(record));
            }
        }
Beispiel #7
0
        public void MapModelToEntity()
        {
            var mapper = new DALPostLinkMapper();
            ApiPostLinkServerRequestModel model = new ApiPostLinkServerRequestModel();

            model.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, 1);
            PostLink response = mapper.MapModelToEntity(1, model);

            response.CreationDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.LinkTypeId.Should().Be(1);
            response.PostId.Should().Be(1);
            response.RelatedPostId.Should().Be(1);
        }
        public static async Task <PostLink> GetLinkData(string link)
        {
            var postLink = new PostLink();

            try
            {
                if (!link.StartsWith("http"))
                {
                    link = "http://" + link;
                }
                var uri = new Uri(link);
            }
            catch
            {
                return(null);
            }
            postLink.LinkUrl = link;
            var webGet = new HtmlWeb();

            try
            {
                var document = await webGet.LoadFromWebAsync(link);

                var metaNodes   = document.DocumentNode.Descendants("meta").Where(m => m.Attributes.Contains("property")).ToList();
                var title       = metaNodes.FirstOrDefault(m => m.Attributes.FirstOrDefault(j => j.Value == "og:title") != null)?.GetAttributeValue("content", "");
                var description = metaNodes.FirstOrDefault(m => m.Attributes.FirstOrDefault(j => j.Value == "og:description") != null)?.GetAttributeValue("content", "");
                var image       = metaNodes.FirstOrDefault(m => m.Attributes.FirstOrDefault(j => j.Value == "og:image") != null)?.GetAttributeValue("content", "");

                var deEntitized = HtmlEntity.DeEntitize(Regex.Replace(title ?? "", "&apos;", "'"));
                title          = Regex.Replace(deEntitized, @"&#39;", "'");
                postLink.Title = title;

                deEntitized      = HtmlEntity.DeEntitize(Regex.Replace(description ?? "", "&apos;", "'"));
                description      = Regex.Replace(deEntitized, @"&#39;", "'");
                postLink.Content = description;
                if (!string.IsNullOrEmpty(image))
                {
                    if (!image.ToLower().StartsWith("http:") && !image.ToLower().StartsWith("https:"))
                    {
                        image = "http:" + image;
                    }
                }

                postLink.ImageUrl = image;
            }
            catch
            {
                return(null);
            }
            return(postLink);
        }
Beispiel #9
0
        public void MapEntityToModel()
        {
            var      mapper = new DALPostLinkMapper();
            PostLink item   = new PostLink();

            item.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, 1);
            ApiPostLinkServerResponseModel response = mapper.MapEntityToModel(item);

            response.CreationDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Id.Should().Be(1);
            response.LinkTypeId.Should().Be(1);
            response.PostId.Should().Be(1);
            response.RelatedPostId.Should().Be(1);
        }
        public void MapEFToBOList()
        {
            var      mapper = new DALPostLinkMapper();
            PostLink entity = new PostLink();

            entity.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, 1, 1);

            List <BOPostLink> response = mapper.MapEFToBO(new List <PostLink>()
            {
                entity
            });

            response.Count.Should().Be(1);
        }
Beispiel #11
0
        public virtual PostLink MapModelToEntity(
            int id,
            ApiPostLinkServerRequestModel model
            )
        {
            PostLink item = new PostLink();

            item.SetProperties(
                id,
                model.CreationDate,
                model.LinkTypeId,
                model.PostId,
                model.RelatedPostId);
            return(item);
        }
        public void MapEFToBO()
        {
            var      mapper = new DALPostLinkMapper();
            PostLink entity = new PostLink();

            entity.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, 1, 1);

            BOPostLink response = mapper.MapEFToBO(entity);

            response.CreationDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Id.Should().Be(1);
            response.LinkTypeId.Should().Be(1);
            response.PostId.Should().Be(1);
            response.RelatedPostId.Should().Be(1);
        }
        public void MapBOToEF()
        {
            var mapper = new DALPostLinkMapper();
            var bo     = new BOPostLink();

            bo.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, 1);

            PostLink response = mapper.MapBOToEF(bo);

            response.CreationDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Id.Should().Be(1);
            response.LinkTypeId.Should().Be(1);
            response.PostId.Should().Be(1);
            response.RelatedPostId.Should().Be(1);
        }
Beispiel #14
0
        public virtual async Task <CreateResponse <ApiPostLinkServerResponseModel> > Create(
            ApiPostLinkServerRequestModel model)
        {
            CreateResponse <ApiPostLinkServerResponseModel> response = ValidationResponseFactory <ApiPostLinkServerResponseModel> .CreateResponse(await this.PostLinkModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                PostLink record = this.DalPostLinkMapper.MapModelToEntity(default(int), model);
                record = await this.PostLinkRepository.Create(record);

                response.SetRecord(this.DalPostLinkMapper.MapEntityToModel(record));
                await this.mediator.Publish(new PostLinkCreatedNotification(response.Record));
            }

            return(response);
        }
Beispiel #15
0
        public async void Get_ShouldReturnRecords()
        {
            var mock   = new ServiceMockFacade <IPostLinkService, IPostLinkRepository>();
            var record = new PostLink();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new PostLinkService(mock.LoggerMock.Object,
                                              mock.MediatorMock.Object,
                                              mock.RepositoryMock.Object,
                                              mock.ModelValidatorMockFactory.PostLinkModelValidatorMock.Object,
                                              mock.DALMapperMockFactory.DALPostLinkMapperMock);

            ApiPostLinkServerResponseModel response = await service.Get(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Beispiel #16
0
        public virtual async Task <UpdateResponse <ApiPostLinkServerResponseModel> > Update(
            int id,
            ApiPostLinkServerRequestModel model)
        {
            var validationResult = await this.PostLinkModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                PostLink record = this.DalPostLinkMapper.MapModelToEntity(id, model);
                await this.PostLinkRepository.Update(record);

                record = await this.PostLinkRepository.Get(id);

                ApiPostLinkServerResponseModel apiModel = this.DalPostLinkMapper.MapEntityToModel(record);
                await this.mediator.Publish(new PostLinkUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiPostLinkServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiPostLinkServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Beispiel #17
0
        public virtual ApiPostLinkServerResponseModel MapEntityToModel(
            PostLink item)
        {
            var model = new ApiPostLinkServerResponseModel();

            model.SetProperties(item.Id,
                                item.CreationDate,
                                item.LinkTypeId,
                                item.PostId,
                                item.RelatedPostId);
            if (item.LinkTypeIdNavigation != null)
            {
                var linkTypeIdModel = new ApiLinkTypeServerResponseModel();
                linkTypeIdModel.SetProperties(
                    item.LinkTypeIdNavigation.Id,
                    item.LinkTypeIdNavigation.RwType);

                model.SetLinkTypeIdNavigation(linkTypeIdModel);
            }

            if (item.PostIdNavigation != null)
            {
                var postIdModel = new ApiPostServerResponseModel();
                postIdModel.SetProperties(
                    item.PostIdNavigation.Id,
                    item.PostIdNavigation.AcceptedAnswerId,
                    item.PostIdNavigation.AnswerCount,
                    item.PostIdNavigation.Body,
                    item.PostIdNavigation.ClosedDate,
                    item.PostIdNavigation.CommentCount,
                    item.PostIdNavigation.CommunityOwnedDate,
                    item.PostIdNavigation.CreationDate,
                    item.PostIdNavigation.FavoriteCount,
                    item.PostIdNavigation.LastActivityDate,
                    item.PostIdNavigation.LastEditDate,
                    item.PostIdNavigation.LastEditorDisplayName,
                    item.PostIdNavigation.LastEditorUserId,
                    item.PostIdNavigation.OwnerUserId,
                    item.PostIdNavigation.ParentId,
                    item.PostIdNavigation.PostTypeId,
                    item.PostIdNavigation.Score,
                    item.PostIdNavigation.Tag,
                    item.PostIdNavigation.Title,
                    item.PostIdNavigation.ViewCount);

                model.SetPostIdNavigation(postIdModel);
            }

            if (item.RelatedPostIdNavigation != null)
            {
                var relatedPostIdModel = new ApiPostServerResponseModel();
                relatedPostIdModel.SetProperties(
                    item.RelatedPostIdNavigation.Id,
                    item.RelatedPostIdNavigation.AcceptedAnswerId,
                    item.RelatedPostIdNavigation.AnswerCount,
                    item.RelatedPostIdNavigation.Body,
                    item.RelatedPostIdNavigation.ClosedDate,
                    item.RelatedPostIdNavigation.CommentCount,
                    item.RelatedPostIdNavigation.CommunityOwnedDate,
                    item.RelatedPostIdNavigation.CreationDate,
                    item.RelatedPostIdNavigation.FavoriteCount,
                    item.RelatedPostIdNavigation.LastActivityDate,
                    item.RelatedPostIdNavigation.LastEditDate,
                    item.RelatedPostIdNavigation.LastEditorDisplayName,
                    item.RelatedPostIdNavigation.LastEditorUserId,
                    item.RelatedPostIdNavigation.OwnerUserId,
                    item.RelatedPostIdNavigation.ParentId,
                    item.RelatedPostIdNavigation.PostTypeId,
                    item.RelatedPostIdNavigation.Score,
                    item.RelatedPostIdNavigation.Tag,
                    item.RelatedPostIdNavigation.Title,
                    item.RelatedPostIdNavigation.ViewCount);

                model.SetRelatedPostIdNavigation(relatedPostIdModel);
            }

            return(model);
        }
Beispiel #18
0
        /// <summary>
        /// Распарсить.
        /// </summary>
        /// <param name="source">Источник.</param>
        /// <returns>Результат.</returns>
        public IBoardPost Parse(BoardPost2WithParentLink source)
        {
            var data      = source.Post;
            var link      = source.ParentLink;
            var isPreview = source.EntityType != PostStoreEntityType.Post;

            var ipIdRegex  = RegexCache.CreateRegex(IpIdRegexText);
            var ipIdRegex2 = RegexCache.CreateRegex(IpIdRegexText2);
            var colorRegex = RegexCache.CreateRegex(ColorRegexText);

            var flags = new HashSet <Guid>();

            if (data.Banned != "0" && !string.IsNullOrWhiteSpace(data.Banned))
            {
                flags.Add(BoardPostFlags.Banned);
            }
            if (data.Closed != "0" && !string.IsNullOrWhiteSpace(data.Closed))
            {
                flags.Add(BoardPostFlags.Closed);
            }
            if (data.Sticky != "0" && !string.IsNullOrWhiteSpace(data.Sticky))
            {
                flags.Add(BoardPostFlags.Sticky);
            }
            if (isPreview)
            {
                flags.Add(BoardPostFlags.ThreadPreview);
            }
            if (source.Counter == 1)
            {
                flags.Add(BoardPostFlags.ThreadOpPost);
            }
            if (data.Op != "0" && !string.IsNullOrWhiteSpace(data.Op))
            {
                flags.Add(BoardPostFlags.Op);
            }
            if ("mailto:sage".Equals((data.Email ?? "").Trim(), StringComparison.OrdinalIgnoreCase))
            {
                flags.Add(BoardPostFlags.Sage);
            }
            if (data.Edited != "0" && !string.IsNullOrWhiteSpace(data.Edited))
            {
                flags.Add(BoardPostFlags.IsEdited);
            }
            if ((data.Endless ?? 0) != 0)
            {
                flags.Add(BoardPostFlags.Endless);
            }
            string admName = null;

            if (data.Tripcode != null)
            {
                if (data.Tripcode.StartsWith("!!%") && data.Tripcode.EndsWith("%!!"))
                {
                    if ("!!%mod%!!".Equals(data.Tripcode))
                    {
                        admName = "## Mod ##";
                    }
                    else if ("!!%adm%!!".Equals(data.Tripcode))
                    {
                        admName = "## Abu ##";
                    }
                    else if ("!!%Inquisitor%!!".Equals(data.Tripcode))
                    {
                        admName = "## Applejack ##";
                    }
                    else if ("!!%coder%!!".Equals(data.Tripcode))
                    {
                        admName = "## Кодер ##";
                    }
                    else
                    {
                        admName = data.Tripcode.Replace("!!%", "## ").Replace("%!!", " ##");
                    }
                    flags.Add(BoardPostFlags.AdminTrip);
                }
            }
            var number   = data.Number.TryParseWithDefault();
            var thisLink = new PostLink()
            {
                Engine    = MakabaConstants.MakabaEngineId,
                Board     = link.Board,
                OpPostNum = link.OpPostNum,
                PostNum   = number
            };
            var    postDocument = _htmlParser.ParseHtml(data.Comment ?? "", thisLink);
            var    name         = admName != null && string.IsNullOrWhiteSpace(data.Name) ? admName : WebUtility.HtmlDecode(data.Name ?? string.Empty).Replace("&nbsp;", " ");
            string nameColor    = null;
            Color? color        = null;
            var    match        = ipIdRegex.Match(name);
            var    match2       = ipIdRegex2.Match(name);

            if (match.Success)
            {
                name = match.Groups["id"].Captures[0].Value;
            }
            else if (match2.Success)
            {
                name      = match2.Groups["id"].Captures[0].Value;
                nameColor = match2.Groups["style"].Captures[0].Value;
                var cmatch = colorRegex.Match(nameColor);
                if (cmatch.Success)
                {
                    try
                    {
                        var r = byte.Parse(cmatch.Groups["r"].Captures[0].Value, CultureInfo.InvariantCulture.NumberFormat);
                        var g = byte.Parse(cmatch.Groups["g"].Captures[0].Value, CultureInfo.InvariantCulture.NumberFormat);
                        var b = byte.Parse(cmatch.Groups["b"].Captures[0].Value, CultureInfo.InvariantCulture.NumberFormat);
                        color = Color.FromArgb(255, r, g, b);
                    }
                    catch (Exception)
                    {
                        color = null;
                    }
                }
            }
            else if (name.StartsWith("Аноним ID:", StringComparison.OrdinalIgnoreCase))
            {
                name = name.Remove(0, "Аноним ID:".Length).Trim();
            }
            PosterInfo posterInfo = null;

            if (!string.IsNullOrEmpty(name) || !string.IsNullOrWhiteSpace(data.Tripcode))
            {
                posterInfo = new PosterInfo()
                {
                    Name         = HtmlToText(name ?? ""),
                    NameColor    = color,
                    NameColorStr = nameColor,
                    Tripcode     = data.Tripcode
                };
            }
            var           iconAndFlag = ParseFlagAndIcon(data.Icon);
            BoardPostTags tags        = null;

            if (!string.IsNullOrWhiteSpace(data.Tags))
            {
                tags = new BoardPostTags()
                {
                    TagStr = data.Tags,
                    Tags   = new List <string>()
                    {
                        data.Tags
                    }
                };
            }
            BoardPostLikes likes = null;

            if (data.Likes != null || data.Dislikes != null)
            {
                likes = new BoardPostLikes()
                {
                    Likes    = data.Likes ?? 0,
                    Dislikes = data.Dislikes ?? 0
                };
            }
            Core.Models.Posts.BoardPost result;
            if (source.EntityType == PostStoreEntityType.CatalogPost)
            {
                result = new CatalogBoardPost()
                {
                    OnPageSequence = source.Counter
                };
            }
            else
            {
                result = new Core.Models.Posts.BoardPost();
            }
            result.Link              = thisLink;
            result.Comment           = postDocument;
            result.ParentLink        = link;
            result.Subject           = WebUtility.HtmlDecode(data.Subject ?? string.Empty);
            result.BoardSpecificDate = data.Date;
            result.Date              = DatesHelper.FromUnixTime(data.Timestamp.TryParseWithDefault());
            result.Flags             = flags.ToList();
            result.Quotes            = new List <ILink>();
            result.Hash              = data.Md5;
            result.Email             = data.Email;
            result.MediaFiles        = new List <IPostMedia>();
            result.Counter           = source.Counter;
            result.Poster            = posterInfo;
            result.Icon              = iconAndFlag.Icon;
            result.Country           = iconAndFlag.Country;
            result.Tags              = tags;
            result.UniqueId          = Guid.NewGuid().ToString();
            result.Likes             = likes;
            result.LoadedTime        = source.LoadedTime;
            result.OnServerCounter   = source.Post.CountNumber;
            if (data.Files != null)
            {
                foreach (var f in data.Files)
                {
                    BoardLinkBase mediaLink, tnLink;
                    if (IsBoardLink(f.Path, link.Board))
                    {
                        mediaLink = new BoardMediaLink()
                        {
                            Engine = MakabaConstants.MakabaEngineId,
                            Board  = link.Board,
                            Uri    = RemoveBoardFromLink(f.Path),
                        };
                        tnLink = new BoardMediaLink()
                        {
                            Engine = MakabaConstants.MakabaEngineId,
                            Board  = link.Board,
                            Uri    = RemoveBoardFromLink(f.Thumbnail),
                        };
                    }
                    else
                    {
                        mediaLink = new EngineMediaLink()
                        {
                            Engine = MakabaConstants.MakabaEngineId,
                            Uri    = f.Path,
                        };
                        tnLink = new EngineMediaLink()
                        {
                            Engine = MakabaConstants.MakabaEngineId,
                            Uri    = f.Thumbnail,
                        };
                    }
                    var media = new PostMediaWithThumbnail()
                    {
                        MediaLink   = mediaLink,
                        FileSize    = (ulong)(f.Size * 1024),
                        Height      = f.Heigth,
                        Width       = f.Width,
                        Name        = f.Name,
                        MediaType   = f.Type == MakabaMediaTypes.Webm ? PostMediaTypes.WebmVideo : PostMediaTypes.Image,
                        DisplayName = f.DisplayName,
                        FullName    = f.FullName,
                        Nsfw        = f.NotSafeForWork != 0,
                        Hash        = f.Md5,
                        Duration    = f.Duration,
                        Thumbnail   = new PostMediaWithSize()
                        {
                            MediaLink = tnLink,
                            Height    = f.TnHeight,
                            Width     = f.TnWidth,
                            FileSize  = null,
                            MediaType = PostMediaTypes.Image
                        },
                    };
                    result.MediaFiles.Add(media);
                }
            }
            if (source.Counter == 1 && string.IsNullOrWhiteSpace(result.Subject))
            {
                try
                {
                    var lines = result.Comment.ToPlainText();
                    if (lines.Count > 0)
                    {
                        var s = lines.FirstOrDefault(l => !string.IsNullOrWhiteSpace(l));
                        if (s != null)
                        {
                            if (s.Length >= 50)
                            {
                                s = s.Substring(0, 50 - 3) + "...";
                            }
                            result.Subject = s;
                        }
                    }
                }
                catch
                {
                }
            }
            return(result);
        }
Beispiel #19
0
 public PostClickEventArgs(PostLink link) {
     Link = link;
 }
Beispiel #20
0
 public void DisplayPost(PostLink link) {
     PostDisplayingRequested?.Invoke(this, new PostDisplayingRequestedEventArgs(link));
 }
Beispiel #21
0
        public static PostModelType GetAdapterType(PostDataObject item)
        {
            try
            {
                switch (item)
                {
                case null:
                    return(PostModelType.NormalPost);
                }

                switch (string.IsNullOrEmpty(item.PostType))
                {
                case false when item.PostType == "ad":
                    return(PostModelType.AdsPost);
                }
                if (item.SharedInfo.SharedInfoClass != null)
                {
                    return(PostModelType.SharedPost);
                }

                if (!string.IsNullOrEmpty(item.PostType) && item.PostType == "profile_cover_picture" || item.PostType == "profile_picture")
                {
                    return(PostModelType.ImagePost);
                }

                if (!string.IsNullOrEmpty(item.PostType) && item.PostType == "live" && !string.IsNullOrEmpty(item.StreamName))
                {
                    if (ListUtils.SettingsSiteList?.AgoraLiveVideo is 1 && !string.IsNullOrEmpty(ListUtils.SettingsSiteList?.AgoraAppId))
                    {
                        if (item?.LiveTime != null && item?.LiveTime.Value > 0 && string.IsNullOrEmpty(item?.AgoraResourceId) && string.IsNullOrEmpty(item?.PostFile)) //Live
                        {
                            return(PostModelType.AgoraLivePost);
                        }
                        else if (item?.LiveTime != null && item?.LiveTime.Value > 0 && !string.IsNullOrEmpty(item?.AgoraResourceId) && !string.IsNullOrEmpty(item?.PostFile)) //Saved
                        {
                            return(PostModelType.VideoPost);
                        }
                        else //End
                        {
                            return(PostModelType.AgoraLivePost);
                        }
                    }
                    else
                    {
                        return(PostModelType.LivePost);
                    }
                }

                if (item.PostFileFull != null && (GetImagesExtensions(item.PostFileFull) || item.PhotoMulti?.Count > 0 || item.PhotoAlbum?.Count > 0 || !string.IsNullOrEmpty(item.AlbumName)))
                {
                    switch (item.PhotoMulti?.Count)
                    {
                    case > 0:
                        switch (item.PhotoMulti?.Count)
                        {
                        case 2:
                            return(PostModelType.MultiImage2);

                        case 3:
                            return(PostModelType.MultiImage3);

                        case 4:
                            return(PostModelType.MultiImage4);

                        default:
                        {
                            switch (item.PhotoMulti?.Count)
                            {
                            case >= 5:
                                return(PostModelType.MultiImages);
                            }

                            break;
                        }
                        }

                        break;
                    }

                    switch (item.PhotoAlbum?.Count)
                    {
                    case > 0:
                        switch (item.PhotoAlbum?.Count)
                        {
                        case 1:
                            return(PostModelType.ImagePost);

                        case 2:
                            return(PostModelType.MultiImage2);

                        case 3:
                            return(PostModelType.MultiImage3);

                        case 4:
                            return(PostModelType.MultiImage4);

                        default:
                        {
                            switch (item.PhotoAlbum?.Count)
                            {
                            case >= 5:
                                return(PostModelType.MultiImages);
                            }

                            break;
                        }
                        }

                        break;
                    }

                    return(PostModelType.ImagePost);
                }
                switch (string.IsNullOrEmpty(item.PostFileFull))
                {
                case false when item.PostFileFull.Contains(".MP3") || item.PostFileFull.Contains(".mp3") || item.PostFileFull.Contains(".wav"):
                    return(PostModelType.VoicePost);
                }
                switch (string.IsNullOrEmpty(item.PostRecord))
                {
                case false:
                    return(PostModelType.VoicePost);
                }
                switch (string.IsNullOrEmpty(item.PostFileFull))
                {
                case false when GetVideosExtensions(item.PostFileFull):
                    return(PostModelType.VideoPost);
                }
                switch (string.IsNullOrEmpty(item.PostSticker))
                {
                case false:
                    return(PostModelType.StickerPost);
                }
                switch (string.IsNullOrEmpty(item.PostFacebook))
                {
                case false:
                    return(PostModelType.FacebookPost);
                }
                switch (string.IsNullOrEmpty(item.PostVimeo))
                {
                case false:
                    return(PostModelType.VimeoPost);
                }
                switch (string.IsNullOrEmpty(item.PostYoutube))
                {
                case false:
                    return(PostModelType.YoutubePost);
                }
                switch (string.IsNullOrEmpty(item.PostDeepsound))
                {
                case false:
                    return(PostModelType.DeepSoundPost);
                }
                switch (string.IsNullOrEmpty(item.PostPlaytube))
                {
                case false:
                    return(PostModelType.PlayTubePost);
                }
                switch (string.IsNullOrEmpty(item.PostLink))
                {
                case false when item.PostLink.Contains("tiktok"):
                    return(PostModelType.TikTokPost);
                }
                switch (string.IsNullOrEmpty(item.PostLink))
                {
                case false:
                    return(PostModelType.LinkPost);
                }
                if (item.Product?.ProductClass != null)
                {
                    return(PostModelType.ProductPost);
                }
                if (item.Job != null && (item.PostType == "job" || item.Job.Value.JobInfoClass != null))
                {
                    return(PostModelType.JobPost);
                }
                if (item.Offer?.OfferClass != null && item.PostType == "offer")
                {
                    return(PostModelType.OfferPost);
                }
                if (item.Blog != null)
                {
                    return(PostModelType.BlogPost);
                }
                if (item.Event?.EventClass != null)
                {
                    return(PostModelType.EventPost);
                }
                if (item.PostFileFull != null && (item.PostFileFull.Contains(".rar") || item.PostFileFull.Contains(".zip") || item.PostFileFull.Contains(".pdf")))
                {
                    return(PostModelType.FilePost);
                }
                if (item.ColorId != "0")
                {
                    return(PostModelType.ColorPost);
                }
                if (item.PollId != "0")
                {
                    return(PostModelType.PollPost);
                }
                if (item.FundData?.FundDataClass != null)
                {
                    return(PostModelType.FundingPost);
                }
                if (item.Fund?.PurpleFund != null)
                {
                    return(PostModelType.PurpleFundPost);
                }
                return(string.IsNullOrEmpty(item.PostMap) switch
                {
                    false => PostModelType.MapPost,
                    _ => PostModelType.NormalPost
                });
Beispiel #22
0
 public PostDisplayingRequestedEventArgs(PostLink link) {
     Link = link;
 }
Beispiel #23
0
 public NavigateToPostEventArgs(PostLink link) {
     Link = link;
 }