Ejemplo n.º 1
0
        public Task GetRecordInfo([FromForm] int id, [FromForm] int siteId)
        {
            DomainRecord record = SiteAgent.Instance().GetRecordInfo(id);

            if (record == null)
            {
                return(this.ShowError("记录不存在"));
            }
            SiteDomain domain = SiteAgent.Instance().GetDomainInfo(siteId, record.DomainID);

            if (domain == null)
            {
                return(this.ShowError("记录数据错误"));
            }
            return(this.GetResult(new
            {
                record.ID,
                record.DomainID,
                record.CDNType,
                record.CName,
                record.Status,
                record.SubName,
                domain.Domain
            }));
        }
Ejemplo n.º 2
0
        public Task GetCDNInfo([FromForm] int recordId, [FromForm] CDNProviderType type)
        {
            DomainCDN cdn = SiteAgent.Instance().GetDomainCDNInfo(recordId, type);

            if (cdn == null)
            {
                return(this.ShowError("没有记录"));
            }
            return(this.GetResult(cdn));
        }
Ejemplo n.º 3
0
        public Task Save([FromForm] int id, [FromForm] string name, [FromForm] Currency currency, [FromForm] Language language)
        {
            Site site = SiteAgent.Instance().GetSiteInfo(id);

            site.Setting  = this.context.Request.Form.Fill(site.Setting, "Setting.", false);
            site.Name     = name;
            site.Currency = currency;
            site.Language = language;

            return(this.GetResult(SiteAgent.Instance().SaveSiteInfo(site)));
        }
Ejemplo n.º 4
0
        public Task GetWhiteIP([FromForm] int id)
        {
            Site detail = SiteAgent.Instance().GetSiteInfo(id);

            return(this.GetResult(new
            {
                detail.ID,
                detail.WhiteIP,
                detail.SecretKey
            }));
        }
Ejemplo n.º 5
0
        public Task SaveSiteDetail([FromForm] int id, [FromForm] string mobile, [FromForm] string email)
        {
            SiteDetail sitedetail = new SiteDetail()
            {
                SiteID = id,
                Mobile = mobile,
                Email  = email
            };

            return(this.GetResult(SiteAgent.Instance().SaveDetail(sitedetail)));
        }
Ejemplo n.º 6
0
        public Task Save([FromForm] int id, [FromForm] string name, [FromForm] Currency currency, [FromForm] Language language,
                         [FromForm] string prefix)
        {
            Site site = SiteAgent.Instance().GetSiteInfo(id);

            site.Name     = name;
            site.Currency = currency;
            site.Language = language;
            site.Prefix   = prefix;

            return(this.GetResult(SiteAgent.Instance().SaveSiteInfo(site)));
        }
Ejemplo n.º 7
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            MethodInfo method = (context.ActionDescriptor as ControllerActionDescriptor).MethodInfo;

            // 如果带有游客标记则不需要做验证判断
            if (method.HasAttribute <GuestAttribute>())
            {
                return;
            }

            //#1 从Http头中得到商户信息
            bool isSite = context.HttpContext.GetAuth(out string merchant, out string secretKey);

            if (!isSite)
            {
                context.Result = (ContentResult) new Result(false, ResultStatus.SecretKey.ToString());
                return;
            }
            int  siteId = merchant.GetValue <int>();
            Site site   = SiteAgent.Instance().GetSiteInfo(siteId);

            if (site == null || site.SecretKey != secretKey)
            {
                context.Result = (ContentResult) new Result(false, ResultStatus.SecretKey.ToString());
                return;
            }

            //#2 固定参数判断(自动在游戏中创建账户)
            string gameCode = context.HttpContext.Request.Form["GameCode"];
            string userName = context.HttpContext.Request.Form["UserName"];

            if (!string.IsNullOrEmpty(gameCode))
            {
                GameSetting game = GameAgent.Instance().GetGameSetting(gameCode);
                if (game == null)
                {
                    context.Result = (ContentResult) new Result(false, ResultStatus.NoGame.ToString());
                    return;
                }
                if (!string.IsNullOrEmpty(userName))
                {
                    ResultStatus registerStatus = APIAgent.Instance().Register(siteId, userName, game, out UserGame user);
                    if (registerStatus != ResultStatus.Success)
                    {
                        context.Result = (ContentResult) new Result(false, registerStatus.ToString());
                        return;
                    }
                    context.HttpContext.SetItem(user);
                }
                context.HttpContext.SetItem(game);
            }
            context.HttpContext.SetItem(site);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 注册接口(自动)
        /// 在 FilterAttribute 中判断是否存在,如果不存在则自动注册
        /// </summary>
        /// <param name="siteId">所属商户</param>
        /// <param name="userName">用户名</param>
        /// <param name="gameinfo">要进入的游戏接口</param>
        /// <returns></returns>
        public ResultStatus Register(int siteId, string userName, GameSetting game, out UserGame userGame)
        {
            int userId = UserAgent.Instance().GetUserID(siteId, userName);

            if (userId == 0)
            {
                if (!WebAgent.IsUserName(userName, 2, 16))
                {
                    userGame = null;
                    return(ResultStatus.BadUserName);
                }

                // 用户主表注册
                User user = new User()
                {
                    SiteID   = siteId,
                    UserName = userName,
                    CreateAt = DateTime.Now,
                    Status   = UserStatus.Normal
                };
                this.WriteDB.InsertIdentity(user);
                userId = user.ID;
            }

            //#2 写入游戏表
            userGame = UserAgent.Instance().GetUserGameInfo(userId, game.ID);
            if (userGame == null)
            {
                Site           site   = SiteAgent.Instance().GetSiteInfo(siteId);
                RegisterResult result = game.Setting.Register(new RegisterUser()
                {
                    Prefix   = site.Prefix,
                    UserName = userName
                });
                if (result)
                {
                    userGame = new UserGame()
                    {
                        SiteID   = siteId,
                        UserID   = userId,
                        Account  = result.Account,
                        Password = result.Password,
                        GameID   = game.ID,
                        Status   = UserGameStatus.Normal,
                        UpdateAt = DateTime.Now
                    };
                    this.WriteDB.Insert(userGame);
                }
                return(result.Status);
            }
            return(ResultStatus.Success);
        }
