Example #1
0
        public string userId()
        {
            GxConnection gxconn = _ds.Connection as GxConnection;

            if (gxconn != null && !String.IsNullOrEmpty(gxconn.InternalUserId))
            {
                return(gxconn.InternalUserId);
            }
            else
            {
                GXLogging.Debug(log, "UserId method");
                string stmt = ((GxDataRecord)_ds.Db).GetServerUserIdStmt();
                if (string.IsNullOrEmpty(stmt))
                {
                    return(string.Empty);
                }
                else
                {
                    GxCommand cmd = new GxCommand(_ds.Db, stmt, _ds, 0, false, true, _errorHandler);
                    cmd.ErrorMask = GxErrorMask.GX_NOMASK | GxErrorMask.GX_MASKLOOPLOCK;
                    IDataReader reader;
                    cmd.FetchData(out reader);
                    string s = string.Empty;
                    if (reader != null)
                    {
                        s = reader.GetString(0);
                        reader.Close();
                    }
                    return(s);
                }
            }
        }
Example #2
0
        public DateTime serverNowIn(bool hasMilliseconds)
        {
            string stmt = "";

            if (hasMilliseconds)
            {
                stmt = ((GxDataRecord)_ds.Db).GetServerDateTimeStmtMs(_ds.Connection);
            }
            else
            {
                stmt = ((GxDataRecord)_ds.Db).GetServerDateTimeStmt(_ds.Connection);
            }

            if (string.IsNullOrEmpty(stmt))
            {
                if (hasMilliseconds)
                {
                    return(DateTimeUtil.ResetMicroseconds(DateTime.Now));
                }
                else
                {
                    return(DateTimeUtil.ResetMilliseconds(DateTime.Now));
                }
            }
            else
            {
                GxCommand cmd = new GxCommand(_ds.Db, stmt, _ds, 0, false, true, _errorHandler);
                cmd.ErrorMask = GxErrorMask.GX_NOMASK | GxErrorMask.GX_MASKLOOPLOCK;
                IDataReader reader;
                cmd.FetchData(out reader);
                DateTime d = DateTimeUtil.NullDate();
                if (reader != null)
                {
                    d = reader.GetDateTime(0);
                    if (hasMilliseconds)
                    {
                        d = DateTimeUtil.ResetMicroseconds(d);
                    }
                    else
                    {
                        d = DateTimeUtil.ResetMilliseconds(d);
                    }
                    reader.Close();
                }
                return(d);
            }
        }