Example #1
0
    public string GetTopFunctionList()
    {
        string           sql             = "SELECT * FROM dbo.FunctionList WHERE parentId IS NULL ORDER BY orderFlag";
        IList <Function> TopFunctionList = new List <Function>();

        using (DataTable table = SqlHelper.ExecuteDataset(CommonInfo.ConQJVRMS, CommandType.Text, sql).Tables[0])
        {
            foreach (DataRow row in table.Rows)
            {
                Function f = new Function();
                f.Description  = row["Description"].ToString();
                f.FunctionName = row["FunctionName"].ToString();
                f.UrlPath      = row["UrlPath"].ToString();
                f.FunctionID   = new Guid(row["FunctionId"].ToString());
                f.OrderFlag    = int.Parse(row["orderFlag"].ToString());

                if (row["parentid"] == DBNull.Value)
                {
                    f.ParentFunctionId = null;
                }
                else
                {
                    f.ParentFunctionId = new Guid(row["parentId"].ToString());
                }

                TopFunctionList.Add(f);
            }
        }
        SerializeObjectFactory sof = new SerializeObjectFactory();

        return(sof.SerializeToBase64(TopFunctionList));
    }
Example #2
0
    public string AuthUserByAD(string domain, string loginfullName, string loginId, string password)
    {
        IADsUser adUser = null;

        try
        {
            adUser = ADHelper.AuthenticateUser(domain, loginfullName, loginId, password);

            User user = new User();
            user.UserId     = new Guid(adUser.GUID);
            user.GroupId    = Guid.NewGuid();
            user.UserName   = adUser.FullName;
            user.GroupName  = string.Empty;
            user.IsDownLoad = string.Empty;
            //   returnObj = user;

            SerializeObjectFactory sof = new SerializeObjectFactory();
            return(sof.SerializeToBase64(user));
        }
        catch (Exception ex)
        {
            LogWriter.WriteExceptionLog(ex);
            return(string.Empty);
        }
    }
Example #3
0
    public string GetFunctionList()
    {
        List <Function> FunctionListAll = new List <Function>();

        using (DataTable table = SqlHelper.ExecuteDataset(CommonInfo.ConQJVRMS, CommandType.StoredProcedure, "Function_GetFunction").Tables[0])
        {
            foreach (DataRow row in table.Rows)
            {
                Function f = new Function();
                f.Description  = row["Description"].ToString();
                f.FunctionName = row["FunctionName"].ToString();
                f.UrlPath      = row["UrlPath"].ToString();
                f.FunctionID   = new Guid(row["FunctionId"].ToString());
                f.OrderFlag    = int.Parse(row["orderFlag"].ToString());

                if (row["parentid"] == DBNull.Value)
                {
                    f.ParentFunctionId = null;
                }
                else
                {
                    f.ParentFunctionId = new Guid(row["parentId"].ToString());
                }

                FunctionListAll.Add(f);
            }
        }
        SerializeObjectFactory sof = new SerializeObjectFactory();

        return(sof.SerializeToBase64(FunctionListAll));
    }
Example #4
0
    public string AuthUserByForm(string loginName, string password, string IPAddress)
    {
        string encryptPassword = Encryption.Encrypt(password);

        SqlParameter[] Parameters = new SqlParameter[4];
        Parameters[0] = new SqlParameter("@loginName", SqlDbType.NVarChar);
        Parameters[1] = new SqlParameter("@password", SqlDbType.VarChar, 50);
        Parameters[2] = new SqlParameter("@IPAddress", SqlDbType.NVarChar, 15);
        Parameters[3] = new SqlParameter("@IsValidated", SqlDbType.Bit);

        Parameters[0].Value     = loginName;
        Parameters[1].Value     = encryptPassword;
        Parameters[2].Value     = IPAddress;
        Parameters[3].Direction = ParameterDirection.Output;

        try
        {
            using (DataTable resTable = SqlHelper.ExecuteDataset(CommonInfo.ConQJVRMS, CommandType.StoredProcedure, "dbo.Users_ValidateUserAndGetUser", Parameters).Tables[0])
            {
                if (resTable.Rows.Count != 0)
                {
                    if (!bool.Parse(Parameters[3].Value.ToString()))
                    {
                        return(null);
                    }
                    DataRow reader = resTable.Rows[0];
                    User    user   = new User();
                    user.UserId     = new Guid(reader["UserId"].ToString());
                    user.GroupId    = new Guid(reader["Groupid"].ToString());
                    user.UserName   = reader["UserName"].ToString();
                    user.GroupName  = reader["GroupName"].ToString();
                    user.IsDownLoad = reader["IsDownLoad"].ToString();
                    //  returnObj = user;


                    SerializeObjectFactory sof = new SerializeObjectFactory();
                    return(sof.SerializeToBase64(user));
                    // return true;
                }
                else
                {
                    return(null);
                }
            }
        }
        catch (Exception ex)
        {
            LogWriter.WriteExceptionLog(ex);
            return(null);
        }
    }
