Example #1
0
        public async Task CreateMetricIdeaAsync(int?metricId, PlannerTask task, string bucket, string taskURL)
        {
            using (var clientContext = await AuthenticationHelper.GetAppOnlySharePointClientContextAsync())
            {
                var web  = clientContext.Site.RootWeb;
                var list = web.Lists.GetByTitle(SPLists.MetricIdeas.Title);

                var item = list.AddItem(new ListItemCreationInformation());
                if (metricId.HasValue)
                {
                    item[SPLists.MetricIdeas.Columns.Metric] = new FieldLookupValue {
                        LookupId = metricId.Value
                    }
                }
                ;
                item[SPLists.MetricIdeas.Columns.TaskId]   = task.Id;
                item[SPLists.MetricIdeas.Columns.TaskName] = task.Title;
                item[SPLists.MetricIdeas.Columns.TaskURL]  = new FieldUrlValue {
                    Url = taskURL, Description = taskURL
                };
                item[SPLists.MetricIdeas.Columns.TaskStartDate] = task.StartDateTime;
                item[SPLists.MetricIdeas.Columns.InputDate]     = task.CreatedDateTime;
                item[SPLists.MetricIdeas.Columns.TaskStatus]    = bucket;
                item.Update();

                clientContext.ExecuteQuery();
            }
        }
        private void UpdateTaskDetail(PlannerTask task)
        {
            SelectedCategory = null;
            if (task.Title.Equals(_neuAufgabe))
            {
                return;
            }
            PlannerAppliedCategories appliedCategories = task.AppliedCategories;

            System.Reflection.PropertyInfo[] propertyInfos = appliedCategories.GetType().GetProperties();
            foreach (System.Reflection.PropertyInfo propertyInfo in propertyInfos)
            {
                if (propertyInfo.PropertyType == typeof(bool?))
                {
                    if (propertyInfo.GetValue(appliedCategories) == null)
                    {
                        continue;
                    }
                    else if ((bool)propertyInfo.GetValue(appliedCategories) == true)
                    {
                        foreach (CustomCategory i in CustomCategoryGroups)
                        {
                            if (i.Name == propertyInfo.Name)
                            {
                                SelectedCategory = i;
                                return;
                            }
                        }
                    }
                }
            }
            return;
        }
Example #3
0
        public async Task <PlannerTask> AddPlannerTaskAsync(PlannerTask plannerTask)
        {
            signalRMessage.sendMessage($"POST: {graphServiceClient.Planner.Tasks.Request().RequestUrl}");
            var response = await graphServiceClient.Planner.Tasks.Request().AddAsync(plannerTask);

            return(response);
        }
        //https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/planner_post_tasks
        public async Task PlannerTaskCreate()
        {
            // Get a default plan
            var group = await CreateGroup();

            this.testGroup = group;
            await Task.Delay(5000);

            var plannerPlan = await CreatePlan(group);

            PlannerTask taskToCreate = new PlannerTask();

            taskToCreate.PlanId      = plannerPlan.Id;
            taskToCreate.Title       = "New task title";
            taskToCreate.Assignments = new PlannerAssignments();
            taskToCreate.Assignments.AddAssignee("me");
            taskToCreate.AppliedCategories           = new PlannerAppliedCategories();
            taskToCreate.AppliedCategories.Category3 = true;
            taskToCreate.DueDateTime = DateTimeOffset.UtcNow.AddDays(3);

            PlannerTask createdTask = await graphClient.Planner.Tasks.Request().AddAsync(taskToCreate);

            Assert.NotNull(createdTask);
            Assert.Equal(taskToCreate.Title, createdTask.Title);
            Assert.Equal(1, createdTask.Assignments.Count);
            Assert.Equal(createdTask.Assignments.Assignees.First(), createdTask.Assignments.First().Value.AssignedBy.User.Id);
            Assert.Equal(true, createdTask.AppliedCategories.Category3);
            Assert.Equal(taskToCreate.DueDateTime, createdTask.DueDateTime);
        }
