Ejemplo n.º 1
0
        public void UpdateDpiTimeArrival(CS_CallLog callLog, Globals.CallEntry.CallType type)
        {
            CallLogModel model;
            DateTime actionDate = new DateTime();

            using (model = new CallLogModel())
            {
                actionDate = model.GetCallLogActionDateTime(callLog.Xml).Value;
            }

            if (!actionDate.Equals(new DateTime()))
            {
                DateTime date = actionDate.Date;
                CS_DPI datedDPI = _dpiRepository.Get(e => e.Date == date && e.JobID == callLog.JobID);
                CS_DPI newDPI;

                if (null != datedDPI)
                {
                    newDPI = new CS_DPI()
                    {
                        ApprovedBy = datedDPI.ApprovedBy,
                        Calculate = datedDPI.Calculate,
                        CalculationStatus = datedDPI.CalculationStatus,
                        CreatedBy = datedDPI.CreatedBy,
                        CreationDate = datedDPI.CreationDate,
                        CreationID = datedDPI.CreationID,
                        Date = datedDPI.Date,
                        FirstATA = datedDPI.FirstATA,
                        FirstETA = datedDPI.FirstETA,
                        ID = datedDPI.ID,
                        IsContinuing = datedDPI.IsContinuing,
                        JobID = datedDPI.JobID,
                        ModificationDate = datedDPI.ModificationDate,
                        ModificationID = datedDPI.ModificationID,
                        ModifiedBy = datedDPI.ModifiedBy,
                        ProcessStatus = datedDPI.ProcessStatus,
                        ProcessStatusDate = datedDPI.ProcessStatusDate,
                        Total = datedDPI.Total
                    };

                    if (type == Globals.CallEntry.CallType.ETA)
                    {
                        if (!newDPI.FirstETA.HasValue || actionDate < newDPI.FirstETA.Value)
                        {
                            newDPI.FirstETA = actionDate;

                            _dpiRepository.Update(newDPI);
                        }
                    }
                    else
                    {
                        if (!newDPI.FirstATA.HasValue || actionDate < newDPI.FirstATA.Value)
                        {
                            newDPI.FirstATA = actionDate;

                            _dpiRepository.Update(newDPI);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private List<DPICallLogVO> GetDPICallLogTimesFromList(List<CS_CallLogResource> originalCallLogs, DateTime calculationDate)
        {
            List<DPICallLogVO> returnList = new List<DPICallLogVO>();

            CallLogModel model = new CallLogModel();

            for (int i = 0; i < originalCallLogs.Count; i++)
            {
                DPICallLogVO newVO = new DPICallLogVO() { ID = originalCallLogs[i].CallLogID };

                if (originalCallLogs[i].ActionDate.HasValue)
                    newVO.ActionTime = originalCallLogs[i].ActionDate.Value;
                else
                {
                    // Only for old records
                    if (originalCallLogs[i].CS_CallLog.CS_CallType.ID == (int)Globals.CallEntry.CallType.AddedResource)
                    {
                        int jobID = originalCallLogs[i].JobID;
                        int? employeeID = originalCallLogs[i].EmployeeID;
                        int? equipmentID = originalCallLogs[i].EquipmentID;
                        CS_Resource addedResource = _resourceRepository.Get(e => e.Active && e.JobID == jobID &&
                            ((employeeID.HasValue && e.EmployeeID == employeeID.Value) ||
                             (equipmentID.HasValue && e.EquipmentID == equipmentID.Value)));

                        if (null != addedResource)
                            newVO.ActionTime = addedResource.StartDateTime;
                        else
                            newVO.ActionTime = new DateTime();
                    }
                    else if (originalCallLogs[i].CS_CallLog.CS_CallType.IsAutomaticProcess)
                    {
                        newVO.ActionTime = originalCallLogs[i].CS_CallLog.CreationDate;
                    }
                    else
                    {
                        newVO.ActionTime = model.GetCallLogActionDateTime(originalCallLogs[i].CS_CallLog.Xml).Value;
                    }
                }

                if (newVO.ActionTime.Date == calculationDate.Date)
                    returnList.Add(newVO);
            }

            returnList.Sort();

            return returnList;
        }