コード例 #1
0
 public static void AddComment(Comment comment)
 {
     CommentsDataSource comDS = new CommentsDataSource();
     CommentEntry comm = new CommentEntry();
     Converter.CopyFields(comment, comm);
     comDS.AddComment(comm);
 }
コード例 #2
0
        public DatasetCommentsDataSource()
        {
            IEnumerable <EntitySet> entitySets = new List <EntitySet>();

            foreach (Container container in ContainerAliases)
            {
                var sets = EntitySetRepository.GetEntitySets(container.Alias, null) as List <EntitySet>;
                if (sets != null)
                {
                    entitySets = entitySets.Union(sets);
                }
            }

            var cds = new CommentsDataSource();
            IEnumerable <CommentEntry> comments = cds.SelectAll().Where(t => t.ParentType == ParentType.Dataset.ToString());

            _list = (from es in entitySets
                     join c in comments on es.EntitySetName equals c.DatasetId
                     select new DatasetComment(es.EntityId, es.Name, es.Description, es.CategoryValue, es.ContainerAlias, es.LastUpdateDate, es.EntitySetName, c.Subject, c.Username, c.Email, c.PostedOn));

            _list = _list.OrderBy(c => c.CommentDate)
                    .OrderBy(c => c.DatasetName)
                    .OrderBy(c => c.DatasetCategoryValue)
                    .OrderBy(c => c.DatasetContainerAlias);
        }
コード例 #3
0
        static public void AddComment(Comment comment)
        {
            CommentsDataSource comDS = new CommentsDataSource();
            CommentEntry       comm  = new CommentEntry();

            Converter.CopyFields(comment, comm);
            comDS.AddComment(comm);
        }
コード例 #4
0
        static public void Update(Comment comment)
        {
            CommentsDataSource comDS = new CommentsDataSource();
            CommentEntry       comm  = comDS.GetById(comment.RowKey);

            Converter.CopyFields(comment, comm);
            comDS.Update(comm);
        }
コード例 #5
0
        public static Comment GetComment(string id)
        {
            CommentsDataSource comDS = new CommentsDataSource();

            CommentEntry comm = comDS.GetById(id);

            return CreateCommentEnumerator(new List<CommentEntry>() { comm }).FirstOrDefault();
        }
コード例 #6
0
        public static IEnumerable<Comment> GetDatasetComments(string datasetId, string parentType, string container)
        {
            var commentDS = new CommentsDataSource();

            var comments = from g in commentDS.SelectAll()
                          where g.DatasetId == datasetId && g.ParentType == parentType && container == g.PartitionKey
                          select g;

            return CreateCommentEnumerator(comments);
        }
コード例 #7
0
        public static IEnumerable<Comment> GetByParentAndUser(string parentId, string container, string parentType, string user)
        {
            CommentsDataSource comDS = new CommentsDataSource();

            var comments = from g in comDS.SelectAll()
                          where g.DatasetId == parentId && g.PartitionKey == container && g.ParentType == parentType && g.Email == user
                          select g;

            return CreateCommentEnumerator(comments);
        }
コード例 #8
0
        static public IEnumerable <Comment> GetByParentAndUser(string parentId, string container, string parentType, string user)
        {
            CommentsDataSource comDS = new CommentsDataSource();

            var comments = from g in comDS.SelectAll()
                           where g.DatasetId == parentId && g.PartitionKey == container && g.ParentType == parentType && g.Email == user
                           select g;

            return(CreateCommentEnumerator(comments));
        }
コード例 #9
0
        static public IEnumerable <Comment> GetDatasetComments(string datasetId, string parentType, string container)
        {
            var commentDS = new CommentsDataSource();

            var comments = from g in commentDS.SelectAll()
                           where g.DatasetId == datasetId && g.ParentType == parentType && container == g.PartitionKey
                           select g;

            return(CreateCommentEnumerator(comments));
        }
コード例 #10
0
        static public Comment GetComment(string id)
        {
            CommentsDataSource comDS = new CommentsDataSource();

            CommentEntry comm = comDS.GetById(id);

            return(CreateCommentEnumerator(new List <CommentEntry>()
            {
                comm
            }).FirstOrDefault());
        }
