Example #1
0
        public async Task <IActionResult> PutAccount([FromRoute] long id, [FromBody] AccountInfomation account)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != account.Id)
            {
                return(BadRequest());
            }

            _context.Entry(account).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AccountExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #2
0
        /// <summary>
        /// 账户信息相关功能
        /// </summary>
        public static void AccountInfo()
        {
            AccInfo = GetAccountInfomation();
            if (AccInfo != null && AccInfo.Status == "success")
            {
                if (DialerConfig.isNotifyWhenExpire)
                {
                    DateTime overDate = AccInfo.OverDate;
                    TimeSpan left     = overDate.Subtract(DateTime.Today);
                    if (left.TotalDays <= 7)
                    {
                        Binder.BaseBinder.ShowBalloonTip(
                            5000,
                            "提示",
                            "校园网账户将于" + overDate.ToString("yyyy-MM-dd") + "过期,请尽快充值",
                            System.Windows.Forms.ToolTipIcon.Warning);
                    }
                }

                if (DialerConfig.zone == DialerConfig.Campus.Unknown)
                {
                    if (AccInfo.Service.Contains("大学城"))
                    {
                        DialerConfig.zone = DialerConfig.Campus.HEMC;
                    }
                    else if (AccInfo.Service.Contains("东风路"))
                    {
                        DialerConfig.zone = DialerConfig.Campus.DongfengRd;
                    }
                    else if (AccInfo.Service.Contains("龙洞"))
                    {
                        DialerConfig.zone = DialerConfig.Campus.LongDong;
                    }
                    else if (AccInfo.Service.Contains("番禺"))
                    {
                        DialerConfig.zone = DialerConfig.Campus.Panyu;
                    }
                    else
                    {
                        Log4Net.WriteLog("无法匹配的校区字符串:" + AccInfo.Service);
                    }
                }
            }
        }
Example #3
0
        Regulus.Remoting.Value<bool> IVerify.CreateAccount(string name, string password)
        {
            var val =  _Core.Storage.FindAccountInfomation(name);

            Regulus.Remoting.Value<bool> ret = new Regulus.Remoting.Value<bool>();
            val.OnValue += (AccountInfomation result_account) =>
            {
                if (result_account == null)
                {
                    AccountInfomation ai = new AccountInfomation();
                    ai.Id = Guid.NewGuid();
                    ai.Name = name;
                    ai.Password = password;
                    _Core.Storage.Add(ai);
                    ret.SetValue(true);
                }
                ret.SetValue(false);
            };
            return ret;
        }
Example #4
0
 void IStorage.Add(AccountInfomation ai)
 {
 }
Example #5
0
        private void _ToFirst(AccountInfomation account_infomation)
        {
            _AccountInfomation = account_infomation;
            if (VerifySuccessEvent != null)
                VerifySuccessEvent(_AccountInfomation.Id);
            if (account_infomation.Record == null)
            {
                GameRecord record = _BuildFirstRecord();
                Adventurer adv = _BuildAdventurer("Teaching" , record);

                _ToFirstAdventure(record, adv);
            }
            else
            {
                _ToTown(account_infomation.Record.Tone);
            }
        }
Example #6
0
        /// <summary>
        /// 获取账户信息
        /// </summary>
        /// <returns></returns>
        public static AccountInfomation GetAccountInfomation()
        {
            try
            {
                AccountInfomation acci = new AccountInfomation();

                if (DialerConfig.username == "" || DialerConfig.password == "")
                {
                    acci.Status = "用户名或密码为空";
                    return(acci);
                }


                //构造Cookie
                RestClient client = new RestClient("http://222.200.98.8:1800");
                client.CookieContainer = new System.Net.CookieContainer();
                client.UserAgent       = @"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0";

                //获取认证码
                RestRequest   indexRequest  = new RestRequest("/Self/nav_login");
                IRestResponse indexResponse = client.Execute(indexRequest);

                Match match = Regex.Match(indexResponse.Content, @"var checkcode=""([0-9]*)""");

                string code = match.Groups[1].Value;

                //拉取验证码
                client.Execute(new RestRequest("Self/RandomCodeAction.action"));

                //构造认证包
                RestRequest authRequest = new RestRequest("/Self/LoginAction.action", Method.POST);
                authRequest.AddParameter("account", DialerConfig.username);
                MD5    md5      = new MD5CryptoServiceProvider();
                byte[] mdResult = md5.ComputeHash(Encoding.Default.GetBytes(DialerConfig.password));
                authRequest.AddParameter("password", BmobAnalyze.ToHexString(mdResult, mdResult.Length));
                authRequest.AddParameter("code", "");
                authRequest.AddParameter("checkcode", code);
                authRequest.AddParameter("Submit", "登录");


                //认证
                IRestResponse authResponse = client.Execute(authRequest);
                if (authResponse.Content.Contains("登录密码不正确"))
                {
                    acci.Status = "用户名或密码不正确";
                    return(acci);
                }
                if (authResponse.Content.Contains("账号为空请正确填写"))
                {
                    acci.Status = "未知的登录错误";
                    return(acci);
                }


                //获取账户信息
                RestRequest infoRequest = new RestRequest("Self/refreshaccount");
                IRestResponse <accountInfomation> infoResponse = client.Execute <accountInfomation>(infoRequest);

                //转换数据格式
                if (infoResponse.Data == null)
                {
                    acci.Status = "未知的获取错误";
                    return(acci);
                }
                acci.Status    = infoResponse.Data.date;
                acci.Username  = infoResponse.Data.note.welcome;
                acci.Service   = infoResponse.Data.note.service;
                acci.LeftMoney = infoResponse.Data.note.leftmoeny;

                match = Regex.Match(infoResponse.Data.note.overdate, @"([0-9]*)-([0-9]*)-([0-9]*)");
                DateTime overDate = new DateTime(
                    int.Parse(match.Groups[1].Value),
                    int.Parse(match.Groups[2].Value),
                    int.Parse(match.Groups[3].Value));

                acci.OverDate = overDate;
                return(acci);
            }
            catch (Exception e)
            {
                Log4Net.WriteLog(e.Message, e);
                AccountInfomation acci = new AccountInfomation();
                acci.Status = "内部错误";
                return(acci);
            }
        }
