Example #1
0
        private void Follow(object sender, EventArgs e)
        {
            // add a folow object to link the logged in user and this bug
            // need a timestamp for the notification, also needs some leeway as sending to the server may take a second
            // or more depending on connection.
            DateTime timestamp    = DateTime.Now;
            string   stringTime   = timestamp.ToString("yyyy-MM-dd HH:mm:ss");;
            string   toStringTime = timestamp.AddSeconds(5).ToString("yyyy-MM-dd HH:mm:ss");
            // create a follow project object which will notify the project poster that a user wants access
            SqlFollow sq = new SqlFollow();

            Connection.GetDbConn().CreateCommand(SqlFollow.FollowBug(UserObject.loggedUser.iduser, currentBug.idbug));

            // has to create a notification with relevant deatils
            SqlNotifications notif = new SqlNotifications();

            notif.InsertNotification(UserObject.loggedUser.iduser, currentBug.project, currentBug.idbug, "", "bugfollow", "", timestamp);
            // have to get the new notif's id to make a toNotif object, have to use time here as its possible
            // that a user might make multiple requests or might follow, unfollow, then want back in
            // copied logic from following a project here as unlikely user will have multiple notifications on the same project
            // with the same timestamp
            DataSet getNotifId = Connection.GetDbConn().GetDataSet($"SELECT idnotification FROM notification" +
                                                                   $" WHERE usernotif = {UserObject.loggedUser.iduser} AND project = {currentBug.project}  AND timestamp BETWEEN '{stringTime}' AND '{toStringTime}' ");
            string newNotifId = getNotifId.Tables[0].Rows[0].ItemArray.GetValue(0).ToString();
            // need to notify the bug's poster
            DataSet bugPoster = Connection.GetDbConn().GetDataSet($"SELECT poster FROM bug WHERE idbug = {currentBug.idbug}");
            string  posterId  = bugPoster.Tables[0].Rows[0].ItemArray.GetValue(0).ToString();

            notif.InsertToNotify(newNotifId, posterId, "0");


            MessageBox.Show("Followed");
        }
Example #2
0
        private void Follow(object sender, EventArgs e, string project)
        {
            // need a timestamp for the notification, also needs some leeway as sending to the server may take a second
            // or more depending on connection.
            DateTime timestamp    = DateTime.Now;
            string   stringTime   = timestamp.ToString("yyyy-MM-dd HH:mm:ss");;
            string   toStringTime = timestamp.AddSeconds(5).ToString("yyyy-MM-dd HH:mm:ss");
            // create a follow project object which will notify the project poster that a user wants access
            SqlFollow sq = new SqlFollow();

            Connection.GetDbConn().CreateCommand(SqlFollow.FollowProject(UserObject.loggedUser.iduser, currentProject));

            // has to create a notification with relevant deatils
            SqlNotifications notif = new SqlNotifications();

            notif.InsertNotification(UserObject.loggedUser.iduser, project, "", "", "follow", "", timestamp);
            // have to get the new notif's id to make a toNotif object, have to use time here as its possible
            // that a user might make multiple requests or might follow, unfollow, then want back in
            DataSet getNotifId = Connection.GetDbConn().GetDataSet($"SELECT idnotification FROM notification" +
                                                                   $" WHERE usernotif = {UserObject.loggedUser.iduser} AND project = {project}  AND timestamp BETWEEN '{stringTime}' AND '{toStringTime}' ");
            string newNotifId = getNotifId.Tables[0].Rows[0].ItemArray.GetValue(0).ToString();
            // need to get the project owner's id
            DataSet projectOwner = Connection.GetDbConn().GetDataSet($"SELECT user FROM project WHERE idproject = {project}");
            string  ownerId      = projectOwner.Tables[0].Rows[0].ItemArray.GetValue(0).ToString();

            notif.InsertToNotify(newNotifId, ownerId, "0");


            MessageBox.Show("Followed");
            //catch (Exception)
            //{
            //    MessageBox.Show("Request already sent");
            //}
        }
        private void RequestAccess(object sender, EventArgs e, ProjectObject project)
        {
            // create a follow project object which will notify the project poster that a user wants access
            try
            { // creates follow table row, as this is a private project (public projects are followed on bugsform)
                // sends a notification to the poster of the project to advise the user wants access.
                DateTime         now         = DateTime.Now;
                string           timestamp   = now.ToString("yyyy-MM-dd HH:mm:ss");
                string           timestampTo = now.AddSeconds(5).ToString("yyyy-MM-dd HH:mm:ss");
                SqlProject       sq          = new SqlProject();
                SqlNotifications notif       = new SqlNotifications();

                Connection.GetDbConn().CreateCommand(SqlFollow.FollowProject(UserObject.loggedUser.iduser, project.idproject));

                notif.InsertNotification(UserObject.loggedUser.iduser, project.idproject, "", "", "request access", "", now);

                DataSet getNotifId = Connection.GetDbConn().GetDataSet($"SELECT idnotification FROM notification" +
                                                                       $" WHERE usernotif = {UserObject.loggedUser.iduser} AND project = {project.idproject} AND timestamp BETWEEN '{timestamp}' AND '{timestampTo}'");
                string notifId = getNotifId.Tables[0].Rows[0].ItemArray.GetValue(0).ToString();

                DataSet getProjectOwner = Connection.GetDbConn().GetDataSet($"SELECT user FROM project WHERE idproject = { project.idproject}");
                string  projOwner       = getProjectOwner.Tables[0].Rows[0].ItemArray.GetValue(0).ToString();

                notif.InsertToNotify(notifId, projOwner, "0");
                MessageBox.Show("Request sent to project creator");
            }
            catch (Exception)
            {
                MessageBox.Show("Request already sent");
            }
        }
Example #4
0
        private void Unfollow(object sender, EventArgs e, string project)
        {
            // create a follow project object which will notify the project poster that a user wants access

            SqlFollow sq = new SqlFollow();

            Connection.GetDbConn().CreateCommand(SqlFollow.UnFollowProject(UserObject.loggedUser.iduser, currentProject));

            MessageBox.Show("Unfollowed");

            //catch (Exception)
            //{
            //    MessageBox.Show("Request already sent");
            //}
        }