Exemplo n.º 1
0
        protected internal virtual ICollection <Sentry> getExitCriterias(CmmnElement element)
        {
            if (isPlanItem(element))
            {
                PlanItem planItem = (PlanItem)element;
                return(planItem.ExitCriteria);
            }

            return(new List <Sentry>());
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            EnterpriseStore     store = new EnterpriseStore();
            EnterpriseMemoryDal dal   = new EnterpriseMemoryDal(store);

            Group fooGroup = new Group {
                UId = Guid.NewGuid(), Name = "fooGroup", IsLocal = true
            };
            Group gooGroup = new Group {
                UId = Guid.NewGuid(), Name = "gooGroup", IsLocal = true
            };
            User steve = new User {
                UId = Guid.NewGuid(), Name = "steve"
            };

            dal.UpsertGroup(fooGroup);
            dal.UpsertUser(steve);
            dal.UpsertGroupMembership(new GroupMembershipItem(group: fooGroup, member: steve));

            PlanContainer top = new PlanContainer {
                UId = Guid.NewGuid(), Name = "top"
            };

            top.Security.Dacl.Add(new AccessControlEntry <FileSystemRight> {
                TrusteeUId = gooGroup.UId.Value, Right = FileSystemRight.Execute
            });
            PlanContainer child = new PlanContainer {
                UId = Guid.NewGuid(), Name = "child"
            };

            child.Security.Dacl.Add(new AccessControlEntry <FileSystemRight> {
                TrusteeUId = fooGroup.UId.Value, Right = FileSystemRight.Execute
            });
            top.Children.Add(child);

            store.Containers = new List <PlanContainer>
            {
                top
            };

            PlanItem planItem = new PlanItem
            {
                Name             = "xxx",
                UniqueName       = "xxx",
                PlanContainerUId = child.UId
            };

            store.PlanItems = new List <PlanItem>
            {
                planItem
            };


            bool hasAccess = dal.HasAccess("steve", @"top\child\xxx");
        }
Exemplo n.º 3
0
 public async Task UpdateAsync(PlanItem planItem)
 {
     try
     {
         await _pItemRepository.UpdateAsync(planItem);
     }
     catch (DomainModelsException e)
     {
         throw new ServiceException($"Ошибка в сервисе {nameof(PlanItemService)} в методе {nameof(UpdateAsync)} при обращении к БД", e);
     }
 }
Exemplo n.º 4
0
        public async Task <bool> AddPlanItemAsync(PlanItem item, IdentityUser user)
        {
            item.Id     = Guid.NewGuid();
            item.UserId = user.Id;
            item.IsDone = false;

            _context.PlanItems.Add(item);

            var saveResult = await _context.SaveChangesAsync();

            return(saveResult == 1);
        }
