Esempio n. 1
0
        /// <summary>
        /// Get the Discipline details of the Selected user
        /// </summary>
        /// <param name="siteUrl">Site URL.</param>
        /// <param name="selectedID">Selected User ID.</param>
        /// <param name="listName">List Name.</param>
        /// <returns>Object of ListEntry.</returns>
        /// <exception cref="">Handled in calling method.</exception>
        internal UserDetails GetUserDescipline(string siteUrl, string windowsUserID, string listName)
        {
            UserDetails objUserDetails = null;
            SPList list;
            SPListItem objListItem;
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(siteUrl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        list = web.Lists[listName];

                        string strCAMLQuery = @"<Where><Eq><FieldRef Name='Windows_User_ID'/><Value Type='Text'>" + windowsUserID + "</Value></Eq></Where>";
                        string strViewFields = @"<FieldRef Name='DWBUserName'/><FieldRef Name='Windows_User_ID'/><FieldRef Name='Discipline'/><FieldRef Name='Terminate_Status'/><FieldRef Name='ID'/><FieldRef Name='Privileges'/>";

                        SPQuery query = new SPQuery();
                        query.Query = strCAMLQuery;
                        query.ViewFields = strViewFields;

                        SPListItemCollection listItemCollection = list.GetItems(query);

                        if (listItemCollection != null && listItemCollection.Count > 0)
                        {
                            objListItem = listItemCollection[0];

                            if (objListItem != null)
                            {
                                objUserDetails = new UserDetails();
                                objUserDetails.UserName = Convert.ToString(objListItem["DWBUserName"]);
                                objUserDetails.WindowUserID = Convert.ToString(objListItem["Windows_User_ID"]);
                                objUserDetails.Terminated = Convert.ToString(objListItem["Terminate_Status"]);
                                /// objListItem["Discipline"] - value is stored in this format [ID;#Value - Eg: 2;#Reservoir Engineering]
                                /// If multiple selection allowed [2;#Reservoir Engineering;#1;#Production Technology]
                                string strDiscipline = Convert.ToString(objListItem["Discipline"]);
                                string[] splitter = { ";#" };
                                string[] output = strDiscipline.Split(splitter, StringSplitOptions.None);
                                if (output != null && output.Length == 2)
                                {
                                    objUserDetails.DisciplineID = output[0];
                                    objUserDetails.Discipline = output[1];
                                }
                                objUserDetails.Privileges = Convert.ToString(objListItem["Privileges"]);
                                objUserDetails.RowId = Convert.ToInt32(objListItem["ID"]);
                            }
                        }

                    }
                }
            });
            return objUserDetails;
        }
Esempio n. 2
0
        /// <summary>
        /// Method To change the privileges to Admin if the Checkbox is checked
        /// And Change the privileges to DWB User if the Checkbox is unchecked
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void cbIsAdmin_CheckedChanged(object sender, EventArgs e)
        {
            UserDetails objUserDetails = new UserDetails();
            if(cbIsAdmin.Checked)
            {
                objUserDetails.PrivilegeText = "AD - Admin Privilege";
                objUserDetails.PrivilegeCode = "AD";

            }
            else
            {
                objUserDetails.PrivilegeText = "US - DWB User";
                objUserDetails.PrivilegeCode = "US";
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the user details from screen.
        /// </summary>
        /// <returns></returns>
        private UserDetails GetUserDetails()
        {
            /// Assign the values to the object of UserDetails class
            UserDetails objUserDetails = new UserDetails();

            objUserDetails.UserName = cboUserId.SelectedItem.Text;
            objUserDetails.WindowUserID = cboUserId.SelectedItem.Text;

            if(string.Compare(strMode, ADD) == 0)
            {
                objUserDetails.Terminated = STATUSACTIVE;
            }
            else if(string.Compare(strMode, EDIT) == 0)
            {
                objUserDetails.Terminated = STATUSTERMINATED;
                objUserDetails.RowId = Int32.Parse(HttpContext.Current.Request.QueryString[IDVALUEQUERYSTRING]);
            }

            objUserDetails.Discipline = cboDiscipline.SelectedItem.Text;
            objUserDetails.DisciplineID = cboDiscipline.SelectedItem.Value;

            if(cbIsAdmin.Checked)
            {
                objUserDetails.PrivilegeText = "AD - Admin Privilege";
                objUserDetails.PrivilegeCode = "AD";

            }
            else
            {
                objUserDetails.PrivilegeText = "US - DWB User";
                objUserDetails.PrivilegeCode = "US";
            }

            string strTeams = string.Empty;
            /// Selected team ids separated by ";"
            foreach(ListItem item in lstTeams.Items)
            {
                if(item.Selected)
                {
                    strTeams += item.Text + ";";
                }
            }
            objUserDetails.Team = strTeams;

            return objUserDetails;
        }