Example #7
0
        public Parking(Remoting.ISoulBinder binder, AccountInfomation account_infomation)
        {
            this._Binder = binder;

            this._AccountInfomation = account_infomation;
        }
Example #8
0
        void _ToParking(AccountInfomation account_infomation)
        {
            var stage = new Regulus.Project.Crystal.Game.Stage.Parking(Binder , account_infomation);
            stage.SelectCompiledEvent += _ToAdventure;
            stage.VerifyEvent += _ToVerify;
            _StageMachine.Push(stage);
            _AccountInfomation = account_infomation;

            _StatusEvent(UserStatus.Parking);
        }
Example #9
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,BirthDay,Phone")] AccountInfomation accountInfomation, int[] classIds, int roleId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var Rnb = "";

            switch (roleId)
            {
            case 1:
                Rnb = "A";
                break;

            case 2:
                Rnb = "M";
                break;

            case 3:
                Rnb = "D";
                break;

            default:
                return(BadRequest());
            }
            //Generate RollNumber
            var count = await _context.Account.CountAsync(a => a.RollNumber.Contains(Rnb)) + 1;

            string rollNumber;

            if (count < 10)
            {
                rollNumber = "0000" + count;
            }
            else if (count < 100)
            {
                rollNumber = "000" + count;
            }
            else if (count < 1000)
            {
                rollNumber = "00" + count;
            }
            else if (count < 10000)
            {
                rollNumber = "0" + count;
            }
            else
            {
                rollNumber = count.ToString();
            }

            var rnber = (Rnb + rollNumber).ToLower();

            // Generate Email
            var    str   = accountInfomation.FirstName.Split(" ");
            string email = accountInfomation.LastName;

            foreach (var item in str)
            {
                if (item.Any())
                {
                    email += item[0];
                }
            }

            email = email.ToLower();

            var emailGenerate    = RemoveUTF8.RemoveSign4VietnameseString(email + rnber + "@siingroup.com").ToLower();
            var passwordGenerate = RemoveUTF8.RemoveSign4VietnameseString(email + rnber);

            //Create new account
            Account account = new Account
            {
                RollNumber = rnber,
                Email      = emailGenerate,
                Salt       = PasswordHandle.GetInstance().GenerateSalt()
            };

            account.Password = PasswordHandle.GetInstance().EncryptPassword(passwordGenerate, account.Salt);

            _context.Account.Add(account);

            //Create thông tin đăng nhập để trả về response
            Login login = new Login
            {
                Email    = emailGenerate,
                Password = passwordGenerate
            };

            //Check uniqe by phone
            if (AccountExistsByPhone(accountInfomation.Phone))
            {
                return(Conflict("Tài khoản đã tồn tại trên hệ thống, vui lòng kiểm tra lại!"));
            }
            else
            {
                //Save account
                await _context.SaveChangesAsync();

                //Get ra account.Id để gán cho FK ownerId bên accountinfomation
                accountInfomation.OwnerId = account.Id;
                _context.AccountInfomation.Add(accountInfomation);
                await _context.SaveChangesAsync();

                AccountLogsDefault log = new AccountLogsDefault
                {
                    Title = "Đã tạo tài khoản với email " + login.Email + "!"
                };

                _context.Default.Add(log);

                AccountLogs al = new AccountLogs
                {
                    OwnerId   = account.Id,
                    CreatedBy = accountInfomation.FirstName + " " + accountInfomation.LastName,
                    Default   = log
                };

                _context.Log.Add(al);

                await _context.SaveChangesAsync();

                foreach (var item in classIds)
                {
                    Classes classes = new Classes
                    {
                        OwnerId = account.Id,
                        ClassId = item
                    };
                    _context.Classes.Add(classes);
                    AccountLogsDefault logs = new AccountLogsDefault();
                    var classAccount        = _context.Class.SingleOrDefault(a => a.Id == classes.ClassId);
                    logs.Title = accountInfomation.FirstName + " " + accountInfomation.LastName + " đã xếp bạn vào lớp " + classAccount.Name;
                    _context.Default.Add(logs);
                    AccountLogs als = new AccountLogs
                    {
                        OwnerId   = account.Id,
                        CreatedBy = accountInfomation.FirstName + " " + accountInfomation.LastName,
                        Default   = logs
                    };

                    _context.Log.Add(als);
                }

                await _context.SaveChangesAsync();
            }

            return(Created("", login));
        }