Exemplo n.º 5
0
        public ActionResult Details(Guid id)
        {
            var model = new PromotionDetails(CreatePromotionService().GetById(id));
            var svc   = CreatePromotionService();

            model.ProjectId    = svc.GetProjectFor(model.PromotionId).ProjectID;
            model.ProjectName  = svc.GetProjectFor(model.PromotionId).Title;
            model.PlanItemName = svc.GetPlanItemFor(model.PromotionId).Name;
            model.OldRankName  = PlanItem.CategoryStr(model.OldCategory);
            model.NewRankName  = PlanItem.CategoryStr(model.NewCategory);
            return(View(model));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gibt für die Arbeitszeit bzw. Dienst Frei die Minuten ohne Pause zurück
        /// </summary>
        /// <param name="dienst"></param>
        /// <returns></returns>
        public static int GetArbeitsminutenAmKindOhnePause(this PlanItem dienst)
        {
            var minuten = (int)dienst.Zeitraum.Duration.TotalMinutes;
            int pause;

            if (dienst.NeedPause(out pause))
            {
                return(minuten - pause);
            }

            return(minuten);
        }
Exemplo n.º 7
0
        public bool EditPlanItem(PlanItemEdit model)
        {
            PlanItem entity = GetPlanItemById(model.PlanID);

            entity.Name           = model.Name;
            entity.Details        = model.Detail;
            entity.ModifiedUTC    = DateTimeOffset.Now;
            entity.LastModifiedBy = _userId;
            UpdateProjectModifiedDate(model.ProjectID);
            Context.TrySave();
            return(true);
        }
Exemplo n.º 8
0
 public PlanItemDetails(PlanItem item)
 {
     this.PlanItemID     = item.PlanItemID;
     this.Name           = item.Name;
     this.Details        = item.Details;
     this.Category       = $"{item.CategoryString}";
     this.ProjectID      = Guid.Parse(item.ProjectID.ToString());
     this.CreatorID      = item.CreatorID;
     this.LastModifiedBy = item.LastModifiedBy;
     this.CreatedUTC     = item.CreatedUTC;
     this.ModifiedUTC    = item.ModifiedUTC;
 }
Exemplo n.º 9
0
        public PlanItem Create(PlanItem planItem)
        {
            try
            {
                var createdItem = _pItemRepository.Create(planItem);

                return(createdItem);
            }
            catch (DomainModelsException e)
            {
                throw new ServiceException($"Ошибка в сервисе {nameof(PlanItemService)} в методе {nameof(Create)} при обращении к БД", e);
            }
        }
Exemplo n.º 10
0
        public async void TestNumberSkip()
        {
            var now  = PlanItem.NowTime() + second2ms;
            var item = new PlanItem
            {
                Message = MessageHelper.Simple("test", "test", "test", "test"),
                Option  = new PlanOption
                {
                    plan_type  = plan_date_type.second,
                    plan_value = 1,
                    plan_repet = 30,
                    plan_time  = now,
                    skip_set   = 29,
                },
                RealInfo = new PlanRealInfo
                {
                    plan_time = now
                }
            };
            DateTime next;

            for (int i = 0; i < 29; i++)
            {
                await item.CheckNextTime();

                item.RealInfo.skip_num++;//模拟成功

                now += second2ms;
                next = PlanItem.FromTime(item.RealInfo.plan_time);
                Console.WriteLine($"{PlanItem.FromTime(now)} => {next} : {item.RealInfo.plan_state} skip:{item.RealInfo.skip_num}");
                Assert.IsTrue(item.RealInfo.plan_state == Plan_message_state.skip, $"状态错误{Plan_message_state.queue}=>{item.RealInfo.plan_state}");
                Assert.IsTrue(item.RealInfo.plan_time == now, $"结果时间不同{now}=>{item.RealInfo.plan_time}");
            }

            await item.CheckNextTime();

            item.RealInfo.exec_num++;//模拟成功

            now += second2ms;
            next = PlanItem.FromTime(item.RealInfo.plan_time);
            Console.WriteLine($"{PlanItem.FromTime(now)} => {next} : {item.RealInfo.plan_state} skip:{item.RealInfo.skip_num} exec:{item.RealInfo.exec_num}");
            Assert.IsTrue(item.RealInfo.plan_state == Plan_message_state.queue, $"状态错误{Plan_message_state.queue}=>{item.RealInfo.plan_state}");
            Assert.IsTrue(item.RealInfo.plan_time == now, $"结果时间不同{now}=>{item.RealInfo.plan_time}");


            await item.CheckNextTime();

            Console.WriteLine($"{PlanItem.FromTime(now)} => {PlanItem.FromTime(item.RealInfo.plan_time)} : {item.RealInfo.plan_state}");
            Assert.IsTrue(item.RealInfo.plan_state == Plan_message_state.close, $"状态错误{Plan_message_state.close}=>{item.RealInfo.plan_state}");
        }
Exemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void setUp()
        {
            task = createElement(casePlanModel, "aTask", typeof(Task));

            planItem            = createElement(casePlanModel, "PI_aTask", typeof(PlanItem));
            planItem.Definition = task;

            sentry = createElement(casePlanModel, "aSentry", typeof(Sentry));

            onPart        = createElement(sentry, "anOnPart", typeof(PlanItemOnPart));
            onPart.Source = planItem;
            createElement(onPart, null, typeof(PlanItemTransitionStandardEvent));
            onPart.StandardEvent = PlanItemTransition.complete;
        }
Exemplo n.º 12
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            planitem = e.Parameter as PlanItem;
            plan     = planitem.obj;

            editNombre.Text      = plan.Get <string>("nombre");
            editDescripcion.Text = plan.Get <string>("descripcion");
            char[]   delimeter = { '/', ' ', ':' };
            string[] fechaCom  = plan.Get <string>("fecha").Split(delimeter);

            string fec = fechaCom[1] + "/" + fechaCom[0] + "/" + fechaCom[2];

            editFecha.Date = DateTime.Parse(fec);

            string hor    = fechaCom[3];
            string minute = fechaCom[4];
            string am_pm  = fechaCom[5];

            string horaOrga = organizarHora(hor, minute, am_pm);

            //editFecha.Date = DateTime.Parse(fechaCom[0]);

            editHora.Time = TimeSpan.Parse(horaOrga);

            ParseFile   file = plan.Get <ParseFile>("imagen");
            Uri         ur   = file.Url;
            BitmapImage img  = new BitmapImage(ur);

            editImage.Source = img;

            NombreLugarTxt.Text = plan.Get <string>("direccion");

            gPoint = plan.Get <ParseGeoPoint>("lugar");

            // Specify a known location

            BasicGeoposition posicion = new BasicGeoposition()
            {
                Latitude = gPoint.Latitude, Longitude = gPoint.Longitude
            };
            Geopoint point = new Geopoint(posicion);

            // Set map location
            editMap.Center           = point;
            editMap.ZoomLevel        = 17.0f;
            editMap.LandmarksVisible = true;


            AddIcons(gPoint);
        }