Example #5
0
        private void TratarAtribuicoes(PlannerTask task, PlannerTasks objModel)
        {
            if (task.Assignments.Count <= 0)
            {
                return;
            }

            foreach (var assignment in task.Assignments)
            {
                var usuario = _context.Users.FirstOrDefault(p => p.Id == assignment.Key);

                if (usuario == null)
                {
                    var user = _usersService.ObterUsuarioPorId(assignment.Key).Result;
                    usuario = Users.FromModel(user);
                    if (usuario.Tasks == null)
                    {
                        usuario.Tasks = new List <PlannerTasks>();
                    }
                    usuario.Tasks.Add(objModel);
                    _context.Users.Add(usuario);
                    _context.SaveChanges();
                }
                else
                {
                    usuario.Tasks.Add(objModel);
                    _context.Users.Attach(usuario);
                    _context.Entry(usuario).State = EntityState.Modified;
                    _context.SaveChanges();
                }
            }
        }
Example #6
0
        public static async Task <PlannerTask> CreateTaskAsync(PlannerTask task)
        {
            var accessToken   = AuthenticationHelper.GetGraphAccessTokenAsync();
            var tasksEndPoint = string.Format("{0}tasks", AADAppSettings.GraphBetaResourceUrl);

            var requestMessage = new HttpRequestMessage(HttpMethod.Post, tasksEndPoint);

            requestMessage.Content = new StringContent(JsonConvert.SerializeObject(task, new JsonSerializerSettings {
                DefaultValueHandling = DefaultValueHandling.Ignore
            }), System.Text.Encoding.UTF8, "application/json");

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", await accessToken);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                var responseMessage = await client.SendAsync(requestMessage);

                if (responseMessage.StatusCode != System.Net.HttpStatusCode.Created)
                {
                    throw new Exception();
                }

                var payload = await responseMessage.Content.ReadAsStringAsync();

                task      = JsonConvert.DeserializeObject <PlannerTask>(payload);
                task.etag = responseMessage.Headers.ETag;
                return(task);
            }
        }
Example #7
0
        public static async Task UpdateTaskDescriptionAsync(PlannerTask task, string description)
        {
            if (task.etag == null)
            {
                throw new ArgumentNullException("task.etag");
            }

            var accessToken   = AuthenticationHelper.GetGraphAccessTokenAsync();
            var tasksEndPoint = string.Format("{0}tasks/{1}/details", AADAppSettings.GraphBetaResourceUrl, task.id);

            var requestMessage = new HttpRequestMessage(new HttpMethod("PATCH"), tasksEndPoint);

            TaskDetails details = new TaskDetails {
                description = description, previewType = "description"
            };

            requestMessage.Content = new StringContent(JsonConvert.SerializeObject(details), System.Text.Encoding.UTF8, "application/json");

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", await accessToken);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.IfMatch.Add(new EntityTagHeaderValue(task.etag.Tag, task.etag.IsWeak));
                var responseMessage = await client.SendAsync(requestMessage);

                if (responseMessage.StatusCode != System.Net.HttpStatusCode.NoContent)
                {
                    throw new Exception();
                }
            }
        }
