Пример #1
0
 public static void PointChecker(User1 user1, User2 user2)
 {
     if (user1.Points == 3)
     {
         Console.WriteLine("Game OVER!" + user1.Name + " WINS!");
         System.Environment.Exit(0);
     }
     else if (user2.Points == 3)
     {
         Console.WriteLine("Game OVER!" + user2.Name + " WINS!");
         System.Environment.Exit(0);
     }
 }
Пример #2
0
        public static void Do()
        {
            var usrFrom = new User {
                name = "张鹏飞", age = 28
            };
            var   data  = JsonConvert.SerializeObject(usrFrom);
            var   jObj  = JsonConvert.DeserializeObject(data) as JObject;
            User1 usrTo = new User1();

            Console.WriteLine(usrTo);
            //Map<User, User1>(usrFrom, usrTo);
            Map(typeof(User), typeof(User1), usrFrom, usrTo);
            Console.WriteLine(usrTo);
        }
Пример #3
0
        // GET: User/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            User1 user1 = db.User1.Find(id);

            if (user1 == null)
            {
                return(HttpNotFound());
            }
            return(View(user1));
        }
Пример #4
0
        public bool Update(User1 user)
        {
            var ExistingUser = db.Users.Single(u => u.ID == user.ID);

            ExistingUser.Active      = user.Active;
            ExistingUser.DateUpdated = DateTime.Now;
            ExistingUser.Email       = user.Email;
            ExistingUser.Firstname   = user.Firstname;
            ExistingUser.Password    = user.Password;
            ExistingUser.Surname     = user.Surname;
            ExistingUser.Username    = user.Username;
            Save();
            return(true);
        }
Пример #5
0
        public ActionResult Login(User1 user)
        {
            var userInDb = db.User1.FirstOrDefault(x => x.Name == user.Name && x.Password == user.Password);

            if (userInDb != null)
            {
                FormsAuthentication.SetAuthCookie(userInDb.Name, false);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewBag.Message = "Invalid User Name or Password";
                return(View());
            }
        }
Пример #6
0
 public override bool Equals(object obj)
 {
     if (obj == null)
     {
         return(false);
     }
     else if (this.GetType() != obj.GetType())
     {
         return(false);
     }
     else
     {
         return(((User1.Equals(((Chat)obj).User1)) && (User2.Equals(((Chat)obj).User2))) || ((User1.Equals(((Chat)obj).User2)) && (User2.Equals(((Chat)obj).User1))));
     }
 }
Пример #7
0
 public bool Equals(UserEventMore other)
 {
     if (Id != other.Id)
     {
         return(false);
     }
     if (User1 != other.User1 && (User1 == null || !User1.Equals(other.User1)))
     {
         return(false);
     }
     if (User2 != other.User2 && (User2 == null || !User2.Equals(other.User2)))
     {
         return(false);
     }
     return(User3 == other.User3 || (User3 != null && User3.Equals(other.User3)));
 }
Пример #8
0
        public ActionResult Index()
        {
            var mvcName = typeof(Controller).Assembly.GetName();
            var isMono  = Type.GetType("Mono.Runtime") != null;

            ViewData ["Version"] = mvcName.Version.Major + "." + mvcName.Version.Minor;
            ViewData ["Runtime"] = isMono ? "Mono" : ".NET";

            // For ActiveRecord Start
            User1 obj = User1.Find(1);

            // For ActiveRecord End

            ViewData ["Runtime"] = obj.User_id;
            return(View());
        }
        public void SetUp()
        {
            drive = new Driver();
            drive.SetUpChromeDriver();
            user             = new User1();
            accountPage      = new AccountPage();
            passwordEditPage = new PasswordEditPage();
            startPage        = new StartPage();
            loginPage        = new LoginPage();

            drive.NavigatePage(startPage.GetPageURL());
            drive.FindElementByXPath(startPage.ButtonLogin()).Click();
            drive.FindElementByIdAndInputData(loginPage.InputEmail()).SendKeys(user.Email);
            drive.FindElementByIdAndInputData(loginPage.InputPassword()).SendKeys(user.Password);
            drive.FindElementByXPath(loginPage.ButtonLogin()).Click();
        }
