Beispiel #1
0
        public BotModel(Bot bot)
        {
            this.Id             = bot.Id;
            this.Name           = bot.Name ?? bot.IPAddress;
            this.WorkHours      = Format.AsAge(bot.CreationDate);
            this.Profit         = Format.AsBitCoin(bot.Balance);
            this.Efficiency     = Format.AsPercent(bot.Share, bot.TotalShare);
            this.EfficiencyText = string.Format("工作:{0} (总数:{1})", bot.Share, bot.TotalShare);
            this.Shares         = Format.AsCurrentAndPercent(bot.Share, Server.Recent.TotalShare);
            this.Action         = bot.Account == null ? "Authorize" : "Manage";
            this.ActionText     = bot.Account == null ? "认领" : "管理";

            //try get mine information from bot
            var cm = ComputeManager.ByBot(bot);

            if (cm != null)
            {
                var mine = Mine.Find(cm.MineId);
                if (mine != null)
                {
                    this.MineIcon = mine.Icon;
                    this.MineText = mine.IconName;
                }
            }

            //try get bot speed
            var speed = Server.Recent.TestBotSpeed(bot.Id);

            this.StatusIcon = "/Content/status/" + Format.AsSpeedIcon(speed) + ".png";
            this.StatusText = Format.AsSpeed(speed);
        }
Beispiel #2
0
        public static CreateEditProfileModel Build(string mineOrProfileId)
        {
            var mineId = int.Parse(mineOrProfileId);
            var mp     = MineProfile.TryFind(mineId);

            if (mp != null)
            {
                mineId = mp.MineId;
            }

            var mine  = App.Web.Business.Data.Mine.Find(mineId);
            var model = new CreateEditProfileModel
            {
                Id              = mp != null ? mp.Id : 0,
                Mine            = mine.DisplayName,
                MineId          = mine.Id,
                MineIcon        = mine.Icon,
                MineIconText    = mine.IconName,
                MineDescription = mine.Description,
                MineTaxRate     = Format.AsPercent(mine.TaxRate, 100),
                CustomAccount   = mp != null ? mp.CustomAccount : string.Empty,
                CustomPassword  = mp != null ? mp.CustomPassword : string.Empty
            };

            return(model);
        }
Beispiel #3
0
        public MineModel(Mine mine, MineProfile profile = null)
        {
            this.Id       = profile == null ? mine.Id : profile.Id;
            this.Address  = mine.Address;
            this.HomePage = mine.HomePage;
            //this.Certificated = mine.Certificated;
            this.DisplayName = mine.DisplayName;
            this.Name        = mine.Name;
            this.Icon        = mine.Icon;
            this.IconText    = mine.IconName;
            this.Description = mine.Description ?? "暂时没啥好说的";
            //this.Offshore = mine.Offshore;
            //this.Private = mine.Private;
            this.Speed     = mine.Speed;
            this.Tax       = Format.AsPercent(mine.TaxRate, 100);
            this.Status    = mine.IsOnline ? "正常" : "离线"; //满载
            this.UpdatedAt = mine.CheckTime;

            this.Ownership = mine.Account != null && mine.Account.UserId == WebSecurity.CurrentUserId;

            this.Action     = "Profile";//profile == null ? "Profile" : "Edit";
            this.ActionText = profile == null ? "自定义" : "修改";
        }