Esempio n. 1
0
        public void DeActive(Mahasiswa mhsw)
        {
            try
            {
                //--------------------------- Menonaktifkan Status User --------------------------------------
                string URI          = "http://127.0.0.1:8000/api/status/deactivate/" + mhsw.nim;
                string myParameters = "";

                using (WebClient wc = new WebClient())
                {
                    wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                    string HtmlResult = wc.UploadString(URI, "PUT", myParameters);
                }
                //------------------------- End Menonaktifkan Status User ------------------------------------
            }
            catch (WebException w)
            {
                Console.WriteLine(w.Message);
                MessageBox.Show("Terjadi kesalahan pada jaringan, silahkan coba lagi !!", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                this.kegiatan.Focus();
                return;
            }
        }
Esempio n. 2
0
 public Logout(Mahasiswa mhsw)
 {
     InitializeComponent();
     mhs = mhsw;
     Console.WriteLine("Jam Masuk nyaa-> " + mhs.waktu_masuk);
 }
Esempio n. 3
0
        // Proses login, ketika tombol Login di click
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            MainWindow home     = new MainWindow();
            string     NIM      = NIMText.Text;
            string     TglLahir = TglLahirText.Text;

            // Validasi Input
            if (NIM.Equals(""))
            {
                MessageBox.Show("NIM tidak boleh kosong!", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                this.NIMText.Focus();
                return;
            }
            if (TglLahir.Equals(""))
            {
                MessageBox.Show("Tanggal lahir tidak boleh kosong!", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                this.TglLahirText.Focus();
                return;
            }

            // Force login untuk keluar aplikasi
            if (NIM.ToLower().Equals("teknisi"))
            {
                if (TglLahir.ToLower().Equals("jtkpolban"))
                {
                    MessageBox.Show("FORCE LOGIN DETECTED, EXITING PROGRAM...", "SUCCESS", MessageBoxButton.OK, MessageBoxImage.Information);
                    //tools.preventKill(0);
                    System.Environment.Exit(0);
                }
            }

            // Cek user data
            WebRequest req = WebRequest.Create("http://127.0.0.1:8000/api/mahasiswa/" + NIM);

            req.ContentType = "application/json; charset=utf-8";
            string jsonText = null;

            try
            {
                var response = (HttpWebResponse)req.GetResponse();
                using (var sr = new StreamReader(response.GetResponseStream()))
                {
                    jsonText = sr.ReadToEnd();
                }
            }catch (WebException w)
            {
                Console.WriteLine(w.Message);
                MessageBox.Show("Terjadi kesalahan pada jaringan, silakan coba lagi!", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                this.NIMText.Focus();
                return;
            }

            // Retrieve data mahasiswa
            Mahasiswa mhs = JsonConvert.DeserializeObject <Mahasiswa>(jsonText);

            if (mhs.code.Equals(200))
            {
                try
                {
                    DateTime dt = DateTime.ParseExact(mhs.tanggal_lahir, "yyyy-MM-dd",
                                                      CultureInfo.InvariantCulture);
                    mhs.tanggal_lahir = dt.ToString("ddMMyyyy");
                }
                catch (FormatException fe)
                {
                    Console.WriteLine(fe);
                }

                // Check user login validity
                if (mhs.nim != null && mhs.tanggal_lahir == TglLahir)
                {
                    tools.readxml(mhs);
                    Console.WriteLine("Running on PC : " + mhs.no_pc);

                    //---------------------------Penambahan User Active 1--------------------------------------
                    //string URI = "http://encode.jtk.polban.ac.id/elib/api/login/aktif.php";
                    //string myParameters = "npa="+ user.User_npa + "&active=1";
                    string URI          = "http://127.0.0.1:8000/api/status/activate/" + mhs.nim;
                    string myParameters = "nomor_pc=" + mhs.no_pc;

                    using (WebClient wc = new WebClient())
                    {
                        wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                        string HtmlResult = wc.UploadString(URI, "PUT", myParameters);
                    }
                    //-------------------------End Penambahan User Active 1--------------------------------------

                    Login login = new Login(mhs);
                    login.Show();
                    //tools.preventKill(0);

                    Close();
                }
                else
                {
                    MessageBox.Show("NIM atau tanggal lahir salah !", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                    this.NIMText.Focus();
                }
            }
            else
            {
                MessageBox.Show("NIM atau tanggal lahir salah !", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                this.NIMText.Focus();
            }
        }