Exemplo n.º 13
0
        public async void TestMonth()
        {
            var day  = (short)new Random(GetHashCode()).Next(0, 32);
            var item = new PlanItem
            {
                Message = MessageHelper.Simple("test", "test", "test", "test"),
                Option  = new PlanOption
                {
                    plan_type  = plan_date_type.month,
                    plan_value = day,
                    plan_time  = 10000
                },
                RealInfo = new PlanRealInfo
                {
                    plan_time = PlanItem.NowTime()
                }
            };
            await item.CheckNextTime();

            var next = PlanItem.FromTime(item.RealInfo.plan_time);

            Console.WriteLine($"{day}=>{(int)next.DayOfWeek} {next} : {item.RealInfo.plan_state}");
            Assert.IsTrue(next.Day == day, $"结果时间不同{day}=>{next.Day}");

            item = new PlanItem
            {
                Message = MessageHelper.Simple("test", "test", "test", "test"),
                Option  = new PlanOption
                {
                    plan_type  = plan_date_type.month,
                    plan_value = -31,
                    plan_time  = 10000
                },
                RealInfo = new PlanRealInfo
                {
                    plan_time = PlanItem.NowTime()
                }
            };
            await item.CheckNextTime();

            next = PlanItem.FromTime(item.RealInfo.plan_time);
            Console.WriteLine($"{next} : {item.RealInfo.plan_state}");
            Assert.IsTrue(next.Day == 1, $"结果时间不同{next.Day}=>1");

            item.RealInfo.exec_num = 1;
            await item.CheckNextTime();

            Assert.IsTrue(item.RealInfo.plan_state == Plan_message_state.close, $"状态错误{Plan_message_state.close}=>{item.RealInfo.plan_state}");
        }
