コード例 #1
0
ファイル: LoginDAL.cs プロジェクト: Ndiya999/Bulabula
        public int GetGroupID(Group group)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspGetGroupID", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@groupName", group.GroupName);

                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);

                try
                {
                    con.Open();
                    cmd.ExecuteNonQuery();
                    int value = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());

                    return value;
                }
                catch (Exception e)
                {
                    e.Message.ToString();
                    HttpContext.Current.Response.Redirect("~/Error_Pages/503.htm");
                    return -1;
                }
            }
        }
コード例 #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
ファイル: Reusable_Methods.cs プロジェクト: Ndiya999/Bulabula
        public string EventNotifications()
        {
            string notification = "";

            NotificationDAL notificationDAL = new NotificationDAL();

            List<Notification> NotificationsList = new List<Notification>();
            NotificationsList = notificationDAL.GetEventNotificationsForGroupMembers();

            for (int i = 0; i < NotificationsList.Count; ++i)
            {
                int postId = NotificationsList[i].PostId;
                Post aPost = new Post(postId);

                List<Event_Post> EventNameList = new List<Event_Post>();
                EventNameList = notificationDAL.GetEventName(aPost);

                string eventDisplayText = "";
                if (EventNameList[0].EventName.Length > 30)
                {
                    eventDisplayText = EventNameList[0].EventName.Substring(0, 30) + "...";
                }
                else
                {
                    eventDisplayText = EventNameList[0].EventName;
                }

                List<Member> GroupMembersList = new List<Member>();

                Group aGroup = new Group(NotificationsList[i].GroupId);
                GroupMembersList = notificationDAL.GetGroupMembers(aGroup);

                for (int j = 0; j < GroupMembersList.Count; ++j)
                {
                    string friendId = aMember.MemberId; //PERSON WHO IS LOGGED IN

                    //CHECK TO SEE IF PE
                    if (friendId == GroupMembersList[j].MemberId)
                    {
                        List<Member> MemberList = new List<Member>();
                        Member aFriend = new Member(NotificationsList[i].MemberId);
                        MemberList = notificationDAL.GetMemberDisplayName(aFriend);

                        List<Group> GroupList = new List<Group>();
                        Group Group = new Group(NotificationsList[i].GroupId);
                        GroupList = notificationDAL.GetGroupDescription(Group);

                        notification += MemberList[0].DisplayName + " created the event '" + eventDisplayText + "' in the group '" + GroupList[0].GroupDescription + "'\n\n";
                    }
                }
            }
            return notification;
        }
コード例 #4
0
ファイル: ChatDAL.cs プロジェクト: Ndiya999/Bulabula
        public int InsertChatText(Group group, string ChatText, Member member)
        {
            using (SqlConnection dbcon = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspInsertChatText", dbcon);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@GroupID", group.GroupId));
                cmd.Parameters.Add(new SqlParameter("@MemberID", member.MemberId));
                cmd.Parameters.Add(new SqlParameter("@ChatText", ChatText));

                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);
                int postId = 0;
                try
                {
                    dbcon.Open();
                    cmd.ExecuteNonQuery();
                    postId = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());
                }
                catch (SqlException e)
                {
                    MessageBox.Show(e.ToString());
                }
                return postId;

            }
        }
コード例 #5
0
ファイル: ClientUpdate.cs プロジェクト: Ndiya999/Bulabula
        private void OpenWrapper(int i)
        {
            #region OPENING WRAPPER
            aPost = (Post)ArrayPosts[i];

            ArrayMembers = bl.GetMemberDisplayName(aPost.MemberId);
            countMembers = ArrayMembers.Count;

            for (int a = 0; a < countMembers; ++a)
            {
                aMember = (Member)ArrayMembers[a];

                NotificationDAL notificationDAL = new NotificationDAL();
                Group group = new Group(aPost.GroupId);

                string groupDescription = notificationDAL.GetGroupDescription2(group);

                concatinater.Append("<div class='aPost typeOfText' id='");
                concatinater.Append(aPost.PostId);
                concatinater.Append("'><div class='msgeHeading ui-corner-all' ><h2 class='ui-corner-all'> Posted by: <a href='#' id='");
                concatinater.Append(aPost.MemberId);
                concatinater.Append("' class='btnMemberProfile' style='font-weight:normal; '>");
                concatinater.Append(aMember.DisplayName);

                bool isForMember = false;

                string date = "";

                date = reusable_Methods.FormatDateTime(aPost.CreateDate);

                if (aPost.MemberId == memberID)
                { isForMember = true; }

                if (GroupID == aPost.GroupId)
                {

                }
                else
                {
                    concatinater.Append("</a> <span class='space'></span> in group: <a id='");
                    concatinater.Append(aPost.GroupId);

                    concatinater.Append("' class='btnGoToGroupPage groupDesc'>");
                    concatinater.Append(groupDescription);

                }

                concatinater.Append("</a>");
                if (isForMember)
                {
                    concatinater.Append("<span class='ui-icon ui-icon-closethick floatright deletePost pointer ' title ='Delete this post' style='display:none;'></span>");
                }

                concatinater.Append("<span class='DateWithTime ui-corner-all floatright'>");
                concatinater.Append(date);
                //concatinater.Append(Convert.ToDateTime(aPost.CreateDate).ToString("D"));
                concatinater.Append("</span></h2></div> <div class='postContentArea'> <div> ");

            }

            #endregion
        }