Пример #10
0
        public IHttpActionResult NewUser([FromBody] User1 value)
        {
            list.Add(value);
            SqlConnection connect = new SqlConnection(ConfigurationManager.ConnectionStrings["mypc"].ConnectionString);

            if (connect.State != ConnectionState.Open)
            {
                connect.Open();
            }
            SqlCommand cmds;

            cmds = new SqlCommand("insert into BonusSetting values (2,'hello world',23)", connect);
            cmds.ExecuteNonQuery();
            connect.Close();
            return(Ok(1));
        }
Пример #11
0
        public ActionResult Login(User1 user)
        {
            var usr = db.User1.Single(u => u.Email == user.Email && u.Password == user.Password);

            if (usr != null)
            {
                Session["UserId"] = usr.UserId.ToString();
                Session["Email"]  = usr.Email.ToString();
                return(RedirectToAction("Index", "Home", new { area = "Home" }));
            }
            else
            {
                ModelState.AddModelError("", "Email or password is wrong!");
            }
            return(View());
        }
 public ActionResult ChangePassword(string oldPassword, string newPassword, string confirmNewPassword)
 {
     if (Session["UserId"] != null)
     {
         int   usrId = Convert.ToInt32(Session["UserId"].ToString());
         User1 user  = db.User1.Single(usr => usr.UserId == usrId);
         if (oldPassword != user.Password && oldPassword != newPassword && newPassword == confirmNewPassword)
         {
             user.Password = newPassword;
             db.SaveChanges();
         }
     }
     else
     {
     }
     return(RedirectToAction("Settings", "Home", new { area = "Home" }));
 }
Пример #13
0
        public HttpResponseMessage GeneratePasswordResetLink([FromBody] User1 passwordToken)
        {
            _context = new CivilWorksEntities2();
            UserPasswordActivation passwordReset = null;

            try
            {
                User1 data_ = _context.User1.Where(x => x.UserName == passwordToken.UserName).FirstOrDefault <User1>();
                if (data_ == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "No record found for this user"));
                    // return new BO.ErrorObject { ErrorMessage = "No record found for this user.", errorObject = "", ErrorLevel = ErrorLevel.Error };
                }
                #region Insert link
                CivilWorksEntities2 context1 = new CivilWorksEntities2();
                userActivation.PasswordActivattionKey = Guid.NewGuid();
                userActivation.DateCreated            = System.DateTime.Now;
                userActivation.UserID     = data_.ID;
                userActivation.IsExpired  = false;
                userActivation.ExpiryDate = System.DateTime.Now.AddDays(1);
                context1.UserPasswordActivations.Add(userActivation);
                context1.SaveChanges();
                #endregion


                string Message = "Dear " + data_.FirstName + ",<br><br>You are receiving this email because you (or someone pretending to be you) requested that your password be reset on the " + Utility.GetConfigValue("Website") + " site.  If you do not wish to reset your password, please ignore this message.<br><br>To reset your password, please click the following link, or copy and paste it into your web browser:<br><br>" + Utility.GetConfigValue("ForgotPasswordLink") + "/" + userActivation.PasswordActivattionKey + " <br><br>Your username, in case you've forgotten: " + data_.UserName + "<br><br>Thanks";
                #region  company mail object
                EmailMessage emCompany = new EmailMessage();
                emCompany.ApplicationName = "Civil Works";
                emCompany.ToEmail         = passwordToken.UserName;
                emCompany.EMailSubject    = "Civil Works Reset Password Link";
                emCompany.EMailBody       = Message;
                #endregion

                MessagingHelper mh = new MessagingHelper();
                mh.SendMail(passwordToken.UserName, emCompany.EMailSubject, Message);


                User1 userDb = _context.User1.Where(p => p.UserName == passwordToken.UserName && p.IsDeleted.Value == false).FirstOrDefault <User1>();
                return(Request.CreateResponse(HttpStatusCode.OK, userDb));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Пример #14
