예제 #1
0
파일: userBusiness.cs 프로젝트: Puiatmp/b2e
        public autenticaRetorno AutenticarUsuario(string user, string pass)
        {
            userData         usuarioData = new userData();
            autenticaRetorno retorno     = new autenticaRetorno();

            try
            {
                retorno.Sucesso = true;
                retorno.User    = usuarioData.AutenticarUsuario(user, pass);
                if (retorno.User.Id != 0)
                {
                    retorno.Mensagem = "Usuário autenticado com sucesso.";
                }
                else
                {
                    retorno.Mensagem = "Usuário ou senha inválidos.";
                }
            }
            catch (Exception ex)
            {
                Tratamento(ex.HResult, ex.Message, ex.Source, "userBusiness.AutenticarUsuario(" + user + ", " + pass + ")", ex.StackTrace, false, utilData.DB);
                retorno.Sucesso  = false;
                retorno.Mensagem = "Erro ao autenticar usuario.";
            }
            return(retorno);
        }
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            userData userData = db.userData.Find(id);

            if (userData == null)
            {
                return(HttpNotFound());
            }
            {
                Guid memberId;
                Guid.TryParse(User.Identity.GetUserId(), out memberId);
                if (memberId == id)
                {
                    return(View(userData));
                }
                else
                {
                    return(View("NotAuthorized"));
                }
            }
        }
        async void AddMedia_Tapped(object sender, EventArgs e)
        {
            await CrossMedia.Current.Initialize();

            if (CrossMedia.IsSupported == false)
            {
                await DisplayAlert("Alert", "Not supported !", "OK");
            }
            else
            {
                var file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions()
                {
                });

                if (file != null)
                {
                    imgStr = file.GetStream();
                    await fire.saveImage(imgStr, user1);

                    user1 = await DBhelper.GetUser(UserLocalEmail.Text);

                    userPhoto.Source = ImageSource.FromUri(new Uri(user1.imageUrl));
                }
            }
        }
예제 #4
0
        private void btnDelAll_Click(object sender, EventArgs e)
        {
            userData data = new userData();

            data.deleteAllAnimals("admin");
            succesDelete.Show();
        }
예제 #5
0
        public static async Task <List <userData> > getAllUsers()
        {
            List <userData> dataToReturn = new List <userData>();

            await databaseManager.selectQuery("SELECT * FROM users", delegate(DbDataReader reader)
            {
                if (reader.HasRows)
                {
                    userData userDetails       = new userData();
                    userDetails.balance        = (decimal)reader["balance"];
                    userDetails.username       = (string)reader["username"];
                    userDetails.id             = (int)reader["id"];
                    userDetails.cookie         = (string)reader["cookie"];
                    userDetails.positiveRates  = (int)reader["positiveRates"];
                    userDetails.negativeRates  = (int)reader["negativeRates"];
                    userDetails.registerDate   = (DateTime)reader["registerDate"];
                    userDetails.soldAccounts   = (int)reader["soldAccounts"];
                    userDetails.boughtAccounts = (int)reader["boughtAccounts"];
                    userDetails.admin          = ( bool )reader["admin"];
                    userDetails.seller         = (bool)reader["seller"];
                    userDetails.lastUpdate     = DateTime.Now;
                    userDetails.loginIP        = ( string )reader["loginIP"];
                    userDetails.banReason      = (string)reader["banReason"];
                    userDetails.sellerDate     = (DateTime)reader["sellerDate"];
                    userDetails.phoneNumber    = (string)reader["phoneNumber"];
                    userDetails.lastLogin      = (DateTime)reader["lastLogin"];
                    userDetails.paypalemail    = ( string )reader["paypalemail"];

                    dataToReturn.Add(userDetails);
                }
            }).Execute();

            return(dataToReturn);
        }
예제 #6
0
        private void btnBoth_Click(object sender, EventArgs e)
        {
            userData data = new userData();

            data.deleteCategory(animalNum, 3, "admin");
            succesDelete.Show();
        }
        protected async override void OnAppearing()
        {
            base.OnAppearing();
            user1 = await DBhelper.GetUser(UserLocalEmail.Text);

            SurnameDataChangePage.Text = user1.Surname;
        }
        protected async override void OnAppearing()
        {
            base.OnAppearing();
            user1 = await DBhelper.GetUser(UserLocalEmail.Text);

            DepartmentDataChangePage.Text = user1.Department;
        }