Ejemplo n.º 9
0
        public Task GetWhiteIP([FromForm] int id)
        {
            SiteDetail detail = SiteAgent.Instance().GetDetailInfo(id) ?? new SiteDetail()
            {
                SiteID = id
            };

            return(this.GetResult(new
            {
                detail.SiteID,
                detail.WhiteIP
            }));
        }
Ejemplo n.º 10
0
        public Task DomainList([FromForm] int id)
        {
            List <SiteDomain>   domains = SiteAgent.Instance().GetDomainList(id);
            List <DomainRecord> records = BDC.DomainRecord.Where(t => BDC.SiteDomain.Any(p => p.SiteID == id && p.ID == t.DomainID)).ToList();

            return(this.GetResult(this.ShowResult(domains, t => new
            {
                t.ID,
                t.SiteID,
                t.Domain,
                Records = records.Where(p => p.DomainID == t.ID)
            })));
        }
Ejemplo n.º 11
0
        public Task GetAdminUrl([FromForm] int id)
        {
            SiteDetail detail = SiteAgent.Instance().GetDetailInfo(id) ?? new SiteDetail()
            {
                SiteID = id
            };

            return(this.GetResult(new
            {
                detail.SiteID,
                detail.AdminURL,
                Domain = (SettingAgent.Instance().GetSetting(SettingType.AdminDomain) ?? string.Empty).Split(',')
            }));
        }
Ejemplo n.º 12
0
        public Task TemplateList([FromForm] int siteId, [FromForm] PlatformSource?platform)
        {
            var list = BDC.ViewSiteTemplate.Where(t => t.SiteID == siteId)
                       .Where(platform, t => t.Platform == platform.Value);
            Site site = SiteAgent.Instance().GetSiteInfo(siteId);

            return(this.GetResult(this.ShowResult(list, t => new
            {
                t.ID,
                t.Name,
                t.Platform,
                t.Domain,
                IsDefault = site.GetTemplateID(t.Platform) == t.ID
            })));
        }
Ejemplo n.º 13
0
        public Task AddSite([FromForm] int id, [FromForm] string name, [FromForm] Currency currency, [FromForm] Language language,
                            [FromForm] string prefix)
        {
            Site site = new Site()
            {
                ID       = id,
                Name     = name,
                Currency = currency,
                Language = language,
                Status   = Site.SiteStatus.Open,
                Prefix   = prefix
            };

            return(this.GetResult(SiteAgent.Instance().AddSite(site)));
        }
Ejemplo n.º 14
0
        public Task GetTemplate([FromForm] int templateId)
        {
            ViewSiteTemplate template = SiteAgent.Instance().GetTemplateInfo(templateId);
            Site             site     = SiteAgent.Instance().GetSiteInfo(template.SiteID);

            return(this.GetResult(new
            {
                template.ID,
                template.SiteID,
                template.Name,
                template.Platform,
                template.Domain,
                IsDefault = site.GetTemplateID(template.Platform) == templateId,
                Models = template.Configs.ToDictionary(t => t.ViewID, t => new { t.ModelID, t.ID })
            }));
        }
Ejemplo n.º 15
0
        public Task AddSite([FromForm] int id, [FromForm] string name, [FromForm] Currency currency, [FromForm] Language language,
                            [FromForm] int pcTemplate, [FromForm] int h5Template, [FromForm] int appTemplate)
        {
            Site site = new Site()
            {
                ID          = id,
                Name        = name,
                Currency    = currency,
                Language    = language,
                PCTemplate  = pcTemplate,
                H5Template  = h5Template,
                APPTemplate = appTemplate,
                Status      = Site.SiteStatus.Normal
            };

            return(this.GetResult(SiteAgent.Instance().AddSite(site)));
        }