コード例 #11
0
        static public IEnumerable <String> GetSubscribers(string objectId, string container, string parentType, string exclude)
        {
            CommentsDataSource comDS = new CommentsDataSource();
            var results = from com in comDS.SelectAll()
                          where com.Notify == true &&
                          com.Email != "" &&
                          com.DatasetId == objectId &&
                          com.PartitionKey == container &&
                          com.ParentType == parentType &&
                          com.RowKey != exclude
                          select com;

            return(results.AsEnumerable().Select(c => c.Email).Distinct());
        }
コード例 #12
0
        public static IEnumerable<Comment> GetComments(DateTime? fromDate, DateTime? toDate)
        {
            // We should use values SqlDateTime.MinValue otherwies exception during query execution
            //January 1, 1753.
            if (!fromDate.HasValue)
                fromDate = SqlDateTime.MinValue.Value;

            //December 31, 9999.
            if (!toDate.HasValue)
                toDate = DateTime.Now;

            var commentDS = new CommentsDataSource();

            var comments = (from comm in commentDS.SelectAllWithHidden()
                            where comm.PostedOn >= fromDate && comm.PostedOn <= toDate
                            select comm).AsEnumerable();

            return CreateCommentEnumerator(comments);
        }
コード例 #13
0
        public ActionResult DeleteRequest(string rowKey)
        {
            Request re = RequestRepository.GetRequest(rowKey);

            if (re == null)
            {
                throw new ApplicationException("Requested request does not exist.");
            }

            var commentsDataSource = new CommentsDataSource();

            commentsDataSource.UpdateStatusByParent(rowKey, "Request", "Hidden");

            re.Status = "Hidden";
            RequestRepository.UpdateRequest(re);

            //string result = string.Format("<h2 style='color:red'>Request: \"{0}\" is deleted</h2>", re.Subject);
            //return Json(result);
            return(Json(new StatusInfo {
                Status = re.Status, Show = true
            }));
        }
コード例 #14
0
        static public IEnumerable <Comment> GetComments(DateTime?fromDate, DateTime?toDate)
        {
            // We should use values SqlDateTime.MinValue otherwies exception during query execution
            //January 1, 1753.
            if (!fromDate.HasValue)
            {
                fromDate = SqlDateTime.MinValue.Value;
            }

            //December 31, 9999.
            if (!toDate.HasValue)
            {
                toDate = DateTime.Now;
            }

            var commentDS = new CommentsDataSource();

            var comments = (from comm in commentDS.SelectAllWithHidden()
                            where comm.PostedOn >= fromDate && comm.PostedOn <= toDate
                            select comm).AsEnumerable();

            return(CreateCommentEnumerator(comments));
        }
コード例 #15
0
 public static void DeleteComment(string id)
 {
     CommentsDataSource comDS = new CommentsDataSource();
     comDS.DeleteComment(id);
 }
コード例 #16
0
 public static void DeleteByParent(string parentId, string container)
 {
     CommentsDataSource comDS = new CommentsDataSource();
     comDS.DeleteByParent(parentId, container);
 }
コード例 #17
0
        public static IEnumerable<String> GetSubscribers(string objectId, string container, string parentType, string exclude)
        {
            CommentsDataSource comDS = new CommentsDataSource();
            var results = from com in comDS.SelectAll()
                          where com.Notify == true
                          && com.Email != ""
                          && com.DatasetId == objectId
                          && com.PartitionKey == container
                          && com.ParentType == parentType
                          && com.RowKey != exclude
                          select com;

            return results.AsEnumerable().Select(c => c.Email).Distinct();
        }
コード例 #18
0
 public static void Update(Comment comment)
 {
     CommentsDataSource comDS = new CommentsDataSource();
     CommentEntry comm = comDS.GetById(comment.RowKey);
     Converter.CopyFields(comment, comm);
     comDS.Update(comm);
 }
コード例 #19
0
        static public void DeleteByParent(string parentId, string container)
        {
            CommentsDataSource comDS = new CommentsDataSource();

            comDS.DeleteByParent(parentId, container);
        }
コード例 #20
0
        static public void DeleteComment(string id)
        {
            CommentsDataSource comDS = new CommentsDataSource();

            comDS.DeleteComment(id);
        }
コード例 #21
0
 private void LoadComments()
 {
     CommentsDataSource ds = new CommentsDataSource();
     Comments = new List<Comment>(CommentRepository.GetDatasetComments(DatasetId, ParentType.ToString(), Container));
 }