public DataTable GetDataTable(DO_DocumentComment objComment, DocumentComment flag)
    {
        DataTable dt = new DataTable();

        SqlConnection conn = new SqlConnection();
        SQLManager    co   = new SQLManager();

        conn = co.GetConnection();

        SqlDataAdapter da = new SqlDataAdapter();

        da.SelectCommand             = new SqlCommand("Scrl_AddEditDelDocComment", conn);
        da.SelectCommand.CommandType = CommandType.StoredProcedure;
        da.SelectCommand.Parameters.Add("@FlagNo", SqlDbType.Int).Value                    = flag;
        da.SelectCommand.Parameters.Add("@CommentId", SqlDbType.BigInt).Value              = objComment.CommentId;
        da.SelectCommand.Parameters.Add("@CaseId", SqlDbType.BigInt).Value                 = objComment.CaseId;
        da.SelectCommand.Parameters.Add("@Comment", SqlDbType.Text).Value                  = objComment.Comment;
        da.SelectCommand.Parameters.Add("@addedby", SqlDbType.BigInt).Value                = objComment.addedby;
        da.SelectCommand.Parameters.Add("@ContentTypeID", SqlDbType.BigInt).Value          = objComment.ContentTypeID;
        da.SelectCommand.Parameters.Add("@strCommentedText", SqlDbType.VarChar, 500).Value = objComment.CommentedText;
        da.SelectCommand.Parameters.Add("@ParentID", SqlDbType.VarChar, 500).Value         = objComment.ParentID;
        //da.SelectCommand.Parameters.Add("@OldParentID", SqlDbType.VarChar, 500).Value = objComment.OldParentID;
        da.Fill(dt);
        co.CloseConnection(conn);
        return(dt);
    }
        //
        // GET: /Document/Details/5

        public ViewResult Details(int id)
        {
            var      doc_user = User.Identity.Name;
            Document document = context.Document.Single(x => x.DocumentId == id);

            document.Comments = document.Comments.OrderBy(x => x.CommentCreation).ToList();
            Comment comment = new Comment();

            comment.DocumentId      = document.DocumentId;
            comment.CommentUserName = doc_user;
            DocumentComment doc_com = new DocumentComment()
            {
                Comment  = comment,
                Document = document
            };

            return(View(doc_com));
        }