コード例 #6
0
ファイル: ClientUpdate.cs プロジェクト: Ndiya999/Bulabula
        public void MoveShape(string postText, string sessionMemberID, int groupID)
        {
            memberID = sessionMemberID;
            StringBuilder htmlText = new StringBuilder();
            Member aMember = new Member(memberID);
            htmlText.Append(postText);

            //htmlText.Replace("cat", "dog",);
            //htmlText.S
            //string[] parts = postText.Split('');
            Text_Post aText_Post = new Text_Post(postText);
            Group aGroup = new Group();
            aGroup.GroupId = groupID;

            int postId = postDAL.InsertText(aGroup, aText_Post, aMember);

            #region GET POST
            ArrayPosts = bl.GetASinglePost(postId);
            int count = ArrayPosts.Count;

            for (int i = 0; i < count; ++i)
            {

                OpenWrapper(i);

                #region TEXT POST
                GetTextPosts();
                #endregion

                CloseWrapper();

            }
            string postToClients = concatinater.ToString();

            #endregion

            //Updating all Clients
            Clients.shapeMoved(Context.ConnectionId, postToClients, groupID);
        }
コード例 #7
0
ファイル: ClientUpdate.cs プロジェクト: Ndiya999/Bulabula
        public void InsertChatText(string sessionMemberID, int groupID, string ChatText)
        {
            //Article_Post article_Post = new Article_Post(ChatText);
            Group group = new Group(groupID);
            Member thisMember = new Member(sessionMemberID);

               int postID = chatDAL.InsertChatText(group, ChatText, thisMember);
               Post post = new Post(postID);
               Article_Post thisArticle = chatDAL.getChatText(ref post);

               //BulabulaApp.Other_Classes. date new = reusable_Methods.FormatDateTime(aPost.CreateDate);
               Reusable_Methods reusable_Methods = new Reusable_Methods();
               string date = reusable_Methods.FormatDateTimeForChat(post.CreateDate);
               thisMember =  chatDAL.GetMemberDisplayName(thisMember);

               concatinater.Append(" <div class='chatMemberWrapper'>");
                concatinater.Append("<div class='memberNameSection  '> <a id=");
                concatinater.Append(thisMember.MemberId);
                concatinater.Append(" class='btnMemberProfile pointer' ><em>");
                concatinater.Append(thisMember.DisplayName);
                concatinater.Append("</em></a></div>");
                concatinater.Append("</a></div>");
               concatinater.Append("<div class='chatContentSection '>");
               concatinater.Append(thisArticle.ArticleText);

               concatinater.Append("</div> <div class='clr'></div>");

               concatinater.Append(" </div>");
               string chatString = concatinater.ToString();

               Clients.updateChat(Context.ConnectionId, chatString, groupID.ToString(), sessionMemberID);
        }
コード例 #8
0
ファイル: ClientUpdate.cs プロジェクト: Ndiya999/Bulabula
        public void AddEventPost(string sessionMemberID, string startDate, string endDate, string name, string host, string venue, int groupID, string details, string type)
        {
            memberID = sessionMemberID;
            StringBuilder htmlText = new StringBuilder();
            Member aMember = new Member(memberID);

            Group aGroup = new Group(groupID);

            PostDAL postDAL = new PostDAL();

            Reusable_Methods reusable_Methods = new Reusable_Methods();

             /*
              * NEEDS ATTENTION !!!!!!!!!
              *
              *
              */

            DateTime startDateD = reusable_Methods.CreateDateTime(startDate);
            DateTime endDateD = reusable_Methods.CreateDateTime(endDate);

              /*
            * END NEEDS ATTENTION !!!!!!!!!
            */

            //DateTime startDateD = reusable_Methods.FormatDateFromDateTimePicker(startDate);
              //  DateTime endDateD = reusable_Methods.FormatDateFromDateTimePicker(endDate);

            Event_Post aEvent_Post = new Event_Post(name, details, venue, startDateD, endDateD, host, type);
            int postId = postDAL.InsertEvent(aEvent_Post, aGroup, aMember);

            #region GET POST
            ArrayPosts = bl.GetASinglePost(postId);
            int count = ArrayPosts.Count;

            for (int i = 0; i < count; ++i)
            {

                OpenWrapper(i);

                #region EVENT POST
                GetEventPosts();
                #endregion

                CloseWrapper();

            }

            #endregion

             string postToClients = concatinater.ToString();

            //Updating all Clients
            Clients.insertEvent(Context.ConnectionId, postToClients, groupID);
        }
