public void BuildTimeSheet(DateTime startDate, DateTime endDate, string memberID, string maxStart, string minEnd, string lunchDeduction, string adminChargeCode, bool markSchedulesDone)
        {
            api = new ApiProxy();
            var chargeTo = new ChargeTo();

            if (adminChargeCode.All(char.IsNumber) && int.TryParse(adminChargeCode, out int t))
            {
                chargeTo.TicketNumber = t;
            }
            else
            {
                chargeTo.ChargeCode   = adminChargeCode;
                chargeTo.ChargeCodeId = getAndCacheChargeCodeId(adminChargeCode);
            }

            raiseProgressEvent("Getting existing time entries...");
            var timeList = api.GetTimeEntryList(startDate, endDate, memberID);

            raiseProgressEvent("Getting existing schedule entries...");
            var scheduleList = api.GetScheduleEntryList(startDate, endDate, memberID);

            var tec = new TimeEntryCreator(api);

            raiseProgressEvent("Creating time entries...");
            timeList = tec.CreateTimeEntriesForSchedules(timeList, scheduleList, memberID, chargeTo);

            raiseProgressEvent("Creating admin time...");
            tec.CreateAdminTimeToFillGaps(startDate, endDate, maxStart, minEnd, lunchDeduction, timeList, memberID, chargeTo);

            if (markSchedulesDone)
            {
                raiseProgressEvent("Marking schedules as Done...");
                markSchedulesAsDone(scheduleList);
            }

            raiseProgressEvent("Time sheet has been updated.");
        }
Example #2
0
 public TimeEntryCreator(ApiProxy api)
 {
     this.api = api;
 }