Beispiel #1
0
        void DeleteTask()
        {
            if (SelectedTask != null && CurrentEnvironment != null)
            {
                if (CurrentEnvironment.IsConnected)
                {
                    if (CurrentEnvironment.AuthorizationService.IsAuthorized(AuthorizationContext.Administrator, null))
                    {
                        if (_popupController.ShowDeleteConfirmation(SelectedTask.Name) == MessageBoxResult.Yes)
                        {
                            int index = ScheduledResourceModel.ScheduledResources.IndexOf(SelectedTask);
                            int indexInFilteredList = TaskList.IndexOf(SelectedTask);
                            if (index != -1)
                            {
                                Dev2Logger.Log.Info(String.Format("Delete Schedule Name: {0} Resource:{1} Env:{2}", SelectedTask.Name, SelectedTask.ResourceId, CurrentEnvironment.Name));

                                ScheduledResourceModel.DeleteSchedule(SelectedTask);
                                //if delete is successfull then do the code below
                                ScheduledResourceModel.ScheduledResources.RemoveAt(index);
                                NotifyOfPropertyChange(() => TaskList);
                                if (indexInFilteredList <= TaskList.Count && indexInFilteredList > 0)
                                {
                                    SelectedTask = TaskList[indexInFilteredList - 1];
                                }
                                else if (indexInFilteredList == 0 && TaskList.Count > 0)
                                {
                                    SelectedTask = TaskList[0];
                                }
                            }
                            NotifyOfPropertyChange(() => History);
                        }
                    }
                    else
                    {
                        ShowError(@"Error while saving: You don't have permission to schedule on this server.
You need Administrator permission.");
                    }
                }
                else
                {
                    ShowError(NotConnectedErrorMessage);
                }
            }
        }