Ejemplo n.º 1
0
        public void DeleteTask(int taskID)
        {
            Task task = Tasks.GetTask(UserSession.LoginUser, taskID);

            if (task.CreatorID != UserSession.CurrentUser.UserID && !UserSession.CurrentUser.IsSystemAdmin)
            {
                return;
            }

            TaskAssociations associations = new TaskAssociations(UserSession.LoginUser);

            associations.DeleteByReminderIDOnly(taskID);

            Tasks subtasks = new Tasks(UserSession.LoginUser);

            subtasks.LoadIncompleteByParentID(taskID);
            foreach (Task subtask in subtasks)
            {
                DeleteTask(subtask.TaskID);
            }

            if (task.ReminderID != null)
            {
                Data.Reminder reminder = Reminders.GetReminder(UserSession.LoginUser, (int)task.ReminderID);
                reminder.Delete();
                reminder.Collection.Save();
            }

            string description = String.Format("{0} deleted task {1} ", UserSession.CurrentUser.FirstLastName, task.Description);

            ActionLogs.AddActionLog(UserSession.LoginUser, ActionLogType.Delete, ReferenceType.Tasks, taskID, description);
            task.Delete();
            task.Collection.Save();
        }
Ejemplo n.º 2
0
        public static string GetReminder(RestCommand command, int reminderID)
        {
            Reminder reminder = Reminders.GetReminder(command.LoginUser, reminderID);

            if (reminder.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(reminder.GetXml("Reminder", true));
        }
Ejemplo n.º 3
0
        public ReminderProxy GetReminder(int reminderID)
        {
            Reminder reminder = Reminders.GetReminder(TSAuthentication.GetLoginUser(), (int)reminderID);

            if (reminder.OrganizationID != TSAuthentication.OrganizationID)
            {
                return(null);
            }
            return(reminder.GetProxy());
        }
Ejemplo n.º 4
0
        public void DismissReminder(int reminderID)
        {
            Reminder reminder = Reminders.GetReminder(TSAuthentication.GetLoginUser(), (int)reminderID);

            if (reminder.OrganizationID != TSAuthentication.OrganizationID)
            {
                return;
            }

            if (!TSAuthentication.IsSystemAdmin && reminder.UserID != TSAuthentication.UserID)
            {
                return;
            }
            reminder.IsDismissed = true;
            reminder.Collection.Save();
        }
Ejemplo n.º 5
0
        public ReminderProxy EditReminder(int?reminderID, ReferenceType refType, int refID, string description, DateTime dueDate, int userID)
        {
            Reminder reminder;

            if (reminderID == null)
            {
                string logdescription;
                reminder = (new Reminders(TSAuthentication.GetLoginUser())).AddNewReminder();
                reminder.OrganizationID = TSAuthentication.OrganizationID;
                User reminderUser = (User)Users.GetUser(TSAuthentication.GetLoginUser(), userID);
                if (refType == ReferenceType.Tickets)
                {
                    logdescription = String.Format("Added Reminder for {0} , for {1}", reminderUser.FirstLastName, Tickets.GetTicketLink(TSAuthentication.GetLoginUser(), refID));
                }
                else
                {
                    logdescription = String.Format("Added Reminder for {0}", reminderUser.FirstLastName);
                }

                ActionLogs.AddActionLog(TSAuthentication.GetLoginUser(), ActionLogType.Insert, ReferenceType.Tickets, refID, logdescription);
                ActionLogs.AddActionLog(TSAuthentication.GetLoginUser(), ActionLogType.Insert, ReferenceType.Users, userID, logdescription);
            }
            else
            {
                reminder = Reminders.GetReminder(TSAuthentication.GetLoginUser(), (int)reminderID);
                if (reminder.OrganizationID != TSAuthentication.OrganizationID)
                {
                    return(null);
                }
            }

            User user = Users.GetUser(reminder.Collection.LoginUser, userID);

            if (user.OrganizationID != TSAuthentication.OrganizationID)
            {
                return(null);
            }

            reminder.Description  = description;
            reminder.RefType      = refType;
            reminder.RefID        = refID;
            reminder.DueDate      = dueDate;
            reminder.UserID       = userID;
            reminder.HasEmailSent = false;
            reminder.Collection.Save();
            return(reminder.GetProxy());
        }
Ejemplo n.º 6
0
        public void DeleteAssociation(int reminderID, int refID, ReferenceType refType)
        {
            try
            {
                LoginUser        loginUser    = TSAuthentication.GetLoginUser();
                TaskAssociations associations = new TaskAssociations(loginUser);
                associations.DeleteAssociation(reminderID, refID, refType);
                string description = String.Format("{0} deleted task association to {1} ", TSAuthentication.GetUser(loginUser).FirstLastName, Enum.GetName(typeof(ReferenceType), refType));
                TaskLogs.AddTaskLog(loginUser, reminderID, description);

                Reminder task = Reminders.GetReminder(loginUser, reminderID);
                if (task.UserID != null && loginUser.UserID != task.UserID)
                {
                    SendModifiedNotification(loginUser.UserID, task.ReminderID);
                }
            }
            catch (Exception ex)
            {
                DataUtils.LogException(UserSession.LoginUser, ex);
            }
        }
        static void Main(string[] args)
        {
            string path = Directory.GetCurrentDirectory() + "/../Notes";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string[] date;
            string   date1, time1, startTime;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("... Personal Notes & Reminders ...\n");
                Console.WriteLine("1. Enter a note.");
                Console.WriteLine("2. View a note");
                Console.WriteLine("3. Delete a note");
                Console.WriteLine("4. Create a reminder");
                Console.WriteLine("5. View a reminder");
                Console.WriteLine("6. Delete a reminder");
                Console.WriteLine("7. Exit\n");
                Console.Write("Enter your option: ");
                int choice = Convert.ToInt32(Console.ReadLine());

                switch (choice)
                {
                case 1:
                    Console.Clear();
                    date = DateTime.Now.ToString("dd.MM.yyyy").Split('.');
                    string fileName = date[0] + date[1] + date[2];
                    Console.Write("Enter the Note: ");
                    string note = Console.ReadLine();
                    Notebook.CreateNote(note, fileName);
                    Console.WriteLine("Note created\n");
                    Console.Write("Press any Key to continue... ");
                    Console.ReadKey();
                    break;

                case 2:
                    Console.Clear();
                    Console.Write("Enter the Date (DD.MM.YYYY): ");
                    date = Console.ReadLine().Split('.');
                    string fileName2 = date[0] + date[1] + date[2];
                    string note1     = Notebook.GetNote(fileName2);
                    Console.WriteLine(note1);
                    Console.Write("Press any Key to continue... ");
                    Console.ReadKey();
                    break;

                case 3:
                    Console.Clear();
                    Console.Write("Enter the Date (DD.MM.YYYY): ");
                    date = Console.ReadLine().Split('.');
                    string fileName3 = date[0] + date[1] + date[2];
                    Notebook.DeleteNote(fileName3);
                    Console.Write("Press any Key to continue... ");
                    Console.ReadKey();
                    break;

                case 4:
                    Console.Clear();
                    Console.Write("Enter the date (DD.MM.YYYY): ");
                    date1 = Console.ReadLine();
                    Console.Write("Enter the date (DD.MM.YYYY): ");
                    time1     = Console.ReadLine();
                    startTime = date1 + " " + time1 + " " + "+05:30";
                    Console.Write("Enter the duration: ");
                    int duration = Convert.ToInt32(Console.ReadLine());
                    Console.Write("Enter the location: ");
                    string location = Console.ReadLine();
                    Console.Write("Enter the description: ");
                    string description = Console.ReadLine();
                    Console.Write("Enter the title: ");
                    string title = Console.ReadLine();
                    Reminders.CreateReminder(startTime, duration, title, description, location);
                    Console.Write("Press any Key to continue... ");
                    Console.ReadKey();
                    break;

                case 5:
                    Console.Clear();
                    Console.Write("Enter the date (DD.MM.YYYY): ");
                    date1 = Console.ReadLine();
                    Console.Write("Enter the date (DD.MM.YYYY): ");
                    time1     = Console.ReadLine();
                    startTime = date1 + " " + time1 + " " + "+05:30";
                    Reminders.GetReminder(startTime);
                    Console.Write("Press any Key to continue... ");
                    Console.ReadKey();
                    break;

                case 6:
                    Console.Clear();
                    Console.Write("Enter the date (DD.MM.YYYY): ");
                    date1 = Console.ReadLine();
                    Console.Write("Enter the date (DD.MM.YYYY): ");
                    time1     = Console.ReadLine();
                    startTime = date1 + " " + time1 + " " + "+05:30";
                    Reminders.DeleteReminder(startTime);
                    Console.Write("Press any Key to continue... ");
                    Console.ReadKey();
                    break;

                case 7:
                    Environment.Exit(0);
                    break;

                default:
                    Console.Clear();
                    Console.WriteLine("Invalid Option !\n");
                    Console.Write("Press any Key to continue... ");
                    Console.ReadKey();
                    break;
                }
            }
        }