public JsonResult RequestSession(string sessionID, string secretKey)
        {
            var viewModel = new IndexViewModel()
            {
                SessionID = sessionID, SecretKey = secretKey, UserID = "userid", Pin = "1234"
            };

            viewModel.Hash     = HashMD5.GetMd5Hash(viewModel.Pin + viewModel.SecretKey);
            Session["Request"] = viewModel;
            return(Json(viewModel));
        }
        public string Get(string userid, string sessionid, string hash)
        {
            var pin         = "1234";
            var pinAndKey   = ReadFromFile();
            var currentHash = HashMD5.GetMd5Hash(pinAndKey);

            if (hash == currentHash)
            {
                var newkey = Guid.NewGuid().ToString();

                var newpinAndKey = pin + newkey;
                WriteToFile(newpinAndKey);
                return(newkey);
            }
            return(string.Empty);
        }
Example #3
0
        // Сохранение карточки сотрудника

        private async void bntSaveCard_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Шифрование пароля

                if (pbNewPassword.Password != "")
                {
                    using (MD5 md5Hash = MD5.Create())
                    {
                        Staff staff = (_isNewRecord) ? _newStaff : DataContext as Staff;
                        staff.Password = HashMD5.GetMd5Hash(md5Hash, pbNewPassword.Password);
                    }
                }

                // Добавление нового сотрудника

                if (_isNewRecord)
                {
                    _ID_Row = _databasenEtities.Staff.Add(_newStaff).ID;
                }

                // Добавление нового телефона

                for (int i = 0; i < _phoneList.Count; i++)
                {
                    if (_phoneList[i].ID_Staff == 0)
                    {
                        _phoneList[i].ID_Staff = _ID_Row;
                        _databasenEtities.PhoneStaff.Add(_phoneList[i]);
                    }
                }

                // Добавление нового Email

                for (int i = 0; i < _emailList.Count; i++)
                {
                    if (_emailList[i].ID_Staff == 0)
                    {
                        _emailList[i].ID_Staff = _ID_Row;
                        _databasenEtities.EmailStaff.Add(_emailList[i]);
                    }
                }

                // Удаление телефонов и email

                _databasenEtities.PhoneStaff.RemoveRange(_delPhoneList);
                _databasenEtities.EmailStaff.RemoveRange(_delEmailList);

                int resultDB = await _databasenEtities.SaveChangesAsync();

                MessageService.MetroMessageDialogResult(resultDB);

                if (_isNewRecord && resultDB > -1)
                {
                    cbCountry.SelectedIndex = -1;

                    _newStaff   = new Staff();
                    DataContext = _newStaff;

                    dgPhone.ItemsSource = dgEmail.ItemsSource = null;
                    _ID_Row             = 0;
                }

                pbNewPassword.Password = "";
            }
            catch (Exception ex)
            {
                MessageService.MetroMessageDialogError(ex.Message);
            }
        }