예제 #1
0
 private void GetProcess()
 {
     wait = true;
     if (PID_arma3 == 0)
     {
         if (File.Exists(appdata + "PID.dat"))
         {
             string tmp = File.ReadAllText(appdata + "PID.dat");
             PID_arma3 = Int32.Parse(tmp);
         }
     }
     try
     {
         myProcesses = Process.GetProcesses();
         foreach (Process myProcess in myProcesses)
         {
             if (myProcess.Id == PID_arma3)
             {
                 myProcess.Kill();
             }
         }
     }
     catch
     {
     }
     if (cancreateMD5)
     {
         CreateMD5.RunWorkerAsync();
         cancreateMD5 = false;
     }
 }
예제 #2
0
        private void db_Click(object sender, RoutedEventArgs e)
        {
            string path     = @"C:\Users\Pc\Desktop\CLIENT\a.txt";
            string fileData = File.ReadAllText(path);

            FileInfo   fi = new FileInfo(path);
            myDatabase db = new myDatabase();

            db.TryCreateTable(tbMsgToSend);

            string a = fi.LastAccessTime + " " + fi.LastWriteTime;
            //string[] input = a.Split(' ');


            int      id    = 1;
            string   name  = fi.Name;
            DateTime date  = fi.LastWriteTime;
            int      bytes = int.Parse(fi.Length + "");
            string   md5   = CreateMD5.GetMD5HashData(fileData);
            string   path2 = fi.FullName;


            db.AddFile(id, name, date, bytes, md5, path2);

            tbMsgToSend.Text += "\nID : " + id + "\nNAME : " + name + "\nDATE : " + date + "\nBYTE : " + bytes + "\nMD5 : " + md5 + "\nPATH : " + path2;
        }
