Пример #1
0
    //Function to display the menu after choosing '1' in the main menu
    private void showSubMenu1()
    {
        if (unfinishedList.Count > 0)
        {
            System.Console.Clear();
            System.Console.WriteLine("Här är listan över alla uppgifter:");

            foreach (Task task in unfinishedList)
            {
                if (task is TaskType1)
                {
                    TaskType1 item1 = (TaskType1)task;
                    System.Console.WriteLine($" Id: {item1.getId()}, Namn: {item1.getName()}. Nuvarande status: {item1.getStatus()}, Är kontrollerad: {item1.getIsChecked()}");
                }
                else
                {
                    TaskType2 item2 = (TaskType2)task;
                    System.Console.WriteLine($" Id: {item2.getId()}, Namn: {item2.getName()}. Nuvarande status: {item2.getStatus()}, Datum: {item2.getDate().ToString("yyyy/MM/dd")}");
                }
            }
        }
        else
        {
            System.Console.Write("\nListan är tom, vänlige lägg till nya uppgifter");
            Animate('.', 100, 10);
            showMenu();
        }
        showSubMenu1_1();
    }
Пример #2
0
        //Add 2 entries to the list
        public void Test1()
        {
            //Arrange
            Menu menu  = new Menu();
            Task task1 = new TaskType1(1, "Task 1", Status.leftToDo, true);
            Task task2 = new TaskType2(2, "Task 2", Status.Done, DateTime.Today);

            menu.unfinishedList.Add(task1);
            menu.unfinishedList.Add(task2);

            //Act
            var expected = 2;
            var result   = menu.unfinishedList.Count;

            //Assert
            Assert.Equal(expected, result);
        }
Пример #3
0
        //Archive all completed information
        public void Test3()
        {
            //Arrange
            Menu menu  = new Menu();
            Task task1 = new TaskType1(1, "Task 1", Status.leftToDo, true);
            Task task2 = new TaskType1(2, "Task 2", Status.Done, true);
            Task task3 = new TaskType2(3, "Task 3", Status.leftToDo, DateTime.Today);
            Task task4 = new TaskType2(4, "Task 4", Status.Done, DateTime.Today);

            menu.unfinishedList.Add(task1);
            menu.unfinishedList.Add(task2);
            menu.unfinishedList.Add(task3);
            menu.unfinishedList.Add(task4);

            //Act
            List <Task> expected = new List <Task>();

            expected.Add(task2);
            expected.Add(task4);
            menu.archiveAllTasks();

            //Assert
            Assert.Equal(expected, menu.finishedList);
        }
Пример #4
0
        public override void ExecuteCRMWorkFlowActivity(CodeActivityContext executionContext, LocalWorkflowContext crmWorkflowContext)
        {
            ITracingService      tracingService      = executionContext.GetExtension <ITracingService>();
            IOrganizationService organisationService = crmWorkflowContext.OrganizationService;

            tracingService.Trace("Started...");



            EntityReference application = Application.Get(executionContext);

            if (application == null || application.Id == Guid.Empty)
            {
                throw new ArgumentException("Application parameter is invalid", nameof(application));
            }

            // Read the task type ids to filter application tasks by
            List <Guid> taskTypeIds = new List <Guid>();

            AddIdToList(TaskType1.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType2.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType3.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType4.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType5.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType6.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType7.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType8.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType9.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType10.Get(executionContext), taskTypeIds);
            Guid[] taskTypeIdArray = taskTypeIds.ToArray();

            var fetchCrBuilder = "";

            foreach (var task in taskTypeIdArray)
            {
                fetchCrBuilder += "<value>{" + task.ToString() + "}</value>";
            }

            var fetch = @"<fetch>
                              <entity name='defra_applicationtaskdefinition'>
                                <attribute name='defra_applicationtaskdefinitionid' />
                                <filter type='and'>
                                  <condition attribute='defra_tasktypeid' operator='in'>
                                   " + fetchCrBuilder + @"
                                  </condition>
                                  <condition attribute='statecode' operator='eq' value='0' />
                                </filter>
                              </entity>
                            </fetch>";

            tracingService.Trace(string.Format("fetchXML: {0}", fetch));

            tracingService.Trace("Try to run RetrieveMultiple...");
            var appTaskdefs = organisationService.RetrieveMultiple(new FetchExpression(fetch)).Entities;

            if (appTaskdefs.Count == 0)
            {
                return;
            }

            tracingService.Trace("DataAccessApplicationTask");
            DataAccessApplicationTask dalAppTask = new DataAccessApplicationTask(organisationService, tracingService);

            tracingService.Trace("DataAccessApplication");
            DataAccessApplication dalApp = new DataAccessApplication(organisationService, tracingService);

            tracingService.Trace("GetApplicationTypeAndOwner");
            ApplicationTypesAndOwners applicationDetails = dalApp.GetApplicationTypeAndOwner(application.Id);


            foreach (var appTaskdef in appTaskdefs)
            {
                tracingService.Trace(string.Format("Create application task name: {0}", appTaskdef.Id.ToString()));
                dalAppTask.CreateApplicationTask(application.Id, applicationDetails.OwningUser, applicationDetails.OwningTeam, appTaskdef.Id);
            }

            tracingService.Trace("Finished");
        }
