コード例 #1
0
        private static User_Object build_user_object_from_dataset(DataSet resultSet )
        {
            User_Object user = new User_Object();

            DataRow userRow = resultSet.Tables[0].Rows[0];
            user.UFID = userRow["UFID"].ToString();
            user.UserID = Convert.ToInt32(userRow["UserID"]);
            user.UserName = userRow["username"].ToString();
            user.Email = userRow["EmailAddress"].ToString();
            user.Given_Name = userRow["FirstName"].ToString();
            user.Family_Name = userRow["LastName"].ToString();
            user.Send_Email_On_Submission = Convert.ToBoolean(userRow["SendEmailOnSubmission"]);
            user.Can_Submit = Convert.ToBoolean(userRow["Can_Submit_Items"]);
            user.Is_Temporary_Password = Convert.ToBoolean(userRow["isTemporary_Password"]);
            user.Nickname = userRow["Nickname"].ToString();
            user.Organization = userRow["Organization"].ToString();
            user.Organization_Code = userRow["OrganizationCode"].ToString();
            user.Department = userRow["Department"].ToString();
            user.College = userRow["College"].ToString();
            user.Unit = userRow["Unit"].ToString();
            user.Default_Rights = userRow["Rights"].ToString();
            user.Preferred_Language = userRow["Language"].ToString();
            user.Is_Internal_User = Convert.ToBoolean(userRow["Internal_User"]);
            user.Edit_Template_Code = userRow["EditTemplate"].ToString();
            user.Edit_Template_MARC_Code = userRow["EditTemplateMarc"].ToString();
            user.Is_System_Admin = Convert.ToBoolean(userRow["IsSystemAdmin"]);
            user.Is_Portal_Admin = Convert.ToBoolean(userRow["IsPortalAdmin"]);
            user.Include_Tracking_In_Standard_Forms = Convert.ToBoolean(userRow["Include_Tracking_Standard_Forms"]);
            user.Receive_Stats_Emails = Convert.ToBoolean(userRow["Receive_Stats_Emails"]);
            user.Has_Item_Stats = Convert.ToBoolean(userRow["Has_Item_Stats"]);

            if (Convert.ToInt32(userRow["descriptions"]) > 0)
                user.Has_Descriptive_Tags = true;

            foreach (DataRow thisRow in resultSet.Tables[1].Rows)
            {
                user.Add_Template(thisRow["TemplateCode"].ToString());
            }

            foreach (DataRow thisRow in resultSet.Tables[2].Rows)
            {
                user.Add_Project(thisRow["ProjectCode"].ToString());
            }

            user.Items_Submitted_Count = resultSet.Tables[3 ].Rows.Count;
            foreach (DataRow thisRow in resultSet.Tables[3 ].Rows)
            {
                if (!user.BibIDs.Contains(thisRow["BibID"].ToString().ToUpper()))
                    user.Add_BibID(thisRow["BibID"].ToString().ToUpper());
            }

            // Add links to regular expressions
            foreach (DataRow thisRow in resultSet.Tables[4 ].Rows)
            {
                user.Add_Editable_Regular_Expression(thisRow["EditableRegex"].ToString());
            }

            // Add links to aggregations
            foreach (DataRow thisRow in resultSet.Tables[5 ].Rows)
            {
                user.Add_Aggregation(thisRow["Code"].ToString(), thisRow["Name"].ToString(), Convert.ToBoolean(thisRow["CanSelect"]), Convert.ToBoolean(thisRow["CanEditItems"]), Convert.ToBoolean(thisRow["IsAggregationAdmin"]), Convert.ToBoolean(thisRow["OnHomePage"]));
            }

            // Add the current folder names
            Dictionary<int, User_Folder> folderNodes = new Dictionary<int, User_Folder>();
            List<User_Folder> parentNodes = new List<User_Folder>();
            foreach (DataRow folderRow in resultSet.Tables[6 ].Rows)
            {
                string folderName = folderRow["FolderName"].ToString();
                int folderid = Convert.ToInt32(folderRow["UserFolderID"]);
                int parentid = Convert.ToInt32(folderRow["ParentFolderID"]);
                bool isPublic = Convert.ToBoolean(folderRow["isPublic"]);

                User_Folder newFolderNode = new User_Folder(folderName, folderid) {isPublic = isPublic};
                if (parentid == -1)
                    parentNodes.Add(newFolderNode);
                folderNodes.Add(folderid, newFolderNode);
            }
            foreach (DataRow folderRow in resultSet.Tables[6 ].Rows)
            {
                int folderid = Convert.ToInt32(folderRow["UserFolderID"]);
                int parentid = Convert.ToInt32(folderRow["ParentFolderID"]);
                if (parentid > 0)
                {
                    folderNodes[parentid].Add_Child_Folder(folderNodes[folderid]);
                }
            }
            foreach (User_Folder rootFolder in parentNodes)
                user.Add_Folder(rootFolder);

            foreach (DataRow itemRow in resultSet.Tables[7 ].Rows)
            {
                user.Add_Bookshelf_Item(itemRow["BibID"].ToString(), itemRow["VID"].ToString());
            }

            foreach (DataRow groupRow in resultSet.Tables[8].Rows)
            {
                user.Add_User_Group(groupRow[0].ToString());
            }

            return user;
        }