예제 #3
0
    public static void CreateFiles()
    {
        #region 路径要在使用的时候根据情况修改
        string filesPath = @"D:\UnityWorkFile\ARForAndroid\AssetBundlesMD5File\files.txt";
        string fenziPath = @"D:\UnityWorkFile\ARForAndroid\AssetBundles\AssetBundles";

        #endregion

        if (File.Exists(filesPath))
        {
            File.Delete(filesPath);
        }

        FileStream   fileStream   = new FileStream(filesPath, FileMode.CreateNew);
        StreamWriter streamWriter = new StreamWriter(fileStream);

        string modleMD5 = CreateMD5.CreateMD5File(fenziPath);

        streamWriter.WriteLine("AssetBundle" + "|" + modleMD5);

        streamWriter.Close();
        fileStream.Close();

        Debug.Log("MD5文件创建完毕");
    }
 public void Sign(string Account, string Password)
 {
     try
     {
         string PasswordMD5 = CreateMD5.EncryptWithMD5(Password);
         var    Signupd     = new SignUpD();
         Signupd.SignUP(Account, PasswordMD5);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void Change(string Account, string OldPassword, string NewPassword)
 {
     try
     {
         var OldMD5  = CreateMD5.EncryptWithMD5(OldPassword);
         var NewMD5  = CreateMD5.EncryptWithMD5(NewPassword); //加密
         var ChangeP = new ChangePswD();
         ChangeP.Change(Account, OldMD5, NewMD5);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void login(string Account, string Password)
 {
     try
     {
         var PasswordMD5 = CreateMD5.EncryptWithMD5(Password);  //加密
         var Get         = new GetUsers();
         var u           = Get.GetUser(Account, PasswordMD5);
         if (u == null)
         {
             throw new Exception("用户名或密码错误!");
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #7
0
        private void btn_quet_Click(object sender, EventArgs e)
        {
            VanTayDTO vantay = new VanTayDTO();

            vantay.mavanTay = CreateMD5.MD5Hash(txt_ma.Text);
            String    url = localhost + "rest/vantay/getvantaybyid";
            ResultAPI rs  = CreateProductAsync(url, vantay);

            if (rs != null)
            {
                if (Int32.Parse(rs.ketqua) >= 3)
                {
                    MessageBox.Show("Đã check thẻ quá 3 lần!");
                }
                else
                {
                    MessageBox.Show("OK!");
                }
            }

            /////
        }
예제 #8
0
        public string Login(AdminLoginModel model)
        {
            if (ModelState.IsValid)
            {
                string password = CreateMD5.Create(model.password);

                if (context.Admin.Where(i => i.Username == model.username && i.Password == password).Any())
                {
                    Session["admin"] = context.Admin.Where(i => i.Username == model.username && i.Password == password).Select(i => new SessionAdminModel()
                    {
                        Id       = i.ID,
                        Name     = i.Name,
                        Lastname = i.LastName,
                        Password = i.Password,
                        Username = i.Username
                    }).FirstOrDefault();

                    return("succeed");
                }
            }
            return("failed");
        }
예제 #9
0
        public string PasswordSettings(PasswordModel model)
        {
            string adminPassword = context.Admin.Select(i => i.Password).FirstOrDefault();
            string lastPassword  = CreateMD5.Create(model.LastPassword);

            if (ModelState.IsValid)
            {
                if (adminPassword.Equals(lastPassword) && model.NewPassword.Equals(model.ConfirmPassword))
                {
                    Admin admin = context.Admin.FirstOrDefault();
                    admin.Password = CreateMD5.Create(model.NewPassword);

                    Session["admin"] = admin;

                    context.SaveChanges();

                    return("succeed");
                }
            }

            return("failed");
        }
예제 #10
0
        public string ForgetPassword()
        {
            try
            {
                string tempPassword = new Random().Next(88888888, 99999999).ToString();

                context.Admin.FirstOrDefault().Password = CreateMD5.Create(tempPassword);
                context.SaveChanges();

                Mail mail   = new Mail();
                bool result = mail.SendNewPassword(context.Smtp.FirstOrDefault(), context.Admin.Select(i => i.Mail).FirstOrDefault(), tempPassword);

                if (result)
                {
                    return("succeed");
                }

                return("failed");
            }
            catch (Exception)
            {
                return("failed");
            }
        }
        public VMregisterInfomation Register(ViewModelRegister viewmodelRegister)
        {
            VMregisterInfomation vMregisterInfomation = null;

            try
            {
                vMregisterInfomation = new VMregisterInfomation();
                if (viewmodelRegister.Account != "")                                                                                         //判断用户账号是否为空
                {
                    var u = unitOfWork.SysUserRepository.Get().Where(s => s.UserAccount.Equals(viewmodelRegister.Account)).FirstOrDefault(); //查找是否存在账号,存在返回账号所在对象,否则返回null
                    if (u == null)                                                                                                           //判断账号是否存在
                    {
                        // 账号规范放在 UI  进行
                        #region 账号规范
                        foreach (char c in viewmodelRegister.Account)  //规范账号必须由字母和数字构成
                        {
                            if (!(('0' <= c && c <= '9') || ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')))
                            {
                                throw new Exception("账号必须只由字母和数字构成!");
                            }
                        }
                        #endregion
                        if (viewmodelRegister.Password != "")   //判断密码是否为空
                        {
                            // 密码规范放在 UI  进行
                            #region 密码规范
                            int number = 0, character = 0;
                            foreach (char c in viewmodelRegister.Password)  //规范密码必须由ASCII码33~126之间的字符构成
                            {
                                if (!(33 <= c && c <= 126))
                                {
                                    throw new Exception("符号错误,请重新输入!");
                                }
                                if ('0' <= c && c <= '9') //number记录数字个数
                                {
                                    number++;
                                }
                                else                     //character记录字符个数
                                {
                                    character++;
                                }
                            }
                            if (number < 5 || character < 2) //密码的安全系数
                            {
                                throw new Exception("密码安全系数太低!");
                            }
                            #endregion
                            if (viewmodelRegister.Password.Equals(viewmodelRegister.SurePassword)) //判断密码与确认密码是否相等 放在 UI  进行
                            {
                                if (viewmodelRegister.Answer != "1" + "2" + "3" + "4" + "5")       //判断拾回密码是否为空
                                {
                                    // 下面需要调试 看看 ,逻辑过程是否合理,另外角色根据具体场景,一般是默认缺省的角色,其他的角色在用户管理界面进行重新 赋予高级角色
                                    var sysRole = unitOfWork.SysRoleRepository.Get().Where(s => s.RoleName.Equals(viewmodelRegister.RoleName)).FirstOrDefault();   //寻找用户所选择角色在UserRole里的实例,返回对象
                                    if (sysRole != null)
                                    {
                                        var CurrentUser = new SysUser();
                                        CurrentUser.UserAccount      = viewmodelRegister.Account;
                                        CurrentUser.UserPassword     = CreateMD5.EncryptWithMD5(viewmodelRegister.Password);
                                        CurrentUser.UserAnswer       = CreateMD5.EncryptWithMD5(viewmodelRegister.Answer);
                                        CurrentUser.RememberPassword = "******";
                                        unitOfWork.SysUserRepository.Insert(CurrentUser);   //增加新SysUser
                                        unitOfWork.Save();

                                        var CurrentUserRole = new SysUserRole();
                                        CurrentUserRole.SysUserID = CurrentUser.ID;
                                        CurrentUserRole.SysRoleID = sysRole.ID;
                                        unitOfWork.SysUserRoleRepository.Insert(CurrentUserRole); //增加新SysUserRole
                                        unitOfWork.Save();                                        //对更改进行保存
                                        vMregisterInfomation.message = "注册成功";
                                        return(vMregisterInfomation);
                                    }
                                }
                                else
                                {
                                    throw new Exception("密码拾回问题答案不能为空!");
                                }
                            }
                            else
                            {
                                throw new Exception("两次输入的密码不一致!");//2次密码不一致放在 UI 进行判断
                            }
                        }
                        else
                        {
                            throw new Exception("密码不能为空!");
                        }
                    }
                    else
                    {
                        throw new Exception("用户名已存在!");
                    }
                }
                else
                {
                    throw new Exception("账号不能为空!");
                }
            }
            catch (Exception ex)
            {
                vMregisterInfomation.message = ex.Message;
                return(vMregisterInfomation);
            }

            return(vMregisterInfomation);
        }
예제 #12
0
 private void Start_Buttons_Click(object sender, EventArgs e)
 {
     CreateMD5.RunWorkerAsync();
 }