Esempio n. 1
0
        private string login(string ip, string mac, string longitude, string latitude)
        {
            string methodName = string.Format("login({0},{1},{2},{3})", mac, ip, longitude, latitude);

            LogHelper.DebugFormat("{0}.{1}:--- start ---", className, methodName);

            double lon = 0.0;
            double lat = 0.0;

            double.TryParse(longitude, out lon);
            double.TryParse(latitude, out lat);
            int    res    = new Absen().Login(mac, ip, lon, lat);
            string result = res.ToString();

            result = Retriever.RetrieveLoginData(mac, ip);

            LogHelper.DebugFormat("{0}.{1}:--- end ---", className, methodName);
            return(result);
        }
Esempio n. 2
0
        public static string RetrieveLoginData(string mac, string ip)
        {
            string methodName = "RetrieveLoginData()";

            log.DebugFormat("------------START---{0}-{1}-({2})-----------", className, methodName, "");

            string loginData = "";
            Absen  x         = new Absen();

            try
            { using (SqlConnection conn = new SqlConnection(ConnectionString))
              {
                  using (SqlCommand cmd = new SqlCommand("getUserLoginInformation", conn))
                  {
                      cmd.CommandType = CommandType.StoredProcedure;
                      cmd.Parameters.Add("@mac", SqlDbType.VarChar).SqlValue        = mac;
                      cmd.Parameters.Add("@ip_address", SqlDbType.VarChar).SqlValue = ip;
                      conn.Open();

                      using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                      {
                          log.DebugFormat("------------DATA---{0}-{1}-({2})-----------", className, methodName, reader.HasRows.ToString());
                          while (reader.Read())
                          {
                              x.firstlogin = ((DateTime)reader["first_login"]).ToString();
                              x.lastlogin  = ((DateTime)reader["last_login"]).ToString();
                              x.isfull     = ((Int16)reader["is_full"] == 1)? true : false;
                              x.lateCount  = (int)reader["late_count"];
                              x.isLate     = ((Int16)reader["is_late"] == 1) ? true : false;
                          }
                      }
                      conn.Close();
                  }
              } }
            catch (Exception ex) { log.Error(ex); }

            loginData = new JavaScriptSerializer().Serialize(x);
            log.DebugFormat("------------END---{0}-{1}-({2})-----------", className, methodName, "");
            return(loginData);
        }