0
        public ActionResult SysAdminRegisterSave(User1 model)       //用户注册保存
        {
            if (ModelState.IsValid)
            {
                var db = new AirDataBase();
                db.Database.CreateIfNotExists();

                var sysAdminRegister = new User1();
                sysAdminRegister.UserName     = model.UserName;
                sysAdminRegister.UserPassword = model.UserPassword;

                db.User.Add(sysAdminRegister);
                db.SaveChanges();
            }

            return(Redirect("SysIndex"));
        }
        // Delete user:
        public bool DeleteUser(int id)
        {
            var query = from o in DB.Users1
                        where o.UserID == id
                        select o;

            User1 user = query.SingleOrDefault();

            if (user == null)
            {
                return(false);
            }

            DB.Users1.Remove(user);
            DB.SaveChanges();
            return(true);
        }
Пример #16
0
        public void STRUCTURES_M()
        {
            //STRUCTURES - take less memory, but cannot contain virtual methods, inheritance, ...
            Console.WriteLine("\t\t\tSTRUCTURES");
            Book b;

            b.author = "King";
            b.title  = "Title name";
            b.name   = "Name of structure";
            b.Print();
            Console.WriteLine();
            Book[] books = new Book[2];                                      //Massive of structures
            books[0]        = new Book("First author", "Title 1", "Name 1"); //using constructor for structure
            books[1].author = "Second author";
            books[1].title  = "Title 2";
            books[1].name   = "Name 2";
            foreach (Book book in books)
            {
                book.Print();
            }
            Console.WriteLine();
            Book tom = new Book("Tom", "Tom1", "Tom2");//using constructor for structure

            tom.Print();
            User user1 = new User {
                name = "HANNA", age = 24
            };                                                 //initialization of objects

            //objects of STRUCTURE as parameter of method
            ChangeUser(user1);         //doesn't change the initial values of user1
            Console.WriteLine($"{user1.name}, {user1.age}");
            ChangeUser_ref(ref user1); ////change the initial values of user1
            Console.WriteLine($"{user1.name}, {user1.age}");

            User1 user2 = new User1 {
                name = "HANNA", age = 24
            };

            //objects of CLASS as parameter of method
            ChangeUser(user2);      //change the initial values of user2, but not via constructor in method
            Console.WriteLine($"{user2.name}, {user2.age}");
            ChangeUser1(ref user2); ////change the initial values of user2 via constructor in method
            Console.WriteLine($"{user2.name}, {user2.age}");
            Program.CheckReturnToContent();
        }
        // Add new order:
        /// <summary>
        /// Only supports addition of a buyer or a seller.
        /// </summary>
        /// <param name="userModel"></param>
        /// <returns></returns>
        public UserModel AddUser(UserModel userModel)
        {
            User1 user = new User1();

            user.FullName    = userModel.FullName;
            user.DateOfBirth = userModel.DateOfBirth;
            user.Email       = userModel.Email;
            user.Gender      = userModel.Gender;
            user.IdCard      = userModel.IdCard;
            user.Image       = userModel.Image;
            user.UserName    = userModel.UserName;
            user.Password    = userModel.Password;
            user.Role_Id     = Consts.BuyerRoleId;// userModel.RoleName.ToLower() == "Buyer".ToLower() ? Consts.BuyerRoleId : Consts.SellerRoleId;

            DB.Users1.Add(user);
            DB.SaveChanges();
            return(userModel); // Return the added user with all its fields.
        }
