コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Assignment"/> class.
 /// </summary>
 public Assignment(Task.Task task, WorkCalendarBase workCalendar, AbstractContour contourBucket, double units, long delay)
 {
     _task            = task;
     _contourBucket   = contourBucket;
     _units           = units;
     _workingCalendar = workCalendar;
     _delay           = new DelayImpl(delay);
 }
コード例 #2
0
ファイル: Assignment.cs プロジェクト: 0anion0/IBN
 /// <summary>
 /// Initializes a new instance of the <see cref="Assignment"/> class.
 /// </summary>
 public Assignment(Task.Task task, WorkCalendarBase workCalendar, AbstractContour contourBucket, double units, long delay)
 {
     _task = task;
     _contourBucket = contourBucket;
     _units = units;
     _workingCalendar = workCalendar;
     _delay = new DelayImpl(delay);
 }
コード例 #3
0
        public void SetActualWorkTest()
        {
            WorkCalendarFactory calFactory    = new WorkCalendarFactory();
            ContourFactory      factory       = new ContourFactory();
            AbstractContour     contourBucket = factory.Create <StandardContour>(ContourTypes.FrontLoaded);
            WorkCalendarBase    calendar      = calFactory.Create <DefaultCalendar>(null);
            Task task = new Task();

            task.Start = CalendarHelper.Tick2Milis(new DateTime(2008, 01, 01).Ticks);
            Assignment assignment = new Assignment(task, calendar, contourBucket, 1.0, 0);
            long       duration   = CalendarHelper.MilisPerHour() * 13 + CalendarHelper.MilisPerMinute() * 20;

            assignment.Duration = duration;

            long work = assignment.GetWork(assignment.Start, assignment.End);

            assignment.SetActualWork(CalendarHelper.MilisPerMinute() * 48);
        }
コード例 #4
0
        public void TimePhaseTest()
        {
            string fileName            = @"C:\Projects\MsProjectSynchronization\MsProject\ExceptionOverlapped.xml";
            long   assignmentStart     = CalendarHelper.Tick2Milis(new DateTime(2008, 8, 4, 9, 0, 0).Ticks);
            long   assignmentFinish    = CalendarHelper.Tick2Milis(new DateTime(2008, 8, 19, 3, 0, 0).Ticks);
            int    calendarUID         = 3;
            int    baseCalendarUID     = 1;
            int    assignmentID        = 2;
            double units               = 1.0;
            long   duration            = 24 * CalendarHelper.MilisPerHour();
            double percentWorkComplete = 0.58;

            XmlDocument doc = new XmlDocument();

            doc.AppendChild(doc.CreateElement("ss"));

            WorkCalendarFactory calFactory    = new WorkCalendarFactory();
            ContourFactory      factory       = new ContourFactory();
            AbstractContour     contourBucket = factory.Create <StandardContour>(ContourTypes.Flat);

            WorkCalendar calendarBase = (WorkCalendar)LoadCalendar(fileName, baseCalendarUID);
            WorkCalendar calendar     = (WorkCalendar)LoadCalendar(fileName, calendarUID);

            calendar.BaseCalendar = calendarBase;

            Task task = new Task();

            task.Start = assignmentStart;

            Assignment assignment = new Assignment(task, calendar, contourBucket, units, 0);

            //long duration = CalendarHelper.MilisPerHour() * 40; //+ CalendarHelper.MilisPerMinute() * 20;
            assignment.End = assignmentFinish;

            List <TimePhasedDataType> timePhasedList = LoadTimePhase(fileName, assignmentID);

            contourBucket = factory.Create <PersonalContour>(new KeyValuePair <Assignment, TimePhasedDataType[]>(assignment, timePhasedList.ToArray()));
            XmlDocument debugdoc = DebugInterval((PersonalContour)contourBucket, assignment);

            assignment     = new Assignment(task, calendar, contourBucket, units, 0);
            assignment.End = assignmentFinish;

            if (assignment.Duration != duration)
            {
                throw new Exception("bad duration");
            }

            long work = assignment.GetWork(assignment.Start, assignment.End);

            assignment.SetActualWork(work * percentWorkComplete);
            long actualWork = assignment.GetWork(assignment.Start, assignment.Stop);



            foreach (TimePhasedDataType timePhase in TimePhasedService.GetTimePhaseData(assignment, TimePhasedDataType.TimePhaseType.AssignmentRemainingWork))
            {
                XmlElement element = doc.CreateElement("TimePhaseData");
                XmlNode    node    = element.AppendChild(doc.CreateElement("Type"));
                node.InnerText = timePhase.Type.ToString();
                node           = element.AppendChild(doc.CreateElement("UID"));
                node.InnerText = timePhase.UID.ToString();
                node           = element.AppendChild(doc.CreateElement("Start"));
                node.InnerText = new DateTime(CalendarHelper.Milis2Tick(timePhase.Start)).ToString("yyyy-MM-ddTHH:mm:ss");
                node           = element.AppendChild(doc.CreateElement("Finish"));
                node.InnerText = new DateTime(CalendarHelper.Milis2Tick(timePhase.Finish)).ToString("yyyy-MM-ddTHH:mm:ss");
                node           = element.AppendChild(doc.CreateElement("Unit"));
                node.InnerText = timePhase.Unit.ToString();
                node           = element.AppendChild(doc.CreateElement("Value"));
                node.InnerText = String.Format("PT{0}H{1}M{2}S", timePhase.Value / CalendarHelper.MilisPerHour(),
                                               (timePhase.Value % CalendarHelper.MilisPerHour()) / CalendarHelper.MilisPerMinute(),
                                               (timePhase.Value % CalendarHelper.MilisPerMinute()) / (CalendarHelper.MilisPerMinute() / 60));
                doc.DocumentElement.AppendChild(element);
            }
        }