Esempio n. 1
0
        //  private static System.Timers.Timer aTimer;
        // private AutoResetEvent autoEvent;

        protected void Initialize(HttpControllerContext requestContext)  //override
        {
            //vkUserInf = new VkUserInfo();
            vkUserInf       = new VkManager();
            likeInformation = new LikeInfo();
            usersLike       = new Dictionary <string, User>();
            likesInfo       = new Dictionary <string, bool>();
            tempDict        = new Dictionary <string, List <User> >();
            tempList        = new List <User>();
            tempUser        = new User();
            //   autoEvent = new AutoResetEvent(false);

            //  base.Initialize(requestContext);
        }
        public async Task <IActionResult> NewIs(LikeInfo likeInfo)
        {
            var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password);

            using (var client = new Neo4JClient(settings))
            {
                LikeService myService = new LikeService(client);
                myService.addMetadata(likeInfo);
                string aux = await myService.CreateRelationshipLike(myService.likeInfos);

                Response ans = new Response()
                {
                    Ans = aux
                };
                return(Created(Neo4JClient.uri, ans));
            }
        }
        public static bool TryParseLikeInfo(string _data, out LikeInfo _likeInfo)
        {
            _likeInfo = null;

            try
            {
                var values = _data.Split(';', StringSplitOptions.RemoveEmptyEntries);

                _likeInfo = new LikeInfo
                {
                    OwnerId = int.Parse(values[0]),
                    ItemId  = int.Parse(values[1]),
                    IsLiked = int.Parse(values[2]) == 1
                };

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 4
0
        public async Task <LikeInfo> LikeNumber(Guid id)
        {
            var user = await userManager.GetUserAsync(HttpContext.User);

            var article = dataManager.Articles.GetArticle(id);

            if (!dataManager.Articles.IsLike(user, article))
            {
                dataManager.Articles.AddLike(user, article);
            }
            else
            {
                dataManager.Articles.DeleteLike(user, article);
            }

            LikeInfo li = new LikeInfo()
            {
                Num   = dataManager.Articles.LikeAmount(article),
                IsSet = dataManager.Articles.IsLike(user, article)
            };

            return(li);
        }
Esempio n. 5
0
        public static MsCrmResultObject GetEntityLikeInfo(Guid entityId, string entityName, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();

            try
            {
                #region | SQL QUERY |
                string query = @"   DECLARE @LikeCount INT
                                    DECLARE @DislikeCount INT

                                    SELECT
	                                    @LikeCount= COUNT(0)
                                    FROM
	                                    new_likerecord AS l (NOLOCK)
                                    WHERE
	                                    l.{1}Id='{0}'
	                                    AND
	                                    l.new_liketype=1
                                        AND
                                        l.statecode=0

                                    SELECT
	                                    @DislikeCount= COUNT(0)
                                    FROM
	                                    new_likerecord AS l (NOLOCK)
                                    WHERE
	                                    l.{1}Id='{0}'
	                                    AND
	                                    l.new_liketype=0
                                        AND
                                        l.statecode=0

                                    SELECT 
	                                    @LikeCount AS LikeCount
	                                    ,@DislikeCount AS DislikeCount"    ;
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, entityId, entityName));

                if (dt != null && dt.Rows.Count > 0)
                {
                    List <Education> returnList = new List <Education>();
                    LikeInfo         _like      = new LikeInfo();
                    _like.LikeCount    = (int)dt.Rows[0]["LikeCount"];
                    _like.DislikeCount = (int)dt.Rows[0]["DislikeCount"];
                    _like.Entity       = new EntityReference(entityName, entityId);

                    returnValue.Success      = true;
                    returnValue.ReturnObject = _like;
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result  = "M056"; //"Beğeni kaydı bulunamadı!";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result  = ex.Message;
            }
            return(returnValue);
        }
Esempio n. 6
0
        protected override void CreateChildControls()
        {
            if (this.ContextNode == null)
            {
                return;
            }

            if (ShowExecutionTime)
            {
                Timer.Start();
            }

            // gather posts for this content
            List <PostInfo> posts;

            posts = DataLayer.GetPostsForContent(this.ContextNode).ToList();

            string postsMarkup;

            postsMarkup = WallHelper.GetWallPostsMarkup(this.ContextNode.Path, posts);

            CommentInfo contentCommentInfo;
            LikeInfo    contentLikeInfo;

            var settings = new QuerySettings()
            {
                EnableAutofilters = FilterStatus.Disabled
            };
            var allCommentsAndLikes = ContentQuery.Query(ContentRepository.SafeQueries.InTreeAndTypeIs, settings,
                                                         this.ContextNode.Path, new[] { "Comment", "Like" }).Nodes.ToList();

            var commentNodeTypeId = NodeType.GetByName("Comment").Id;
            var likeTypeId        = NodeType.GetByName("Like").Id;

            var commentsForPost         = allCommentsAndLikes.Where(c => c.NodeTypeId == commentNodeTypeId).ToList();
            var likesForPostAndComments = allCommentsAndLikes.Where(l => l.NodeTypeId == likeTypeId).ToList();
            var likesForPost            = likesForPostAndComments.Where(l => RepositoryPath.GetParentPath(RepositoryPath.GetParentPath(l.Path)) == this.ContextNode.Path).ToList();

            var commentMarkupStr = WallHelper.GetCommentMarkupStr();

            // get comments for this content
            contentCommentInfo = new CommentInfo(commentsForPost, likesForPostAndComments, commentMarkupStr);

            // get likes for this content
            contentLikeInfo = new LikeInfo(likesForPost, this.ContextNode.Id);

            var markupStr = WallHelper.GetContentWallMarkup(
                this.ContextNode,
                contentCommentInfo.HiddenCommentsMarkup,
                contentCommentInfo.CommentsMarkup,
                contentCommentInfo.CommentCount,
                contentLikeInfo,
                postsMarkup);

            this.Controls.Add(new Literal {
                Text = markupStr
            });

            if (ShowExecutionTime)
            {
                Timer.Stop();
            }

            base.CreateChildControls();
            this.ChildControlsCreated = true;
        }
Esempio n. 7
0
        public static MsCrmResultObject GetEntityLikeInfo(Guid entityId, string entityName, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();
            try
            {
                #region | SQL QUERY |
                string query = @"   DECLARE @LikeCount INT
                                    DECLARE @DislikeCount INT

                                    SELECT
                                        @LikeCount= COUNT(0)
                                    FROM
                                        new_likerecord AS l (NOLOCK)
                                    WHERE
                                        l.{1}Id='{0}'
                                        AND
                                        l.new_liketype=1
                                        AND
                                        l.statecode=0

                                    SELECT
                                        @DislikeCount= COUNT(0)
                                    FROM
                                        new_likerecord AS l (NOLOCK)
                                    WHERE
                                        l.{1}Id='{0}'
                                        AND
                                        l.new_liketype=0
                                        AND
                                        l.statecode=0

                                    SELECT
                                        @LikeCount AS LikeCount
                                        ,@DislikeCount AS DislikeCount";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, entityId, entityName));

                if (dt != null && dt.Rows.Count > 0)
                {
                    List<Education> returnList = new List<Education>();
                    LikeInfo _like = new LikeInfo();
                    _like.LikeCount = (int)dt.Rows[0]["LikeCount"];
                    _like.DislikeCount = (int)dt.Rows[0]["DislikeCount"];
                    _like.Entity = new EntityReference(entityName, entityId);

                    returnValue.Success = true;
                    returnValue.ReturnObject = _like;
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result = "M056"; //"Beğeni kaydı bulunamadı!";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }
            return returnValue;
        }
 public static string SerializeInfo(LikeInfo _likeInfo)
 {
     return($"{_likeInfo.OwnerId};{_likeInfo.ItemId};{(_likeInfo.IsLiked ? 1 : 0)}");
 }
Esempio n. 9
0
        protected override void CreateChildControls()
        {
            if (this.ContextNode == null)
            {
                return;
            }

            if (ShowExecutionTime)
            {
                Timer.Start();
            }

            // gather posts for this content
            List <PostInfo> posts;

            using (new OperationTrace("Wall - Gather posts"))
            {
                posts = DataLayer.GetPostsForContent(this.ContextNode).ToList();
            }
            string postsMarkup;

            using (new OperationTrace("Wall - Posts markup"))
            {
                postsMarkup = WallHelper.GetWallPostsMarkup(this.ContextNode.Path, posts);
            }

            CommentInfo contentCommentInfo;
            LikeInfo    contentLikeInfo;

            using (new OperationTrace("Wall - Gather content comments"))
            {
                var commentsAndLikesQuery = "+TypeIs:(Comment Like) +InTree:\"" + this.ContextNode.Path + "\"";
                var settings = new QuerySettings()
                {
                    EnableAutofilters = false
                };
                var allCommentsAndLikes = ContentQuery.Query(commentsAndLikesQuery, settings).Nodes.ToList();

                var commentNodeTypeId = NodeType.GetByName("Comment").Id;
                var likeTypeId        = NodeType.GetByName("Like").Id;

                var commentsForPost         = allCommentsAndLikes.Where(c => c.NodeTypeId == commentNodeTypeId).ToList();
                var likesForPostAndComments = allCommentsAndLikes.Where(l => l.NodeTypeId == likeTypeId).ToList();
                var likesForPost            = likesForPostAndComments.Where(l => RepositoryPath.GetParentPath(RepositoryPath.GetParentPath(l.Path)) == this.ContextNode.Path).ToList();

                var commentMarkupStr = WallHelper.GetCommentMarkupStr();

                // get comments for this content
                contentCommentInfo = new CommentInfo(commentsForPost, likesForPostAndComments, commentMarkupStr);

                // get likes for this content
                contentLikeInfo = new LikeInfo(likesForPost, this.ContextNode.Id);
            }

            using (new OperationTrace("Wall - Content comments markup"))
            {
                var markupStr = WallHelper.GetContentWallMarkup(
                    this.ContextNode,
                    contentCommentInfo.HiddenCommentsMarkup,
                    contentCommentInfo.CommentsMarkup,
                    contentCommentInfo.CommentCount,
                    contentLikeInfo,
                    postsMarkup);

                this.Controls.Add(new Literal {
                    Text = markupStr
                });
            }

            if (ShowExecutionTime)
            {
                Timer.Stop();
            }

            base.CreateChildControls();
            this.ChildControlsCreated = true;
        }
Esempio n. 10
0
 public void addMetadata(LikeInfo likeInfo)
 {
     this.myLikeInfos.Add(likeInfo);
 }