/// <summary> /// Increment by 1 by asunto passed on parameter /// </summary> /// <param name="prmAsuntoToFetch"></param> public void Increment(Entidades.Asunto prmAsuntoToFetch, bool refreshAverageAsuntoByHour = true) { try { validateInput(prmAsuntoToFetch); // Find specific balance on the list Entidades.Balance balance = getBalanceByAsunto(prmAsuntoToFetch); // DateTime to process in increment DateTime dateToIncrement; // If the asunto is assigned correctly if (prmAsuntoToFetch.isAssigned) { // Set date of increment on date of assignment dateToIncrement = prmAsuntoToFetch.AssignmentDate; // If the asunto is previously saved on temporaly list if (isLoadedOnTemporalyList(prmAsuntoToFetch)) { // Decrement value on temporaly location saved balance.Decrement(prmAsuntoToFetch.SendingDate); } } else { // If is not assigned means probably change status on program execution _lstOfTemporalyCountedAsuntos.Add(prmAsuntoToFetch); // Set va dateToIncrement = prmAsuntoToFetch.SendingDate; } // Increment balance finded balance.Increment(dateToIncrement); } catch (Exception ex) { throw ex; } }
/// <summary> /// Create a list of balance by a list of operator /// </summary> /// <param name="prmListOfOperatorsToCreate"></param> /// <returns></returns> private List <Entidades.Balance> CreateList(List <Entidades.Operador> prmListOfOperatorsToCreate) { // Create a new List for return on process List <Entidades.Balance> lstNewBalance = new List <Entidades.Balance>(); // Check if input parameters are correct if (prmListOfOperatorsToCreate == null) { throw new Exception("La lista no ha sido comunicada o esta vacía"); } // Iterates over the list of operators to generate the list foreach (var operatorLogged in prmListOfOperatorsToCreate) { // Generate a new balance entity Entidades.Balance newBalance = new Entidades.Balance() { UserName = operatorLogged.UserName, FirstName = operatorLogged.Nombre, LastName = operatorLogged.Apellido, StartTime = operatorLogged.WorkingDayTime.StartTime, EndTime = operatorLogged.WorkingDayTime.EndTime, TotalWorkTime = operatorLogged.TotalWorkTime }; if (operatorLogged.Breaks.Count >= 1) { newBalance.BreakOneStart = operatorLogged.Breaks[0].StartTime; newBalance.BreakOneEnd = operatorLogged.Breaks[0].EndTime; } if (operatorLogged.Breaks.Count >= 2) { newBalance.BreakTwoStart = operatorLogged.Breaks[1].StartTime; newBalance.BreakTwoEnd = operatorLogged.Breaks[1].EndTime; } if (operatorLogged.Breaks.Count >= 3) { newBalance.BreakThreeStart = operatorLogged.Breaks[2].StartTime; newBalance.BreakThreeEnd = operatorLogged.Breaks[2].EndTime; } // Generate a new instance of balance and save on the list lstNewBalance.Add(newBalance); } // Return the list proceseed return(lstNewBalance); }
/// <summary> /// Runs a Simulation of incrementing asuntos and automatic assign asuntos /// </summary> /// <param name="lstAsuntosToAssign"></param> /// <param name="lstOperatorsToAssignate"></param> public void GetAutomaticAsuntoAssignationByAverageHour(List <Entidades.Asunto> lstAsuntosToAssign, List <Entidades.Operador> lstOperatorsToAssignate) { // Get balance list based on parameter operators List <Entidades.Balance> lstBalanceFilteredByOperatorInParameter = List.Where(balance => lstOperatorsToAssignate.Exists( oper => oper.Equals(balance.UserName) )).ToList(); // Start Simulation status over filtered balance lstBalanceFilteredByOperatorInParameter.ForEach(balance => balance.InitSimulation()); // Iterates over all asuntos passed by parameter foreach (var asuntoToAssign in lstAsuntosToAssign) { // Get operator ordered by balance Entidades.Balance selectedBalance = lstBalanceFilteredByOperatorInParameter.OrderBy(balance => balance.SimulationAverageAsuntoByHour).First(); // Get operator Related to balance Entidades.Operador selectedOperator = lstOperatorsToAssignate.Find(oper => oper.Equals(selectedBalance.UserName)); // Assign operador to asunto asuntoToAssign.Oper = selectedOperator; // Increment simulation Balance selectedBalance.SimulateAverageIncrementingByOne(); } }