当前位置: 首页>>代码示例>>C#>>正文


C# Task.UpdateAssignees方法代码示例

本文整理汇总了C#中Task.UpdateAssignees方法的典型用法代码示例。如果您正苦于以下问题:C# Task.UpdateAssignees方法的具体用法?C# Task.UpdateAssignees怎么用?C# Task.UpdateAssignees使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Task的用法示例。


在下文中一共展示了Task.UpdateAssignees方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestOverdueTasks

        public void TestOverdueTasks()
        {
            InitOrgStore();
            IndexOrgStore();
            var assignedUser = new User { Id = IlluminateDatabase.GenerateId<User>(), NameIdentifier = "nameidentifier", OrgKey = "OrgKey", EmailAddress = "[email protected]", DateOfBirth = new DateTime(1990, 1, 1), FirstName = "Test", LastName = "User", Config = new Config { Settings = new Dictionary<string, object>() } };
            var newtask = new Task
            {
                Id = IlluminateDatabase.GenerateId<Task>(),
                Type = new TaskType { Name = "test task" },
                DueDate = DateTime.Now.AddDays(-1),
                ConsolidatedCompletionDate = DateTime.Now,
                CreatedBy = Orguser.ToSimpleUser(),
                Title = "test task title",
                Description = "test task description",
                AssignedUsers = new List<SimpleUser> { assignedUser .ToSimpleUser()}
            };
            //store the task in the db
            using (var session = OrgStore.OpenSession())
            {
                session.Store(assignedUser);
                session.Store(newtask);
                
                
                session.SaveChanges();
                newtask.UpdateAssignees(session);
                while (OrgStore.DatabaseCommands.GetStatistics().StaleIndexes.Length != 0)
                {
                    Thread.Sleep(100);
                }

                var result = Task.GetNumberOverdueContextTasks(assignedUser.Id, null, session);
                Assert.AreEqual(1,result);

                //pretend user completes task

                newtask.CompletedDate = DateTime.Now;
                newtask.ConsolidatedCompletionDate = DateTime.Now;
                session.SaveChanges();
                while (OrgStore.DatabaseCommands.GetStatistics().StaleIndexes.Length != 0)
                {
                    Thread.Sleep(100);
                }

                result = Task.GetNumberOverdueContextTasks(assignedUser.Id, null, session);
                Assert.AreEqual(0, result);
            }

        }
开发者ID:andyevans2000,项目名称:Illuminate,代码行数:48,代码来源:TaskTests.cs

示例2: PerformAction

        /// <summary>
        /// perform an action on the leave process
        /// </summary>
        /// <param name="documentStore">The RavenDB document store to be used</param>
        /// <param name="triggerprocess">The initiator process - e.g. leave or sickness</param>
        /// <param name="action">The action to be performed</param>
        public override void PerformAction(IDocumentStore documentStore,
                                            WorkflowInitiator triggerprocess,
                                           WorkflowHandlerAction action)
        {
            //we know its a Leave so cast it to the correct type
            var leave = (Leave) triggerprocess;

            switch (action.Action) //depending on the type of action do different things
            {
                case WorkflowHandlerAction.Actions.AddTask: //add a task
                    //what am I creating?
                    var actionmodel = action.DeserialiseObject<CreateProcessTaskActionModel>();

                    //need to convert the actionmodel into an event.
                    var newtask = new Task
                                      {
                                          Id = IlluminateDatabase.GenerateId<Task>(),
                                          Type = new TaskType {Name = actionmodel.TaskName},
                                          AssignedRoles =
                                              (from role in actionmodel.AssignedRoles select Role.GetRole(role)).ToList(),
                                          DueDate = actionmodel.DueDate,
                                          ConsolidatedCompletionDate = actionmodel.DueDate,
                                          CreatedBy = leave.UserCreatedProcess,
                                          Title = actionmodel.Title,
                                          Description = actionmodel.Description,
                                          ParentItemId = leave.Id
                                      };
                    using (var session = documentStore.OpenSession())
                    {
                        session.Store(newtask);
                        newtask.UpdateAssignees(session, leave.Subject.UserId);
                        session.SaveChanges();
                    }

                    break;
                case WorkflowHandlerAction.Actions.AddMeeting: //add a meeting

                    var meetingactionmodel = action.DeserialiseObject<CreateProcessMeetingActionModel>();

                    //need to convert the actionmodel into an event. but problem is looking up user?
                    var newMeeting = new Meeting
                                         {
                                             Id = IlluminateDatabase.GenerateId<Meeting>(),
                                             Type = new TaskType {Name = meetingactionmodel.TaskName},
                                             AssignedRoles =
                                                 (from role in meetingactionmodel.AssignedRoles
                                                  select Role.GetRole(role)).ToList(),
                                             Invitees = new List<Invitee> {Invitee.FromSimpleUser(leave.Subject)},
                                             DueDate = meetingactionmodel.DueDate,
                                             ConsolidatedCompletionDate = meetingactionmodel.DueDate,
                                             CreatedBy = leave.UserCreatedProcess,
                                             Title = meetingactionmodel.Title,
                                             Description = meetingactionmodel.Description,
                                             ParentItemId = leave.Id,
                                             DurationMinutes = 30
                                         };
                    //now save the new mmeeting
                    using (var session = documentStore.OpenSession())
                    {
                        session.Store(newMeeting);
                        newMeeting.UpdateAssignees(session, leave.Subject.UserId);
                        session.SaveChanges();
                    }

                    break;
                case WorkflowHandlerAction.Actions.DeleteTask: //delete scheduled a task

                    using (var session = documentStore.OpenSession())
                    {
                        var task = session.Load<Task>(action.Value);
                        session.Delete(task);
                        session.SaveChanges();
                    }
                    break;
                case WorkflowHandlerAction.Actions.DeleteMeeting: //delete a scheduled meeting
                    using (var session = documentStore.OpenSession())
                    {
                        var meeting = session.Load<Meeting>(action.Value);
                        session.Delete(meeting);
                        session.SaveChanges();
                    }
                    break;
            }
        }
