Пример #1
0
        /// <summary>
        /// Check if person can work this shift - ie does it overlap with an existing shift.
        /// does not check if they have the correct tags
        /// </summary>
        /// <param name="newShift"></param>
        /// <returns></returns>
        public bool CanWorkThis(ShiftSlotOld newShift)
        {
            foreach (ShiftOld item in _shiftsWorking[newShift.day])
            {
                if ((int.Parse(newShift.startHour) >= int.Parse(item.startHour))
                    &&
                    (int.Parse(newShift.endHour) <= int.Parse(item.endHour)))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Used to actually load the data into memory
        /// </summary>
        public void LoadSkeleton(string input)
        {
            // Variables required to process input
            // a copy of the array of lists of days
            List <string> daysOfWeek = TimeUtilities.daysOfWeek;
            // holds semi-processed data
            List <string> splitRawData = new List <string>();

            // raw input
            string rawData = input;

            // if there was an error loading the data or file is empty
            if (rawData == "")
            {
                return;
            }


            // remove all the extra whitespaces
            rawData = rawData.Trim();
            // temporary hold the raw data split by newline character
            string[] temp = rawData.Split('\n');


            // loop through split string and extract the useful information omitting not useful data
            for (int x = 0; x < temp.Length; x++)
            {
                // check if this commented out and skip this iteration if it is
                if (temp[x] == "" || temp[x][0] == '#' || temp[x] == System.Environment.NewLine || temp[x] == "\r")
                {
                    continue;
                }

                splitRawData.Add(temp[x].Trim());
            }

            // extract the main useful data
            author     = splitRawData[1];
            startDay   = splitRawData[2];
            endDay     = splitRawData[3];
            scheduleID = Int32.Parse(splitRawData[4]);
            payDay     = splitRawData[5];

            // now extract the remaining data

            // start at this position
            int rawDataLoop = 8;

            // loop once per day of the week
            for (int x = 0; x < daysOfWeek.Count; x++)
            {
                // get the list for the current day
                List <ShiftSlotOld> loadInProgress = shiftSlots[daysOfWeek[x]];

                // while the current line isn't a closing day for this day of the week ie "</monday>"
                while (!splitRawData[rawDataLoop].Contains("/" + daysOfWeek[x]))
                {
                    // used to ignore opening tags i.e. "<monday>"
                    if (!splitRawData[rawDataLoop].Contains(daysOfWeek[x]))
                    {
                        // create a new shift slot object and populate with the approperiate data
                        ShiftSlotOld newSlot = new ShiftSlotOld();

                        // split line by ','
                        temp = splitRawData[rawDataLoop].Split(',');

                        // only process if there are 4 or more items post-split
                        if (!(temp.Length < 4))
                        {
                            // populate data
                            newSlot.shiftName = temp[0].Trim();
                            newSlot.day       = daysOfWeek[x];
                            if (Int32.Parse(temp[1]) < 1000)
                            {
                                newSlot.startHour = "0" + temp[1].Trim();
                            }
                            else
                            {
                                newSlot.startHour = temp[1].Trim();
                            }

                            if (Int32.Parse(temp[2]) < 1000)
                            {
                                newSlot.endHour = "0" + temp[2].Trim();
                            }
                            else
                            {
                                newSlot.endHour = temp[2].Trim();
                            }
                            newSlot._employeesRequired = Int32.Parse(temp[3].Trim());

                            // add to list
                            loadInProgress.Add(newSlot);

                            // increment count of shifts
                            totalShiftsAvailabile += newSlot._employeesRequired;
                        }
                    }
                    // increment loop value
                    rawDataLoop++;
                }
            }

            rawData = null;
        }
Пример #3
0
 /// <summary>
 /// Unassigns Employee from this job
 /// </summary>
 /// <param name="index">Index of employee to unassign</param>
 public void UnassignEmployee(ShiftSlotOld shift, int employeeIndex)
 {
 }