private void AddUpdateButtonClick(object sender, RoutedEventArgs e)
        {
            if (updateText != null)
            {
                DataHandling.UpdateTask(selectedTask);
                DataHandling.AddTaskUpdate(selectedTaskID, addUpdateTextBox.Text);

                DataStructures.NotificationStruct notificationStruct = new DataStructures.NotificationStruct();
                notificationStruct.notificationSender     = Application.Current.Properties["username"].ToString();
                notificationStruct.notificationText       = "[" + selectedTask.taskName + "]: " + addUpdateTextBox.Text;
                notificationStruct.taskID                 = selectedTaskID;
                notificationStruct.notificationTime       = DateTime.Now;
                notificationStruct.notificationRecipients = selectedTask.notifyUsers;

                DataHandling.AddNotification(notificationStruct);

                DataHandling.GetTasksFull();

                int taskIndex = 0;

                foreach (DataStructures.TaskRowStruct task in DataStructures.taskRows)
                {
                    if (task.taskName.Equals(selectedTask.taskName))
                    {
                        taskIndex = DataStructures.taskRows.IndexOf(task);
                    }
                }

                ViewTaskWindow updatedTask = new ViewTaskWindow(DataStructures.taskRows[taskIndex]);
                updatedTask.Show();
                Close();
            }
        }
