Example #1
0
 public bool addDetail(LogDetail detail)
 {
     if (detail.save())
     {
         _details.Add(detail);
         return(true);
     }
     return(false);
 }
Example #2
0
        public bool logout()
        {
            if (_id < 1)
            {
                return(false);
            }
            string strSQL = "SELECT COUNT(1) FROM TblUserLog WHERE userLogID=" + _id;

            if (_conn.executeData(strSQL, Common.getCaller()))
            {
                DbDataReader dr = _conn.Reader;
                if (dr.HasRows)
                {
                    dr.Read();
                    int rowCount = dr.GetInt32(0);
                    dr.Close();
                    dr.Dispose();
                    if (rowCount < 1)
                    {
                        return(false);
                    }
                    strSQL = "SELECT sysdate FROM dual";
                    if (_conn.executeData(strSQL, Common.getCaller()))
                    {
                        dr = _conn.Reader;
                        if (dr.HasRows)
                        {
                            dr.Read();
                            _end = dr.GetDateTime(0);
                            dr.Close();
                            dr.Dispose();
                            strSQL = "UPDATE TblUserLog SET userLogEnd=" + _conn.formatDateTime(_end) +
                                     " WHERE userLogID=" + _id;
                            if (_conn.executeSQL(strSQL, Common.getCaller()))
                            {
                                LogDetail detail = new LogDetail(this);
                                detail.MenuID  = 0;
                                detail.SQLText = "Application log out.";
                                if (detail.save())
                                {
                                    _details.Add(detail);
                                    return(true);
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        dr.Close();
                        dr.Dispose();
                        return(false);
                    }
                }
                dr.Close();
                dr.Dispose();
            }
            return(false);
        }
Example #3
0
        public bool login(string username, string machineID)
        {
            if (Connection.formatValue(username) == "")
            {
                return(false);
            }
            if (Connection.formatValue(machineID) == "")
            {
                return(false);
            }
            string strSQL = "SELECT sysdate FROM dual";

            if (_conn.executeData(strSQL, Common.getCaller()))
            {
                DbDataReader dr = _conn.Reader;
                if (dr.HasRows)
                {
                    dr.Read();
                    _start = dr.GetDateTime(0);
                    dr.Close();
                    dr.Dispose();
                    strSQL = "SELECT sqcUserLogID.nextVal FROM dual";
                    if (_conn.executeData(strSQL, Common.getCaller()))
                    {
                        dr = _conn.Reader;
                        if (dr.HasRows)
                        {
                            dr.Read();
                            _id = dr.GetInt32(0);
                            dr.Close();
                            dr.Dispose();
                            strSQL = "INSERT INTO TblUserLog VALUES(" + _id + ", '" +
                                     Connection.formatValue(username) + "', '" +
                                     Connection.formatValue(machineID) + "', to_date('" +
                                     _start.ToString("yyyy/MM/ss HH:mm:ss") + "', 'yyyy/mm/dd hh24:mi:ss'), NULL)";
                            if (_conn.executeSQL(strSQL, Common.getCaller()))
                            {
                                _details.Clear();
                                LogDetail detail = new LogDetail(this);
                                detail.MenuID  = 0;
                                detail.SQLText = "Application log in";
                                if (detail.save())
                                {
                                    _details.Add(detail);
                                    return(true);
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        dr.Close();
                        dr.Dispose();
                    }
                }
                dr.Close();
                dr.Dispose();
            }
            return(false);
        }