Пример #18
0
        public void Start()
        {
            User1 user1 = new User1()
            {
                Id = 1, Name = "Felix", Password = "******"
            };

            eventBus.Publish(new EventDescriptor("User", "Created", user1));
            eventBus.Publish(new EventDescriptor("User", "Created", user1));
            eventBus.Publish(new ModelCreatedEvent <User1>(this, user1));

            eventBus.Publish(new ConsoleStarted(this));
            while (true)
            {
                string cmd = Console.ReadLine();
                eventBus.Publish(new CommandReadEvent(this, cmd));
            }
        }
        private void ExportUserstoExcel(string stringFileName)
        {
            Excel._Application ExcelApplication;
            Excel.Workbook     ExcelWorkbook;
            Excel.Worksheet    ExcelWorksheet;
            object             objectMisValue = System.Reflection.Missing.Value;

            Excel.Range ExcelRangeCellinstance;
            ExcelApplication = new Excel.Application();
            ExcelWorkbook    = ExcelApplication.Workbooks.Add(objectMisValue);

            ExcelWorksheet = (Excel.Worksheet)ExcelWorkbook.Worksheets.get_Item(1);
            ExcelApplication.DisplayAlerts = false;
            ExcelRangeCellinstance         = ExcelWorksheet.get_Range("A1", Type.Missing);
            int intRow    = 1;
            int intColumn = 1;

            foreach (string string1 in User.StringArrayUesrProperties)
            {
                ExcelWorksheet.Cells[intRow, intColumn] = string1;
                intColumn++;
            }
            intRow++;
            foreach (User User1 in Users1)
            {
                intColumn = 1;
                foreach (string string1 in User1.Properties())
                {
                    ExcelWorksheet.Cells[intRow, intColumn] = string1;
                    intColumn++;
                }
                intRow++;
            }
            //Highlight first row
            Excel.Range ExcelRange1 = ExcelWorksheet.get_Range("A1", Type.Missing);
            ExcelRange1.EntireRow.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black);
            ExcelRange1.Interior.Color       = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightSkyBlue);
            ExcelRange1.EntireRow.Font.Size  = 14;
            ExcelRange1.EntireRow.AutoFit();
            //Save Excel
            ExcelWorkbook.SaveAs(stringFileName, Excel.XlFileFormat.xlWorkbookNormal, objectMisValue, objectMisValue, objectMisValue, objectMisValue, Excel.XlSaveAsAccessMode.xlExclusive, objectMisValue, objectMisValue, objectMisValue, objectMisValue, objectMisValue);
            ExcelWorkbook.Close();
            MessageBox.Show("Saved Successfully", "Active Directory", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Пример #20
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (LatestUpdate != 0UL)
            {
                hash ^= LatestUpdate.GetHashCode();
            }
            if (User1 != 0UL)
            {
                hash ^= User1.GetHashCode();
            }
            if (User2 != 0UL)
            {
                hash ^= User2.GetHashCode();
            }
            hash ^= messages_.GetHashCode();
            return(hash);
        }
Пример #21
0
        /// <summary>
        /// Создать нового пользователя
        /// </summary>
        /// <param name="creationInfo">Данные для создания нового пользователя</param>
        /// <param name="cancellationToken">Токен отмены операции</param>
        /// <returns>Созданный пользователь</returns>
        public User1 CreateAsync(UserCreationInfo creationInfo)
        {
            if (creationInfo == null)
            {
                throw new ArgumentNullException(nameof(creationInfo));
            }

            //cancellationToken.ThrowIfCancellationRequested();

            //if (this.loginIndex.ContainsKey(creationInfo.Login))
            //{
            //    throw new UserDuplicationException(creationInfo.Login);
            //}

            var id  = Guid.NewGuid();
            var now = DateTime.UtcNow;

            var user = new User1
            {
                Id           = id,
                Login        = creationInfo.Login,
                PasswordHash = creationInfo.PasswodHash,
                RegisteredAt = now
            };

            string CurrentDir = @"D:\univer\6 sem\tok\TokenApp\TokenApp\todoList.db";

            using (SQLiteConnection connection = new SQLiteConnection(string.Format("Data Source={0};", CurrentDir)))
            {
                connection.Open();
                using (var command2 = new SQLiteCommand("INSERT INTO 'users' ('userid', 'login', 'password', 'registeredat') VALUES ('" + user.Id.ToString() + "', '" + user.Login + "', '"
                                                        + user.PasswordHash + "', '" + user.RegisteredAt.ToString() + "');", connection))
                {
                    var a = command2.ExecuteNonQuery();
                    connection.Close();
                }
            }

            //this.primaryKeyIndex.Add(id, user);
            //this.loginIndex.Add(user.Login, user);

            return(user);
        }
