Parcourir la source

Chopped KanbanReference and fixed subscribers for schedules

Kenric Nugteren il y a 2 ans
Parent
commit
13c7b4ce7b

+ 0 - 22
prs.classes/Entities/Kanban/KanbanReference.cs

@@ -44,26 +44,4 @@ namespace Comal.Classes
     public class JobRequisitionKanban : EntityKanban<JobRequisition, JobRequisitionLink>
     { 
     }
-
-    [Obsolete("Replaced with EntityKanban", false)]
-    [UserTracking(typeof(Kanban))]
-    public class KanbanReference : Entity, IPersistent, IRemotable, ILicense<TaskManagementLicense>
-    {
-        [EntityRelationship(DeleteAction.Cascade)]
-        public KanbanLink Kanban { get; set; }
-
-        public Guid KanbanID { get; set; }
-
-        public string LinkType { get; set; }
-        public Guid LinkID { get; set; }
-        public string LinkProperty { get; set; }
-        public PackableStringDictionary Data { get; set; }
-
-        protected override void Init()
-        {
-            base.Init();
-            Data = new PackableStringDictionary();
-            Kanban = new KanbanLink();
-        }
-    }
 }

+ 32 - 0
prs.scheduler/SchedulePlugin.cs

@@ -3,6 +3,7 @@ using InABox.Clients;
 using InABox.Core;
 
 using System;
+using System.Collections.Generic;
 using System.Linq;
 
 namespace Comal.TaskScheduler.Shared
@@ -45,6 +46,37 @@ namespace Comal.TaskScheduler.Shared
 
             new Client<Kanban>().Save(kanban, "Task Created by Scheduler");
 
+            var subscribers = new List<KanbanSubscriber>();
+            if(kanban.EmployeeLink.ID != Guid.Empty)
+            {
+                if(kanban.ManagerLink.ID == kanban.EmployeeLink.ID)
+                {
+                    var subscriber = new KanbanSubscriber();
+                    subscriber.Kanban.ID = kanban.ID;
+                    subscriber.Employee.ID = schedule.EmployeeLink.ID;
+                    subscriber.Assignee = true;
+                    subscriber.Manager = true;
+                    subscribers.Add(subscriber);
+                }
+                else
+                {
+                    var subscriber = new KanbanSubscriber();
+                    subscriber.Kanban.ID = kanban.ID;
+                    subscriber.Employee.ID = schedule.EmployeeLink.ID;
+                    subscriber.Assignee = true;
+                    subscribers.Add(subscriber);
+                }
+            }
+            if (kanban.ManagerLink.ID != Guid.Empty && kanban.ManagerLink.ID != kanban.EmployeeLink.ID)
+            {
+                var subscriber = new KanbanSubscriber();
+                subscriber.Kanban.ID = kanban.ID;
+                subscriber.Employee.ID = schedule.ManagerLink.ID;
+                subscriber.Manager = true;
+                subscribers.Add(subscriber);
+            }
+            new Client<KanbanSubscriber>().Save(subscribers, "");
+
             if (schedule.Report.IsValid())
             {
                 Guid docid = Guid.Empty;

+ 3 - 1
prs.shared/Grids/ScheduleItemGrid.cs

@@ -153,7 +153,9 @@ namespace PRS.Shared
 
             using (var client = new Client<Schedule>())
             {
-                var schedule = client.Load(new Filter<Schedule>(x => x.ID).IsEqualTo(row.Get<Schedule, Guid>(x => x.ID))).FirstOrDefault();
+                var schedule = client.Query(
+                    new Filter<Schedule>(x => x.ID).IsEqualTo(row.Get<Schedule, Guid>(x => x.ID)),
+                    new Columns<Schedule>(x => x.ID).Add(x => x.Active)).ToObjects<Schedule>().FirstOrDefault();
                 schedule.Active = !schedule.Active;
                 client.Save(schedule, schedule.Active ? "Activated Schedule" : "Disabled Schedule");
             }