コード例 #1
0
        public Comments()
        {
            InitializeComponent();

            // Load the publication recoverying from the Session
            this.publication = controller.GetPublicationFromSession();

            // Check if the publication exist
            if (publication != null)
            {
                // Set the maximum lenght allowed per comment
                textBox_Comment.MaxLength = Comment.MaxLength;
                // Set the content box to its initial value
                ResetContentBox();
                // Display the comments of the current publication
                RefreshComments(controller.GetListComments(publication));
            }
            else
            {
                // If the publication could not be loaded,
                // display an error message and exit
                MessageBox.Show("NO hay una publicación cargada!",
                                "ERROR",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                /// Close the window without prompt message
                this.Close();
            }
        }
コード例 #2
0
ファイル: CtrMuro.cs プロジェクト: CLN-Group/Share-This-Web
        /// <summary>
        /// Get the path to the publication picture.
        /// NOTE: if publication do not have a picture, returns NULL.
        /// </summary>
        /// <param name="u">Publication with a picture</param>
        /// <returns>A string with the path to the picture</returns>
        public static string GetPublicationPictureFile(Publication p)
        {
            if (p != null && !String.IsNullOrEmpty(p.Picture))
                return Config.ShortPublicationsPictures + p.Picture;

            return null;
        }
コード例 #3
0
 public Comment(DateTime date, string comment, Publication publication, User author)
 {
     Date = date;
     Value = comment;
     Publication = publication;
     Author = author;
 }
コード例 #4
0
        /// <summary>
        /// Create a new comment and store it.
        /// </summary>
        /// <param name="value">Value of the comment</param>
        /// <param name="date">Date when the comment was written</param>
        /// <param name="author">Author who wrote the comment</param>
        /// <param name="publication">Publication where the comment belongs</param>
        public void CreateComment(string value, DateTime date, User author, Publication publication)
        {
            if (!ValidContent(value))
                throw new Exception("El contenido no puede estar vacio ni ser mayor a 500 caracteres.");

            if (publication == null)
                throw new Exception("La publicación no es válida.");

            Comment comment = new Comment(date, value, publication, author);

            // Store the new comment
            dataPublications.AddComment(publication, comment);
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Load the user into the session if it is
            user = muro.LoadLoggedUser(this);
            publication = (Publication)Session["publication"];

            ListWithComments.ItemDataBound += ListWithComments_ItemDataBound;
            timer1.Tick += timer1_Tick;
            btnSendComment.Click += btnSendComment_Click;
            btnGoHome.Click += btnGoHome_Click;

            if (!IsPostBack)
            {
                // If the publication doesn't exist, close the page inmediately
                if (!LoadPublication())
                    muro.ClosePageWithErrorForUserNotLogged(this);

                RefreshComments();
            }
        }
コード例 #6
0
ファイル: CtrMuro.cs プロジェクト: CLN-Group/Share-This-Web
        /// <summary>
        /// Change the image attribute for a publication.
        /// </summary>
        /// <param name="p">Publication that will change his image</param>
        /// <param name="fileName">The name of the file in the local server.</param>
        public void SetPublicationImage(Publication p, string fileName)
        {
            if (p == null)
                throw new Exception("La publicación no ha podido ser identificada.");

            if (String.IsNullOrEmpty(fileName))
                throw new Exception("La imagen no se ha podido ser accedido para su almacenamiento.");

            dataPublications.SetPicture(p, fileName);
        }
コード例 #7
0
ファイル: CtrMuro.cs プロジェクト: CLN-Group/Share-This-Web
        // *************************** //
        //  COMMENTS related COMMENTS  //
        // *************************** //
        /// <summary>
        /// Get all the comments in a specific publication
        /// </summary>
        /// <param name="p">Publication with the comments</param>
        /// <returns>A list with comments</returns>
        public List<Comment> GetListWithComments(Publication p)
        {
            if (p == null)
                throw new Exception("Error al identificar la publicación.");

            return dataComments.GetElementsByPublication(p);
        }
コード例 #8
0
ファイル: CtrMuro.cs プロジェクト: CLN-Group/Share-This-Web
        // **************       ************** //
        //  PUBLICATIONS related PUBLICATIONS  //
        // **************       ************** //
        /// <summary>
        /// Create a new publication and store it.
        /// </summary>
        /// <param name="value">Content of the publication</param>
        /// <param name="date">Date that was written</param>
        /// <param name="author">User who wrote the publication</param>
        /// <param name="picture">Path to the picture of the publication</param>
        /// <returns>The new publication added</returns>
        public Publication CreatePublication(string value, DateTime date, User author)
        {
            if (!ValidContent(value))
                throw new Exception("El contenido no puede estar vacio ni ser mayor a 500 caracteres.");

            if (author == null)
                throw new Exception("El usuario no ha podido ser identificado.");

            // Create the new publication without the picture
            Publication publication = new Publication(value, date, author.IdUser, null);

            // Save the new publication
            dataPublications.Add(publication);

            // Return the created publication
            return publication;
        }
コード例 #9
0
ファイル: CtrMuro.cs プロジェクト: CLN-Group/Share-This-Web
        // *************************** //
        //  COMMENTS related COMMENTS  //
        // *************************** //
        /// <summary>
        /// Create a new comment for a specific publication.
        /// </summary>
        /// <param name="value">Value of the comment</param>
        /// <param name="date">Date when the publication has been written</param>
        /// <param name="publication">Publication that belongs the comment</param>
        /// <param name="author">User who wrote the comment</param>
        public void CreateComment(string value, DateTime date, Publication publication, User author)
        {
            if (!ValidContent(value))
                throw new Exception("El contenido no puede estar vacio ni ser mayor a 500 caracteres.");

            if (author == null)
                throw new Exception("El usuario no pudo ser identificado.");

            if (publication == null)
                throw new Exception("La publicación no pudo ser identificada.");

            Comment c = new Comment(date, value, publication.IdPublication, author.IdUser);

            dataComments.Add(c);
        }
コード例 #10
0
ファイル: CtrMuro.cs プロジェクト: CLN-Group/Share-This-Web
        /// <summary>
        /// Get count of comments in a specific publication
        /// </summary>
        /// <param name="p">Publication that holds the comments</param>
        /// <returns>An integer with the amount of comments</returns>
        public int CountCommentsInPublication(Publication p)
        {
            if (p == null)
                throw new Exception("La publicación no ha podido ser identificada.");

            return dataComments.CountItemsInPublication(p);
        }
コード例 #11
0
        /// <summary>
        /// Try to load the publication using GET parameter
        /// </summary>
        /// <returns>True if success, False on error</returns>
        private bool LoadPublication()
        {
            this.publication = null;

            int RequestedPublicationId;
            try // to get user from GET responce
            {
                RequestedPublicationId = Convert.ToInt32(Request.QueryString["publication"]);
            }
            catch // On error, return false
            {
                return false;
            }

            Publication aux = controller.GetPublicationById(RequestedPublicationId);
            if (aux != null) // if true, the ID doesn't exist
            {
                this.publication = aux;
                Session.Add("publication", publication);
                return true;
            }
            else
            {
                return false;
            }
        }
コード例 #12
0
        /// <summary>
        /// Create a new publication and store it.
        /// </summary>
        /// <param name="value">Content of the publication</param>
        /// <param name="date">Date that was written</param>
        /// <param name="author">User who wrote the publication</param>
        /// <param name="picture">Path to the picture of the publication</param>
        /// <returns>The new publication added</returns>
        public Publication CreatePublication(string value, DateTime date, User author, string picture)
        {
            if (!ValidContent(value))
                throw new Exception("El contenido no puede estar vacio ni ser mayor a 500 caracteres.");

            // If the picture is already set,
            // then check the integrity of the picture
            if (picture != null && !File.Exists(picture))
                throw new Exception("La imagen no ha podido ser accedida para su almacenamiento.");

            // Create the new publication without the picture
            Publication publication = new Publication(value, date, author, null);

            if (picture != null)
            {
                // Now, store the picture in a local file with an unique name and set it to the user
                publication.Picture = StoreFile(picture, Config.AppPublicationsPictures, (new Random()).Next().ToString());
            }

            // Save the new publication
            dataPublications.Add(publication);

            // Return the created publication
            return publication;
        }
コード例 #13
0
 /// <summary>
 /// Get all the comments in a generic list
 /// </summary>
 /// <returns>A generic list with all the publications</returns>
 public List<Comment> GetListComments(Publication p)
 {
     // Recover the list from the data layer
     return dataPublications.GetComments(p);
 }
コード例 #14
0
ファイル: Muro.cs プロジェクト: CLN-Group/Share-This-WinForms
        /// <summary>
        /// Add a publication into the form.
        /// </summary>
        /// <param name="p">Publication to add</param>
        /// <param name="IndexPublication">Index of the publication on the list, used as the ID</param>
        private void AddPublicationIntoPanel(Publication p, int IndexPublication)
        {
            // Create the panel object with the publication info inside
            Panel newPublication = CreatePanelPublication(p.Value, p.Author.CompleteName, Image.FromFile(Config.AppAvatars + p.Author.Avatar), "COMMENTS", p.Date, p.Author.UserName, IndexPublication);

            // Insert the publication panel into the flow layout panel in the form
            this.flowLayoutPanel_Publications.Controls.Add(newPublication);
        }