Пример #22
0
    // Start is called before the first frame update
    void Awake()
    {
        multiUsers          = false;
        rightHandController = GameObject.Find("RightHand Controller");
        leftHandController  = GameObject.Find("LeftHand Controller");
        scene        = GameObject.Find("Scene");
        selectables  = GameObject.Find("Selectables");
        cameraOffset = GameObject.Find("Camera Offset");
        XRRig        = GameObject.Find("XR Rig");

        user1 = (User1)this.GetComponent(typeof(User1));
        user2 = (User2)this.GetComponent(typeof(User2));

        MeshCollider[] colliders = FindObjectsOfType <MeshCollider>();
        for (int i = 0; i < colliders.Length; i++)
        {
            GameObject.Destroy(colliders[i]);
        }
    }
Пример #23
0
        private ClaimsIdentity GetIdentity(string username, string pass /*UserRegistrationInfo userInfo*/)
        {
            if (pass == null)
            {
                throw new ArgumentNullException(nameof(pass));
            }

            User1 person = null;

            try
            {
                person = this.userRepository.Get(username);
            }
            catch (UserNotFoundException)
            {
                throw new AuthenticationException();
            }

            var currentHash = this.HashPassword(pass);

            person.Role = "admin";

            if (!person.PasswordHash.Equals(currentHash))
            {
                person = null;
            }

            if (person != null)
            {
                var claims = new List <Claim>
                {
                    new Claim(ClaimsIdentity.DefaultNameClaimType, person.Login),
                    new Claim(ClaimsIdentity.DefaultRoleClaimType, person.Role)
                };
                ClaimsIdentity claimsIdentity =
                    new ClaimsIdentity(claims, "Token", ClaimsIdentity.DefaultNameClaimType,
                                       ClaimsIdentity.DefaultRoleClaimType);
                return(claimsIdentity);
            }

            return(null);
        }
Пример #24
0
        public HttpResponseMessage Signin([FromBody] User1 user)
        {
            _context = new CivilWorksEntities2();

            string Pass = user.Password;
            //Invitation invitation = _context.Invitations.Include("Company")
            //                                          .Include("User.UserCompanies")
            //                                          .Where(p => p.UniqueID == invitationBO.UniqueID).FirstOrDefault<Invitation>();



            User1 data_ = _context.User1
                          .Where(x => x.UserName == user.UserName && x.IsDeleted.Value == false).FirstOrDefault <User1>();

            if (data_ == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "No record found for this user"));
                //  return new BO.ErrorObject { ErrorMessage = "No record found for this user.", errorObject = "", ErrorLevel = ErrorLevel.Error };
            }
            bool isPasswordCorrect = false;

            try
            {
                isPasswordCorrect = PasswordHash.ValidatePassword(user.Password, ((User1)data_).Password);

                if (!isPasswordCorrect)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid credentials"));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, data_));
                }

                // return new BO.ErrorObject { ErrorMessage = "Invalid credentials.Please check details..", errorObject = "", ErrorLevel = ErrorLevel.Error };
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid credentials"));
                //return new BO.ErrorObject { ErrorMessage = "Invalid credentials.Please check details..", errorObject = "", ErrorLevel = ErrorLevel.Error };
            }
        }