예제 #9
0
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            userData user = db.userDatas.Find(id);

            if (user == null)
            {
                return(HttpNotFound());
            }
            Guid memberID;

            Guid.TryParse(User.Identity.GetUserId(), out memberID);
            if (user.userId == memberID)
            {
                // find the user's record
                var currentUser = db.userDatas.Find(memberID);
                // save the current photo into TempData
                TempData["oldPhoto"] = currentUser.avatar; // save the current photo info
                return(View(user));
            }
            else
            {
                return(View("notAuthorized"));
            }
        }
예제 #10
0
        // GET: userData/Delete/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            userData userData = db.userData.Find(id);

            if (userData == null)
            {
                return(HttpNotFound());
            }
            Guid memberID;

            Guid.TryParse(User.Identity.GetUserId(), out memberID);
            if (userData.ID == memberID)
            {
                db.userData.Remove(userData);
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View("NotAuthenticated"));
            }
        }
예제 #11
0
        //  [HttpPost]
        public async Task <IHttpActionResult> registration(userData account)
        {
            //User.Identity.Name==>Claims["Name"]
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                UserStore <IdentityUser> store =
                    new UserStore <IdentityUser>(new context());

                UserManager <IdentityUser> manager =
                    new UserManager <IdentityUser>(store);
                IdentityUser user = new IdentityUser();
                user.UserName     = account.Name;
                user.PasswordHash = account.Password;

                IdentityResult result = await manager.CreateAsync(user, account.Password);

                if (result.Succeeded)
                {
                    //string locat = Url.Link("DefaultApi", new { })
                    return(Created("", "register Sucess " + user.UserName));
                }
                else
                {
                    return(BadRequest((result.Errors.ToList())[0]));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
예제 #12
0
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            userData user = db.userDatas.Find(id);

            if (user == null)
            {
                return(HttpNotFound());
            }
            Guid memberId;

            Guid.TryParse(User.Identity.GetUserId(), out memberId);
            if (user.userId == memberId)
            {
                return(View(user));
            }
            else
            {
                return(View("notAuthorized"));
            }
            // old code: return View(userData);
        }
예제 #13
0
        public async void SaveUserData(SocketUser person, userData userData)
        {
            DateTime now = DateTime.Now;

            using (var database = new MySqlConnection(Program.DbConnection))
            {
                using (var sqlcommand = new MySqlCommand())
                {
                    await database.OpenAsync();

                    sqlcommand.Connection  = database;
                    sqlcommand.CommandType = CommandType.Text;
                    try
                    {
                        string oString = "UPDATE users SET userName = @userName, cash = @cash, lastSeen = @lastseen WHERE identifier = @identifier";
                        sqlcommand.CommandText = oString;
                        sqlcommand.Parameters.AddWithValue("@identifier", person.Id);
                        sqlcommand.Parameters.Add("@userName", DbType.String).Value = person.Username + "#" + person.Discriminator;
                        sqlcommand.Parameters.Add("@cash", DbType.String).Value     = userData.cash;
                        sqlcommand.Parameters.Add("@lastSeen", DbType.String).Value = now;

                        await sqlcommand.ExecuteNonQueryAsync();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("MySQL error: " + e.Message);
                        throw;
                    }
                }
                //await database.CloseAsync();
            }
        }
예제 #14
0
    // Start is called before the first frame update
    void Start()
    {
        if (useratm == null)
        {
            // Get file path to data stored in the JSON file
            string filepath = Application.streamingAssetsPath + "/userData.json";

            // read info of the json file
            string jsonString = File.ReadAllText(filepath);

            // store json data into the userData list
            userData data = JsonUtility.FromJson <userData>(jsonString);

            // Get all the users from the json file and get their
            foreach (User user in data.Users)
            {
                users.Add(user.Username, user);     // add user to the list
                //Debug.Log(user.Username);
                foreach (SessionLog session in user.logins)
                {
                    //Debug.Log("Length: " + session.Lengthofsess + "\t Time: " + session.Timeofsess);
                }
            }
            dumpTKL();
        }
    }
예제 #15
0
        // GET: userData/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            userData userData = db.userData.Find(id);

            if (userData == null)
            {
                return(HttpNotFound());
            }
            var rec     = db.coreValuesRecognitions.Where(r => r.recognizedID == id);
            var reclist = rec.ToList();

            ViewBag.rec = reclist;
            var totalcnt = reclist.Count();
            var rec1Cnt  = reclist.Where(r => r.award == coreValuesRecognition.CoreValues.Excellence).Count();
            var rec2Cnt  = reclist.Count(r => r.award == coreValuesRecognition.CoreValues.Integrity);
            var rec3Cnt  = reclist.Count(r => r.award == coreValuesRecognition.CoreValues.Stewardship);
            var rec4Cnt  = reclist.Count(r => r.award == coreValuesRecognition.CoreValues.Innovate);
            var rec5Cnt  = reclist.Count(r => r.award == coreValuesRecognition.CoreValues.Balance);


            ViewBag.total       = totalcnt;
            ViewBag.Excellence  = rec1Cnt;
            ViewBag.Integrity   = rec2Cnt;
            ViewBag.Stewardship = rec3Cnt;
            ViewBag.Innovate    = rec4Cnt;
            ViewBag.Balance     = rec5Cnt;

            return(View(userData));
        }
