Пример #1
0
        public static ValidationItemViewModel ValidateUpvoteAccountMinVPRule(GetAccountsModel accountDetails, ValidationVariables vars)
        {
            ValidationPriority   prio       = ValidationPriority.High;
            ValidationResultType resultType = ValidationResultType.Failure;

            var validationItem = new ValidationItemViewModel();

            validationItem.Title               = string.Format("Minimum required VP for account {0} is {1} %", vars.UpvoteAccount, vars.VPMinRequired);
            validationItem.Priority            = prio;
            validationItem.PriorityDescription = prio.ToString();
            validationItem.OrderId             = 60;

            // get comments within range
            var vpCalculated = CalculationHelper.CalculateVotingManaPercentage(accountDetails);

            if (vpCalculated >= vars.VPMinRequired)
            {
                resultType = ValidationResultType.Success;
                validationItem.ResultMessage = string.Format("VP of account {0} is {1} %.", vars.UpvoteAccount, vpCalculated.ToString("N"));
            }
            else
            {
                resultType = ValidationResultType.Failure;
                validationItem.ResultMessage = string.Format("VP of account {0} is {1} %.", vars.UpvoteAccount, vpCalculated.ToString("N"));
            }

            validationItem.ResultType            = resultType;
            validationItem.ResultTypeDescription = resultType.ToString();

            return(validationItem);
        }
Пример #2
0
        /// <summary>
        /// This method calls the getAccounts method from Steem
        /// </summary>
        /// <param name="accountName">The name of the account</param>
        /// <returns>Returns the results mapped to <see cref="GetAccountsModel" /> class</returns>
        private GetAccountsModel GetAccountDetails(string accountName)
        {
            var account = new GetAccountsModel();

            try
            {
                if (!String.IsNullOrEmpty(accountName))
                {
                    using (var csteemd = new CSteemd(ConfigurationHelper.HostName))
                    {
                        // account details
                        var response = csteemd.get_accounts(new ArrayList()
                        {
                            accountName
                        });
                        if (response != null)
                        {
                            var accountResult = response.ToObject <List <GetAccountsModel> >();
                            account = accountResult.FirstOrDefault();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex);
            }

            return(account);
        }
Пример #3
0
        protected override object DoExecute()
        {
            ApiParameters = String.Format("account/list/?application_id={0}&search={1}", ServerUrlHelper.Instance.GetApplicationId(Server), _nickname);
            GetAccountsModel model = RestCallHelper.GetCall <GetAccountsModel>(ApiParameters);

            return(model);
        }
Пример #4
0
        public static decimal CalculateVotingManaPercentage(GetAccountsModel accountDetails)
        {
            var secondsAgo = DateTime.UtcNow.Subtract(accountDetails.last_vote_time).TotalSeconds;
            var vpNow      = accountDetails.voting_power + (10000 * secondsAgo / 432000);
            var vp         = Math.Min(Math.Round(vpNow / 100, 2), 100);

            return((decimal)vp);
        }