Example #8
0
        public async Task <PlannerTask> CreateAsync(string planId, string title, DateTimeOffset?startDate, string ownerId, string description)
        {
            var newIdearBucket = await plannerService.GetNewIdeaBucketAsync(planId);

            if (newIdearBucket == null)
            {
                throw new ApplicationException("Could not found New Idea bucket.");
            }

            var plannerTask = new PlannerTask
            {
                PlanId        = planId,
                BucketId      = newIdearBucket.Id,
                Title         = title,
                StartDateTime = startDate,
                Assignments   = new PlannerAssignments()
            };

            plannerTask.Assignments.AddAssignee(ownerId);
            plannerTask = await graphServiceClient.Planner.Tasks.Request().AddAsync(plannerTask);

            //await Task.Delay(3000);

            var planerTaskDetails = new PlannerTaskDetails {
                Description = description
            };
            var plannerTaskRequestBuilder = graphServiceClient.Planner.Tasks[plannerTask.Id];

            PlannerTaskDetails details = null;

            int count = 1;

            while (true)
            {
                try
                {
                    details = await plannerTaskRequestBuilder.Details.Request().GetAsync();

                    break;
                }
                catch (Exception ex)
                {
                    if (count < 6)
                    {
                        await Task.Delay(1000);
                    }
                    else
                    {
                        throw new Exception("Task created. But failed to create its details. ", ex);
                    }
                }
                count++;
            }

            details = await plannerTaskRequestBuilder.Details
                      .Request(new[] { new HeaderOption("If-Match", details.GetEtag()) })
                      .UpdateAsync(planerTaskDetails);

            return(plannerTask);
        }
        private async Task CreateTaskSDK(MyTask myTask)
        {
            if (myTask == null)
            {
                return;
            }

            if (String.IsNullOrWhiteSpace(myTask.planId))
            {
                return;
            }

            if (String.IsNullOrWhiteSpace(myTask.title))
            {
                return;
            }

            try
            {
                var graphServiceClient = await GetGraphServiceAsync();

                var plannerTask = new PlannerTask
                {
                    Title           = myTask.title,
                    PlanId          = myTask.planId,
                    PercentComplete = myTask.percentComplete
                };

                await graphServiceClient.Planner.Tasks.Request().AddAsync(plannerTask);
            }
            catch (Exception)
            {
            }
        }
Example #10
0
 public ConfigurationGeneral(General General_, Paths paths_, PlannerTask plannerTask_, PriceType priceType_, Reprocess reprocess_)
 {
     this.general     = General_;
     this.paths       = paths_;
     this.plannerTask = plannerTask_;
     this.priceType   = priceType_;
     this.reprocess   = reprocess_;
 }
Example #11
0
        //private void Executable_TV_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        //{
        //    if (SelectedTask != null)
        //    {
        //        SelectedTask.Seeing_TBlock = Visibility.Collapsed;
        //        SelectedTask.Seeing_TBox = Visibility.Visible;
        //        SelectedTask.IsExpanded = false;
        //    }
        //}

        private void InProgress_TV_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (SelectedTask != null)
            {
                SelectedTask.IsSelected = false;
            }
            SelectedTask = null;
        }
    public void SetPersonNames()
    {
        PlannerTask refTask = detailTask.refTask.GetComponent <PlannerTask>();

        refTask.fee     = fee;
        refTask.sam     = sam;
        refTask.chris   = chris;
        refTask.terence = terence;
    }
        /// <summary>
        /// Reads a value from the spreadsheet.
        /// </summary>
        /// <returns>The value that was read.</returns>
        public PlannerTask Read()
        {
            while (!_currentRow.IsEmpty())
            {
                /*
                 * Percentage complete (0-100)
                 *   todo:          0
                 *   in progress:  50
                 *   completed:   100
                 * Task priority (0-10)
                 *   urgent:    0, 1*
                 *   important: 2, 3*, 4
                 *   medium:    5*, 6, 7
                 *   low:       8, 9*, 10
                 */

                PlannerTask task;

                try
                {
                    var title           = _currentRow.Cell(1).GetValue <string>();
                    var percentComplete = _currentRow.Cell(2).GetValue <int>();
                    var priority        = _currentRow.Cell(3).GetValue <int>();
                    var orderHint       = _currentRow.Cell(4).GetValue <string>();
                    var description     = _currentRow.Cell(5).GetValue <string>();

                    task = new PlannerTask
                    {
                        Title           = title,
                        PercentComplete = percentComplete,
                        Priority        = priority,
                        OrderHint       = orderHint,
                        TaskDetail      = new TaskDetailResponse
                        {
                            Description = description,
                            Checklist   = new Dictionary <string, Checklist>(),
                            References  = new Dictionary <string, Reference>(),
                        },
                    };
                }
                catch
                {
                    // Skip row
                    continue;
                }
                finally
                {
                    GoToNextRow();
                }

                return(task);
            }

            // End of file
            return(null);
        }
