コード例 #1
0
ファイル: LoginDAL.cs プロジェクト: Ndiya999/Bulabula
        public bool AssignMemberTogroup(Group_Member group_Member)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspAssignMemberTogroup", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@MemberID", group_Member.MemberId);
                cmd.Parameters.AddWithValue("@GroupID", group_Member.GroupId);

                try
                {
                    con.Open();
                    int x = cmd.ExecuteNonQuery();
                    return true;
                }
                catch (Exception e)
                {
                    e.Message.ToString();
                    HttpContext.Current.Response.Redirect("~/Error_Pages/503.htm");
                    return false;
                }
            }
        }
コード例 #2
0
ファイル: Login.aspx.cs プロジェクト: Ndiya999/Bulabula
        /// <summary>
        /// Assigns member to module groups found in the active directory
        /// </summary>
        /// <param name="username"></param>
        public void AssignMemberToGroups(string username)
        {
            arrayGroups = userInformation.GetAllGroupsForAUser();
            int count = arrayGroups.Count;

            for (int i = 0; i < count; ++i)
            {
                bool isValidFirst3CharsOfModulesCode = false;
                bool isValidLast4CharsOfModulesCode = false;
                //eliminate none modules codes
                if (arrayGroups[i].ToString().Length == 7) //Number of characters in module code. eg ONT3210
                {
                    string first3CharsOfModulesCode = arrayGroups[i].ToString().Substring(0, 3);
                    foreach (char c in first3CharsOfModulesCode)
                    {
                        if ((int)c >= 65 && (int)c <= 90) //First 3 characters on modulue code EACH between A - Z
                        {
                            isValidFirst3CharsOfModulesCode = true;
                        }
                        else
                        {
                            isValidFirst3CharsOfModulesCode = false;
                            break;
                        }
                    }

                    string last4CharsOfModulesCode = arrayGroups[i].ToString().Substring(3, 4);
                    foreach (char c in last4CharsOfModulesCode)
                    {
                        if ((int)c >= 48 && (int)c <= 57) //Last 4 characters on modulue code EACH between 0 - 9
                        {
                            isValidLast4CharsOfModulesCode = true;
                        }
                        else
                        {
                            isValidLast4CharsOfModulesCode = false;
                            break;
                        }
                    }

                    if (isValidFirst3CharsOfModulesCode == true && isValidLast4CharsOfModulesCode == true)
                    {
                        //add group to database if group not in database
                        dal = new LoginDAL();
                        Group group;
                        if (!dal.GroupExists(group = new Group(arrayGroups[i].ToString())))
                        {
                            dal.InsertGroup(group = new Group(arrayGroups[i].ToString(), userInformation.GetGroupDescription(arrayGroups[i].ToString())));
                        }
                        //finally assign the member to a module group found in the active directory
                        Group_Member group_Member = new Group_Member(username, dal.GetGroupID(group));
                        dal.AssignMemberTogroup(group_Member);
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Assigns member to module groups found in the active directory
        /// </summary>
        /// <param name="username"></param>
        public void AssignMemberToGroups(string username)
        {
            arrayGroups = userInformation.GetAllGroupsForAUser();
            int count = arrayGroups.Count;

            for (int i = 0; i < count; ++i)
            {
                bool isValidFirst3CharsOfModulesCode = false;
                bool isValidLast4CharsOfModulesCode  = false;
                //eliminate none modules codes
                if (arrayGroups[i].ToString().Length == 7) //Number of characters in module code. eg ONT3210
                {
                    string first3CharsOfModulesCode = arrayGroups[i].ToString().Substring(0, 3);
                    foreach (char c in first3CharsOfModulesCode)
                    {
                        if ((int)c >= 65 && (int)c <= 90) //First 3 characters on modulue code EACH between A - Z
                        {
                            isValidFirst3CharsOfModulesCode = true;
                        }
                        else
                        {
                            isValidFirst3CharsOfModulesCode = false;
                            break;
                        }
                    }

                    string last4CharsOfModulesCode = arrayGroups[i].ToString().Substring(3, 4);
                    foreach (char c in last4CharsOfModulesCode)
                    {
                        if ((int)c >= 48 && (int)c <= 57) //Last 4 characters on modulue code EACH between 0 - 9
                        {
                            isValidLast4CharsOfModulesCode = true;
                        }
                        else
                        {
                            isValidLast4CharsOfModulesCode = false;
                            break;
                        }
                    }

                    if (isValidFirst3CharsOfModulesCode == true && isValidLast4CharsOfModulesCode == true)
                    {
                        //add group to database if group not in database
                        dal = new LoginDAL();
                        Group group;
                        if (!dal.GroupExists(group = new Group(arrayGroups[i].ToString())))
                        {
                            dal.InsertGroup(group = new Group(arrayGroups[i].ToString(), userInformation.GetGroupDescription(arrayGroups[i].ToString())));
                        }
                        //finally assign the member to a module group found in the active directory
                        Group_Member group_Member = new Group_Member(username, dal.GetGroupID(group));
                        dal.AssignMemberTogroup(group_Member);
                    }
                }
            }
        }
コード例 #4
0
ファイル: LoginDAL.cs プロジェクト: Ndiya999/Bulabula
        public bool AssignMemberTogroup(Group_Member group_Member)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspAssignMemberTogroup", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@MemberID", group_Member.MemberId);
                cmd.Parameters.AddWithValue("@GroupID", group_Member.GroupId);

                try
                {
                    con.Open();
                    int x = cmd.ExecuteNonQuery();
                    return(true);
                }
                catch (Exception e)
                {
                    e.Message.ToString();
                    HttpContext.Current.Response.Redirect("~/Error_Pages/503.htm");
                    return(false);
                }
            }
        }