Ejemplo n.º 1
0
        private List <AccountInfoModel> LoadCmppAccount()
        {
            List <AccountInfoModel> lst = null;
            string    sql = "select * from t_spaccountinfo";
            DataTable dt  = MySqlDBExec.GetDateTable(sql, null);

            if (dt != null && dt.Rows.Count > 0)
            {
                lst = new List <AccountInfoModel>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    AccountInfoModel aim = new AccountInfoModel();
                    aim.eprId        = int.Parse(dt.Rows[i]["EprId"].ToString());
                    aim.loginname    = dt.Rows[i]["LoginName"].ToString();
                    aim.password     = dt.Rows[i]["Password"].ToString();
                    aim.senddelay    = int.Parse(dt.Rows[i]["SendDelay"].ToString());
                    aim.serviceid    = dt.Rows[i]["ServiceId"].ToString();
                    aim.spid         = dt.Rows[i]["Pid"].ToString();
                    aim.protocolType = dt.Rows[i]["ProtocolType"].ToString();
                    aim.serviceIp    = dt.Rows[i]["ServiceIp"].ToString();
                    aim.servicePort  = int.Parse(dt.Rows[i]["ServicePort"].ToString());
                    aim.spnumber     = dt.Rows[i]["Spnumber"].ToString();
                    lst.Add(aim);
                }
            }
            return(lst);
        }