Example #14
0
        public ActionResult ModalEditTask(int id)
        {
            PlannerTask pt = db.Tasks.FirstOrDefault(task => task.Id == id);

            if (pt != null)
            {
                return(PartialView(pt));
            }
            return(HttpNotFound());
        }
 private void UpdateDescription(PlannerTask task)
 {
     if (task.Title.Equals(_neuAufgabe))
     {
         Description = "";
     }
     else
     {
         Description = _graphClient.Planner.Tasks[_selectedTask.Id].Details.Request().GetAsync().Result.Description;
     }
 }
 private void UpdateDueDate(PlannerTask task)
 {
     if (task.DueDateTime == null)
     {
         SelectedDueDate = null;
     }
     else
     {
         SelectedDueDate = task.DueDateTime.Value.DateTime;
     }
 }
Example #17
0
        public RedirectResult Move(int id, string where)
        {
            PlannerTask pt = db.Tasks.SingleOrDefault(task => task.Id == id);

            if (pt != null)
            {
                pt.Status = where.Equals("current") ? "Текущее задание" : "Просроченное задание";
                db.SaveChanges();
            }
            return(Redirect("/"));
        }
Example #18
0
        public RedirectResult Delete(int id)
        {
            var task = new PlannerTask {
                Id = id
            };

            db.Tasks.Attach(task);
            db.Tasks.Remove(task);
            db.SaveChanges();
            return(Redirect("/"));
        }
        public void StartExchange_TestLos_10110()
        {
            ControllerOfOutput  co  = new ControllerOfOutput(true);
            FakeLogOfSuccession los = new FakeLogOfSuccession(false);
            PlannerText         pln = new PlannerText(co, los);

            PlannerTask tmpTask1 = new PlannerTask(false);

            tmpTask1.id = 1;
            tmpTask1.uploadDownload.Add(new FileSupertypeFake(1, 2, WorkResult.Success, false, ActionType.Source));
            tmpTask1.uploadDownload.Add(new FileSupertypeFake(1, 2, WorkResult.Success, false, ActionType.Destination));
            pln.tasks.Add(tmpTask1);

            PlannerTask tmpTask2 = new PlannerTask(false);

            tmpTask2.id = 2;
            tmpTask2.uploadDownload.Add(new FileSupertypeFake(1, 3, WorkResult.Error, false, ActionType.Source));
            tmpTask2.uploadDownload.Add(new FileSupertypeFake(2, 4, WorkResult.Error, false, ActionType.Destination));
            pln.tasks.Add(tmpTask2);

            PlannerTask tmpTask3 = new PlannerTask(false);

            tmpTask3.id = 3;
            tmpTask3.uploadDownload.Add(new FileSupertypeFake(1, 3, WorkResult.Other, false, ActionType.Source));
            tmpTask3.uploadDownload.Add(new FileSupertypeFake(2, 4, WorkResult.Other, false, ActionType.Destination));
            pln.tasks.Add(tmpTask3);

            PlannerTask tmpTask4 = new PlannerTask(false);

            tmpTask4.id = 4;
            tmpTask4.uploadDownload.Add(new FileSupertypeFake(1, 3, WorkResult.NothingHappens, false, ActionType.Source));
            tmpTask4.uploadDownload.Add(new FileSupertypeFake(2, 4, WorkResult.NothingHappens, false, ActionType.Destination));
            pln.tasks.Add(tmpTask4);

            PlannerTask tmpTask5 = new PlannerTask(false);

            tmpTask5.id = 5;
            tmpTask5.uploadDownload.Add(new FileSupertypeFake(1, 3, WorkResult.Success, false, ActionType.Source));
            tmpTask5.uploadDownload.Add(new FileSupertypeFake(1, 3, WorkResult.Success, false, ActionType.Source));
            tmpTask5.uploadDownload.Add(new FileSupertypeFake(1, 3, WorkResult.Error, false, ActionType.Source));
            tmpTask5.uploadDownload.Add(new FileSupertypeFake(2, 4, WorkResult.Success, false, ActionType.Destination));
            tmpTask5.uploadDownload.Add(new FileSupertypeFake(2, 4, WorkResult.Success, false, ActionType.Destination));
            tmpTask5.uploadDownload.Add(new FileSupertypeFake(2, 4, WorkResult.Other, false, ActionType.Destination));
            pln.tasks.Add(tmpTask5);

            ResultController rc = pln.StartExchange();

            Assert.True(los.boolResultSaved[0]);
            Assert.False(los.boolResultSaved[1]);
            Assert.True(los.boolResultSaved[2]);
            Assert.True(los.boolResultSaved[3]);
            Assert.False(los.boolResultSaved[4]);
        }
        private async void Add_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                GraphServiceClient graphClient = await GraphServiceHelper.GetGraphServiceClientAsync();

                if (graphClient != null &&
                    !string.IsNullOrWhiteSpace(_input?.Text))
                {
                    PlannerTask task = new PlannerTask
                    {
                        Title = _input.Text
                    };
                    if (TaskType != TaskTypeAllTasksId && TaskType != TaskTypeClosedTasksId)
                    {
                        task.BucketId = TaskType;
                    }

                    task.PlanId = PlanId;
                    _input.Text = string.Empty;
                    CanAddTask  = false;
                    PlannerTask taskCreated = await graphClient.Planner.Tasks.Request().AddAsync(task);

                    PlannerPlan                 plan          = Plans.FirstOrDefault(s => s.Id == InternalPlanId);
                    PlannerTaskViewModel        taskViewModel = new PlannerTaskViewModel(taskCreated);
                    Dictionary <string, string> buckets       = Buckets.ToDictionary(s => s.Id, s => s.Name);
                    if (plan != null)
                    {
                        taskViewModel.GroupId = plan.Owner;
                    }

                    if (!string.IsNullOrEmpty(taskViewModel.BucketId) && buckets.ContainsKey(taskViewModel.BucketId))
                    {
                        taskViewModel.BucketName = buckets[taskViewModel.BucketId];
                    }

                    if (taskCreated.PlanId == InternalPlanId)
                    {
                        taskViewModel.PropertyChanged += TaskViewModel_PropertyChanged;
                        _allTasks.Add(taskViewModel);
                        Tasks.Insert(0, taskViewModel);
                    }
                }
            }
            catch (Exception exception)
            {
                MessageDialog messageDialog = new MessageDialog(exception.Message);
                await messageDialog.ShowAsync();
            }

            CanAddTask = true;
        }
