/// <summary> /// /// </summary> /// <param name="activityTimeId"></param> public static void calcAvgServiceDuration(int activityTimeId) { DAL.activityTime activityTime = ActivityTimeDal.GetActivityTimeById(activityTimeId); double avg = activityTime.avgServiceDuration.Value; findUnusualSequences(activityTimeId, avg, true); }
/// <summary> /// find sequence of unusual turns /// </summary> /// <param name="activityTimeId"></param> public static void findUnusualSequences(int activityTimeId, double avg, bool IsServiceDuration) { var line = DAL.TurnDal.GetLinePerActivityTime(activityTimeId); List <int> significantDeviationIndexes = new List <int>(); DAL.activityTime activityTime = ActivityTimeDal.GetActivityTimeById(activityTimeId); int i = 0; bool isSignificantStatus = false; //שומרת ברשימה את האינדקסים של כל התחלה וסוף של תורים חריגים foreach (var item in line) { bool isSignificant = IsSignificantDeviation(item, avg, IsServiceDuration); if (isSignificant && !isSignificantStatus) { significantDeviationIndexes.Add(i); isSignificantStatus = true; } else if (!isSignificant && isSignificantStatus) { significantDeviationIndexes.Add(i - 1); isSignificantStatus = false; } i++; } int sum = 0; int index = 0; // עוברת על מערך האינדקסים ובודקת האם הרצף משמעותי -אם כן ממשיכה ובודקת האם קים הפרש משמעותי בינו לבין הרצף הבא //אם כן ממשיכה לסכום- אם לא בודקת האם זהו רצף ארוך מספיק כדי להכניסו לטבלת חריגים for (i = 1; i < significantDeviationIndexes.Count; i += 2) { int length = significantDeviationIndexes[i] - significantDeviationIndexes[i - 1]; if (length > minSequence) { sum += length; if (index == 0) { index = significantDeviationIndexes[i - 1]; } } if (significantDeviationIndexes[i + 1] - significantDeviationIndexes[i] > minSequence) {/* * if (sum >= minToDivide) * //todo: SetUnusualActivityTime(line.Skip(index).Take(significantDeviationIndexes[i]).ToList()); * else * //todo: UpdateStatistics(line.Skip(index).Take(significantDeviationIndexes[i]).ToList(), activityTime); * index = 0; * sum = 0; */ } } }
public static void calcAvgWaitingPeople(int activityTimeId) { //ההבדל בין הזמן המשוער לזמן האמיתי //הנתון המענין כמה דחיפות היו בזמן הזה צריך לדעת ממוצע דחיפות //numOfPushTimes לפי //מאד דומה לפונקציה למעלה //todo: כשמאתחלים משמרת חדשה לאפס נתונים DAL.activityTime activityTime = ActivityTimeDal.GetActivityTimeById(activityTimeId); double avg = activityTime.avgWaitings.Value; findUnusualSequences(activityTimeId, avg, false); }
public static void UpdateActivityTime(activityTime activityTime) { try { using (onLineEntities1 entities = new onLineEntities1()) { var updateActivityTime = entities.activityTimes.FirstOrDefault(a => a.activityTimeId == activityTime.activityTimeId); updateActivityTime.avgServiceDuration = activityTime.avgServiceDuration.Value; //todo: updateActivityTime.StandardDeviation = activityTime.StandardDeviation.Value; updateActivityTime.sampleSize = updateActivityTime.sampleSize.Value; entities.SaveChanges(); } } catch (Exception) { throw; } }