Exemplo n.º 3
0
        // Check if Comment Exists
        public Boolean commentExists(string _documentid)
        {
            Boolean _exists            = false;
            string  selectCommentQuery = "SELECT * FROM DocumentComment WHERE DocumentID=@doc;";

            conn = new SqlConnection(DBConnection.ConnectionString);     // Set connection string
            using (conn)
            {
                conn.Open();
                using (var cmd = conn.CreateCommand())
                {
                    try
                    {
                        cmd.CommandText = selectCommentQuery;
                        cmd.Prepare();
                        cmd.Parameters.AddWithValue("@doc", _documentid);
                        SqlDataReader rdr = cmd.ExecuteReader();

                        DocumentComment _temp = null;
                        while (rdr.Read())
                        {
                            _temp = new DocumentComment(long.Parse(rdr["DocumentID"].ToString()), rdr["UserID"].ToString(), rdr["DocumentComments"].ToString());
                        }

                        if (_temp != null)
                        {
                            _exists = true;
                        }

                        return(_exists);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error: " + e);
                        return(_exists);
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
        }
    public void AddEditDel_Case(DO_DocumentComment objComment, DocumentComment flag)
    {
        SqlConnection conn = new SqlConnection();
        SQLManager    co   = new SQLManager();

        conn = co.GetConnection();

        cmd             = new SqlCommand("Scrl_AddEditDelDocComment", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add("@FlagNo", SqlDbType.Int).Value = flag;

        cmd.Parameters.Add("@CommentId", SqlDbType.BigInt).Value     = objComment.CommentId;
        cmd.Parameters.Add("@CaseId", SqlDbType.BigInt).Value        = objComment.CaseId;
        cmd.Parameters.Add("@Comment", SqlDbType.Text).Value         = objComment.Comment;
        cmd.Parameters.Add("@addedby", SqlDbType.BigInt).Value       = objComment.addedby;
        cmd.Parameters.Add("@ContentTypeID", SqlDbType.BigInt).Value = objComment.ContentTypeID;
        cmd.ExecuteNonQuery();

        co.CloseConnection(conn);
    }
Exemplo n.º 5
0
        // Display student uploads
        public void displayUploads()
        {
            UserDetails         _user        = (UserDetails)HttpContext.Current.Session["User"];
            List <UserDocument> _uploadsList = new List <UserDocument>();

            if (_user.UserType == 1)
            {
                _uploadsList = model.selectUploadFiles(_user.UserID);
            }
            else if (_user.UserType == 2)
            {
                string _studentID = UploadView.studentID;
                _uploadsList = model.selectUploadFiles(_studentID);
            }

            Hashtable _formattedMessageData = new Hashtable();
            int       _counter = 1;

            if (_uploadsList.Count > 0)
            {
                string   _sender  = string.Empty;
                string[] _headers = { "Date", "Time", "File", "Comment" };
                _formattedMessageData.Add(0, _headers);
                foreach (UserDocument _doc in _uploadsList)
                {
                    string[]        _fileUploadSegments = _doc.UploadPath.Split('/');
                    string          _file       = _fileUploadSegments[4];
                    DocumentComment _comment    = model.selectComment(_doc.DocumentID.ToString());
                    string          _commentStr = (_comment == null) ? "n/a" : _comment.DocumentComments;
                    string[]        _tempArray  = { _doc.DocumentID.ToString(), _doc.Date.ToShortDateString(), _doc.Time.ToShortTimeString(), _file, _commentStr };
                    _formattedMessageData.Add(_counter, _tempArray);
                    _counter++;
                }
                UploadView.setUploadTable(_formattedMessageData);
            }
            else
            {
                UploadView.noMessages = "No Upload History Found.";
            }
        }
        public ActionResult AddComment(DocumentComment doc_com)
        {
            DateTime now = DateTime.Now;

            doc_com.Comment.CommentCreation     = now;
            doc_com.Comment.CommentModification = now;
            if (ModelState.IsValid)
            {
                context.Comment.Add(doc_com.Comment);

                context.SaveChanges();

                doc_com.Document = doc_com.Document;
                doc_com.Document.DocumentRate         = doc_com.Document.DocumentRate + doc_com.Comment.CommentRate;
                doc_com.Document.DocumentModification = now;
                context.Entry(doc_com.Document).State = EntityState.Modified;
                context.SaveChanges();
            }
            Document document = context.Document.Include(x => x.Comments).Single(x => x.DocumentId == doc_com.Comment.DocumentId);

            Success("Comment added successfully !");
            return(PartialView("_ListComments", document.Comments));
        }
Exemplo n.º 7
0
        public IList <DocumentComment> GetCommentsFromDocument(byte[] documentByteArray)
        {
            List <DocumentComment> docComments = new List <DocumentComment>();

            using (MemoryStream documentMemoryStream = new MemoryStream(documentByteArray))
            {
                using (WordprocessingDocument document = WordprocessingDocument.Open(documentMemoryStream, false))
                {
                    XDocument xmlDocument = document.MainDocumentPart.GetXDocument();

                    IList <XElement> documentElements = FilterOutXmlNodes(xmlDocument.Root);

                    string commentId = string.Empty;
                    foreach (Comment comment in document.MainDocumentPart.WordprocessingCommentsPart.Comments)
                    {
                        DocumentComment documentComment = new DocumentComment();

                        // Populate the other values from the comment object
                        documentComment.Author   = comment.Author;
                        documentComment.Initials = comment.Initials;
                        documentComment.Date     = comment.Date.HasValue ? comment.Date.Value : DateTime.Now;

                        // Populate the actual comment text into the object
                        foreach (Text text in comment.Descendants <Text>())
                        {
                            documentComment.CommentText += text.InnerText;
                        }

                        documentComment.CommentedText = GetCommentedOnText(documentElements, comment);

                        docComments.Add(documentComment);
                    }
                }
            }

            return(docComments);
        }