Esempio n. 1
0
        public override async Task <OperationResult <VoidResponse> > Edit(CommentModel model, CancellationToken ct)
        {
            return(await Task.Run(() =>
            {
                if (!TryReconnectChain(ct))
                {
                    return new OperationResult <VoidResponse>(new ApplicationError(Localization.Errors.EnableConnectToBlockchain));
                }

                var keys = ToKeyArr(model.PostingKey);
                if (keys == null)
                {
                    return new OperationResult <VoidResponse>(new ApplicationError(Localization.Errors.WrongPrivatePostingKey));
                }

                var op = new CommentOperation(model.ParentAuthor, model.ParentPermlink, model.Author, model.Permlink, model.Title, model.Body, model.JsonMetadata);
                var resp = _operationManager.BroadcastOperations(keys, ct, op);

                var result = new OperationResult <VoidResponse>();
                if (!resp.IsError)
                {
                    result.Result = new VoidResponse(true);
                }
                else
                {
                    OnError(resp, result);
                }
                return result;
            }, ct));
        }
Esempio n. 2
0
 /// <summary>
 /// 确认删除按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btn_ok_Click(object sender, EventArgs e)
 {
     try
     {
         //调用CommentOperation类里的DelComment方法,通过传入id,进行删除操作
         CommentOperation.DelComment(Int32.Parse(Request.QueryString["id"]));
         SmallScript.goRedirect(Response, Session, "删除成功!", "admin/CommentList.aspx");
     }
     catch
     {
         //删除失败提示
         SmallScript.MessageBox(Page, "删除失败!");
     }
 }
Esempio n. 3
0
        public override async Task <OperationResult <VoidResponse> > CreateOrEdit(CommentModel model, CancellationToken ct)
        {
            var isConnected = await TryReconnectChain(ct);

            if (!isConnected)
            {
                return(new OperationResult <VoidResponse>(new ValidationException(LocalizationKeys.EnableConnectToBlockchain)));
            }

            var keys = ToKeyArr(model.PostingKey);

            if (keys == null)
            {
                return(new OperationResult <VoidResponse>(new ValidationException(LocalizationKeys.WrongPrivatePostingKey)));
            }

            var op = new CommentOperation(model.ParentAuthor, model.ParentPermlink, model.Author, model.Permlink, model.Title, model.Body, model.JsonMetadata);

            BaseOperation[] ops;
            if (model.Beneficiaries != null && model.Beneficiaries.Any())
            {
                var beneficiaries = model.Beneficiaries
                                    .Select(i => new Ditch.Golos.Operations.Beneficiary(i.Account, i.Weight))
                                    .ToArray();
                ops = new BaseOperation[]
                {
                    op,
                    new BeneficiariesOperation(model.Login, model.Permlink, "GBG", beneficiaries)
                };
            }
            else
            {
                ops = new BaseOperation[] { op };
            }

            var resp = await _operationManager.BroadcastOperationsSynchronous(keys, ct, ops);

            var result = new OperationResult <VoidResponse>();

            if (resp.IsError)
            {
                result.Exception = new RequestException(resp);
            }
            else
            {
                result.Result = new VoidResponse();
            }

            return(result);
        }
Esempio n. 4
0
        public override async Task <OperationResult <VoidResponse> > CreateOrEdit(CommentModel model, CancellationToken ct)
        {
            return(await Task.Run(() =>
            {
                if (!TryReconnectChain(ct))
                {
                    return new OperationResult <VoidResponse>(new AppError(LocalizationKeys.EnableConnectToBlockchain));
                }

                var keys = ToKeyArr(model.PostingKey);
                if (keys == null)
                {
                    return new OperationResult <VoidResponse>(new AppError(LocalizationKeys.WrongPrivatePostingKey));
                }

                var op = new CommentOperation(model.ParentAuthor, model.ParentPermlink, model.Author, model.Permlink, model.Title, model.Body, model.JsonMetadata);

                BaseOperation[] ops;
                if (model.Beneficiaries != null && model.Beneficiaries.Any())
                {
                    var beneficiaries = model.Beneficiaries
                                        .Select(i => new DitchBeneficiary(i.Account, i.Weight))
                                        .ToArray();
                    ops = new BaseOperation[]
                    {
                        op,
                        new BeneficiariesOperation(model.Login, model.Permlink, new Asset(1000000000, 3, "SBD"), beneficiaries)
                    };
                }
                else
                {
                    ops = new BaseOperation[] { op };
                }

                var resp = _operationManager.BroadcastOperationsSynchronous(keys, ct, ops);

                var result = new OperationResult <VoidResponse>();
                if (!resp.IsError)
                {
                    result.Result = new VoidResponse();
                }
                else
                {
                    OnError(resp, result);
                }

                return result;
            }, ct));
        }
