Ejemplo n.º 1
0
        /// <summary>
        /// 获取数据变更痕迹数据
        /// </summary>
        /// <param name="info">变更痕迹</param>
        /// <returns>变更痕迹</returns>
        public DataMark GetInfo(DataMark info, ref DataTable columnDt)
        {
            StringBuilder        sqlBuilder = new StringBuilder();
            List <DataParameter> parameters = new List <DataParameter>();

            try
            {
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    sqlBuilder.Append("SELECT T1.MARKID,T1.OPERATETIME,T2.USERDES AS OPERATEUSER,T1.OPERATETYPE,T1.DATAKIND,T3.COMMENTS AS DATAKINDDES,T1.OriginalData,T1.ChangedData ");
                    sqlBuilder.Append("FROM T_BD_DATAMARK T1 ");
                    sqlBuilder.Append("left JOIN T_QM_USERINFO T2 ON t1.OPERATEUSER=T2.USERID ");
                    sqlBuilder.Append("left JOIN ALL_TAB_COMMENTS T3 ON T3.OWNER='PLP' AND T1.DATAKIND=T3.TABLE_NAME ");
                    sqlBuilder.Append("WHERE T1.MARKID=:MARKID");
                    //获取变更痕迹信息
                    info = session.Get <DataMark>(sqlBuilder.ToString(), new DataParameter("MARKID", info.MARKID));

                    //获取字段描述信息
                    if (columnDt != null)
                    {
                        sqlBuilder.Clear();
                        sqlBuilder.Append("SELECT T1.COLUMN_NAME AS COLUMNNAME, T1.COMMENTS AS COLUMNDES ");
                        sqlBuilder.Append("FROM USER_COL_COMMENTS T1, ALL_TAB_COMMENTS T2 ");
                        sqlBuilder.Append("WHERE T1.TABLE_NAME = T2.TABLE_NAME  AND T1.TABLE_NAME = :TABLENAME");
                        parameters.Add(new DataParameter("TABLENAME", info.DATAKIND));

                        session.FillTable(columnDt, sqlBuilder.ToString(), parameters.ToArray());
                    }
                }

                return(info);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取用户和密码是否正确
        /// </summary>
        /// <param name="user">条件</param>
        /// <returns>用户信息</returns>
        public LoginInfo IsLogin(LoginInfo login)
        {
            StringBuilder        sqlBuilder = new StringBuilder();
            DataTable            powerDt    = new DataTable();
            List <DataParameter> parameters = new List <DataParameter>();

            try
            {
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    //获取用户信息
                    sqlBuilder.Append(" SELECT * ");
                    sqlBuilder.Append(" FROM T_USER AS A WHERE LoginUserID = @LoginUserID AND PASSWORD = @PASSWORD  ");

                    if (login.LoginUserID != "admin")
                    {
                        sqlBuilder.Append("  AND ISSTOP='0' ");
                    }
                    parameters.Add(new DataParameter {
                        ParameterName = "LoginUserID", DataType = DbType.String, Value = login.LoginUserID
                    });
                    parameters.Add(new DataParameter {
                        ParameterName = "PASSWORD", DataType = DbType.String, Value = login.PassWord
                    });

                    login = session.Get <LoginInfo>(sqlBuilder.ToString(), parameters.ToArray());

                    if (login != null)
                    {
                        //获取用户权限
                        sqlBuilder.Clear();
                        sqlBuilder.Append(@"
                                SELECT T1.AUTHORITYID FROM T_ROLEAUTHORITY T1
                                INNER JOIN T_USERROLE T2 ON T1.ROLEID = T2.ROLEID
                                WHERE T2.USERID = @USERID
                                UNION
                                SELECT AUTHORITYID FROM T_USERAUTHORITY
                                WHERE USERID = @USERID");

                        parameters.Clear();
                        parameters.Add(new DataParameter("USERID", login.UserID));

                        session.FillTable(powerDt, sqlBuilder.ToString(), parameters.ToArray());

                        login.Powers = new List <string>();
                        foreach (DataRow row in powerDt.Rows)
                        {
                            login.Powers.Add(row["AUTHORITYID"].ToString());
                        }

                        //获取用户所属的组织机构
                        sqlBuilder.Clear();
                        sqlBuilder.Append(" SELECT * ");
                        sqlBuilder.Append(" FROM T_USERORGAIZATION AS A WHERE USERID = @USERID");

                        parameters.Clear();
                        parameters.Add(new DataParameter {
                            ParameterName = "USERID", DataType = DbType.String, Value = login.UserID
                        });
                    }
                }
                return(login);
            }
            catch (Exception ex)
            {
                throw;
            }
        }