Example #21
0
        private void OnDisable()
        {
            if (this.m_rootTask != null)
            {
                if (this.m_rootTask.GetStatus() == EBTStatus.BT_RUNNING)
                {
                    this.m_rootTask.abort(this.agent);
                    BehaviorTask.DestroyTask(this.m_rootTask);
                }

                this.m_rootTask = null;
            }
        }
Example #22
0
    public static async Task <PlannerTask> AddPlannerTask(PlannerTask plannerTask, string clientId)
    {
        var graphClient = GetAuthenticatedClient();

        if (!string.IsNullOrEmpty(clientId))
        {
            var hubContext = GlobalHost.ConnectionManager.GetHubContext <MwHub>();
            hubContext.Clients.Client(clientId).addMessage("POST: " + graphClient.Planner.Tasks.Request().RequestUrl);
        }
        var response = await graphClient.Planner.Tasks.Request().AddAsync(plannerTask);

        return(response);
    }
    public void GetPersonNames()
    {
        PlannerTask refTask = detailTask.refTask.GetComponent <PlannerTask>();

        fee     = refTask.fee;
        sam     = refTask.sam;
        chris   = refTask.chris;
        terence = refTask.terence;

        SetPerson("fee", feeObj, fee);
        SetPerson("sam", samObj, sam);
        SetPerson("chris", chrisObj, chris);
        SetPerson("terence", terenceObj, terence);
    }
        public void StartExchange_NothingHappensFiles_NothingHappens()
        {
            PlannerText pln = this.GetPlannerText();

            PlannerTask tmpTask1 = new PlannerTask(false);

            tmpTask1.uploadDownload.Add(new FileSupertypeFake(1, 2, WorkResult.NothingHappens, false, ActionType.Source));
            tmpTask1.uploadDownload.Add(new FileSupertypeFake(1, 2, WorkResult.NothingHappens, false, ActionType.Destination));
            pln.tasks.Add(tmpTask1);

            ResultController rc = pln.StartExchange();

            Assert.AreEqual(rc.globalWorkRes, WorkResult.NothingHappens);
        }