Esempio n. 5
0
 /// <summary>
 /// Page_Load
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         CommentEntity ce = CommentOperation.GetComment(int.Parse(Request.QueryString["id"].ToString()));
         if (ce != null)
         {
             lb_id.Text       = ce.Id.ToString();
             tb_ct.Text       = ce.CommentTitle;
             tb_context.Text  = ce.ConText;
             tb_agree.Text    = ce.Agree.ToString();
             tb_disagree.Text = ce.DisAgree.ToString();
             lb_nid.Text      = ce.nid.ToString();
             lb_uid.Text      = ce.uid.ToString();
             lb_uptime.Text   = ce.UpTime.ToString();
         }
     }
 }
Esempio n. 6
0
    /// <summary>
    /// 确认修改
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn_edit_Click(object sender, EventArgs e)
    {
        int    id       = int.Parse(Request.QueryString["id"].ToString());
        String ct       = tb_ct.Text;
        String context  = tb_context.Text;
        int    agree    = int.Parse(tb_agree.Text);
        int    disagree = int.Parse(tb_disagree.Text);

        try
        {
            CommentOperation.EditComment(ct, context, agree, disagree, id);
            SmallScript.MessageBox(Page, "修改评论成功。");
            SmallScript.goRedirect(Response, Session, "跳转到评论列表 ", "admin/CommentList.aspx");
        }
        catch
        {
            SmallScript.MessageBox(Page, "修改失败!");
            return;
        }
    }
Esempio n. 7
0
        public override async Task <OperationResult <VoidResponse> > CreateOrEdit(CommentModel model, CancellationToken ct)
        {
            var isConnected = await TryReconnectChain(ct);

            if (!isConnected)
            {
                return(new OperationResult <VoidResponse>(new ValidationException(LocalizationKeys.EnableConnectToBlockchain)));
            }

            var keys = ToKeyArr(model.PostingKey);

            if (keys == null)
            {
                return(new OperationResult <VoidResponse>(new ValidationException(LocalizationKeys.WrongPrivatePostingKey)));
            }

            var op = new CommentOperation(model.ParentAuthor, model.ParentPermlink, model.Author, model.Permlink, model.Title, model.Body, model.JsonMetadata);

            BaseOperation[] ops;
            if (model.Beneficiaries != null && model.Beneficiaries.Any())
            {
                var beneficiaries = model.Beneficiaries
                                    .Select(i => new Ditch.Steem.Operations.Beneficiary(i.Account, i.Weight))
                                    .ToArray();
                ops = new BaseOperation[]
                {
                    op,
                    new BeneficiariesOperation(model.Login, model.Permlink, new Asset(1000000000, Config.SteemAssetNumSbd), beneficiaries)
                };
            }
            else
            {
                ops = new BaseOperation[] { op };
            }

            return(await Broadcast(keys, ops, ct));
        }
Esempio n. 8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.nid    = int.Parse(Request.QueryString["nid"].ToString());
     assComments = CommentOperation.GetCommentsByNid(nid);
 }
Esempio n. 9
0
 public PostTable(long blockNum, short trxNum, short opNum, DateTime timestamp, CommentOperation operation)
     : base(blockNum, trxNum, opNum, timestamp)
 {
     Login    = operation.Author;
     JsonData = operation.JsonMetadata;
     Permlink = operation.Permlink;
     Title    = operation.Title;
     Body     = operation.Body;
 }