Ejemplo n.º 16
0
        public Task AddTemplate([FromForm] string name, [FromForm] int siteId, [FromForm] PlatformSource source, [FromForm] int isDefault, [FromForm] string domain, [FromForm] int templateId)
        {
            if (templateId == 0)
            {
                return(this.ShowError("请选择来源模板"));
            }

            ViewSiteTemplate template = new ViewSiteTemplate()
            {
                SiteID   = siteId,
                Name     = name,
                Platform = source,
                Domain   = domain
            };

            return(this.GetResult(SiteAgent.Instance().AddTemplate(template, isDefault == 1, templateId)));
        }
Ejemplo n.º 17
0
        public Task GetDomainClipboard([FromForm] int siteId, [FromForm] int domainId)
        {
            SiteDomain domain = SiteAgent.Instance().GetDomainInfo(siteId, domainId);

            if (domain == null)
            {
                return(this.ShowError("域名错误"));
            }
            IEnumerable <DomainRecord> records = SiteAgent.Instance().GetDomainRecordList(domainId).Where(t => t.Status == DomainRecord.RecordStatus.Finish);

            if (records.Count() == 0)
            {
                return(this.ShowError("没有已完成的记录"));
            }

            List <string> clipboard = new List <string>();

            foreach (DomainRecord record in records)
            {
                clipboard.Add($"域名:{record.SubName}.{domain.Domain} 指向到(别名记录) {record.CName}");
            }
            return(this.GetResult(clipboard));
        }
Ejemplo n.º 18
0
 /// <summary>
 /// 删除记录
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Task DeleteRecord([FromForm] int id)
 {
     return(this.GetResult(SiteAgent.Instance().DeleteRecord(id)));
 }
Ejemplo n.º 19
0
        public Task Info([FromForm] int id)
        {
            Site site = SiteAgent.Instance().GetSiteInfo(id);

            return(this.GetResult(site));
        }
Ejemplo n.º 20
0
 public Task SitePayMul([FromForm] string IDs, [FromForm] decimal money)
 {
     return(this.GetResult(SiteAgent.Instance().SitePayMul(IDs, money)));
 }
Ejemplo n.º 21
0
 public Task SitePay([FromForm] int id, [FromForm] decimal money)
 {
     return(this.GetResult(SiteAgent.Instance().SitePay(id, money)));
 }
Ejemplo n.º 22
0
 public Task GetSiteGameSetting([FromForm] int id)
 {
     return(this.GetResult(SiteAgent.Instance().GetSiteGameSetting(id)));
 }
Ejemplo n.º 23
0
 public Task LoadSiteGameSetting([FromForm] int siteid)
 {
     return(this.GetResult(SiteAgent.Instance().LoadSiteGameSetting(siteid)));
 }
Ejemplo n.º 24
0
 public Task SaveSiteGameSetting([FromForm] int id, [FromForm] SiteGameStatus status, [FromForm] decimal rate, [FromForm] byte sort)
 {
     return(this.GetResult(SiteAgent.Instance().SaveSiteGameSetting(id, status, rate, sort)));
 }
Ejemplo n.º 25
0
 public Task SaveStatus([FromForm] int id, [FromForm] SiteStatus status)
 {
     return(this.GetResult(SiteAgent.Instance().SaveStatus(id, status)));
 }
Ejemplo n.º 26
0
 public Task SaveWhiteIP([FromForm] int id, [FromForm] string whiteIP, [FromForm] string secretKey)
 {
     return(this.GetResult(SiteAgent.Instance().SaveWhiteIP(id, whiteIP, secretKey)));
 }
Ejemplo n.º 27
0
 /// <returns></returns>
 public Task AddDomain([FromForm] int siteId, [FromForm] string domain, [FromForm] string subName, [FromForm] CDNProviderType provider)
 {
     return(this.GetResult(SiteAgent.Instance().AddDomain(siteId, domain,
                                                          (subName ?? string.Empty).Split(','), provider)));
 }
Ejemplo n.º 28
0
 public Task UpdateCDNProvider([FromForm] int recordId, [FromForm] CDNProviderType provider, [FromForm] string cname)
 {
     return(this.GetResult(SiteAgent.Instance().UpdateCDNProvider(recordId, provider, cname)));
 }
Ejemplo n.º 29
0
 public Task SaveAdminUrl([FromForm] int id, [FromForm] string adminURL)
 {
     return(this.GetResult(SiteAgent.Instance().SaveAdminUrl(id, adminURL)));
 }
Ejemplo n.º 30
0
 public Task AddRecord([FromForm] int siteId, [FromForm] int domainId, [FromForm] string subName, [FromForm] CDNProviderType provider)
 {
     return(this.GetResult(SiteAgent.Instance().AddDomainRecord(siteId, domainId, subName, provider)));
 }