Exemplo n.º 2
0
        public static void GetNotifications()
        {
            using (SqlConnection sqlConn = new SqlConnection(Properties.Settings.Default.PDMDatabaseConnectionString))
            {
                SqlCommand getNotificationsComm = new SqlCommand("SELECT * FROM dbo.Notifications", sqlConn);

                sqlConn.Open();

                SqlDataReader reader = getNotificationsComm.ExecuteReader();

                DataStructures.notificationRows.Clear();

                while (reader.Read())
                {
                    string   recipientsString, readByRecipientsString, hiddenByRecipientsString;
                    string[] recipientsArray, readByRecipientsArray, hiddenByRecipientsArray;

                    DataStructures.NotificationStruct notification = new DataStructures.NotificationStruct();

                    notification.notificationID     = reader.GetInt32(0);
                    notification.notificationText   = reader.GetString(1);
                    notification.notificationTime   = reader.GetDateTime(2);
                    notification.notificationSender = reader.GetString(3);
                    recipientsString         = reader.GetString(4);
                    notification.taskID      = reader.GetInt32(5);
                    readByRecipientsString   = reader.GetString(6);
                    hiddenByRecipientsString = reader.GetString(7);

                    recipientsArray         = recipientsString.Split(',');
                    readByRecipientsArray   = readByRecipientsString.Split(',');
                    hiddenByRecipientsArray = hiddenByRecipientsString.Split(',');

                    notification.notificationRecipients = new List <string>();
                    notification.readByRecipients       = new List <string>();
                    notification.hiddenByRecipients     = new List <string>();

                    foreach (string recipient in recipientsArray)
                    {
                        notification.notificationRecipients.Add(recipient);
                    }

                    foreach (string recipient in readByRecipientsArray)
                    {
                        notification.readByRecipients.Add(recipient);
                    }

                    foreach (string recipient in hiddenByRecipientsArray)
                    {
                        notification.hiddenByRecipients.Add(recipient);
                    }

                    DataStructures.notificationRows.Add(notification);
                }

                reader.Close();
                sqlConn.Close();
            }
        }
        private void AddUpdateKeyPressed(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (Keyboard.Modifiers == ModifierKeys.Shift)
                {
                    int ci = addUpdateTextBox.CaretIndex;
                    addUpdateTextBox.Text      += Environment.NewLine;
                    addUpdateTextBox.CaretIndex = ci + 1;
                }
                else
                {
                    if (updateText != null)
                    {
                        DataHandling.UpdateTask(selectedTask);
                        DataHandling.AddTaskUpdate(selectedTaskID, addUpdateTextBox.Text);

                        DataStructures.NotificationStruct notificationStruct = new DataStructures.NotificationStruct();
                        notificationStruct.notificationSender     = Application.Current.Properties["username"].ToString();
                        notificationStruct.notificationText       = "[" + selectedTask.taskName + "]: " + addUpdateTextBox.Text;
                        notificationStruct.taskID                 = selectedTaskID;
                        notificationStruct.notificationTime       = DateTime.Now;
                        notificationStruct.notificationRecipients = selectedTask.notifyUsers;

                        DataHandling.AddNotification(notificationStruct);

                        DataHandling.GetTasksFull();

                        int taskIndex = 0;

                        foreach (DataStructures.TaskRowStruct task in DataStructures.taskRows)
                        {
                            if (task.taskName.Equals(selectedTask.taskName))
                            {
                                taskIndex = DataStructures.taskRows.IndexOf(task);
                            }
                        }

                        ViewTaskWindow updatedTask = new ViewTaskWindow(DataStructures.taskRows[taskIndex]);
                        updatedTask.Show();
                        Close();
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void EditTaskButtonClick(object sender, RoutedEventArgs e)
        {
            int taskID = DataHandling.GetTaskID(selectedTask.taskName, selectedTask.details);
            int assignedToUserIndex = Properties.Settings.Default.UsersStringCollection.IndexOf(AssignToComboBox.SelectedItem.ToString());

            assignedUsername = Properties.Settings.Default.UsernamesStringCollection[assignedToUserIndex];

            if (selectedTask.taskFiles == null)
            {
                selectedTask.taskFiles = new List <string>();
            }

            string[] taskFilesArray  = selectedTask.taskFiles.ToArray();
            string   taskFilesString = string.Join(",", taskFilesArray);

            if (selectedTask.notifyUsers.Contains(assignedUsername) != true)
            {
                selectedTask.notifyUsers.Add(assignedUsername);
            }

            DataHandling.UpdateTask(taskID, TaskNameTextBox.Text, StartDatePicker.SelectedDate.Value, DeadlinePicker.SelectedDate.Value, TaskDetailsTextBox.Text,
                                    selectedTask.taskListFileTableDir, selectedTask.assignedBy, assignedUsername, StatusComboBox.Text, taskFilesString, selectedTask.notifyUsers);

            string updateString = GetUpdatedFields();

            DataHandling.AddTaskUpdate(taskID, updateString);

            DataStructures.NotificationStruct notificationStruct = new DataStructures.NotificationStruct();
            notificationStruct.notificationSender     = Application.Current.Properties["username"].ToString();
            notificationStruct.notificationText       = "[" + selectedTask.taskName + "]: " + updateString;
            notificationStruct.taskID                 = taskID;
            notificationStruct.notificationTime       = DateTime.Now;
            notificationStruct.notificationRecipients = selectedTask.notifyUsers;

            DataHandling.AddNotification(notificationStruct);

            DataHandling.GetTasksFull();

            Close();
        }
Exemplo n.º 5
0
        public static void AddNotification(DataStructures.NotificationStruct notification)
        {
            using (SqlConnection sqlConn = new SqlConnection(Properties.Settings.Default.PDMDatabaseConnectionString))
            {
                SqlCommand addNotificationComm = new SqlCommand("AddNotificationSP", sqlConn);
                addNotificationComm.CommandType = CommandType.StoredProcedure;

                string[] recipientsArray  = notification.notificationRecipients.ToArray();
                string   recipientsString = string.Join(",", recipientsArray);

                addNotificationComm.Parameters.AddWithValue("@notificationText", notification.notificationText);
                addNotificationComm.Parameters.AddWithValue("@notificationTimeDate", notification.notificationTime);
                addNotificationComm.Parameters.AddWithValue("@notificationSender", notification.notificationSender);
                addNotificationComm.Parameters.AddWithValue("@notificationRecipients", recipientsString);
                addNotificationComm.Parameters.AddWithValue("@taskID", notification.taskID);
                addNotificationComm.Parameters.AddWithValue("@readByRecipients", "");
                addNotificationComm.Parameters.AddWithValue("@hiddenByRecipients", "");

                sqlConn.Open();
                int i = addNotificationComm.ExecuteNonQuery();
                sqlConn.Close();
            }
        }
        private void CreateTaskButtonClick(object sender, RoutedEventArgs e)
        {
            int    assignedToUserIndex = Properties.Settings.Default.UsersStringCollection.IndexOf(AssignToComboBox.Text);
            string assignedUsername    = Properties.Settings.Default.UsernamesStringCollection[assignedToUserIndex];

            newTask.taskName             = TaskNameTextBox.Text;
            newTask.startDate            = StartDatePicker.SelectedDate.Value;
            newTask.deadline             = DeadlinePicker.SelectedDate.Value;
            newTask.details              = TaskDetailsTextBox.Text;
            newTask.taskListFileTableDir = TaskNameTextBox.Text;
            newTask.assignedBy           = System.Windows.Application.Current.Properties["username"].ToString();
            newTask.assignedTo           = assignedUsername;
            newTask.taskStatus           = StatusComboBox.SelectedValue.ToString();
            newTask.lastEdited           = DateTime.Now;
            newTask.taskFiles            = new List <string>();
            newTask.notifyUsers          = new List <string>();
            string[] taskFilesArray  = newTask.taskFiles.ToArray();
            string   taskFilesString = string.Join(",", taskFilesArray);

            string[] notifyUsersArray = new string[0];
            notifyUsersArray.Append(newTask.assignedBy);
            notifyUsersArray.Append(newTask.assignedTo);
            string notifyUsersString = string.Join(",", notifyUsersArray);

            using (SqlConnection sqlConn = new SqlConnection(Properties.Settings.Default.PDMDatabaseConnectionString))
            {
                SqlCommand createTask = new SqlCommand("CreateTaskSP", sqlConn);
                createTask.CommandType = CommandType.StoredProcedure;
                createTask.Parameters.AddWithValue("@taskname", newTask.taskName);
                createTask.Parameters.AddWithValue("@startdate", newTask.startDate);
                createTask.Parameters.AddWithValue("@deadline", newTask.deadline);
                createTask.Parameters.AddWithValue("@details", newTask.details);
                createTask.Parameters.AddWithValue("@tasklistfiletabledir", newTask.taskListFileTableDir);
                createTask.Parameters.AddWithValue("@assignedby", newTask.assignedBy);
                createTask.Parameters.AddWithValue("@assignedto", newTask.assignedTo);
                createTask.Parameters.AddWithValue("@taskstatus", newTask.taskStatus);
                createTask.Parameters.AddWithValue("@lastedited", newTask.lastEdited);
                createTask.Parameters.AddWithValue("@taskFiles", taskFilesString);
                createTask.Parameters.AddWithValue("@notifyUsers", notifyUsersString);

                sqlConn.Open();
                int i = createTask.ExecuteNonQuery();

                string     sqlQuery = "INSERT INTO dbo.TaskListFiles (name,is_directory,is_archive) VALUES ('" + TaskNameTextBox.Text + "', 1, 0);";
                SqlCommand createFileTableDirComm = new SqlCommand(sqlQuery, sqlConn);
                createFileTableDirComm.CommandType = CommandType.Text;
                createFileTableDirComm.ExecuteNonQuery();

                Directory.SetCurrentDirectory(Properties.Settings.Default.FileDirectory);
                Directory.CreateDirectory(TaskNameTextBox.Text);
            }

            DataHandling.GetTasksFull();

            int newTaskID = DataHandling.GetTaskID(newTask.taskName, newTask.details);

            DataStructures.NotificationStruct notificationStruct = new DataStructures.NotificationStruct();
            notificationStruct.notificationSender     = Application.Current.Properties["username"].ToString();
            notificationStruct.notificationText       = "Created Task: " + newTask.taskName;
            notificationStruct.taskID                 = newTaskID;
            notificationStruct.notificationTime       = DateTime.Now;
            notificationStruct.notificationRecipients = new List <string>();
            notificationStruct.notificationRecipients.Add(newTask.assignedTo);
            notificationStruct.notificationRecipients.Add(newTask.assignedBy);

            DataHandling.AddNotification(notificationStruct);

            string taskFilesUpdateString = DataHandling.AddTaskFiles(newTask, selectFiles);

            if (taskFilesUpdateString.Equals("Added File(s): ") == false)
            {
                DataHandling.AddTaskUpdate(newTaskID, taskFilesUpdateString);

                DataHandling.GetTasksFull();
            }


            Close();
        }