Example #25
0
        /// <summary>
        /// Изменение выделенного элемента
        /// </summary>
        /// <param name="tree"></param>
        private void SelectedItemChanged(TreeView tree)
        {
            if (SelectedTask != null)
            {
                SelectedTask.IsSelected = false;
                SelectedTask.IsExpanded = false;
            }

            if (tree.SelectedItem != null)
            {
                SelectedTask            = (PlannerTask)tree.SelectedItem;
                SelectedTask.IsSelected = true;
            }
        }
    private void DisplayedToRef(GameObject refObj, GameObject displayedObj)
    {
        //gets the variables from displayed
        PlannerTask      refTask = refObj.GetComponent <PlannerTask>();
        PlannerDetailObj disTask = displayedObj.GetComponent <PlannerDetailObj>();

        refTask.taskName        = GetLabel(disTask.taskNameObj);
        refTask.taskDescription = GetLabel(disTask.taskDescriptionObj);
        refTask.taskColour      = disTask.taskColourObj.GetComponent <UISprite>().color;

        //set name tags
        disTask.nameToggle.SetPersonNames();
        //show the edit in thumbnail
        refTask.SetDisplayedTask();
    }
Example #27
0
        public RedirectResult Edit(int id, string taskName, string taskDescription, DateTime?taskDeadline, string[] taskTags, string taskStatus)
        {
            PlannerTask pt = db.Tasks.SingleOrDefault(task => task.Id == id);

            if (pt != null)
            {
                pt.Header      = taskName;
                pt.Description = taskDescription;
                pt.Deadline    = (DateTime)taskDeadline;
                pt.Status      = taskStatus;
                pt.FormTags(taskTags);
                db.SaveChanges();
            }
            return(Redirect("/"));
        }
