예제 #1
0
        private IEnumerable<ItemID> GetIDs()
        {
            for (int i = 2; i < 14; i++)
            {
                HtmlNode node = PostNode.SelectSingleNode($"div[{i}]/div[1]/a[1]");

                if (node is null)
                    break;

                string id = node.GetAttributeValue("href", "").GetID();

                yield return new ItemID(id, ItemID.Type.Post);
            }
        }
        public async Task<IHttpActionResult> PostNode(PostNode node)
        {
            if (null == node)
                return BadRequest();
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            nodeDAO = new NodeDAO();
            nodeDetailDAO = new NodeDetailDAO();

            //<-Generate Node and NodeDetail->
            Node newNode = new Node();
            NodeDetail newDetail = new NodeDetail();


            // <-Get Node Inform from Post Node->
            newNode.NodeId = node.NodeId;
            newNode.NodeLocation = node.NodeLocation;
            newNode.Status = true;

            // <-Get NodeDetail Inform from Post Node->
            newDetail.NodeId = node.NodeId;
            newDetail.Raining = node.Raining;
            newDetail.Humidity = node.Humidity;
            newDetail.SoilMoisture = node.SoilMoisture;
            newDetail.Temperature = node.Temperature;
            var dateTime = DateTime.Now;
            var dateTimeOffset = new DateTimeOffset(dateTime);
            var unixDateTime = dateTimeOffset.ToUnixTimeSeconds();
            newDetail.updateTime = unixDateTime;
            try
            {
                if (!await nodeDAO.UpdateOrInsertNode(newNode))
                {
                    return BadRequest();
                }
                if (!await nodeDetailDAO.InsertOrUpdateNodeDetail(newDetail))
                {
                    return BadRequest();
                }

            }
            catch (DbUpdateException)
            {
                return BadRequest();
            }
            return Ok(node);
        }
예제 #3
0
        private IEnumerable <ItemID> CollectPostIDs()
        {
            for (int i = 1; i < 13; i++)
            {
                HtmlNode upload = PostNode.SelectSingleNode($"div[{i}]");

                if (upload is null)
                {
                    break;
                }

                string id = upload.SelectSingleNode("div[1]/a[1]").GetAttributeValue("href", "").GetID();

                yield return(new ItemID(id, ItemID.Type.Post));
            }
        }
예제 #4
0
    protected void OnButtonPostEditClicked(object sender, EventArgs e)
    {
        PostNode selected = (PostNode)nodeviewPosts.NodeSelection.SelectedNode;

        if (selected == null)
        {
            return;
        }
        if (vboxPostEdit.Visible && selected.PostID.ToString() == entryPostEditID.Text)
        {
            vboxPostEdit.Hide();
            return;
        }

        vboxPostEdit.Show();
        entryPostEditID.Text             = selected.PostID.ToString();
        entryPostEditAuthor.Text         = selected.AuthorID.ToString();
        entryPostEditTags.Text           = GetPostTags(selected.PostID);
        entryPostEditTitle.Text          = selected.Title;
        textviewPostEditText.Buffer.Text = selected.Text;
    }
예제 #5
0
    protected void OnButtonPostDeleteClicked(object sender, EventArgs e)
    {
        PostNode selected = (PostNode)nodeviewPosts.NodeSelection.SelectedNode;

        if (selected == null)
        {
            return;
        }

        // Delete post-tag connections to this post
        MySqlCommand dbcmd = new MySqlCommand();

        dbcmd.Connection = DBCon;
        try {
            dbcmd.CommandText = "DELETE FROM posts_tags WHERE (post_id = @id)";
            dbcmd.Prepare();
            dbcmd.Parameters.AddWithValue("@id", selected.PostID);
            dbcmd.ExecuteNonQuery();

            DatabaseUpdate();
        } catch (MySqlException ex) {
            Console.WriteLine("Error: {0}", ex.ToString());
        }

        // Delete this post

        dbcmd            = new MySqlCommand();
        dbcmd.Connection = DBCon;
        try {
            dbcmd.CommandText = "DELETE FROM posts WHERE (id = @id)";
            dbcmd.Prepare();
            dbcmd.Parameters.AddWithValue("@id", selected.PostID);
            dbcmd.ExecuteNonQuery();

            DatabaseUpdate();
        } catch (MySqlException ex) {
            Console.WriteLine("Error: {0}", ex.ToString());
        }
    }
예제 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (BlogProperties.StopProcessing)
        {
            Visible = false;
            return;
        }

        lblTitle.Text = GetString("Blog.CommentView.Comments");

        SetupControl();


        if (PostNode != null)
        {
            // Check permissions for blog
            if (BlogProperties.CheckPermissions)
            {
                if (CMSContext.CurrentUser.IsAuthorizedPerDocument(PostNode, NodePermissionsEnum.Read) != AuthorizationResultEnum.Allowed)
                {
                    Visible = false;
                }
            }

            if (Visible)
            {
                rptComments.ItemDataBound            += new RepeaterItemEventHandler(rptComments_ItemDataBound);
                ctrlCommentEdit.OnAfterCommentSaved  += new OnAfterCommentSavedEventHandler(ctrlCommentEdit_OnAfterCommentSaved);
                ctrlCommentEdit.OnBeforeCommentSaved += new OnBeforeCommentSavedEventHandler(ctrlCommentEdit_OnBeforeCommentSaved);
                ctrlCommentEdit.UseCaptcha            = BlogProperties.UseCaptcha;
                ctrlCommentEdit.EnableSubscriptions   = BlogProperties.EnableSubscriptions;
                ctrlCommentEdit.RequireEmails         = BlogProperties.RequireEmails;
                ctrlCommentEdit.ClearFormAfterSave    = true;

                pnlSubscription.Visible     = BlogProperties.EnableSubscriptions;
                plcBtnSubscribe.Visible     = BlogProperties.EnableSubscriptions;
                elemSubscription.DocumentID = PostNode.DocumentID;
                elemSubscription.NodeID     = PostNode.NodeID;
                elemSubscription.Culture    = PostNode.DocumentCulture;
            }

            // Check if trackback should displayed
            if (DisplayTrackbacks && BlogProperties.EnableTrackbacks)
            {
                pnlTrackbackURL.Visible = true;
                lblURLValue.Text        = TextHelper.EnsureMaximumLineLength(URLHelper.GetAbsoluteUrl(BlogHelper.GetBlogPostTrackbackUrl(PostNode.NodeGUID, PostNode.GetDocumentName(), PostNode.DocumentCulture)), TrackbackURLSize);
            }
        }

        // Make sure info label is dispalyed to the user when saved succesfully
        if (QueryHelper.GetBoolean("saved", false))
        {
            ctrlCommentEdit.CommentSavedText = GetString("Blog.CommentView.CommentSaved");
        }

        if (Visible)
        {
            ReloadComments();
        }
    }