Exemplo n.º 14
0
        public void Converting_FPL_should_give_correct_FMS()
        {
            var garminFplBuilder = Create.GarminFpl();

            garminFplBuilder.AddWaypoint("AIRPORT", "EDDC", 51.134344, 51.134344);
            garminFplBuilder.AddWaypoint("VOR", "DRN", 51.015547, 13.598889);
            garminFplBuilder.AddWaypoint("INT", "DC422", 51.065489, 13.457303);
            garminFplBuilder.AddWaypoint("NDB", "FS", 51.193011, 13.850031);
            garminFplBuilder.AddWaypoint("USER WAYPOINT", "TEST1", 51.378353, 13.115295);
            garminFplBuilder.AddWaypoint("USER WAYPOINT", "TEST2", -51.378353, 13.115295);
            garminFplBuilder.AddWaypoint("USER WAYPOINT", "TEST3", -51.378353, -13.115295);
            garminFplBuilder.AddWaypoint("USER WAYPOINT", "TEST4", 51.378353, -13.115295);
            GarminFpl garminFpl = garminFplBuilder.Build();

            IGarminFplToFmsService service = new GarminFplToFmsService(new FplToFmsWaypointTypeConverter());
            FmsFlightplan          fms     = service.CreateFmsFlightplanFromGarminFpl(garminFpl);

            fms.Header.Source.Should().Be('I');
            fms.Header.VersionNumber.Should().Be(3);
            fms.Header.WaypointCount.Should().Be(7);

            PlanItem waypoint1 = fms.PlanItems[0];

            waypoint1.Typ.Should().Be(WaypointType.Airport);
            waypoint1.Id.Should().Be("EDDC");
            waypoint1.Altitude.Should().Be(0);
            waypoint1.Latitude.Should().Be(51.134344);
            waypoint1.Longitude.Should().Be(51.134344);

            PlanItem waypoint5 = fms.PlanItems[4];

            waypoint5.Typ.Should().Be(WaypointType.LatLon);
            waypoint5.Id.Should().Be("+51.378_+013.115");

            PlanItem waypoint6 = fms.PlanItems[5];

            waypoint6.Typ.Should().Be(WaypointType.LatLon);
            waypoint6.Id.Should().Be("-51.378_+013.115");

            PlanItem waypoint7 = fms.PlanItems[6];

            waypoint7.Typ.Should().Be(WaypointType.LatLon);
            waypoint7.Id.Should().Be("-51.378_-013.115");

            PlanItem waypoint8 = fms.PlanItems[7];

            waypoint8.Typ.Should().Be(WaypointType.LatLon);
            waypoint8.Id.Should().Be("+51.378_-013.115");
        }
        public void UpsertPlan_Null_Plan_Throws_Exception()
        {
            // Arrange
            PlanItem    planItem = null;
            DynamoDbDal dal      = new DynamoDbDal
            {
                PlanTable = _planTable
            };

            // Act
            Exception ex = Assert.Throws <Exception>(() => dal.UpsertPlan(planItem));

            // Assert
            StringAssert.AreEqualIgnoringCase("Plan cannot be null.", ex.Message);
        }
        public async Task SpreadPlanItems(WebUser user, PlanItem item)
        {
            var planItems = (await _planItemService.GetListAsync(user.Id))
                            .Where(x => x.Closed == false &&
                                   x.Month.Date >= item.Month.Date &&
                                   x.CategoryId == item.CategoryId)
                            .ToList();

            foreach (var planItem in planItems)
            {
                planItem.SummPlan = item.SummPlan;
                await _planItemService.UpdateAsync(planItem);
            }
            await _planItemService.SaveAsync();
        }
        PlanContainer GetPlanContainer(string planUniqueName, bool returnTail, out PlanItem planItem)
        {
            string[] paths = planUniqueName.Split('\\');

            List <PlanContainer> list = _store.Containers;

            bool          ok   = true;
            PlanContainer root = null;
            PlanContainer tail = null;

            for (int i = 0; i < paths.Length - 1; i++)
            {
                PlanContainer curr = list.Find(x => x.Name.Equals(paths[i], StringComparison.OrdinalIgnoreCase));
                if (curr != null)
                {
                    if (tail == null)
                    {
                        tail          = curr.Clone(true);
                        tail.Security = curr.Security;
                        root          = tail;
                    }
                    else
                    {
                        PlanContainer child = curr.Clone(true);
                        child.Security = curr.Security;
                        tail.Children.Add(child);
                        tail = child;
                    }

                    list = curr.Children;
                }
                else
                {
                    ok = false;
                    break;
                }
            }

            planItem = null;
            if (ok)
            {
                planItem = _store.PlanItems.Find(p =>
                                                 p.UniqueName.Equals(paths[paths.Length - 1], StringComparison.OrdinalIgnoreCase) && p.PlanContainerUId == tail.UId);
                ok = planItem != null;
            }

            return(ok ? returnTail ? tail : root : null);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Обновляет данные по учебному плану.
        /// </summary>
        /// <param name="plan">Учебный план.</param>
        public void Update(PlanItem plan)
        {
            using (var sqlh = new SqlHelper())
            {
                sqlh.ExecNoQuery(@"
update TrainingPlan.specialty_plan
set
	name = @Name,
	specialty_detail = @SpecialtyDetail,
	semester = @Semester,
	lesson_type = @LessonType,
	discipline = @Discipline,
	auditory = @Auditory
where specialty_plan = @Id", plan);
            }
        }
Exemplo n.º 19
0
        private bool IsFbReached(string fbName, PlanItem fb, DataProvider dpS88, out bool hasError)
        {
            hasError = false;
            int ecosAddr;
            var r = Utilities.GetFeedbackAddress(fb, out var ecosAddr1, out var ecosAddr2, out _, out _);

            if (r)
            {
                var ec1 = 0;
                var ec2 = 0;
                if (ecosAddr1 != null)
                {
                    ec1 = ecosAddr1.Value;
                }
                if (ecosAddr2 != null)
                {
                    ec2 = ecosAddr2.Value;
                }
                Utilities.GetValidAddress(ec1, ec2, false, false, out ecosAddr, out _);
            }
            else
            {
                ecosAddr = fb.Addresses.Addr;
            }

            if (ecosAddr == 0)
            {
                Ctx?.LogInfo($"Feedback({fbName}) does not have a valid address.");
                hasError = true;
                return(false);
            }

            var r0 = dpS88.GetFeedbackByAddress(ecosAddr, out var item, out var itemOffset, out var itemPin);

            if (item == null)
            {
                return(false);
            }

            var pinState = item.Pin((uint)itemPin);

//#if DEBUG
//            Trace.WriteLine($"{r0} > {ecosAddr} is {itemOffset}:{itemPin} = {pinState}");
//#endif
            return(pinState);
        }
Exemplo n.º 20
0
        ///
        /// <summary>
        ///   +-----------------+                                       +-----------------+
        ///   | Case1            \                                      | aCaseDefinition |
        ///   +-------------------+-----------------+                   +-----------------+
        ///   |                                     |                            |
        ///   |     +------------------------+      |                   +-----------------+
        ///   |    / X                        \     |                   |  aCasePlanModel |
        ///   |   +    +-------+  +-------+    +    |                   +-----------------+
        ///   |   |    |   A   |  |   B   |    |    |  ==>                       |
        ///   |   +    +-------+  +-------+    +    |                   +-----------------+
        ///   |    \                          /     |                   |        X        |
        ///   |     +------------------------+      |                   +-----------------+
        ///   |                                     |                           / \
        ///   +-------------------------------------+                          /   \
        ///                                                 +-----------------+     +-----------------+
        ///                                                 |        A        |     |        B        |
        ///                                                 +-----------------+     +-----------------+
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testActivityTreeWithOneStageAndNestedHumanTasks()
        public virtual void testActivityTreeWithOneStageAndNestedHumanTasks()
        {
            // given
            Stage     stage      = createElement(casePlanModel, "X", typeof(Stage));
            HumanTask humanTaskA = createElement(casePlanModel, "A", typeof(HumanTask));
            HumanTask humanTaskB = createElement(casePlanModel, "B", typeof(HumanTask));

            PlanItem planItemX = createElement(casePlanModel, "PI_X", typeof(PlanItem));
            PlanItem planItemA = createElement(stage, "PI_A", typeof(PlanItem));
            PlanItem planItemB = createElement(stage, "PI_B", typeof(PlanItem));

            planItemX.Definition = stage;
            planItemA.Definition = humanTaskA;
            planItemB.Definition = humanTaskB;

            // when
            IList <CaseDefinitionEntity> caseDefinitions = transform();

            // then
            assertEquals(1, caseDefinitions.Count);

            CaseDefinitionEntity caseDefinition = caseDefinitions[0];
            IList <CmmnActivity> activities     = caseDefinition.Activities;

            CmmnActivity casePlanModelActivity = activities[0];

            IList <CmmnActivity> children = casePlanModelActivity.Activities;

            assertEquals(1, children.Count);

            CmmnActivity planItemStage = children[0];

            assertEquals(planItemX.Id, planItemStage.Id);

            children = planItemStage.Activities;
            assertEquals(2, children.Count);

            CmmnActivity childPlanItem = children[0];

            assertEquals(planItemA.Id, childPlanItem.Id);
            assertTrue(childPlanItem.Activities.Count == 0);

            childPlanItem = children[1];
            assertEquals(planItemB.Id, childPlanItem.Id);
            assertTrue(childPlanItem.Activities.Count == 0);
        }
Exemplo n.º 21
0
        public static bool NeedPause(this PlanItem dienst, out int pause)
        {
            pause = 0;

            if (dienst.Zeitraum.Duration.NeedPause())
            {
                pause = 30;
                return(true);
            }

            //wenn keine Pause aber Großteam noch ist
            if (dienst.HatGrossteam)
            {
                var tp = new TimePeriodCollection(new List <ITimePeriod>()
                {
                    dienst.Zeitraum, dienst.Arbeitstag.Grossteam
                });

                if (tp.HasGaps())
                {
                    var gapCalculator = new TimeGapCalculator <TimeRange>(new TimeCalendar());
                    var gaps          = gapCalculator.GetGaps(tp);

                    var gap = (int)Math.Round(gaps.First().Duration.TotalMinutes, MidpointRounding.ToEven); //sollte nur eine geben, sind ja nur 2 Zeiten

                    if (gap < 30)
                    {
                        pause = 30 - gap;
                        return(true);
                    }
                }
                else
                {
                    var periodCombiner  = new TimePeriodCombiner <TimeRange>();
                    var combinedPeriods = periodCombiner.CombinePeriods(tp);

                    if (combinedPeriods.First().Duration.NeedPause())
                    {
                        pause = 30;
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 22
0
        public Guid DeletePlanItem(Guid id)
        {
            PlanItem val     = GetPlanItemById(id);
            var      project = new ProjectService(_userId).GetProjectById(val.ProjectID);

            project.ModifiedUTC = DateTimeOffset.Now;
            var pid = project.ProjectID;

            //Context.PlanItems.Attach(val);
            //if (Context.PlanItems.AsNoTracking().Contains(val))
            //{
            Context.PlanItems.Remove(val);
            //}
            Context.Promotions.RemoveRange(Context.Promotions.Where(e => e.PlanId == id));
            Context.TrySave();
            CheckAndRemoveUnbound();
            return(pid);
        }
Exemplo n.º 23
0
        private async Task WaitForFb(string fbName, PlanItem fb, DataProvider dpS88)
        {
            await Task.Run(() =>
            {
                var reached = false;
                while (!reached && !IsCanceled())
                {
                    reached = IsFbReached(fbName, fb, dpS88, out var hasError);
                    // TODO handle hasError (e.g. cancel route)
                    if (!reached)
                    {
                        System.Threading.Thread.Sleep(TimeBetweenFbTestMsecs);
                    }
                }

                SendDebugMessage($"{fbName} reached!");
            }, CancelSource.Token);
        }
Exemplo n.º 24
0
        protected internal virtual PlanItemDefinition getDefinition(CmmnElement element)
        {
            if (isPlanItem(element))
            {
                PlanItem planItem = (PlanItem)element;
                return(planItem.Definition);
            }
            else
            {
                if (isDiscretionaryItem(element))
                {
                    DiscretionaryItem discretionaryItem = (DiscretionaryItem)element;
                    return(discretionaryItem.Definition);
                }
            }

            return(null);
        }
Exemplo n.º 25
0
        protected internal virtual PlanItemControl getItemControl(CmmnElement element)
        {
            if (isPlanItem(element))
            {
                PlanItem planItem = (PlanItem)element;
                return(planItem.ItemControl);
            }
            else
            {
                if (isDiscretionaryItem(element))
                {
                    DiscretionaryItem discretionaryItem = (DiscretionaryItem)element;
                    return(discretionaryItem.ItemControl);
                }
            }

            return(null);
        }
Exemplo n.º 26
0
        public bool CreatePlanItem(PlanItemCreate model)
        {
            PlanItem entity = new PlanItem
            {
                PlanItemID     = Guid.NewGuid(),
                Name           = model.Name,
                Details        = model.Detail,
                ProjectID      = model.ProjectID,
                Category       = model.Category,
                CreatorID      = _userId,
                LastModifiedBy = _userId,
                CreatedUTC     = DateTimeOffset.Now,
                ModifiedUTC    = null
            };

            UpdateProjectModifiedDate(model.ProjectID);
            Context.PlanItems.Add(entity);
            return(Context.TrySave());
        }
Exemplo n.º 27
0
        public static int GetGrossteamZeitInMinmuten(this PlanItem planzeit)
        {
            if (planzeit.HatGrossteam)
            {
                var gtMinuten = (int)planzeit.Arbeitstag.Grossteam.Duration.TotalMinutes;
                var overlap   = 0;

                if (planzeit.Zeitraum.IntersectsWith(planzeit.Arbeitstag.Grossteam))
                {
                    overlap = (int)planzeit.Zeitraum.GetIntersection(planzeit.Arbeitstag.Grossteam).Duration.TotalMinutes;
                }

                return(gtMinuten - overlap);
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 28
0
        private static void AdjustEndzeitEnde(PlanItem planItem)
        {
            var ende = planItem.Arbeitstag.SpätdienstEnde;

            switch (planItem.Dienst)
            {
            case DienstTyp.Frühdienst:
            case DienstTyp.AchtUhrDienst:
            case DienstTyp.KernzeitStartDienst:
            case DienstTyp.NeunUhrDienst:
            case DienstTyp.ZehnUhrDienst:
                ende = planItem.Arbeitstag.KernzeitGruppeEnde;
                break;

            case DienstTyp.FsjFrühdienst:
            case DienstTyp.FsjKernzeitdienst:
            case DienstTyp.FsjSpätdienst:
                ende = planItem.Arbeitstag.SpätdienstEndeFsj;
                break;

            case DienstTyp.KernzeitEndeDienst:
                ende = planItem.Arbeitstag.KernzeitGruppeEnde;
                break;

            case DienstTyp.SechszehnUhrDienst:
                ende = planItem.Arbeitstag.SechzehnUhrDienst;
                break;

            case DienstTyp.SpätdienstEnde:
                ende = planItem.Arbeitstag.SpätdienstEnde;
                break;

            default:
                break;
            }

            if (planItem.Zeitraum.End > ende)
            {
                var minuten = ende - planItem.Zeitraum.End;
                planItem.Zeitraum.Move(minuten);
            }
        }
Exemplo n.º 29
0
        public string SavePlanItem(string planDefineID, string periodID, PlanItem planItem)
        {
            PlanDac    dac    = new PlanDac();
            PlanFilter filter = new PlanFilter();

            filter.MyStatus    = 1;
            filter.PlanDefines = new List <string>()
            {
                planDefineID
            };
            filter.Periods = new List <string>()
            {
                periodID
            };
            List <PlanInfo> planList = PlanService.Current.Get(filter);
            PlanInfo        plan     = new PlanInfo();

            if (planList == null || planList.Count <= 0)
            {
                plan.PlanDefineID = planDefineID;
                plan.Period.ID    = periodID;
                plan.PlanItems    = new List <PlanItem>()
                {
                    planItem
                };
                PlanService.Current.SavePlanInfo(plan);
            }
            else
            {
                plan = planList[0];
                PlanItem planItemInfo = plan.PlanItems.Find(item => item.ID == planItem.ID);
                if (planItemInfo == null)
                {
                    dac.SavePlanItem(plan.ID, planItem);
                }
                else
                {
                    dac.UpdatePlanItem(planItem);
                }
            }
            return(plan.ID);
        }
Exemplo n.º 30
0
        public PlanItem UpsertPlan(PlanItem plan)
        {
            if (plan == null)
            {
                throw new Exception("Plan cannot be null.");
            }

            if (plan.UId == Guid.Empty)
            {
                throw new Exception("Plan unique id cannot be empty.");
            }

            if (string.IsNullOrWhiteSpace(plan.Name))
            {
                throw new Exception("Plan name cannot be null or empty.");
            }

            if (string.IsNullOrWhiteSpace(plan.UniqueName))
            {
                throw new Exception("Plan unique name cannot be null or empty.");
            }

            if (string.IsNullOrWhiteSpace(PlanTable))
            {
                throw new Exception("Plan table name must be specified.");
            }

            try
            {
                string   output = JsonConvert.SerializeObject(plan, Formatting.Indented, _settings);
                Document doc    = Document.FromJson(output);

                Table table = Table.LoadTable(_client, PlanTable);
                table.PutItem(doc);
            }
            catch (Exception ex)
            {
                Debug.Write(ex.Message);
                throw;
            }
            return(plan);
        }