コード例 #1
0
ファイル: FrmWallet.cs プロジェクト: Mitclub/MIT.Eth
 private void CreateAccount(object sender, FrmPassword.GetPasswordEventArgs e)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(e.M_Password))
         {
             if (ClsNethereum.createNewAccount(e.M_Password))
             {
                 DisplayFromAccount();
             }
             else
             {
                 string     strMessage = @"The registration process is failed.It may be caused in unstable network environment.Please try again later. For repeated issue, please contact ";
                 FrmMessage msg        = new FrmMessage(M_MessageType.Error
                                                        , strMessage
                                                        , true);
                 msg.ShowDialog();
             }
         }
     }
     catch (Exception ex)
     {
         ClsCommon.WriteLog(ex.ToString(), Consts.M_LogType.M_Error);
     }
 }
コード例 #2
0
ファイル: FrmWallet.cs プロジェクト: Mitclub/MIT.Eth
        private void DisplayFromAccount()
        {
            if (m_HasAccount)
            {
                this.lblAccount.Text = ClsNethereum.M_DefultAccount;

                // get ether:
                double dBalance = (double)ClsNethereum.GetMyBalance();
                this.lblBalanceEther.Text = dBalance.ToString("N");// Math.Round(dBalance, 5).ToString();

                // get MIT:
                var MIT = ClsNethereum.GetMITBalance(ClsNethereum.M_DefultAccount);
                if (MIT.IsSuccess)
                {
                    double dBalanceMIT = (double)MIT.Data;
                    this.lblBalanceMIT.Text = dBalanceMIT.ToString("N");// Math.Round(dBalanceMIT, 5).ToString("N");
                }

                // get MIT Locked status:
                var lockStatus = ClsNethereum.CheckMITLocked(ClsNethereum.M_DefultAccount);
                if (lockStatus.IsSuccess)
                {
                    this.lblLocked.Text = (!lockStatus.Data).ToString();
                }

                btnAddAccount.Enabled = false;
            }
            else
            {
                btnAddAccount.Enabled = true;
            }
        }
コード例 #3
0
ファイル: FrmMain.cs プロジェクト: Mitclub/MIT.Eth
        /// <summary>
        /// lock MIT token
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLock_Click(object sender, EventArgs e)
        {
            try
            {
                lblError.Visible = false;

                if (string.IsNullOrWhiteSpace(txtAccount.Text.Trim()))
                {
                    lblError.Text = "[Amount] is invalid.";
                    lblError.Visible = true;
                    return;
                }

                if (dtmLock.Value <= DateTime.Now)
                {
                    lblError.Text = "[Locking period] is invalid. It must be later than now.";
                    lblError.Visible = true;
                    return;
                }

                var unLockResult = ClsNethereum.unLockAccount(this.txtPassword.Text.Trim());
                if (unLockResult.IsSuccess == false)
                {
                    lblError.Text = unLockResult.Message;
                    this.lblError.Visible = true;
                    return;
                }

                TimeSpan cha = (dtmLock.Value - TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)));
                Int32 t = (Int32)cha.TotalSeconds;

                // lock Ether
                var lockResult = ClsNethereum.LockMIT(txtAccount.Text.Trim(), t);

                if (lockResult.IsSuccess)
                {
                    new FrmMessage(M_MessageType.Success, lockResult.Data, false).ShowDialog();
                }
                else
                {
                    new FrmMessage(M_MessageType.Error, lockResult.Message, false).ShowDialog();
                }
            }
            catch (Exception ex)
            {
                ClsCommon.WriteLog(ex.ToString(), Consts.M_LogType.M_Error);
            }
        }
コード例 #4
0
ファイル: FrmWallet.cs プロジェクト: Mitclub/MIT.Eth
        private void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                if (!validateForSend())
                {
                    return;
                }

                var unLockResult = ClsNethereum.unLockAccount(this.txtPassword.Text.Trim());
                if (unLockResult.IsSuccess == false)
                {
                    new FrmMessage(M_MessageType.Error, unLockResult.Message, false).ShowDialog();
                    return;
                }

                ResponseModel <string> sendResult = null;

                if (rdoEther.Checked)
                {
                    // send Ether
                    sendResult = ClsNethereum.SendTransaction(ClsNethereum.M_DefultAccount, txtTo.Text.Trim(), Convert.ToDouble(txtAmount.Text));
                }
                else
                {
                    // send MIT
                    sendResult = ClsNethereum.SendMIT(ClsNethereum.M_DefultAccount, txtTo.Text.Trim(), Convert.ToDouble(txtAmount.Text));
                }

                if (sendResult.IsSuccess)
                {
                    new FrmMessage(M_MessageType.Success, sendResult.Data, false).ShowDialog();
                }
                else
                {
                    new FrmMessage(M_MessageType.Error, sendResult.Message, false).ShowDialog();
                }
            }
            catch (Exception ex)
            {
                ClsCommon.WriteLog(ex.ToString(), Consts.M_LogType.M_Error);
            }
        }
コード例 #5
0
ファイル: FrmMain.cs プロジェクト: Mitclub/MIT.Eth
        /// <summary>
        /// unlock MIT token
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUnlock_Click(object sender, EventArgs e)
        {
            try
            {
                lblError.Visible = false;

                if (string.IsNullOrWhiteSpace(txtAccount.Text.Trim()))
                {
                    lblError.Text = "[Amount] is invalid.";
                    lblError.Visible = true;
                    return;
                }

                var unLockResult = ClsNethereum.unLockAccount(this.txtPassword.Text.Trim());
                if (unLockResult.IsSuccess == false)
                {
                    lblError.Text = unLockResult.Message;
                    this.lblError.Visible = true;
                    return;
                }

                // lock Ether
                var lockResult = ClsNethereum.UnlockMIT(txtAccount.Text.Trim());
                if (lockResult.IsSuccess)
                {
                    new FrmMessage(M_MessageType.Success, lockResult.Data, false).ShowDialog();
                }
                else
                {
                    new FrmMessage(M_MessageType.Error, lockResult.Message, false).ShowDialog();
                }
            }
            catch (Exception ex)
            {
                ClsCommon.WriteLog(ex.ToString(), Consts.M_LogType.M_Error);
            }

        }