コード例 #1
0
        public TimeSheetDay GenerateATimeSheetDay(DateTime initDay)
        {
            var tsday = new TimeSheetDay();

            tsday.Day     = initDay;
            tsday.Catalog = GetTimeSheetType(tsday.Day);

            // Generate Planned Items
            tsday.ShiftItems = new List <ShiftRecord>();
            int plannedCount = rand.Next(3);

            for (int k = 0; k < plannedCount; k++)
            {
                ShiftRecord plannedItem = new ShiftRecord();
                plannedItem.FromTime      = k == 0 ? tsday.Day.AddHours(-tsday.Day.Hour + rand.Next(8)) : tsday.ShiftItems[k - 1].ToTime.AddHours(rand.Next(2));
                plannedItem.ToTime        = plannedItem.FromTime.AddHours(rand.Next(4) + 6);
                plannedItem.TimeSheetType = k == 0
                    ? SampleTimeSheetTypeList.RandomBelongsCatalogs(TimeSheetCatalog.Shift)
                    : SampleTimeSheetTypeList.RandomBelongsCatalogs(TimeSheetCatalog.Shift, TimeSheetCatalog.Overtime);
                plannedItem.Status = GetTimeSheetStatus(plannedItem.TimeSheetType.Catalog);
                tsday.ShiftItems.Add(plannedItem);
            }

            // Generate RealTime Items
            tsday.LeaveItems = new List <LeaveRecord>();
            int realTimeCount = plannedCount;

            for (int k = 0; k < realTimeCount; k++)
            {
                LeaveRecord realItem = new LeaveRecord();
                realItem.FromTime      = k == 0 ? tsday.ShiftItems[0].FromTime : tsday.LeaveItems[k - 1].ToTime.AddHours(rand.Next(3));
                realItem.ToTime        = realItem.FromTime.AddHours(rand.Next(4) + 6);
                realItem.TimeSheetType = SampleTimeSheetTypeList.RandomBelongsCatalogs(TimeSheetCatalog.Leave);
                realItem.Status        = GetTimeSheetStatus(realItem.TimeSheetType.Catalog);
                tsday.LeaveItems.Add(realItem);
            }

            if (tsday.ShiftItems.Count > 0 || tsday.LeaveItems.Count > 0)
            {
                tsday.Status = rand.Next(2) == 0 ? TimeSheetStatus.None : TimeSheetStatus.Locked;
            }

            return(tsday);
        }
コード例 #2
0
ファイル: TimeSheetItem.cs プロジェクト: hoangitk/mysample
 public ShiftRecord(ShiftRecord shiftRecord) : base(shiftRecord)
 {
 }