开发者ID:andyevans2000,项目名称:Illuminate,代码行数:90,代码来源:DefaultLeaveWorkflow.cs

示例3: PerformAction

        /// <summary>
        /// Perform an action on the default sickness workflow
        /// </summary>
        /// <param name="documentStore">The document store to use</param>
        /// <param name="triggerprocess">The workflow initiator that triggered this</param>
        /// <param name="action">The action to be performed</param>
        public override void PerformAction(IDocumentStore documentStore, WorkflowInitiator triggerprocess, WorkflowHandlerAction action)
        {
            var sickness = (Sickness) triggerprocess; //we know its a sickness so cast to it

            switch (action.Action) //depending on the action type act accordingly
            {
                case WorkflowHandlerAction.Actions.AddTask:
                    //what am I creating? - deserialise the contents of the action
                    var actionModel = action.DeserialiseObject<CreateProcessTaskActionModel>();

                    //need to convert the actionmodel into an event - in this case a task
                    var newtask = new Task
                                        {
                                            Id = IlluminateDatabase.GenerateId<Task>(),
                                            Type = new TaskType {Name = actionModel.TaskName},
                                            AssignedRoles = (from role in actionModel.AssignedRoles select Role.GetRole(role)).ToList(),
                                            DueDate = actionModel.DueDate,
                                            ConsolidatedCompletionDate = actionModel.DueDate>=DateTime.Now ? actionModel.DueDate : DateTime.Now,
                                            CreatedBy = sickness.UserCreatedProcess,
                                            Title =string.Format( actionModel.Title,sickness.Subject.FullName),
                                            Description = string.Format( actionModel.Description,sickness.Subject.FullName),
                                            ParentItemId = sickness.Id
                                        };
                    //store the task in the db
                    using (var session = documentStore.OpenSession())
                    {
                        session.Store(newtask);
                        newtask.UpdateAssignees(session, sickness.Subject.UserId);
                        session.SaveChanges();
                    }
                    
                    break;
                case WorkflowHandlerAction.Actions.AddMeeting:
   
                    var meetingactionmodel = action.DeserialiseObject<CreateProcessMeetingActionModel>();

                    //need to convert the actionmodel into an event. but problem is looking up user?
                    var newmeeting = new Meeting
                    {
                        Id = IlluminateDatabase.GenerateId<Meeting>(),
                        Type = new TaskType { Name = meetingactionmodel.TaskName },
                        AssignedRoles = (from role in meetingactionmodel.AssignedRoles select Role.GetRole(role)).ToList(),
                        Invitees = new List<Invitee> { Invitee.FromSimpleUser(sickness.Subject)},
                        DueDate = meetingactionmodel.DueDate,
                        ConsolidatedCompletionDate = meetingactionmodel.DueDate >= DateTime.Now ? meetingactionmodel.DueDate : DateTime.Now,
                        CreatedBy = sickness.UserCreatedProcess,
                        Title = meetingactionmodel.Title,
                        Description = meetingactionmodel.Description,
                        ParentItemId = sickness.Id
                    };
                    //save the meeting in the DB
                    using (var session = documentStore.OpenSession())
                    {
                        session.Store(newmeeting);
                        newmeeting.UpdateAssignees(session, sickness.Subject.UserId);
                        session.SaveChanges();
                    }
       
                    break;
                case WorkflowHandlerAction.Actions.DeleteTask:
                    //delete the task from the DB
                    using (var session = documentStore.OpenSession())
                    {
                        var task = session.Load<Task>(action.Value);
                        session.Delete(task);
                        session.SaveChanges();
                    }
                    break;
                case WorkflowHandlerAction.Actions.DeleteMeeting:
                    //delete the meeting from the DB
                    using (var session = documentStore.OpenSession())
                    {
                        var meeting = session.Load<Meeting>(action.Value);
                        session.Delete(meeting);
                        session.SaveChanges();
                    }
                    break; 
                case WorkflowHandlerAction.Actions.NotifyActorsOfCreation:
                    using (var session = documentStore.OpenSession())
                    {
                        
                        var managerCreatedSickness=sickness.UserCreatedProcess.UserId==sickness.CurrentProcessOwner.UserId;
                        //if the manager created the sickness notify the employee 
                        Notification notification;
                        if (managerCreatedSickness)
                        {
                            notification = new Notification
                                               {
                                                   
                                                   NotificationRecipients = new[]
                                                                                {
                                                                                    new NotificationRecipient
                                                                                        {
                                                                                            NotificationDeliveryTypes =
//.........这里部分代码省略.........
开发者ID:andyevans2000,项目名称:Illuminate,代码行数:101,代码来源:DefaultSicknessWorkflow.cs


注:本文中的Task.UpdateAssignees方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。