Ejemplo n.º 2
0
        public ActionResult Profile()
        {
            AccountModel     am  = AccountService.GetAccountByEmail(User.Identity.Name);
            AccountInfoModel aim = AccountService.GetAccountInfo(am.Id);

            return(View(aim));
        }
        public AccountInfoWindow()
        {
            InitializeComponent();

            DataContext = new AccountInfoModel();
            // ReadInfo();
        }
        public async static void SendLoginRequest(string email, string password)
        {
            var authenticationString = $"{email}:{password}";
            var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(authenticationString));

            var requestMessage = new HttpRequestMessage(HttpMethod.Post, Constants.API_LOGIN_POST);

            requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Basic", base64EncodedAuthenticationString);

            LoginRequestResponseModel loginResult = new LoginRequestResponseModel();
            HttpResponseMessage       response    = await SendRequest(requestMessage);

            LoginResultEventArgs args = new LoginResultEventArgs();

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                string           responseBody = response.Content.ReadAsStringAsync().Result;
                AccountInfoModel model        = JsonConvert.DeserializeObject <AccountInfoModel>(responseBody);

                args.AccountData = model;
                args.Successful  = true;
            }
            else
            {
                args.Message     = response.ReasonPhrase;
                args.Successful  = false;
                args.AccountData = null;
            }

            LoginActionResult?.Invoke(null, args);
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> Post([FromBody] PostTest testdata)
        {
            var model = testdata;

            try
            {
                var auth = new FirebaseAuthProvider(new Firebase.Auth.FirebaseConfig(ApiKey));
                var ab   = await auth.SignInWithEmailAndPasswordAsync(model.Email, model.Password);

                string FbToken        = ab.FirebaseToken;
                string FbRefreshToken = ab.RefreshToken;

                var user = ab.User;
                client = new FireSharp.FirebaseClient(iconfig);

                if (FbToken != "")
                {
                    FirebaseResponse response = await client.GetTaskAsync("Accounts/" + user.LocalId);

                    AccountInfoModel obj = response.ResultAs <AccountInfoModel>();

                    return(StatusCode(200, new { token = FbToken }));
                }
                else
                {
                    // Якщо трабли з авторизацією.
                    return(StatusCode(400));
                }
            }
            catch (FirebaseAuthException ex)
            {
                // Якщо спіймали екцепшн.
                return(StatusCode(400, new { error = ex.Reason.ToString() }));
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> InviteMember(int projectId, string accountName)
        {
            bool isNewMember = false;

            if (!Validator.IsValidEmailAddress(accountName))
            {
                return(BadRequest(Context.GetStringResource("EmailWrongFormat", StringResourceType.Error)));
            }

            AccountInfoModel account = await EzTask.Account.GetAccountInfo(accountName);

            if (account == null)
            {
                isNewMember = true;
                string name = accountName.Split('@')[0];
                ResultModel <AccountModel> registerResult = await EzTask.Account.RegisterNew(new AccountModel
                {
                    AccountName = accountName,
                    Password    = Guid.NewGuid().ToString().Substring(0, 6),
                    FullName    = name,
                    DisplayName = name
                });

                if (registerResult.Status == ActionStatus.Ok)
                {
                    account = new AccountInfoModel {
                        AccountId = registerResult.Data.AccountId
                    };
                }
            }

            ProjectMemberModel model = new ProjectMemberModel
            {
                AccountId  = account.AccountId,
                ProjectId  = projectId,
                ActiveCode = Guid.NewGuid().ToString().Replace("-", "")
            };

            ResultModel <bool> alreadyAdded = await EzTask.Project.HasAlreadyAdded(model);

            if (alreadyAdded.Data)
            {
                return(BadRequest(Context.GetStringResource("AddedAccount", StringResourceType.ProjectPage)));
            }

            ResultModel <ProjectMemberModel> iResult = await EzTask.Project.AddMember(model);

            if (iResult.Status == ActionStatus.Ok)
            {
                string inviteTitle = Context.GetStringResource("InviteTitleEmail", StringResourceType.ProjectPage);
                await EzTask.Project.SendInvitation(model.ProjectId, model.AccountId,
                                                    isNewMember, inviteTitle, model.ActiveCode);
            }
            else
            {
                return(BadRequest(Context.GetStringResource("RequestFailed", StringResourceType.Error)));
            }

            return(PartialView("_AddNewMemberItemTemplate", iResult.Data));
        }
Ejemplo n.º 7
0
        public ActionResult Register(AccountInfoModel model)
        {
            DebugEx.WriteLineF("Registration step 1: {0}", model);
            if (ModelState.IsValid)
            {
                MembershipCreateStatus createStatus;
                Membership.CreateUser(null, model.Password, model.Email, null, null, true, null, out createStatus);

                //if (createStatus == MembershipCreateStatus.Success)
                //{
                //    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie *//*);
                //    return RedirectToAction("Index", "Home");
                //}
                //else
                //{
                //    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                //}
                //RegistrationModel regModel = new RegistrationModel();
                //regModel.AccountInfo = model;
                //regModel.WizzardStep = RegistrationWizzardStep.ACCOUNT_INFO;
                //this.TempData["registration"] = regModel;

                return(View("RegisterStep2", new PlayerInfoModel()));
            }
            return(View(model));
        }
Ejemplo n.º 8
0
        public async Task GetToken([FromBody] AccountModel account)
        {
            var identity = GetIdentity(account);

            if (identity == null)
            {
                Response.ContentType = "application/json";
                await Response.WriteAsync("Не верный логин или пароль");

                return;
            }
            var now = DateTime.UtcNow;
            var jwt = new JwtSecurityToken(
                issuer: AuthOptions.ISSUER,
                audience: AuthOptions.AUDIENCE,
                notBefore: now,
                claims: identity.Claims,
                expires: now.Add(TimeSpan.FromMinutes(AuthOptions.LIFETIME)),
                signingCredentials: new SigningCredentials(AuthOptions.GetSymmetricSecurityKey(),
                                                           SecurityAlgorithms.HmacSha256)
                );

            AccountInfoModel accountInfoModel = _account.GetAccountInfo(account);
            var encodedJwt = new JwtSecurityTokenHandler().WriteToken(jwt);

            accountInfoModel.Token = encodedJwt;

            Response.ContentType = "application/json";
            await Response.WriteAsync(JsonConvert.SerializeObject(encodedJwt,
                                                                  new JsonSerializerSettings {
                Formatting = Formatting.Indented
            }));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Update account information
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <ResultModel <AccountInfoModel> > UpdateAccount(AccountInfoModel model)
        {
            ResultModel <AccountInfoModel> result = new ResultModel <AccountInfoModel>
            {
                Status = ActionStatus.NotFound
            };

            var entity = model.ToEntity();

            var accountInfo = await UnitOfWork
                              .AccountInfoRepository
                              .GetAsync(c => c.Id == model.AccountInfoId);

            if (accountInfo != null)
            {
                accountInfo.Update(entity);

                int updateRecord = await UnitOfWork.CommitAsync();

                if (updateRecord > 0)
                {
                    result.Status = ActionStatus.Ok;
                    result.Data   = accountInfo.ToModel();
                }
            }
            return(result);
        }
Ejemplo n.º 10
0
        public AccountInfoModel GetInfo(string username)
        {
            AccountInfoModel acc = new AccountInfoModel();
            string           connectionString = Configuration["ConnectionStrings:DefaultConnection"];

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand("layThongTinTaiKhoan", connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;

                    if (connection.State == ConnectionState.Open)
                    {
                        connection.Close();
                    }

                    command.Parameters.AddWithValue("@UserName", username);
                    SqlDataAdapter da = new SqlDataAdapter(command);
                    DataSet        ds = new DataSet();
                    da.Fill(ds);

                    acc.TenKH    = ds.Tables[0].Rows[0]["TenKH"].ToString();
                    acc.NamSinh  = Convert.ToDateTime(ds.Tables[0].Rows[0]["NamSinh"].ToString());
                    acc.DiaChi   = ds.Tables[0].Rows[0]["DiaChi"].ToString();
                    acc.Quan     = ds.Tables[0].Rows[0]["Quan"].ToString();
                    acc.ThanhPho = ds.Tables[0].Rows[0]["ThanhPho"].ToString();
                    acc.sdt      = ds.Tables[0].Rows[0]["sdt"].ToString();
                    acc.image    = ds.Tables[0].Rows[0]["hinhanh"].ToString();
                }
            }
            return(acc);
        }
        private void updateAccountInfoModel(AccountModelBussines <int> model, AccountInfoModel <int> accInfo)
        {
            accInfo.Age       = model.Age;
            accInfo.FirstName = model.FirstName;
            accInfo.LastName  = model.LastName;

            _context.AccountInfos.Update(accInfo);
        }
Ejemplo n.º 12
0
 public void PerformSuccessfulLogin(AccountInfoModel accountModel)
 {
     UserSettings.UserEmail       = accountModel.Email;
     UserSettings.UserFirstName   = accountModel.FirstName;
     UserSettings.UserLastName    = accountModel.LastName;
     UserSettings.UserAccessToken = accountModel.Accesstoken;
     UserSettings.LoggedOn        = true;
 }
Ejemplo n.º 13
0
        /// <summary>
        /// API call to update account information
        /// </summary>
        /// <param name="acct">
        /// AccountInfoModel class containing all of the information to update a class
        /// </param>
        /// <returns>
        /// Returns an AccountInfoModel containing all of the updated class information
        /// </returns>
        private async Task <AccountInfoModel> UpdateAccount(AccountInfoModel acct)
        {
            HttpResponseMessage response = await ApiHelper.ApiClient.PutAsJsonAsync("v1/user/" + User.GetUserId().ToString(), acct);

            response.EnsureSuccessStatusCode();
            AccountInfoModel ret = await response.Content.ReadAsAsync <AccountInfoModel>();

            return(ret);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Login
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <AccountInfoModel> Login(AccountModel model)
        {
            string hash = Cryptography.GetHashString(model.AccountName);

            model.Password = Encrypt.Do(model.Password, hash);

            AccountInfoModel account = await GetAccount(model.AccountName, model.Password);

            return(account);
        }
Ejemplo n.º 15
0
        public ActionResult Index()
        {
            AccountInfoModel model = new AccountInfoModel
            {
                UserName = UserManager.FindByEmail(User.Identity.Name).UserName,
                Email    = UserManager.FindByEmail(User.Identity.Name).Email,
                Year     = UserManager.FindByEmail(User.Identity.Name).Year
            };

            return(View(model));
        }
 public FinanceRecordViewModel(AccountInfoModel normalAccount, Color recordColor)
 {
     _statisticType = StatisticTypeEnum.NormalAccount;
     AccountID      = normalAccount.AccountID;
     _normalAccount = normalAccount;
     _recordColor   = recordColor;
     RecordItem     = ItemManagementBussiness.Instance.Items.Where(i => i.ItemID == _normalAccount.ItemID).First().ItemName;
     RecordDate     = _normalAccount.AccountDate.ToString("yyyy年MM月dd日");
     Note           = normalAccount.Notice;
     RecordAmount   = normalAccount.AccountAmount.ToString();
     ChangeSelectState(false);
 }
Ejemplo n.º 17
0
        public FrontendSettingsModel GetSettings(long userId)
        {
            var account = _userService.GetAccountByUserId(userId);

            var accountInfo = new AccountInfoModel(account);

            return(new FrontendSettingsModel
            {
                Enums = new FrontendSettings().Enums,
                AccountInfo = accountInfo
            });
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 忘記密碼
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public ResultDto ForgetPassword(AccountInfoModel info)
        {
            if (string.IsNullOrWhiteSpace(info.Account) ||
                string.IsNullOrWhiteSpace(info.Email) ||
                string.IsNullOrWhiteSpace(info.Phone) ||
                string.IsNullOrWhiteSpace(info.Password))
            {
                throw new Exception("請檢查輸入欄位,缺一不可!");
            }

            var checkInfo = this._accountRepository.GetAccount(info.Account);

            if (checkInfo == null)
            {
                return(new ResultDto
                {
                    Success = false,
                    Message = "請確認輸入之帳號!"
                });
            }

            if (checkInfo.Email != info.Email)
            {
                return(new ResultDto
                {
                    Success = false,
                    Message = "請確認輸入的Email,是否與註冊時一致!"
                });
            }

            if (checkInfo.Phone != info.Phone)
            {
                return(new ResultDto
                {
                    Success = false,
                    Message = "請確認輸入的電話,是否與註冊時一致!"
                });
            }

            var condition = this._mapper.Map <AccountCondition>(info);

            condition.ModifyDate = DateTime.Now;
            condition.ModifyUser = condition.Account;
            condition.Password   = ConverPassword(condition.Account, condition.Password);

            var result = this._accountRepository.ForgetPassword(condition);

            return(new ResultDto
            {
                Success = result,
                Message = result ? "更新密碼成功" : "更新密碼失敗"
            });
        }
Ejemplo n.º 19
0
        public void TestAccountInfoModel1()
        {
            AccountInfoModel test = new AccountInfoModel();

            test.username     = "";
            test.password     = "";
            test.phone_number = "";

            Assert.AreEqual(test.username, "");
            Assert.AreEqual(test.password.Length, 0);
            Assert.AreEqual(test.phone_number.Length, 0);
        }
Ejemplo n.º 20
0
        // Called from LoginPage.cs when a successful login is performed
        public void PerformSuccessfulLogin(AccountInfoModel accountModel)
        {
            UserSettings.UserEmail       = accountModel.Email;
            UserSettings.UserFirstName   = accountModel.FirstName;
            UserSettings.UserLastName    = accountModel.LastName;
            UserSettings.UserAccessToken = accountModel.Accesstoken;
            UserSettings.LoggedOn        = true;

            panel_RegisterLogin.Visible = false;
            label_LoggedInText.Location = new Point(410, 32);
            label_LoggedInText.Visible  = true;
            ChangeLoggedInText();
        }
        public UserAccountPage(AccountInfoModel userModel)
        {
            InitializeComponent();

            Input_Password_01.TextChanged += Password_Input_TextChanged;
            Input_Password_02.TextChanged += Password_Input_TextChanged;

            DisableNewPasswordPanel();
            EnableMainInfoPanel();

            lbl_UserEmail.Text  = userModel.Email;
            tBox_FirstName.Text = userModel.FirstName;
            tBox_LastName.Text  = userModel.LastName;
        }
Ejemplo n.º 22
0
        public AccountInfoModel GetInfoForNavbar(string Username)
        {
            var q = (from a in db.Tbl_Login where (a.Login_UserName == Username) select a).SingleOrDefault();

            if (q != null)
            {
                AccountInfoModel infoModel = new AccountInfoModel();
                infoModel.Name = q.Tbl_User.User_Name + " " + q.Tbl_User.User_Family;
                infoModel.Role = q.Tbl_BaseRole.BaseRole_Titel;
                return(infoModel);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 23
0
        public string Register(AccountModel a, AccountInfoModel ai)
        {
            Account dbAccount = Repository.GetAccountByEmail(a.Email);

            if (dbAccount == null)
            {
                var dbRsp  = Repository.InsertAccount((Account)a);
                var dbRsp2 = Repository.InsertAccountInfo(GetAccountByEmail(a.Email).Id, (AccountInfo)ai);
                return(String.IsNullOrWhiteSpace(dbRsp) ? null : ("Problems with database insert action: " + dbRsp));
            }
            else if (dbAccount != null)
            {
                return("1");
            }
            return("2");
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 刪除帳號
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public ResultDto RemoveAccount(AccountInfoModel info)
        {
            if (string.IsNullOrWhiteSpace(info.Account) ||
                string.IsNullOrWhiteSpace(info.Email) ||
                string.IsNullOrWhiteSpace(info.Phone))
            {
                throw new Exception("請檢查輸入欄位,缺一不可!");
            }

            var checkInfo = this._accountRepository.GetAccount(info.Account);

            if (checkInfo == null)
            {
                return(new ResultDto
                {
                    Success = false,
                    Message = "請確認要刪除的帳號!"
                });
            }

            if (checkInfo.Email != info.Email)
            {
                return(new ResultDto
                {
                    Success = false,
                    Message = "請確認輸入的EMail是否與註冊時一致!"
                });
            }

            if (checkInfo.Phone != info.Phone)
            {
                return(new ResultDto
                {
                    Success = false,
                    Message = "請確認輸入的電話是否與註冊時一致!"
                });
            }

            var result = this._accountRepository.RemoveAccount(info.Account);

            return(new ResultDto
            {
                Success = result,
                Message = result ? "刪除成功" : "刪除失敗"
            });
        }
        public void OnClick_Login()
        {
            if (string.IsNullOrEmpty(InputUsername) || string.IsNullOrEmpty(InputPassword))
            {
                return;
            }

            var account = _accounts
                          .Where(x => x.Username == InputUsername && x.Password == InputPassword)
                          .FirstOrDefault();

            if (!(account is null))
            {
                _eventAggregator.PublishOnUIThread(new OnLoginAccepted {
                    AccountInfo = account
                });
                _currentAccount = account;
            }
Ejemplo n.º 26
0
 private void toolStripBtnStart_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < 3; i++)
     {
         AccountInfoModel aim = new AccountInfoModel();
         aim.eprId     = 77 + i;
         aim.loginname = "44191" + i;
         aim.password  = "******" + i;
         aim.senddelay = 50;
         aim.serviceid = "MJS6919908" + i;
         aim.spid      = "44191" + i;
         aim.spnumber  = "10690468" + i;
         CmppSendThread cst = new CmppSendThread(aim);
         cst.WriteLogHandler += new MyDelegate.WriteLogDelegate(WriteLog);
         _cstDic.Add(aim.eprId, cst);
         cst.Start();
     }
 }
Ejemplo n.º 27
0
        //[ValidateAntiForgeryToken]
        public ActionResult Index()
        {
            OrganizationAccountResponse Response = new OrganizationAccountResponse();
            OrganizationAccountRequest  Request  = new OrganizationAccountRequest();
            string AccountType = ConfigurationManager.AppSettings["ACCOUNT_TYPE"];
            string version     = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            ViewBag.Version = version;
            string           filepath = Server.MapPath("~\\Content\\Text\\TermOfUse.txt");
            string           content  = string.Empty;
            AccountInfoModel Model    = new AccountInfoModel();

            // Model.AccountType = ConfigurationManager.AppSettings["ACCOUNT_TYPE"];
            try
            {
                using (var stream = new StreamReader(filepath))
                {
                    content = stream.ReadToEnd();
                }
            }
            catch (Exception exc)
            {
            }
            ViewData["TermOfUse"] = content;

            Response = _isurveyFacade.GetStateList(Request);
            //Model.States.Add(new SelectListItem { Text = "Select a State", Value = "0" });

            foreach (var item in Response.StateList)
            {
                Model.States.Add(new SelectListItem {
                    Text = item.StateName, Value = item.StateId.ToString()
                });
            }
            if (string.IsNullOrEmpty(AccountType))
            {
                return(View("AccessDenied"));
            }
            else
            {
                return(View(Model));
            }
        }
Ejemplo n.º 28
0
        public bool AddNormalPayment(AccountInfoModel model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@AccountDate",   SqlDbType.Date),
                new SqlParameter("@ItemID",        SqlDbType.VarChar,50),
                new SqlParameter("@AccountAmount", SqlDbType.Decimal, 9),
                new SqlParameter("@Notice",        SqlDbType.VarChar, 200)
            };
            parameters[0].Value = model.AccountDate;
            parameters[1].Value = model.ItemID;
            parameters[2].Value = model.AccountAmount;
            parameters[3].Value = model.Notice;

            DbHelperSQL.RunProcedure("AccountInfo_ADD_LK", parameters, out rowsAffected);
            return(true);
        }
Ejemplo n.º 29
0
        private static AccountInfoModel GetAccountInfoModel()
        {
            var authorizedApps = from auth in Database.DataContext.ClientAuthorizations
                                 where auth.User.UserId == Database.LoggedInUser.UserId
                                 select new AccountInfoModel.AuthorizedApp {
                AppName = auth.Client.Name, AuthorizationId = auth.AuthorizationId, Scope = auth.Scope
            };

            Database.LoggedInUser.AuthenticationTokens.Load();
            var model = new AccountInfoModel {
                FirstName            = Database.LoggedInUser.FirstName,
                LastName             = Database.LoggedInUser.LastName,
                EmailAddress         = Database.LoggedInUser.EmailAddress,
                AuthorizedApps       = authorizedApps.ToList(),
                AuthenticationTokens = Database.LoggedInUser.AuthenticationTokens.ToList(),
            };

            return(model);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 更新帳號資訊
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public ResultDto UpdateAccount(AccountInfoModel info)
        {
            if (string.IsNullOrWhiteSpace(info.Account) ||
                string.IsNullOrWhiteSpace(info.Password))
            {
                throw new Exception("請檢查輸入欄位,缺一不可!");
            }

            var accountInfo = this._accountRepository.GetAccount(info.Account);

            if (string.IsNullOrWhiteSpace(accountInfo.Password))
            {
                return(new ResultDto
                {
                    Success = false,
                    Message = "請確認要更新的帳號!"
                });
            }

            var convertPassword = ConverPassword(info.Account, info.Password);

            if (accountInfo.Password != convertPassword)
            {
                return(new ResultDto
                {
                    Success = false,
                    Message = "請確認輸入的密碼是否與註冊時一致!"
                });
            }

            var condition = this._mapper.Map <AccountCondition>(info);

            condition.ModifyDate = DateTime.Now;
            condition.ModifyUser = info.Account;

            var result = this._accountRepository.UpdateAccount(condition);

            return(new ResultDto
            {
                Success = result,
                Message = result ? "更新成功" : "更新失敗"
            });
        }