예제 #16
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            userData userData = db.userDatas.Find(id);

            db.userDatas.Remove(userData);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        private void btnDeleteAmount_Click(object sender, EventArgs e)
        {
            int      deleteMale   = Int32.Parse(numberDeleteMale.Text);
            int      deleteFemale = Int32.Parse(numberDeleteFemale.Text);
            userData data         = new userData();

            data.editAmount(deleteMale, deleteFemale, animalNum, "delete");
            textSuccesDeleted.Show();
        }
        private void btnAddAmount_Click(object sender, EventArgs e)
        {
            int      addMale   = Int32.Parse(numberAddMale.Text);
            int      addFemale = Int32.Parse(numberAddFemale.Text);
            userData data      = new userData();

            data.editAmount(addMale, addFemale, animalNum, "add");
            textSuccesAdded.Show();
        }
예제 #19
0
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        if (vadPassCheck.IsValid && vadAfterFour.IsValid)
        {
            //驗證帳號(信箱)是否已存在
            var ifb = new iFoodBoxDataContext();
            var uAccount = ifb.userAccounts.FirstOrDefault(m => txtAccount.Text.Equals(m.userAccount.ToString()));
            if (uAccount != null)
            {
                lblErrorMsgEmail.Visible = true;
                return;
            }
            //驗證電話是否已存在
            ifb = new iFoodBoxDataContext();
            var uData = ifb.userData.FirstOrDefault(m => txtPhone.Text.Equals(m.userPhone.ToString()));
            if (uData != null)
            {
                lblErrorMsgPhone.Visible = true;
                return;
            }
            //將基本資料存入
            uData = new userData();
            uData.userName = txtName.Text;
            uData.userDate = DateTime.Parse(txtDate.Text);
            if (rBtnM.Checked)//判斷性別
                uData.userSex = true;
            else if (rBtnF.Checked)
                uData.userSex = false;
            else
                uData.userSex = true;
            uData.userAfterFour = txtAfterFour.Text;
            uData.userPhone = txtPhone.Text;
            ifb = new iFoodBoxDataContext();
            ifb.userData.InsertOnSubmit(uData);
            ifb.SubmitChanges();
            //取出userID
            ifb = new iFoodBoxDataContext();
            var tableUserData = from x in ifb.userData
                                where x.userPhone == txtPhone.Text
                                select x;
            var userID = 0;
            foreach (userData ud in tableUserData)
                userID = ud.userID;
            //將帳號資訊存入
            uAccount = new userAccounts();
            uAccount.userAccount = txtAccount.Text;
            uAccount.userPassword = txtPassword.Text;
            uAccount.userID = userID;
            ifb = new iFoodBoxDataContext();
            ifb.userAccounts.InsertOnSubmit(uAccount);
            ifb.SubmitChanges();

            Response.Write(" <script language=JavaScript> alert('資料新增完畢!'); </script> ");
            Response.Redirect("LoginPage.aspx");
        }
    }
