Exemplo n.º 1
0
        public static List <TimeSpan> GetOptionalHoursPerDay(int serviceId, DateTime date)
        {
            List <activityTime> activityTimes = ActivityTimeDal.GetActivityTimesByDay(serviceId, (int)date.DayOfWeek + 1);
            List <TimeSpan>     optionalHours = new List <TimeSpan>();
            int activityTimeIndex             = 0;
            int index = 0;

            activityTimes.OrderBy(a => a.startTime);
            while (activityTimeIndex < activityTimes.Count())
            {
                activityTime           activityTime = activityTimes[activityTimeIndex];
                List <customersInLine> line         = TurnDal.GetLinePerActivityTime(activityTime.activityTimeId);
                double   durationOfService          = activityTime.avgServiceDuration.Value;
                TimeSpan ts = TimeSpan.FromMinutes(durationOfService);
                for (TimeSpan hour = activityTime.startTime; hour < activityTime.endTime; hour = hour.Add(ts))
                {
                    if (TurnBL.IsAvailableHour(ref index, activityTime.numOfWorkers, hour.Add(ts), line))
                    {
                        if (!date.Equals(DateTime.Today) || hour.Add(ts) > DateTime.Now.TimeOfDay)
                        {
                            optionalHours.Add(hour);
                        }
                    }
                    index++;
                }
                activityTimeIndex++;
            }
            return(optionalHours);
        }
Exemplo n.º 2
0
        /// <summary>
        /// calc the new data with the old statisic
        /// </summary>
        /// <param name="line">the turns that are not unuaual</param>
        /// <param name="activityTime"></param>
        private static void UpdateStatistics(List <customersInLine> line, activityTime activityTime, bool IsServiceDuration)
        {
            //todoever: לעשות ביטוי למבדה במקום ה-if
            //שליפת ממוצע משמרת הכפלה ברוחב המדגם הוספת הנתונים החדשים, הוספת מספר הנתונים לרוחב המדגם וחלוקה של הסכום ברוחב המדגם
            //חישוב מחודש של סטיית טקן
            int    totalSampleSize = activityTime.sampleSize.Value + line.Count();
            double activityTimeAvg, newAvg, weightedAverage;

            if (IsServiceDuration)
            {
                activityTimeAvg = activityTime.avgServiceDuration.Value;
                newAvg          = line.Average(lenOfServiceSelector);
            }
            else
            {
                activityTimeAvg = activityTime.avgWaitings.Value;
                newAvg          = line.Average(lenOfWaitingSelector);
            }
            weightedAverage = (activityTimeAvg * activityTime.sampleSize.Value + newAvg * line.Count()) / totalSampleSize;
            double newStandardDeviation = calcStandartDeviation(line, IsServiceDuration);

            //todo: double weightedStandardDeviation = (activityTime.sampleSize.Value * Math.Sqrt(activityTime.sStandardDeviation.Value) + line.Count() * Math.Sqrt(newStandardDeviation));
            //  weightedStandardDeviation += Math.Sqrt(activityTime.sampleSize.Value * (activityTimeAvg - weightedAverage)) + Math.Sqrt(line.Count() * (newAvg - weightedAverage));
            // weightedStandardDeviation /= totalSampleSize;
            //todo: להוציא שורש מכל הסיפור הזה כי זה שונות משוקללת  ולא סטית תקן
            activityTime.sampleSize = totalSampleSize;
            if (IsServiceDuration)
            {
                activityTime.avgServiceDuration = weightedAverage;
                //  activityTime.serviceStandardDeviation = weightedStandardDeviation;
            }
            else
            {
                activityTime.avgWaitings = weightedAverage;
                //   activityTime.waitingStandardDeviation = weightedStandardDeviation;
            }
            ActivityTimeDal.UpdateActivityTime(activityTime);
        }