public FileCommentModel(FileComment fileComment)
 {
     this.Id           = fileComment.Id;
     this.OwnerName    = fileComment.User.UserName;
     this.Content      = fileComment.Content;
     this.CreationDate = fileComment.CreationDate;
 }
Beispiel #2
0
        public FileComment Create(FileComment payload)
        {
            _context.FileComment.Add(payload);
            _context.SaveChanges();

            return(payload);
        }
Beispiel #3
0
        private static void Main(string[] args)
        {
            var errorHandler = new ErrorHandler();
            var parser       = new Parser("../../../testFile.a2l", errorHandler);
            var comment      =
                new FileComment(Environment.NewLine + "A2l file for testing ASAP2 parser." + Environment.NewLine, true);
            var tree = parser.DoParse();

            if (tree != null)
            {
                try
                {
                    if (errorHandler.warnings == 0)
                    {
                        Console.WriteLine("Parsed file with no warnings.");
                    }
                    else
                    {
                        Console.WriteLine("Parsed file with {0} warnings.", errorHandler.warnings);
                    }

                    errorHandler = new ErrorHandler();
                    tree.Validate(errorHandler);

                    if (errorHandler.warnings == 0)
                    {
                        Console.WriteLine("Validated parsed data with no warnings.");
                    }
                    else
                    {
                        Console.WriteLine("Validated parsed data with {0} warnings.", errorHandler.warnings);
                    }

                    Console.WriteLine("Press enter to serialise data.");
                    Console.ReadLine();

                    tree.elements.Insert(0, comment);
                    var ms     = new MemoryStream();
                    var stream = new StreamWriter(ms, new UTF8Encoding(true));
                    parser.Serialise(tree, stream);
                    ms.Position = 0;
                    var sr    = new StreamReader(ms);
                    var myStr = sr.ReadToEnd();
                    Console.WriteLine(myStr);
                }
                catch (ValidationErrorException e)
                {
                    Console.WriteLine("Validation of parsed data failed!");
                    Console.WriteLine(e.ToString());
                }
            }
            else
            {
                Console.WriteLine("Parsing failed!");
            }

            Console.WriteLine("Press enter to close...");
            Console.ReadLine();
        }
Beispiel #4
0
        public void SetFileRating(byte[] hash, uint rating)
        {
            lock (locker_)
            {
                if (FileComments == null)
                {
                    FileComments = new List <FileComments>();
                }

                bool found = false;

                foreach (FileComments comments in FileComments)
                {
                    if (string.Compare(comments.Name, MpdUtilities.EncodeHexString(hash)) == 0)
                    {
                        if (comments.Comments != null &&
                            comments.Comments.Count > 0)
                        {
                            comments.Comments[0].Rate = rating;
                        }
                        else
                        {
                            if (comments.Comments == null)
                            {
                                comments.Comments = new List <FileComment>();
                            }

                            FileComment comment = MuleApplication.Instance.PreferenceObjectManager.CreateFileComment();

                            comment.Rate = rating;

                            comments.Comments.Add(comment);
                        }

                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    FileComments comments = MuleApplication.Instance.PreferenceObjectManager.CreateFileComments(MpdUtilities.EncodeHexString(hash));

                    if (comments.Comments == null)
                    {
                        comments.Comments = new List <FileComment>();
                    }

                    FileComment comment = MuleApplication.Instance.PreferenceObjectManager.CreateFileComment();

                    comment.Rate = rating;

                    comments.Comments.Add(comment);

                    FileComments.Add(comments);
                }
            }
        }
Beispiel #5
0
        internal void WriteFileComment(byte[] array, ref int index, int baseIndex)
        {
            if (FileComment == null)
            {
                return;
            }

            var bytesFileCommentLink = BitConverter.GetBytes(index);

            Array.Copy(bytesFileCommentLink, 0, array, baseIndex + 8, bytesFileCommentLink.Length);

            FileComment.Write(array, ref index);
        }
Beispiel #6
0
        public async Task <FileComment> AddCommentByFileId(int fileId, string commentContent)
        {
            var newEntity = new FileComment
            {
                FileId       = fileId,
                UserId       = UserManager.GetUserId(),
                Content      = commentContent,
                CreationDate = DateTimeOffset.Now
            };
            var result = Context.FileComments.Add(newEntity);
            await Context.SaveChangesAsync();

            return(result.Entity);
        }
Beispiel #7
0
        public void UpdateFileComments(int fileId, string comment)
        {
            File file;

            using (var context = new FileManagerContext())
            {
                file = (from f in context.Files
                        where f.FileId == fileId
                        select f).FirstOrDefault();

                var newComment = new FileComment();
                newComment.CommentText = comment;
                newComment.FileId      = file.FileId;
                context.FileComments.Add(newComment);
                context.SaveChanges();
                context.Files.Attach(file);
                context.Entry(file).State = EntityState.Modified;
                context.SaveChanges();
            }
        }
Beispiel #8
0
 public FileCommentModel(FileComment domainComment)
 {
     this.Id          = domainComment.Id;
     this.CommentText = domainComment.CommentText;
     this.FileId      = domainComment.FileId;
 }
Beispiel #9
0
 public FileComment Update(FileComment payload)
 {
     return(new FileComment());
 }
Beispiel #10
0
 internal override int GetSizeTotal()
 {
     return(GetSize() + FileComment.GetSizeSafe() + ProgramBlock.GetSizeSafe());
 }