Esempio n. 1
0
        internal CswNbtNode createGeneratorNode(CswEnumRateIntervalType IntervalType, String NodeTypeName = "Equipment Schedule", int WarningDays = 0, SortedList Days = null, DateTime?StartDate = null)
        {
            CswNbtNode ret = _CswNbtResources.Nodes.makeNodeFromNodeTypeId(_getNodeTypeId(NodeTypeName), delegate(CswNbtNode NewNode)
            {
                CswNbtObjClassGenerator GeneratorNode = NewNode;
                CswRateInterval RateInt = new CswRateInterval(_CswNbtResources);
                DateTime StDate         = StartDate != null ? (DateTime)StartDate : new DateTime(2012, 1, 15);
                if (IntervalType == CswEnumRateIntervalType.WeeklyByDay)
                {
                    if (null == Days)
                    {
                        Days = new SortedList {
                            { DayOfWeek.Monday, DayOfWeek.Monday }
                        };
                    }
                    RateInt.setWeeklyByDay(Days, StDate);
                }
                else if (IntervalType == CswEnumRateIntervalType.MonthlyByDate)
                {
                    RateInt.setMonthlyByDate(1, StDate.Day, StDate.Month, StDate.Year);
                }
                GeneratorNode.DueDateInterval.RateInterval = RateInt;
                GeneratorNode.WarningDays.Value            = WarningDays;
                //GeneratorNode.postChanges( ForceUpdate: false );
            });

            _finalize();

            return(ret);
        } // createGeneratorNode()
Esempio n. 2
0
        public void MonthlyByDateTest()
        {
            CswRateInterval r         = new CswRateInterval(_CswResources);
            DateTime        StartDate = new DateTime(2012, 10, 15);

            r.setMonthlyByDate(1, 15, 10, 2012);
            Assert.AreEqual(r.getFirst(), StartDate);
            DateTime CurrentDate = StartDate;

            for (Int32 i = 1; i <= 24; i++)
            {
                CurrentDate = CurrentDate.AddMonths(1);
                Assert.AreEqual(r.getNext(CurrentDate), CurrentDate.AddMonths(1));
            }
        }