Пример #5
0
        /// <summary>
        /// Main code activity methoid
        /// </summary>
        /// <param name="executionContext">Standard CRM execution context</param>
        /// <param name="crmWorkflowContext">Standard CRM workflow context</param>
        public override void ExecuteCRMWorkFlowActivity(CodeActivityContext executionContext, LocalWorkflowContext crmWorkflowContext)
        {
            // 1. SETUP

            ITracingService      tracingService      = executionContext.GetExtension <ITracingService>();
            IOrganizationService organisationService = crmWorkflowContext.OrganizationService;

            tracingService.Trace("Started");

            // Validation
            EntityReference application = Application.Get(executionContext);

            if (application == null || application.Id == Guid.Empty)
            {
                throw new ArgumentException("Application parameter is invalid", nameof(application));
            }

            // Read the task type ids to filter application tasks by
            List <Guid> taskTypeIds = new List <Guid>();

            AddIdToList(TaskType1.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType2.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType3.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType4.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType5.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType6.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType7.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType8.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType9.Get(executionContext), taskTypeIds);
            AddIdToList(TaskType10.Get(executionContext), taskTypeIds);
            Guid[] taskTypeIdArray = taskTypeIds.ToArray();

            // Prepare the DALs
            DataAccessApplicationTask dalAppTask = new DataAccessApplicationTask(organisationService, tracingService);
            DataAccessApplication     dalApp     = new DataAccessApplication(organisationService, tracingService);

            // 2. PROCESSING

            // Get Application Type, SubType and owners
            ApplicationTypesAndOwners applicationDetails = dalApp.GetApplicationTypeAndOwner(application.Id);

            // Which tasks should be linked to the application?
            List <Guid> applicableTasks = dalAppTask.GetTaskDefinitionIdsThatApplyToApplication(application.Id, applicationDetails.ApplicationType, applicationDetails.ApplicationSubType, taskTypeIdArray) ?? new List <Guid>();

            // Which tasks are already linked?
            List <ApplicationTaskAndDefinitionId> existingTasks = dalAppTask.GetApplicationTaskIdsLinkedToApplication(application.Id, taskTypeIdArray) ?? new List <ApplicationTaskAndDefinitionId>();

            // Deactivate application tasks that no longer apply
            List <Guid> tasksToRemove = existingTasks.Where(existingTask => !applicableTasks.Contains(existingTask.ApplicationTaskDefinitionId))
                                        .Select(t => t.ApplicationTaskId)
                                        .ToList();

            tasksToRemove.ForEach(dalAppTask.DeactivateApplicationTask);

            // Create application tasks that apply
            List <Guid> tasksToAdd = applicableTasks.Where(applicableTask => existingTasks.All(t => t.ApplicationTaskDefinitionId != applicableTask)).ToList();

            tasksToAdd.ForEach(newtask => dalAppTask.CreateApplicationTask(application.Id, applicationDetails.OwningUser, applicationDetails.OwningTeam, newtask));

            tracingService.Trace("Done");
        }