예제 #20
0
        public userData Indexx()
        {
            userData data = new userData();
            string   id   = getIDFromCookie();

            data.userLevel    = UserManager.getLevel(id);
            data.userNickName = DataBaseAccess.getObject(new User(id)).userNickName;
            data.itemNumber   = ItemManager.getItemNum(id);
            return(data);
        }
예제 #21
0
 public ActionResult Edit([Bind(Include = "ID,lastName,firstName,officeLocation,startDate")] userData userData)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userData).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userData));
 }
예제 #22
0
 public ActionResult Edit([Bind(Include = "ID,Email,lastName,firstName,PhoneNumber,Position,Location,BusinessUnit,hireDate,bio")] userData userData)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userData).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userData));
 }
    static void Main(String[] args)
    {
        String str = args[0];    //check for length and handle error scenarios.
        DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(userData));
        MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(str));
        //deserialize
        userData data = (userData)ser.ReadObject(ms);

        Console.WriteLine(data.Dir + ", " + data.FileFilter + ", " + data.OutPutFile);
    }
 public ActionResult Edit([Bind(Include = "ID,firstName,lastName,businessUnit,hireDate,title")] userData userData)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userData).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userData));
 }
예제 #25
0
        private void btnEditPrice_Click(object sender, EventArgs e)
        {
            int      newPrice = Int32.Parse(inputNewPrice.Text);
            userData data     = new userData();

            nameAnimal.Text     = data.Animals[animalNum];
            quantityMale.Text   = data.Quantity[animalNum, 0].ToString();
            quantityFemale.Text = data.Quantity[animalNum, 1].ToString();
            data.editPrice(newPrice, animalNum, "admin");
            succesEdit.Show();
        }
        protected async override void OnAppearing()
        {
            base.OnAppearing();

            user1 = await DBhelper.GetUser(UserLocalEmail.Text);

            NameData.Text       = user1.Name;
            SurnameData.Text    = user1.Surname;
            departmentData.Text = user1.Department;
            schoolData.Text     = user1.schoolName;
        }
예제 #27
0
    public static void DumpUsers()
    {
        userData newUsers = new userData();
        string   path     = Application.streamingAssetsPath + "/userData.json";

        foreach (User user in users.Values)
        {
            newUsers.Add(user);
        }
        Debug.Log(JsonUtility.ToJson(newUsers));
        File.WriteAllText(path, JsonUtility.ToJson(newUsers));
    }
예제 #28
0
        public ActionResult Create([Bind(Include = "ID,lastName,firstName,officeLocation,startDate")] userData userData)
        {
            if (ModelState.IsValid)
            {
                userData.ID = Guid.NewGuid();
                db.userData.Add(userData);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(userData));
        }
예제 #29
0
    public static void DumpUsers()                                              // dump users into the system(json file) and console
    {
        userData newUsers = new userData();                                     // new users
        string   path     = Application.streamingAssetsPath + "/UserData.json"; // path to system

        foreach (User user in users.Values)
        {
            newUsers.Add(user);                                // add user to userData
        }
        Debug.Log(JsonUtility.ToJson(newUsers));               // show system on console
        File.WriteAllText(path, JsonUtility.ToJson(newUsers)); // add users to system
    }
예제 #30
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            userData data    = new userData();
            int      _male   = Int32.Parse(quantityMale.Text);
            int      _female = Int32.Parse(quantityFemale.Text);
            int      _price  = Int32.Parse(price.Text);

            data.addNewAnimal(nameAnimal.Text, _male, _female, _price, "admin");
            wasAdded.Show();
            quantityMale.Text   = "";
            quantityFemale.Text = "";
            price.Text          = "";
        }
        public async Task saveImage(Stream str, userData user)
        {
            user1 = await dbhelp.GetUser(user.Email);

            var name = user1.Email;
            var data = storage.Child("Images")
                       .Child("ProfileImages")
                       .Child(name.ToString());

            string imageUrl = await data.PutAsync(str, new System.Threading.CancellationToken(), "image/jpeg");

            await dbhelp.UpdatePersonData(user1.Email, user1.Name, user1.schoolName, user1.Department, user1.Surname, user1.password, imageUrl);
        }
예제 #32
0
 partial void UpdateuserData(userData instance);
예제 #33
0
 partial void DeleteuserData(userData instance);
예제 #34
0
 partial void InsertuserData(userData instance);