Example #28
0
        public RedirectResult Add(string taskName, string taskDescription, DateTime?taskDeadline, string[] taskTags, string taskStatus)
        {
            PlannerTask pt = new PlannerTask()
            {
                Header      = taskName,
                Description = taskDescription,
                Deadline    = (DateTime)taskDeadline,
                Status      = taskStatus
            };

            pt.FormTags(taskTags);
            db.Tasks.Add(pt);
            db.SaveChanges();
            return(Redirect("/"));
        }
    private void RefToDisplayed(GameObject refObj, GameObject displayedObj)
    {
        //gets the variables from ref
        PlannerTask      refTask = refObj.GetComponent <PlannerTask>();
        PlannerDetailObj disTask = displayedObj.GetComponent <PlannerDetailObj>();

        disTask.id = refTask.id;
        SetLabel(disTask.taskNameObj, refTask.taskName);
        SetLabel(disTask.taskDescriptionObj, refTask.taskDescription);
        disTask.taskColourObj.GetComponent <UISprite>().color = refTask.taskColour;

        //get name tags
        disTask.nameToggle.GetPersonNames();

        //set UIButton default colour
        disTask.taskNameList.GetComponent <UIButton>().defaultColor = refTask.taskColour;
    }
        private void UpdateCustomPercentComplete(PlannerTask task)
        {
            if (task.Title == _neuAufgabe)
            {
                SelectedPercentComplete = CustomPercentCompleteGroups[0];
                return;
            }

            foreach (CustomPercentComplete i in CustomPercentCompleteGroups)
            {
                if (i.Value == task.PercentComplete)
                {
                    SelectedPercentComplete = i;
                    return;
                }
            }
        }
Example #31
0
    public void UploadTask(PlannerTask task)
    {
        uploadQueue.Clear();

        //update task
        WWWForm form = new WWWForm();

        form.AddField("id", task.id);
        form.AddField("Tsk_Name", task.taskName);
        form.AddField("Tsk_Description", task.taskDescription);
        form.AddField("Tsk_Fee", BoolToString(task.fee));
        form.AddField("Tsk_Sam", BoolToString(task.sam));
        form.AddField("Tsk_Chris", BoolToString(task.chris));
        form.AddField("Tsk_Terence", BoolToString(task.terence));

        uploadQueue.AddLast(form);
    }
Example #32
0
 private void raiseTaskSucceeded(PlannerTask task)
 {
     if (task != null && this.TaskSucceeded != null)
     {
         this.TaskSucceeded(this, task);
     }
 }
Example #33
0
        private void raisePlanFailed(PlannerTask task)
        {
            if (this.TaskFailed != null)
            {
                this.TaskFailed(this, task);
            }

            if (this.PlanFailed != null)
            {
                this.PlanFailed(this, task);
            }
        }
Example #34
0
        private void doAutoPlanning()
        {
            if (!this.AutoReplan)
            {
                return;
            }

            var noPlan = this.m_rootTask == null || this.m_rootTask.GetStatus() != EBTStatus.BT_RUNNING;

            if (noPlan)
            {
                PlannerTask newPlan = this.GeneratePlan();

                if (newPlan != null)
                {
                    if (this.m_rootTask != null)
                    {
                        if (this.m_rootTask.GetStatus() == EBTStatus.BT_RUNNING)
                        {
                            this.m_rootTask.abort(this.agent);
                        }

                        BehaviorTask.DestroyTask(this.m_rootTask);
                    }

                    this.m_rootTask = newPlan;
                }
            }
        }
Example #35
0
 private void raisePlanAborted(PlannerTask task)
 {
     if (this.PlanAborted != null)
     {
         this.PlanAborted(this, task);
     }
 }
Example #36
0
        private void doAutoPlanning()
        {
            if (!this.AutoReplan)
            {
                return;
            }

            this.timeTillReplan -= Workspace.Instance.DeltaTime;

            var noPlan = this.m_rootTask == null || this.m_rootTask.GetStatus() != EBTStatus.BT_RUNNING;

            //if (noPlan || timeTillReplan <= 0)
            if (noPlan)
            {
                timeTillReplan += AutoReplanInterval;

                PlannerTask newPlan = this.GeneratePlan();

                if (newPlan != null)
                {
                    if (this.m_rootTask != null)
                    {
                        if (this.m_rootTask.GetStatus() == EBTStatus.BT_RUNNING)
                        {
                            this.m_rootTask.abort(this.agent);
                            raisePlanAborted(this.m_rootTask);
                        }

                        BehaviorTask.DestroyTask(this.m_rootTask);
                    }

                    this.m_rootTask = newPlan;
                }
            }
        }