private void AddStateCommands(List <string> commands, PublicationState state)
 {
     string[] stateCommands = state.GetCommandsList();
     for (int i = 0; i < stateCommands.Length; i++)
     {
         commands.Add(stateCommands[i]);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Create new comment with rating
 /// </summary>
 /// <param name="gAuthorNode">GDID of autor node</param>
 /// <param name="gTargetNode">GDID of target node</param>
 /// <param name="dimension">Scope for rating</param>
 /// <param name="content">Content</param>
 /// <param name="data">Byte array of data</param>
 /// <param name="publicationState">State of publication</param>
 /// <param name="value">star 1-2-3-4-5</param>
 /// <param name="timeStamp">Time of current action</param>
 /// <returns>Comment</returns>
 public Comment Create(GDID gAuthorNode,
                       GDID gTargetNode,
                       string dimension,
                       string content,
                       byte[] data,
                       PublicationState publicationState,
                       RatingValue value  = RatingValue.Undefined,
                       DateTime?timeStamp = null)
 {
     return(Comments.Create(gAuthorNode, gTargetNode, dimension, content, data, publicationState, value, timeStamp));
 }
Beispiel #3
0
        public override Comment Create(GDID gAuthorNode, GDID gTargetNode, string dimension, string content, byte[] data,
                                       PublicationState publicationState, RatingValue rating = RatingValue.Undefined, DateTime?epoch = null)
        {
            var pair = HostSet.AssignHost(gTargetNode);

            return(Contracts.ServiceClientHub
                   .CallWithRetry <IGraphCommentSystemClient, Comment>(
                       commentSystem => commentSystem.Create(gAuthorNode, gTargetNode, dimension, content, data, publicationState, rating, epoch),
                       pair.Select(host => host.RegionPath)
                       ));
        }
Beispiel #4
0
        public static string ToDomainString(PublicationState status)
        {
            switch (status)
            {
            case PublicationState.Private:   return(GSPublicationState.PRIVATE);

            case PublicationState.Public:    return(GSPublicationState.PUBLIC);

            case PublicationState.Friend:    return(GSPublicationState.FRIEND);

            case PublicationState.Deleted:    return(GSPublicationState.DELETED);

            default: return(GSPublicationState.PUBLIC);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Comment
        /// </summary>
        /// <param name="id">ID</param>
        /// <param name="parentId">Parent comment ID</param>
        /// <param name="authorNode">Author node</param>
        /// <param name="targetNode">Target node</param>
        /// <param name="createDate">Creation Date</param>
        /// <param name="dimension">Scope of comments</param>
        /// <param name="publicationState">Publication state</param>
        /// <param name="rating">Rating (0,1,2,3,4,5)</param>
        /// <param name="message">Message</param>
        /// <param name="data">Data</param>
        /// <param name="likes">Likes count</param>
        /// <param name="dislikes">Dislikes count</param>
        /// <param name="complaintCount">Complaint count</param>
        /// <param name="responseCount">Response count</param>
        /// <param name="inUse">In use (InUse = false - comment has been deleted)</param>
        /// <param name="editable">Can be edited</param>
        public Comment(CommentID id,
                       CommentID?parentId,
                       GraphNode authorNode,
                       GraphNode targetNode,
                       DateTime createDate,
                       string dimension,

                       PublicationState publicationState,
                       RatingValue rating,
                       string message,
                       byte[] data,

                       uint likes,
                       uint dislikes,
                       uint complaintCount,
                       uint responseCount,

                       bool inUse,
                       bool editable)
        {
            ID          = id;
            ParentID    = parentId;
            AuthorNode  = authorNode;
            TargetNode  = targetNode;
            Create_Date = createDate;
            Dimension   = dimension;

            PublicationState = publicationState;
            Rating           = rating;
            Message          = message;
            Data             = data;

            Likes          = likes;
            Dislikes       = dislikes;
            ComplaintCount = complaintCount;
            ResponseCount  = responseCount;

            IsRoot   = !parentId.HasValue;
            In_Use   = inUse;
            Editable = editable;
        }
Beispiel #6
0
        /// <summary>
        /// Create new comment with rating
        /// </summary>
        /// <param name="gAuthorNode">GDID of autor node</param>
        /// <param name="gTargetNode">GDID of target node</param>
        /// <param name="dimension">Scope for rating</param>
        /// <param name="content">Content</param>
        /// <param name="data">Byte array of data</param>
        /// <param name="publicationState">State of publication</param>
        /// <param name="value">star 1-2-3-4-5</param>
        /// <param name="timeStamp">Time of current action</param>
        /// <returns>ID</returns>
        Comment IGraphCommentSystem.Create(GDID gAuthorNode,
                                           GDID gTargetNode,
                                           string dimension,
                                           string content,
                                           byte[] data,
                                           PublicationState publicationState,
                                           RatingValue value,
                                           DateTime?timeStamp)
        {
            try
            {
                // 1. Get nodes for creation new comment
                var authorNode      = DoGetNode(gAuthorNode);
                var targetNode      = DoGetNode(gTargetNode);
                var currentDateTime = timeStamp ?? App.TimeSource.UTCNow;

                if (!GraphHost.CanCreateComment(authorNode, targetNode, dimension, currentDateTime, value))
                {
                    throw new GraphException(StringConsts.GS_CAN_NOT_CREATE_COMMENT_ERROR.Args(authorNode, targetNode, value));
                }

                return(DoCreate(targetNode,
                                authorNode,
                                null, dimension,
                                content,
                                data,
                                publicationState,
                                value,
                                currentDateTime));
            }
            catch (Exception ex)
            {
                Log(MessageType.Error, "GraphCommentSystem.Create()", ex.ToMessageWithType(), ex);
                throw new GraphException(StringConsts.GS_CREATE_COMMENT_ERROR.Args(gTargetNode, gAuthorNode), ex);
            }
        }
Beispiel #7
0
 /// <summary>
 /// Make new Comment
 /// </summary>
 internal static Comment MakeNew(CommentID commentID, CommentID?parentID, GraphNode authorNode, GraphNode targetNode, DateTime create_Date, string dimension, PublicationState publicationState, RatingValue rating, string message, byte[] data)
 {
     return(new Comment(commentID, parentID, authorNode, targetNode, create_Date, dimension, publicationState, rating, message, data, 0, 0, 0, 0, true, true));
 }
Beispiel #8
0
        /// <summary>
        /// Creating new comment
        /// </summary>
        /// <param name="targetNode">Target node</param>
        /// <param name="authorNode">Author node, who made comment</param>
        /// <param name="parentID">Parent comment id</param>
        /// <param name="dimension">Scope of comment</param>
        /// <param name="content">Content</param>
        /// <param name="data">Byte array of data</param>
        /// <param name="publicationState">State of publication</param>
        /// <param name="value">star 1-2-3-4-5</param>
        /// <param name="creationTime">Time of current action</param>
        /// <returns>ID</returns>
        protected virtual Comment DoCreate(GraphNode targetNode,
                                           GraphNode authorNode,
                                           CommentID?parentID,
                                           string dimension,
                                           string content,
                                           byte[] data,
                                           PublicationState publicationState,
                                           RatingValue value,
                                           DateTime?creationTime)
        {
            // Create comment and, if need, volume
            var ctxNode = ForNode(targetNode.GDID); // get shard context for target node
            var volume  = parentID.HasValue         // if we have parentID, we need to place response comment in same volume as parent
        ? getVolume(targetNode.GDID, parentID.Value.G_Volume, ctxNode)
        : getEmptyVolume(targetNode.GDID, dimension, ctxNode);

            if (volume == null)
            {
                throw new GraphException(StringConsts.GS_RESPONSE_VOLUME_MISSING_ERROR);
            }

            var comment = new CommentRow(true)
            {
                G_CommentVolume = volume.G_CommentVolume,
                G_Parent        = parentID.HasValue ? parentID.Value.G_Comment : (GDID?)null,
                G_AuthorNode    = authorNode.GDID,
                G_TargetNode    = targetNode.GDID,
                Create_Date     = creationTime ?? App.TimeSource.UTCNow,
                Dimension       = dimension,

                Message          = content,
                Data             = data,
                PublicationState = GSPublicationState.ToDomainString(publicationState),
                Rating           = (byte)value,

                Like           = 0,
                Dislike        = 0,
                ComplaintCount = 0,
                ResponseCount  = 0,

                IsRoot = !parentID.HasValue,
                In_Use = true
            };

            ForComment(volume.G_CommentVolume).Insert(comment);

            // Update ratings , if comment is root
            if (comment.IsRoot)
            {
                var nodeRating = getNodeRating(targetNode.GDID, dimension, ctxNode);
                nodeRating.UpdateCount(1);                           // Update count of commentaries (only root commentaries counts)
                nodeRating.UpdateRating(value, 1);                   //Update ratings
                nodeRating.Last_Change_Date = App.TimeSource.UTCNow; // update change time
                ctxNode.Update(nodeRating, filter: "Last_Change_Date,Cnt,Rating1,Rating2,Rating3,Rating4,Rating5".OnlyTheseFields());
            }
            // Update parent ResponseCount, if comment is not root
            else if (parentID.HasValue)
            {
                var ctxParent = ForComment(parentID.Value.G_Volume);
                var parent    = getCommentRow(parentID.Value, ctxParent);
                if (parent != null)
                {
                    parent.UpdateResponseCount(1);
                    ctxParent.Update(parent, filter: "ResponseCount".OnlyTheseFields());
                }
            }

            // Update count of commentaries in volume
            volume.Count++;
            ctxNode.Update(volume, filter: "Count".OnlyTheseFields());
            return(Comment.MakeNew(new CommentID(comment.G_CommentVolume, comment.GDID),
                                   parentID,
                                   authorNode,
                                   targetNode,
                                   comment.Create_Date,
                                   comment.Dimension,
                                   GSPublicationState.ToPublicationState(comment.PublicationState),
                                   (RatingValue)comment.Rating,
                                   comment.Message,
                                   comment.Data));
        }
Beispiel #9
0
 public abstract Comment Create(GDID gAuthorNode, GDID gTargetNode, string dimension, string content, byte[] data,
                                PublicationState publicationState, RatingValue rating = RatingValue.Undefined, DateTime?epoch = null);
Beispiel #10
0
 private void ChangePublicationResult(Publication publication, PublicationState result, AspNetDeployEntities entities)
 {
     publication.State = result;
     entities.SaveChanges();
 }
 public void SetState(PublicationState newState)
 {
     m_State = newState;
 }
Beispiel #12
0
 public override Comment Create(GDID gAuthorNode, GDID gTargetNode, string dimension, string content, byte[] data,
                                PublicationState publicationState, RatingValue rating = RatingValue.Undefined, DateTime?epoch = null)
 {
     return(default(Comment));
 }