Example #1
0
        public void ReadSqlSPProfiles(string strConnectionString, string strSiteProfiles)
        {
            this.Clear();

            SqlConnection  sqlConnection = new SqlConnection(strConnectionString);
            SqlDataAdapter daProfiles    = new SqlDataAdapter("SELECT [RecordID], [UserID], [NTName], [PreferredName], [Email], [Manager], [PictureUrl] " +
                                                              "FROM dbo.UserProfile_Full " +
                                                              "WHERE [bDeleted] = 0", sqlConnection);
            SqlDataAdapter daPropertyValues = new SqlDataAdapter("SELECT [RecordID], [PropertyName], [PropertyVal] " +
                                                                 "FROM dbo.PropertyList AS pl, dbo.UserProfileValue AS pv " +
                                                                 "WHERE 	pv.PropertyID = pl.PropertyID", sqlConnection);
            DataTable tableProfiles       = new DataTable();
            DataTable tablePropertyValues = new DataTable();

            sqlConnection.Open();

            daProfiles.Fill(tableProfiles);
            daPropertyValues.Fill(tablePropertyValues);

            sqlConnection.Close();

            // Read data
            foreach (DataRow rowProfile in tableProfiles.Rows)
            {
                long id = 0;

                try { id = Convert.ToInt64(rowProfile["RecordID"]); }
                catch { continue; }

                DataRow[] rowPropValues = tablePropertyValues.Select("RecordID = " + id.ToString());

                RecordUserProfile rp = new RecordUserProfile();

                string strDisplayName = rowProfile["PreferredName"].ToString();
                rp.AccountName = rowProfile["NTName"].ToString();

                foreach (DataRow rowValue in rowPropValues)
                {
                    if (rowValue["PropertyName"] == null || rowValue["PropertyName"] == DBNull.Value)
                    {
                        continue;
                    }
                    if (rowValue["PropertyVal"] == null || rowValue["PropertyVal"] == DBNull.Value)
                    {
                        continue;
                    }
                    string strName = rowValue["PropertyName"].ToString().Trim();
                    string strVal  = rowValue["PropertyVal"].ToString();

                    rp.SetProperty(strName, strVal);
                }

                if (rp.AccountName == null ||
                    rp.AccountName.ToUpper().IndexOf("\\SM_") >= 0 ||
                    rp.AccountName.ToUpper().IndexOf("\\SP_") >= 0 ||
                    rp.AccountName == strDisplayName ||
                    rp.LastName.Trim().Length < 1)
                {
                    continue;
                }

                rp.ProfileURL = strSiteProfiles + "/" + "Person.aspx?accountname=" +
                                System.Web.HttpUtility.UrlEncode(rp.AccountName);

                Add(rp);
            }

            this._bEmpty = false;
        }
Example #2
0
        public void ReadSqlSPProfiles(string strConnectionString, string strSiteProfiles)
        {
            this.Clear();

            SqlConnection sqlConnection = new SqlConnection(strConnectionString);
            SqlDataAdapter daProfiles = new SqlDataAdapter("SELECT [RecordID], [UserID], [NTName], [PreferredName], [Email], [Manager], [PictureUrl] " +
                "FROM dbo.UserProfile_Full " +
                "WHERE [bDeleted] = 0", sqlConnection);
            SqlDataAdapter daPropertyValues = new SqlDataAdapter("SELECT [RecordID], [PropertyName], [PropertyVal] " +
                "FROM dbo.PropertyList AS pl, dbo.UserProfileValue AS pv " +
                "WHERE 	pv.PropertyID = pl.PropertyID", sqlConnection);
            DataTable tableProfiles = new DataTable();
            DataTable tablePropertyValues = new DataTable();

            sqlConnection.Open();

            daProfiles.Fill(tableProfiles);
            daPropertyValues.Fill(tablePropertyValues);

            sqlConnection.Close();

            // Read data
            foreach (DataRow rowProfile in tableProfiles.Rows)
            {
                long id = 0;

                try { id = Convert.ToInt64(rowProfile["RecordID"]); }
                catch { continue; }

                DataRow[] rowPropValues = tablePropertyValues.Select("RecordID = " + id.ToString());

                RecordUserProfile rp = new RecordUserProfile();

                string strDisplayName = rowProfile["PreferredName"].ToString();
                rp.AccountName = rowProfile["NTName"].ToString();

                foreach (DataRow rowValue in rowPropValues)
                {
                    if (rowValue["PropertyName"] == null || rowValue["PropertyName"] == DBNull.Value)
                        continue;
                    if (rowValue["PropertyVal"] == null || rowValue["PropertyVal"] == DBNull.Value)
                        continue;
                    string strName = rowValue["PropertyName"].ToString().Trim();
                    string strVal = rowValue["PropertyVal"].ToString();

                    rp.SetProperty(strName, strVal);
                }

                if (rp.AccountName == null ||
                    rp.AccountName.ToUpper().IndexOf("\\SM_") >= 0 ||
                    rp.AccountName.ToUpper().IndexOf("\\SP_") >= 0 ||
                    rp.AccountName == strDisplayName ||
                    rp.LastName.Trim().Length < 1)
                    continue;

                rp.ProfileURL = strSiteProfiles + "/" + "Person.aspx?accountname=" +
                    System.Web.HttpUtility.UrlEncode(rp.AccountName);

                Add(rp);
            }

            this._bEmpty = false;
        }