Example #5
0
    public string AuthClientUser(string loginName, string password)
    {
        string encryptPassword = Encryption.Encrypt(password);

        string sql = "select UserId,UserName from Users"
                     + " where loginName=@loginName and password = @password and IsLocked=0";

        SqlParameter[] Parameters = new SqlParameter[2];

        Parameters[0] = new SqlParameter("@loginName", SqlDbType.NVarChar);
        Parameters[1] = new SqlParameter("@password", SqlDbType.VarChar, 50);

        Parameters[0].Value = loginName;
        Parameters[1].Value = encryptPassword;

        try
        {
            using (DataTable resTable = SqlHelper.ExecuteDataset(CommonInfo.ConQJVRMS, CommandType.Text, sql, Parameters).Tables[0])
            {
                if (resTable.Rows.Count != 0)
                {
                    DataRow reader = resTable.Rows[0];
                    User    user   = new User();
                    user.UserId = new Guid(reader["UserId"].ToString());

                    user.UserName = reader["UserName"].ToString();

                    SerializeObjectFactory sof = new SerializeObjectFactory();

                    Quanjing.Security.FTPInfo ftp = new Quanjing.Security.FTPInfo(CommonInfo.FtpAddress, CommonInfo.FtpUser, CommonInfo.FtpPwd, "");

                    ftp.SetUserId(user.UserId);
                    return(sof.SerializeToBase64(ftp));
                    // return true;
                }
                else
                {
                    return(null);
                }
            }
        }
        catch (Exception ex)
        {
            LogWriter.WriteExceptionLog(ex);
            return(null);
        }
    }
Example #6
0
    public string CheckUsers(string domainName, string OU, string adminId, string adminPwd, string listUserStr)
    {
        List <User> userList = new List <User>();

        SerializeObjectFactory sof = new SerializeObjectFactory();

        try
        {
            List <string> userIdList = (List <string>)sof.DesializeFromBase64(listUserStr);
            ADHelper.SearchUser(domainName, OU, adminId, adminPwd, userIdList, userList);
            return(sof.SerializeToBase64(userList));
        }
        catch (Exception ex)
        {
            LogWriter.WriteExceptionLog(ex);
            return(string.Empty);
        }
    }
Example #7
0
    public string CheckRules(string rulesStr)
    {
        SerializeObjectFactory sof      = new SerializeObjectFactory();
        StringBuilder          sqlQuery = new StringBuilder();
        List <ObjectRule>      rules    = null;

        try
        {
            rules = (List <ObjectRule>)sof.DesializeFromBase64(rulesStr);
            string sql = "CREATE TABLE #RuleList(ruleId uniqueidentifier);";

            sqlQuery.Append(sql);


            foreach (IRule rule in rules)
            {
                sqlQuery.Append(rule.GetSqlQuery());
            }

            sql = "select * from #RuleList";

            sqlQuery.Append(sql);

            using (DataTable dt = SqlHelper.ExecuteDataset(CommonInfo.ConQJVRMS, CommandType.Text, sqlQuery.ToString()).Tables[0])
            {
                foreach (IRule rule in rules)
                {
                    DataRow[] rows = dt.Select("ruleId='" + rule.RuleId.ToString() + "'");
                    if (rows.Length > 0)
                    {
                        rule.IsValidate = true;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            QJVRMS.Common.LogWriter.WriteExceptionLog(ex);
            return(null);
        }


        return(sof.SerializeToBase64(rules));
    }
Example #8
0
    public string GetUserById(Guid userId)
    {
        //string sql = "select * from Users where loginName=@loginName and IsLocked=0";
        SqlParameter[] Parameters = new SqlParameter[1];
        Parameters[0]       = new SqlParameter("@userId", SqlDbType.UniqueIdentifier);
        Parameters[0].Value = userId;

        QJVRMS.Business.User user = null;
        Guid     groupId;
        bool     isLocked;
        bool     isIPValidate;
        string   loginName, UserName, Email, Telphone, isdownload, groupName;
        DateTime createDate;

        using (IDataReader reader = SqlHelper.ExecuteReader(CommonInfo.ConQJVRMS, CommandType.StoredProcedure, "dbo.Users_GetUserByUserId", Parameters))
        {
            if (!reader.Read())
            {
                throw new Exception("用户ID不存在!");
            }

            groupId      = new Guid(reader["groupId"].ToString());
            isLocked     = bool.Parse(reader["IsLocked"].ToString());
            isIPValidate = bool.Parse(reader["IsIPValidate"].ToString());
            isdownload   = reader["IsDownLoad"].ToString();
            loginName    = reader["logInName"].ToString();
            UserName     = reader["Username"].ToString();
            groupName    = reader["groupName"].ToString();

            Email      = reader["email"].ToString();
            Telphone   = reader["Tel"].ToString();
            createDate = DateTime.Parse(reader["CreateDate"].ToString());
        }

        user           = new User(loginName, UserName, userId, groupId, isLocked, Email, Telphone, createDate, isdownload, isIPValidate);
        user.GroupName = groupName;
        SerializeObjectFactory sof = new SerializeObjectFactory();

        return(sof.SerializeToBase64(user));
    }
Example #9
0
    public string GetUserByLoginName(string loginName)
    {
        string sql = " select u.*,g.GroupName from Users u,[Group] g where u.loginName=@loginName and u.groupId=g.groupId";

        SqlParameter[] Parameters = new SqlParameter[1];
        Parameters[0]       = new SqlParameter("@loginName", SqlDbType.NVarChar);
        Parameters[0].Value = loginName;

        QJVRMS.Business.User user = null;
        Guid     groupId, UserId;
        bool     isLocked, isIPValidate;
        string   UserName, Email, Telphone, isdownload, groupName;
        DateTime createDate;

        using (IDataReader reader = SqlHelper.ExecuteReader(CommonInfo.ConQJVRMS, CommandType.Text, sql, Parameters))
        {
            if (!reader.Read())
            {
                throw new Exception("用户登录ID不存在!");
            }

            groupId      = new Guid(reader["groupId"].ToString());
            isLocked     = bool.Parse(reader["IsLocked"].ToString());
            isIPValidate = bool.Parse(reader["IsIPValidate"].ToString());
            isdownload   = reader["IsDownLoad"].ToString();
            UserId       = new Guid(reader["UserId"].ToString());
            UserName     = reader["Username"].ToString();
            groupName    = reader["groupName"].ToString();

            Email      = reader["email"].ToString();
            Telphone   = reader["Tel"].ToString();
            createDate = DateTime.Parse(reader["CreateDate"].ToString());
        }

        user           = new User(loginName, UserName, UserId, groupId, isLocked, Email, Telphone, createDate, isdownload, isIPValidate);
        user.GroupName = groupName;
        SerializeObjectFactory sof = new SerializeObjectFactory();

        return(sof.SerializeToBase64(user));
    }
Example #10
0
        public static List <User> CheckUsers(string domainName, string OU, string adminId, string adminPwd, List <string> userIdList)
        {
            List <User> userList = new List <User>();

            // ADHelper.SearchUser(domainName, OU, adminId, adminPwd, userIdList, userList);

            QJVRMS.Business.MemWS.MemberShipService mss = new QJVRMS.Business.MemWS.MemberShipService();

            SerializeObjectFactory sof = new SerializeObjectFactory();

            //System.Collections.ArrayList al = new System.Collections.ArrayList(userIdList.Count);

            //foreach (string var in userIdList)
            //{
            //    al.Add(var);
            //}

            string idString = sof.SerializeToBase64(userIdList);

            string returnUserList = mss.CheckUsers(domainName, OU, adminId, adminPwd, idString);

            object o = sof.DesializeFromBase64(returnUserList);

            List <User> users = (List <User>)o;

            //foreach (IADsUser adUser in adList)
            //{
            //    User user = new User();

            //    user.Email = adUser.EmailAddress;
            //    user.UserLoginName = adUser.Name;
            //    user.UserId = new Guid(adUser.GUID);
            //    user.Telphone = adUser.TelephoneNumber.ToString();

            //    userList.Add(user);
            //}

            return(users);
        }