コード例 #9
0
ファイル: PostDAL.cs プロジェクト: Ndiya999/Bulabula
        public int InsertPhoto(Photo_Post photo_Post, Group group, Member member)
        {
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                MemoryStream ms = new MemoryStream();
                photo_Post.Photo.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                SqlCommand cmd = new SqlCommand("uspInsertPhoto", connection);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@GroupID", group.GroupId));
                cmd.Parameters.Add(new SqlParameter("@MemberID", member.MemberId));
                cmd.Parameters.Add(new SqlParameter("@Photo", ms.ToArray()));
                cmd.Parameters.Add(new SqlParameter("@PhotoName", photo_Post.PhotoName));
                cmd.Parameters.Add(new SqlParameter("@PhotoCaption", photo_Post.PhotoCaption));

                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);
                int postId = 0;
                try
                {
                    connection.Open();
                    cmd.ExecuteNonQuery();
                    postId = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());
                }
                catch (SqlException e)
                {
                    MessageBox.Show(e.ToString());
                }
                return postId;

            }
        }
コード例 #10
0
ファイル: PostDAL.cs プロジェクト: Ndiya999/Bulabula
        public int InsertEvent(Event_Post events, Group group, Member member)
        {
            using (SqlConnection dbcon = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspInsertEvent", dbcon);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@GroupID", group.GroupId));
                cmd.Parameters.Add(new SqlParameter("@MemberID", member.MemberId));
                cmd.Parameters.Add(new SqlParameter("@EventName", events.EventName));
                cmd.Parameters.Add(new SqlParameter("@EventDetails", events.EventDetails));
                cmd.Parameters.Add(new SqlParameter("@EventVenue", events.EventVenue));
                cmd.Parameters.Add(new SqlParameter("@StartDate", events.StartDate));
                cmd.Parameters.Add(new SqlParameter("@EndDate", events.EndDate));
                cmd.Parameters.Add(new SqlParameter("@Host", events.Host));
                cmd.Parameters.Add(new SqlParameter("@EventType", events.EventType));

                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);
                int postId = 0;
                try
                {
                    dbcon.Open();
                    cmd.ExecuteNonQuery();
                    postId = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());
                }
                catch (SqlException e)
                {
                    MessageBox.Show(e.ToString());
                }
                return postId;
            }
        }
コード例 #11
0
ファイル: NotificationDAL.cs プロジェクト: Ndiya999/Bulabula
        public bool InsertEventPostNotification(Member member, Post post, Group group)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

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

                cmd.Parameters.AddWithValue("@MemberID", member.MemberId);
                cmd.Parameters.AddWithValue("@PostID", post.PostId);
                cmd.Parameters.AddWithValue("@GroupID", group.GroupId);

                try
                {
                    con.Open();
                    int x = cmd.ExecuteNonQuery();
                    return true;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message.ToString());
                    return false;
                }
            }
        }
コード例 #12
0
ファイル: NotificationDAL.cs プロジェクト: Ndiya999/Bulabula
        public List<Member> GetGroupMembers(Group group)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspGetGroupMembers", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@GroupID", group.GroupId));

                List<Member> MemberList = new List<Member>();

                try
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Member aMember = new Member(reader["MemberID"].ToString(), reader["DisplayName"].ToString(), 1);
                        MemberList.Add(aMember);
                    }//End while
                    reader.Close();
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message.ToString());
                }
                return MemberList;
            }
        }
コード例 #13
0
ファイル: NotificationDAL.cs プロジェクト: Ndiya999/Bulabula
        public string GetGroupDescription2(Group group)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspGetGroupDescription", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@GroupID", group.GroupId));

                string GroupList = null;

                try
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        GroupList = reader["GroupDescription"].ToString();

                    }//End while
                    reader.Close();
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message.ToString());
                }
                return GroupList;
            }
        }
コード例 #14
0
ファイル: MessagesDAL.cs プロジェクト: Ndiya999/Bulabula
        public List<Group> SearchGroup(string group)
        {
            Group m;
            List<Group> groups = new List<Group>();
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspSearchGroupDescription", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@GroupPrefix", group);

                try
                {
                    con.Open();

                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        m = new Group(int.Parse(reader["GroupID"].ToString()), Convert.ToString(reader["GroupDescription"]));
                        groups.Add(m);

                    }//End while
                    reader.Close();
                }
                catch (Exception ex)
                {
                    ex.ToString();
                    // MessageBox.Show(ex.Message);
                }

                return groups;

            }
        }
コード例 #15
0
ファイル: LoginDAL.cs プロジェクト: Ndiya999/Bulabula
        public bool InsertGroup(Group group)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

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

                cmd.Parameters.AddWithValue("@groupName", group.GroupName);
                cmd.Parameters.AddWithValue("@groupDescription", group.GroupDescription);

                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;
                }
            }
        }
コード例 #16
0
ファイル: LoginDAL.cs プロジェクト: Ndiya999/Bulabula
        public bool GroupExists(Group group)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspGroupExists", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@groupName", group.GroupName));

                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);

                try
                {
                    con.Open();
                    cmd.ExecuteNonQuery();
                    int count = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());

                    if (count > 0)
                        return true;
                    else
                        return false;
                }
                catch (Exception e)
                {
                    e.Message.ToString();
                    HttpContext.Current.Response.Redirect("~/Error_Pages/503.htm");
                    return false;
                }
            }
        }