Пример #25
0
      public ActionResult insert(TaskVm t)
      {
          if (ModelState.IsValid)
          {
              List <User1> users = TaskService.users();
              User1        user  = new User1();
              foreach (var i in users)
              {
                  if (i.id == t.user)
                  {
                      user = i;
                  }
              }
              TaskService.insert(new Task {
                    name = t.name, date = t.date, user = user
                });
          }

          return(RedirectToAction("Gettasks", new { id = t.user }));
      }
Пример #26
0
 public ActionResult Register([Bind(Include = "UserId,Email,Password,FirstName,LastName")] User1 user1, string confirmPassword, string confirmEmail)
 {
     if (ModelState.IsValid && confirmPassword == user1.Password)
     {
         if (confirmEmail == user1.Email)
         {
             db.User1.Add(user1);
             db.SaveChanges();
             return(RedirectToAction("Login"));
         }
         else
         {
         }
     }
     else
     {
     }
     ViewBag.Message = user1.FirstName + " " + user1.LastName + " successfully registered";
     return(View(user1));
 }
Пример #27
0
        private static void ExecTran(bool isSuccess)
        {
            var dbContext = NPocoHelper.GetNewInstance(_connStr);
            var newUser   = new User1()
            {
                LoginCode = "test02", Name = "test02", Password = "******"
            };

            //var tran=dbContext.GetTransaction();
            dbContext.BeginTransaction();


            var result = dbContext.Insert <User1>(newUser);

            newUser.LoginCode = "test0201";
            result            = dbContext.Insert <User1>(newUser);

            if (isSuccess)
            {
                dbContext.CompleteTransaction();
            }
            else
            {
                dbContext.AbortTransaction();
            }


            var user = dbContext.FirstOrDefault <User1>("select * from User1 where LoginCode=@LoginCode", newUser);

            if (user == null)
            {
                Console.WriteLine("User 未添加成功");
            }
            else
            {
                Console.WriteLine("User 添加成功");
                //清理数据
                dbContext.Delete(user);
                dbContext.Delete <User1>("where LoginCode='test02'");
            }
        }
Пример #28
0
 public static void RockWinChecker(User1 user1, User2 user2)
 {
     if (user1.Answer == "R" && user2.Answer == "P")
     {
         Console.WriteLine(user2.Name + " won this round");
         user2.AddPoints();
         PointChecker(user1, user2);
         Program.NewRound(user1, user2);
     }
     else if (user1.Answer == "R" && user2.Answer == "S")
     {
         Console.WriteLine(user1.Name + " won this round");
         user1.AddPoints();
         PointChecker(user1, user2);
         Program.NewRound(user1, user2);
     }
     else if (user1.Answer == "R" && user2.Answer == "R")
     {
         Program.DrawRound(user1, user2);
     }
 }
Пример #29
0
    IEnumerator GetRequest(string uri)
    {
        Debug.Log("Coroutine Started");
        using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
        {
            // Request and wait for the desired page.
            yield return(webRequest.SendWebRequest());

            User1 data = JsonUtility.FromJson <User1>(webRequest.downloadHandler.text);

            print("User ID: " + data.user_ID +
                  " User Name: " + data.user_Name +
                  " User Password: "******" User Gender: " + data.user_Gender +
                  " User Seniority: " + data.user_Seniority
                  + "User House: " + data.user_House +
                  "User Login: " + data.user_Login);

            user = data;
        }
    }
Пример #30
0
        public JsonResult Edit(User1 user)
        {
            string         result     = "fail";
            UserRepository repository = new UserRepository();

            try
            {
                repository.Update(user);
                result = repository.Add(user) ? "success" : "fail";
                result = "success";
            }
            catch (Exception ex)
            {
                // to do logging
                result = "fail";
            }
            finally
            {
                repository = null;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }