private void btn_submit_Click(object sender, RoutedEventArgs e)
        {
            Authentication.Authentication auth   = new Authentication.Authentication();
            GamePlay.GameRounds           rounds = new GamePlay.GameRounds();
            auth.UserName    = txt_Username.Text.Trim();
            auth.Password    = txt_oldPswd.Password.ToString().Trim();
            auth.NewPassword = txt_newPswd.Password.ToString().Trim();

            string stus = auth.ChangePassword();

            if (stus == string.Empty)
            {
                var res = MessageBox.Show(stus, "Error Information", MessageBoxButton.OK, MessageBoxImage.Error);
                auth.error_flag = string.Empty;
                if (res.ToString() == "OK")
                {
                    txt_Username.Text    = string.Empty;
                    txt_oldPswd.Password = string.Empty;
                    txt_newPswd.Password = string.Empty;
                    this.Show();
                }
            }
            else
            {
                MessageBox.Show(stus, "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                this.Close();
            }
        }
예제 #2
0
        private void btn_login_Click(object sender, RoutedEventArgs e)
        {
            Authentication.Authentication auth   = new Authentication.Authentication();
            GamePlay.GameRounds           rounds = new GamePlay.GameRounds();
            auth.UserName = txt_Username.Text.Trim();
            auth.Password = txt_Pswd.Password.ToString().Trim();
            string flag = auth.validate_login();

            if (flag == string.Empty)
            {
                rounds.NextRound(2, auth.UserName);
                Screens.Game game = new Screens.Game(auth.UserName);
                game.Show();
            }
            else
            {
                var res = MessageBox.Show(flag, "Error Information", MessageBoxButton.OK, MessageBoxImage.Error);
                auth.error_flag = string.Empty;
                if (res.ToString() == "OK")
                {
                    txt_Username.Text = string.Empty;
                    txt_Pswd.Password = string.Empty;
                    this.Show();
                }
            }
        }
예제 #3
0
        private void btn_reg_Click(object sender, RoutedEventArgs e)
        {
            string email_extension = lblat.Content + cmb_Email_Ext.SelectedItem.ToString();


            Authentication.Authentication auth = new Authentication.Authentication();

            auth.FName     = txt_Fname.Text.ToString();
            auth.LName     = txt_Lname.Text.ToString();
            auth.Email     = txt_email.Text.ToString();
            auth.Email_Ext = email_extension;
            auth.Password  = txt_pass.Password.ToString();
            auth.UserName  = txt_Uname.Text.ToString();

            string flag = auth.Sumbit();

            if (flag == string.Empty)
            {
                var res = MessageBox.Show("Thank you for registration", "Congratulations", MessageBoxButton.OK, MessageBoxImage.Information);
                if (res.ToString() == "OK")
                {
                    this.Close();
                    MainWindow main = new MainWindow();
                    main.Show();
                }
            }
            else
            {
                MessageBox.Show(flag, "Error Information", MessageBoxButton.OK, MessageBoxImage.Error);
                auth.error_flag = string.Empty;
            }
        }
예제 #4
0
        /// <summary>
        /// 增加自定义认证
        /// </summary>
        /// <param name="authentication"></param>
        public static void AddAuthenticationToFirst(Authentication.Authentication authentication)
        {
            List <Authentication.Authentication> au = new List <Authentication.Authentication>();

            au.Add(authentication);
            au.AddRange(AuthenticationPipeline);
            AuthenticationPipeline = au;
        }
예제 #5
0
        private void exit_Click(object sender, RoutedEventArgs e)
        {
            Authentication.Authentication auth = new Authentication.Authentication();
            bool flag = auth.exit();

            if (flag == true)
            {
                MainWindow main = new MainWindow();
                this.Close();
                main.Show();
            }
            //this.Close();
        }
예제 #6
0
        private void btn_logout_Click(object sender, RoutedEventArgs e)
        {
            Authentication.Authentication auth = new Authentication.Authentication();
            auth.UserName = cmb_user.SelectedItem.ToString();
            auth.Password = txt_Pswd.Password.ToString();
            string stus = auth.logout();

            if (stus == string.Empty)
            {
                this.Close();
            }
            else
            {
                MessageBox.Show(stus, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #7
0
        public static void Speak(string text)
        {
            Console.WriteLine("Starting Authtentication");
            AccessTokenInfo token;

            // Note: Sign up at http://www.projectoxford.ai to get a subscription key.  Search for Speech APIs from Azure Marketplace.  Use the subscription key as Client secret below.
            Authentication.Authentication auth = new Authentication.Authentication("recog-hack-luigi", "2147d5958bdf498fb41026f202486331");

            try
            {
                token = auth.GetAccessToken();
                Console.WriteLine("Token: {0}\n", token.access_token);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed authentication.");
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.Message);
                return;
            }

            Console.WriteLine("Starting TTSSample request code execution.");

            string requestUri = "https://speech.platform.bing.com/synthesize";

            var cortana = new Synthesize(new Synthesize.InputOptions()
            {
                RequestUri = new Uri(requestUri),
                // Text to be spoken.
                Text      = text,
                VoiceType = Gender.Male,
                // Refer to the documentation for complete list of supported locales.
                Locale = "it-IT",
                // You can also customize the output voice. Refer to the documentation to view the different
                // voices that the TTS service can output.
                VoiceName = "Microsoft Server Speech Text to Speech Voice (it-IT, Cosimo, Apollo)",
                // Service can return audio in different output format.
                OutputFormat       = AudioOutputFormat.Riff16Khz16BitMonoPcm,
                AuthorizationToken = "Bearer " + token.access_token,
            });

            cortana.OnAudioAvailable += PlayAudio;
            cortana.OnError          += ErrorHandler;
            cortana.Speak(CancellationToken.None).Wait();
        }
예제 #8
0
        public Services SetupRequest()
        {
            if (!string.IsNullOrEmpty(Token) && DateTime.Now <= ExpirationDate)
            {
                return(this);
            }

            var auth     = new Authentication.Authentication(Url, User, Password, ProxyPort, Proxy);
            var response = auth.GetToken();

            if (response.status != ResponseType.success.ToString())
            {
                return(this);
            }

            Token           = response.data.token;
            _expirationDate = DateTime.Now.AddHours(_timeSession);
            return(this);
        }
예제 #9
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string token = "";

            Authentication.Authentication Authentication = new Authentication.Authentication();
            XmlNode xmlToken = Authentication.Login01(this.txtUserName.Text, this.txtPassword.Text);

            if (xmlToken.Name == "error")
            {
                this.lblMsg.Text = "Usuário ou senha inválidos";
            }
            else
            {
                this.lblMsg.Text = "";

                token = xmlToken.SelectSingleNode("returns").InnerText;
                //Response.Write("Usuário autenticado com token " + token);
                Response.Redirect("Home.aspx?tk=" + token);
            }
        }
 public TokenController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager)
 {
     _auth        = new Authentication.Authentication(userManager, signInManager);
     _userManager = userManager;
 }
예제 #11
0
        public static string Interupt(string wavFileLocation)
        {
            var uriEndpoint = @"https://speech.platform.bing.com/recognize";

            //var binDirectoryPath = Server.MapPath("~/bin");
            //var wavFileLocation = string.Format(@"{0}\Assets\AudioFile.wav", binDirectoryPath);

            AccessTokenInfo token;
            string          headerValue;
            CogResponse     result;

            // Note: Sign up at http://www.projectoxford.ai to get a subscription key.  Search for Speech APIs from Azure Marketplace.
            // Use the subscription key as Client secret below.
            Authentication.Authentication auth = new Authentication.Authentication("recog-hack-luigi", "2147d5958bdf498fb41026f202486331");

            //string requestUri = args[0].Trim(new char[] { '/', '?' });
            string requestUri = uriEndpoint.Trim(new char[] { '/', '?' });

            /* URI Params. Refer to the README file for more information. */
            requestUri += @"?scenarios=smd";                                  // websearch is the other main option.
            requestUri += @"&appid=D4D52672-91D7-4C74-8AD8-42B1D98141A5";     // You must use this ID.
            requestUri += @"&locale=en-US";                                   // We support several other languages.  Refer to README file.
            requestUri += @"&device.os=wp7";
            requestUri += @"&version=3.0";
            requestUri += @"&format=json";
            requestUri += @"&instanceid=565D69FF-E928-4B7E-87DA-9A750B96D9E3";
            requestUri += @"&requestid=" + Guid.NewGuid().ToString();

            string host        = @"speech.platform.bing.com";
            string contentType = @"audio/wav; codec=""audio/pcm""; samplerate=16000";

            /*
             * Input your own audio file or use read from a microphone stream directly.
             */
            string     audioFile = wavFileLocation;
            string     responseString;
            FileStream fs = null;

            try
            {
                token = auth.GetAccessToken();
                Console.WriteLine("Token: {0}\n", token.access_token);

                /*
                 * Create a header with the access_token property of the returned token
                 */
                headerValue = "Bearer " + token.access_token;

                Console.WriteLine("Request Uri: " + requestUri + Environment.NewLine);

                HttpWebRequest request = null;
                request                          = (HttpWebRequest)HttpWebRequest.Create(requestUri);
                request.SendChunked              = true;
                request.Accept                   = @"application/json;text/xml";
                request.Method                   = "POST";
                request.ProtocolVersion          = HttpVersion.Version11;
                request.Host                     = host;
                request.ContentType              = contentType;
                request.Headers["Authorization"] = headerValue;

                using (fs = new FileStream(audioFile, FileMode.Open, FileAccess.Read))
                {
                    /*
                     * Open a request stream and write 1024 byte chunks in the stream one at a time.
                     */
                    byte[] buffer    = null;
                    int    bytesRead = 0;
                    using (Stream requestStream = request.GetRequestStream())
                    {
                        /*
                         * Read 1024 raw bytes from the input audio file.
                         */
                        buffer = new Byte[checked ((uint)Math.Min(1024, (int)fs.Length))];
                        while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0)
                        {
                            requestStream.Write(buffer, 0, bytesRead);
                        }

                        // Flush
                        requestStream.Flush();
                    }

                    Console.WriteLine("Response:");
                    using (WebResponse response = request.GetResponse())
                    {
                        Console.WriteLine(((HttpWebResponse)response).StatusCode);

                        using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                        {
                            return(sr.ReadToEnd());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.Message);
            }
            return(null);
        }
 public StartUpViewModel()
 {
     LogInOut       = "Log in";
     LoggedUser     = Authentication.Authentication.Instance;
     LoggedUserName = LoggedUser.Username;
 }
예제 #13
0
 /// <summary>
 /// 增加自定义认证
 /// </summary>
 /// <param name="authentication"></param>
 public static void AddAuthentication(Authentication.Authentication authentication)
 {
     AuthenticationPipeline.Add(authentication);
 }