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
        public void TestIfTotalIsBeingCalculated()
        {
            // Arrange
            DateTime calculationDate = DateTime.Today;
            CS_DPI dpiEntry = new CS_DPI() { ID = 1, Active = true, ProcessStatus = (short)Globals.DPI.DpiStatus.Pending };
            CS_Job jobEntry = new CS_Job()
            {
                ID = 1,
                Active = true,
                EmergencyResponse = false,
                CS_JobInfo = new CS_JobInfo() { InitialCallDate = calculationDate, InitialCallTime = new TimeSpan(10, 0, 0), Active = true }
            };

            FakeObjectSet<CS_DPIResource> fakeDPIResource = new FakeObjectSet<CS_DPIResource>();
            fakeDPIResource.AddObject(new CS_DPIResource()
            {
                DPIID = dpiEntry.ID,
                CS_DPI = dpiEntry,
                EquipmentID = 1
            });
            fakeDPIResource.AddObject(new CS_DPIResource()
            {
                DPIID = dpiEntry.ID,
                CS_DPI = dpiEntry,
                EmployeeID = 1
            });

            FakeObjectSet<CS_CallLogResource> fakeCallLogResource = new FakeObjectSet<CS_CallLogResource>();
            fakeCallLogResource.AddObject(new CS_CallLogResource()
            {
                CS_CallLog = new CS_CallLog
                {
                    CS_CallType = new CS_CallType()
                    {
                        ID = 13,
                        IsAutomaticProcess = false,
                        DpiStatus = (int)Globals.DPI.CallTypeDpiStatus.Start,
                        Active = true
                    },
                    Xml = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><DynamicFieldsAggregator xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Controls><DynamicControls xsi:type=\"DynamicDatePickerXml\"><Name>dtpDate</Name><Label><Text>Work Date Continuing:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>{0}</Text><IsValidEmpty>false</IsValidEmpty><EmptyValueMessage>The Work Date Continuing field is required</EmptyValueMessage><InvalidValueMessage>Invalid Work Date Continuing format</InvalidValueMessage><DateTimeFormat>Default</DateTimeFormat><ShowOn>Both</ShowOn><ValidationGroup>CallEntry</ValidationGroup></DynamicControls><DynamicControls xsi:type=\"DynamicTimeXml\"><Name>txtTime</Name><Label><Text>Work Time Continuing:</Text><Css>dynamicLabel</Css><Style /></Label><Css>input</Css><Style /><Visible>true</Visible><Text>{1}</Text><Mask>99:99</Mask><MaskedType>Time</MaskedType><InputDirection>LeftToRight</InputDirection><IsValidEmpty>false</IsValidEmpty><ValidationGroup>CallEntry</ValidationGroup><InvalidValueMessage>The Work Time Continuing field is invalid</InvalidValueMessage><EmptyValueMessage>The Work Time Continuing field is required.</EmptyValueMessage></DynamicControls><DynamicControls xsi:type=\"DynamicCountableTextBoxXml\"><Name>txtNote</Name><Label><Text>Note:</Text><Css>dynamicLabel</Css><Style /></Label><Css>input</Css><Style /><Visible>true</Visible><MaxChars>255</MaxChars><MaxCharsWarning>250</MaxCharsWarning><Text>They're BACK!</Text><IsRequired>false</IsRequired><ErrorMessage /><ValidationGroup /><TextMode>MultiLine</TextMode><Width>300</Width><Height>150</Height></DynamicControls></Controls><Extenders /></DynamicFieldsAggregator>",
                        calculationDate.ToString("yyyy-MM-dd"), "10:00"),
                    CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 10, 0, 0)
                },
                JobID = 1,
                CallLogID = 1,
                EquipmentID = 1,
                CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 10, 0, 0)
            });
            fakeCallLogResource.AddObject(new CS_CallLogResource()
            {
                CS_CallLog = new CS_CallLog
                {
                    CS_CallType = new CS_CallType()
                    {
                        ID = 18,
                        IsAutomaticProcess = true,
                        DpiStatus = (int)Globals.DPI.CallTypeDpiStatus.End,
                        Active = true
                    },
                    Xml = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><DynamicFieldsAggregator xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Controls><DynamicControls xsi:type=\"DynamicDatePickerXml\"><Name>dtpDate</Name><Label><Text>Work Date Released:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>{0}</Text><IsValidEmpty>false</IsValidEmpty><EmptyValueMessage>The Work Date Released field is required</EmptyValueMessage><InvalidValueMessage>Invalid Work Date format</InvalidValueMessage><DateTimeFormat>Default</DateTimeFormat><ShowOn>Both</ShowOn><ValidationGroup>CallEntry</ValidationGroup></DynamicControls><DynamicControls xsi:type=\"DynamicTimeXml\"><Name>txtTime</Name><Label><Text>Work Time Released:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>{1}</Text><Mask>99:99</Mask><MaskedType>Time</MaskedType><InputDirection>LeftToRight</InputDirection><IsValidEmpty>false</IsValidEmpty><ValidationGroup>CallEntry</ValidationGroup><InvalidValueMessage>The Work Time Released Time field is invalid</InvalidValueMessage><EmptyValueMessage>The Work Time Released field is required.</EmptyValueMessage></DynamicControls><DynamicControls xsi:type=\"DynamicCountableTextBoxXml\"><Name>txtNote</Name><Label><Text>Note:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><MaxChars>255</MaxChars><MaxCharsWarning>250</MaxCharsWarning><Text>They stopped working!</Text><IsRequired>false</IsRequired><ErrorMessage /><ValidationGroup /><TextMode>MultiLine</TextMode><Width>300</Width><Height>150</Height></DynamicControls></Controls><Extenders /></DynamicFieldsAggregator>",
                        calculationDate.ToString("yyyy-MM-dd"), "15:00"),
                    CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 15, 0, 0)
                },
                JobID = 1,
                CallLogID = 2,
                EquipmentID = 1,
                CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 15, 0, 0)
            });

            fakeCallLogResource.AddObject(new CS_CallLogResource()
            {
                CS_CallLog = new CS_CallLog
                {
                    CS_CallType = new CS_CallType()
                    {
                        ID = 13,
                        IsAutomaticProcess = false,
                        DpiStatus = (int)Globals.DPI.CallTypeDpiStatus.Start,
                        Active = true
                    },
                    Xml = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><DynamicFieldsAggregator xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Controls><DynamicControls xsi:type=\"DynamicDatePickerXml\"><Name>dtpDate</Name><Label><Text>Work Date Continuing:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>{0}</Text><IsValidEmpty>false</IsValidEmpty><EmptyValueMessage>The Work Date Continuing field is required</EmptyValueMessage><InvalidValueMessage>Invalid Work Date Continuing format</InvalidValueMessage><DateTimeFormat>Default</DateTimeFormat><ShowOn>Both</ShowOn><ValidationGroup>CallEntry</ValidationGroup></DynamicControls><DynamicControls xsi:type=\"DynamicTimeXml\"><Name>txtTime</Name><Label><Text>Work Time Continuing:</Text><Css>dynamicLabel</Css><Style /></Label><Css>input</Css><Style /><Visible>true</Visible><Text>{1}</Text><Mask>99:99</Mask><MaskedType>Time</MaskedType><InputDirection>LeftToRight</InputDirection><IsValidEmpty>false</IsValidEmpty><ValidationGroup>CallEntry</ValidationGroup><InvalidValueMessage>The Work Time Continuing field is invalid</InvalidValueMessage><EmptyValueMessage>The Work Time Continuing field is required.</EmptyValueMessage></DynamicControls><DynamicControls xsi:type=\"DynamicCountableTextBoxXml\"><Name>txtNote</Name><Label><Text>Note:</Text><Css>dynamicLabel</Css><Style /></Label><Css>input</Css><Style /><Visible>true</Visible><MaxChars>255</MaxChars><MaxCharsWarning>250</MaxCharsWarning><Text>They're BACK!</Text><IsRequired>false</IsRequired><ErrorMessage /><ValidationGroup /><TextMode>MultiLine</TextMode><Width>300</Width><Height>150</Height></DynamicControls></Controls><Extenders /></DynamicFieldsAggregator>",
                        calculationDate.ToString("yyyy-MM-dd"), "10:00"),
                    CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 10, 0, 0)
                },
                JobID = 1,
                CallLogID = 3,
                EmployeeID = 1,
                CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 10, 0, 0)
            });
            fakeCallLogResource.AddObject(new CS_CallLogResource()
            {
                CS_CallLog = new CS_CallLog
                {
                    CS_CallType = new CS_CallType()
                    {
                        ID = 18,
                        IsAutomaticProcess = true,
                        DpiStatus = (int)Globals.DPI.CallTypeDpiStatus.End,
                        Active = true
                    },
                    Xml = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><DynamicFieldsAggregator xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Controls><DynamicControls xsi:type=\"DynamicDatePickerXml\"><Name>dtpDate</Name><Label><Text>Work Date Released:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>{0}</Text><IsValidEmpty>false</IsValidEmpty><EmptyValueMessage>The Work Date Released field is required</EmptyValueMessage><InvalidValueMessage>Invalid Work Date format</InvalidValueMessage><DateTimeFormat>Default</DateTimeFormat><ShowOn>Both</ShowOn><ValidationGroup>CallEntry</ValidationGroup></DynamicControls><DynamicControls xsi:type=\"DynamicTimeXml\"><Name>txtTime</Name><Label><Text>Work Time Released:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>{1}</Text><Mask>99:99</Mask><MaskedType>Time</MaskedType><InputDirection>LeftToRight</InputDirection><IsValidEmpty>false</IsValidEmpty><ValidationGroup>CallEntry</ValidationGroup><InvalidValueMessage>The Work Time Released Time field is invalid</InvalidValueMessage><EmptyValueMessage>The Work Time Released field is required.</EmptyValueMessage></DynamicControls><DynamicControls xsi:type=\"DynamicCountableTextBoxXml\"><Name>txtNote</Name><Label><Text>Note:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><MaxChars>255</MaxChars><MaxCharsWarning>250</MaxCharsWarning><Text>They stopped working!</Text><IsRequired>false</IsRequired><ErrorMessage /><ValidationGroup /><TextMode>MultiLine</TextMode><Width>300</Width><Height>150</Height></DynamicControls></Controls><Extenders /></DynamicFieldsAggregator>",
                        calculationDate.ToString("yyyy-MM-dd"), "16:00"),
                    CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 16, 0, 0)
                },
                JobID = 1,
                CallLogID = 4,
                EmployeeID = 1,
                CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 16, 0, 0)
            });

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_DPIResource>()).Returns(fakeDPIResource);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallLogResource>()).Returns(fakeCallLogResource);

            // Act
            DPIModel model = new DPIModel(mockUnitOfWork.Object);
            IList<CS_DPIResource> returnList = model.ProcessDPIResources(dpiEntry, jobEntry, calculationDate);

            // Assert
            CS_DPIResource equipment = returnList.FirstOrDefault(e => e.EquipmentID == 1);
            CS_DPIResource employee = returnList.FirstOrDefault(e => e.EmployeeID == 1);
            Assert.AreEqual(equipment.Hours * equipment.Rate, equipment.Total);
            Assert.AreEqual(employee.Hours * employee.Rate, employee.Total);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates DPI and its resources (only for screen, not for processing)
        /// </summary>
        /// <param name="currentDPI">Current DPI</param>
        /// <param name="dpiResources">Resources of the DPI</param>
        /// <param name="specialPricing">Special Pricing Information</param>
        /// <param name="manualSpecialPricingList">Manual Special Pricing Table</param>
        public void UpdateDPI(CS_DPI currentDPI, IList<CS_DPIResource> dpiResources, CS_DPISpecialPricing specialPricing, IList<CS_DPIManualSpecialPricing> manualSpecialPricingList)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                decimal total = UpdateDPI(currentDPI, dpiResources, DateTime.Now);

                if (null != specialPricing)
                {
                    CS_DPISpecialPricing oldSpecialPricing = _dpiSpecialPricingRepository.Get(e => e.DPIID == currentDPI.ID && e.Active);
                    if (null == oldSpecialPricing)
                        _dpiSpecialPricingRepository.Add(specialPricing);
                    else
                        _dpiSpecialPricingRepository.Update(specialPricing);
                }

                if (manualSpecialPricingList.Count > 0)
                {
                    IList<CS_DPIManualSpecialPricing> oldManualList = _dpiManualSpecialPricingRepository.ListAll(e => e.Active && e.DPIId == currentDPI.ID);
                    List<int> currentManualIDs = manualSpecialPricingList.Select(e => e.ID).ToList();

                    List<CS_DPIManualSpecialPricing> addList = manualSpecialPricingList.Where(e => e.ID == 0).ToList();
                    List<CS_DPIManualSpecialPricing> updateList = manualSpecialPricingList.Where(e => e.ID != 0).ToList();
                    List<CS_DPIManualSpecialPricing> removeList = oldManualList.Where(e => !currentManualIDs.Contains(e.ID)).ToList();

                    for (int i = 0; i < removeList.Count; i++)
                    {
                        removeList[i].ModificationDate = currentDPI.ModificationDate;
                        removeList[i].ModifiedBy = currentDPI.ModifiedBy;
                        //removeList[i].ModificationID = currentDPI.ModificationID;
                        removeList[i].Active = false;
                    }

                    _dpiManualSpecialPricingRepository.AddList(addList);
                    _dpiManualSpecialPricingRepository.UpdateList(updateList);
                    _dpiManualSpecialPricingRepository.UpdateList(removeList);
                }

                if (currentDPI.ProcessStatus == (short)Globals.DPI.DpiStatus.Approved)
                {
                    currentDPI.Total = total;
                    _callLogRepository.Add(SetCallLogDPIProcess(currentDPI));
                }

                scope.Complete();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates DPI and its resources
        /// </summary>
        /// <param name="currentDPI">Current DPI</param>
        /// <param name="dpiResources">Resources of the DPI</param>
        /// <returns>Total value of resources</returns>
        public decimal UpdateDPI(CS_DPI currentDPI, IList<CS_DPIResource> dpiResources, DateTime calculationDate)
        {
            try
            {
                CS_DPI updateDPI = null;
                //IList<CS_DPIResource> updateDPIResouceList = new List<CS_DPIResource>();

                decimal total = 0;
                bool insuficient = false;

                if (null != currentDPI)
                {
                    for (int i = 0; i < dpiResources.Count; i++)
                    {
                        CS_DPIResource dpiResource = dpiResources[i];

                        //CS_DPIResource addResource = new CS_DPIResource()
                        //{
                        //    ID = dpiResource.ID,
                        //    DPIID = currentDPI.ID,
                        //    EquipmentID = dpiResource.EquipmentID,
                        //    EmployeeID = dpiResource.EmployeeID,
                        //    CalculationStatus = dpiResource.CalculationStatus,
                        //    Hours = dpiResource.Hours,
                        //    ModifiedHours = dpiResource.ModifiedHours,
                        //    IsContinuing = dpiResource.IsContinuing,
                        //    ContinuingHours = dpiResource.ContinuingHours,
                        //    Rate = dpiResource.Rate,
                        //    ModifiedRate = dpiResource.ModifiedRate,
                        //    PermitQuantity = dpiResource.PermitQuantity,
                        //    PermitRate = dpiResource.PermitRate,
                        //    MealQuantity = dpiResource.MealQuantity,
                        //    MealRate = dpiResource.MealRate,
                        //    HasHotel = dpiResource.HasHotel,
                        //    HotelRate = dpiResource.HotelRate,
                        //    ModifiedHotelRate = dpiResource.ModifiedHotelRate,
                        //    Total = dpiResource.Total,
                        //    CreatedBy = dpiResource.CreatedBy,
                        //    //CreationID,
                        //    CreationDate = dpiResource.CreationDate,
                        //    ModifiedBy = currentDPI.ModifiedBy,
                        //    //ModificationID,
                        //    ModificationDate = calculationDate,
                        //    Active = true
                        //};
                        dpiResource.ModificationDate = calculationDate;
                        dpiResource.ModifiedBy = currentDPI.ModifiedBy;
                        //dpiResource.ModificationID = null;

                        if (dpiResource.CalculationStatus == (short)Globals.DPI.CalculationStatus.INSF)
                            insuficient = true;

                        //updateDPIResouceList.Add(addResource);

                        total += dpiResource.Total;
                    }

                    updateDPI = new CS_DPI()
                    {
                        ID = currentDPI.ID,
                        Date = currentDPI.Date,
                        JobID = currentDPI.JobID,
                        ProcessStatus = currentDPI.ProcessStatus,
                        IsContinuing = currentDPI.IsContinuing,
                        ProcessStatusDate = currentDPI.ProcessStatusDate,
                        ApprovedBy = currentDPI.ApprovedBy,
                        CalculationStatus = (short)((insuficient) ? Globals.DPI.CalculationStatus.INSF : Globals.DPI.CalculationStatus.Done),
                        Calculate = currentDPI.Calculate,
                        Total = Math.Round(total),
                        FirstETA = currentDPI.FirstETA,
                        FirstATA = currentDPI.FirstATA,
                        CreatedBy = currentDPI.CreatedBy,
                        //CreationID =,
                        CreationDate = currentDPI.CreationDate,
                        ModifiedBy = currentDPI.CreatedBy,
                        //ModificationID,
                        ModificationDate = calculationDate,
                        Active = true
                    };
                    //currentDPI.CalculationStatus = (short)((insuficient) ? Globals.DPI.CalculationStatus.INSF : Globals.DPI.CalculationStatus.Done);
                    //currentDPI.Total = Math.Round(total);
                    //currentDPI.ModifiedBy = currentDPI.CreatedBy;
                    //currentDPI.ModificationDate = calculationDate;
                }

                //_dpiResourceRepository.UpdateList(updateDPIResouceList);
                _dpiResourceRepository.UpdateList(dpiResources);
                _dpiRepository.Update(updateDPI);
                //_dpiRepository.Update(currentDPI);

                return total;
            }
            catch (Exception ex)
            {
                if (null == ex.InnerException)
                    Logger.Write(string.Format("There was an error Updating the DPI  and DPI Resource data.\n{0}\n{1}", ex.Message, ex.StackTrace));
                else
                    Logger.Write(string.Format("There was an error Updating the DPI  and DPI Resource data.\n{0}\n{1}\nInner Exception:\n{2}\n{3}", ex.Message, ex.StackTrace, ex.InnerException.Message, ex.InnerException.StackTrace));
                throw new Exception("There was an error Updating the DPI  and DPI Resource data.", ex);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Set all values to the CS_CallLog entity
        /// </summary>
        /// <returns>CS_CallLog</returns>
        public CS_CallLog SetCallLogDPIProcess(CS_DPI currentDPI)
        {
            CS_CallLog callLog = new CS_CallLog();

            callLog.Active = true;
            callLog.PrimaryCallTypeId = (int)Globals.CallEntry.PrimaryCallType.JobUpdateNotification;
            callLog.CallDate = DateTime.Now;
            callLog.CalledInByCustomer = null;
            callLog.CalledInByEmployee = null;
            callLog.CallTypeID = (int)Globals.CallEntry.CallType.DPIApproved;
            callLog.CreatedBy = currentDPI.ModifiedBy;
            callLog.CreationDate = currentDPI.ModificationDate;
            //callLog.CreationID = null;
            callLog.HasGeneralLog = null;
            callLog.JobID = currentDPI.JobID;
            callLog.ModificationDate = currentDPI.ModificationDate;
            //callLog.ModificationID
            callLog.ModifiedBy = currentDPI.ModifiedBy;
            callLog.Note = GenerateDPIProcessNote(currentDPI);
            callLog.ShiftTransferLog = null;
            callLog.UserCall = true;
            callLog.Xml = null;

            return callLog;
        }
Ejemplo n.º 6
0
        public IList<CS_DPIResource> ProcessDPIResources(CS_DPI dpiEntity, CS_Job jobEntity, DateTime calculationDate)
        {
            List<CS_DPIResource> returnList = _dpiResourceRepository.ListAll(e => e.DPIID == dpiEntity.ID && e.Active).ToList();

            DateTime jobCallDate = jobEntity.CS_JobInfo.InitialCallDate + jobEntity.CS_JobInfo.InitialCallTime;

            for (int i = 0; i < returnList.Count; i++)
            {
                List<CS_CallLogResource> callLogs = new List<CS_CallLogResource>();
                int equipId = 0, emplId = 0;

                if (returnList[i].EquipmentID.HasValue)
                {
                    equipId = returnList[i].EquipmentID.Value;
                    callLogs = _callLogResourceRepository.ListAll(e => e.EquipmentID == equipId && e.JobID == jobEntity.ID && e.ModificationDate >= calculationDate.Date, "CS_CallLog", "CS_CallLog.CS_CallType").ToList();
                }
                else
                {
                    emplId = returnList[i].EmployeeID.Value;
                    callLogs = _callLogResourceRepository.ListAll(e => e.EmployeeID == emplId && e.JobID == jobEntity.ID && e.ModificationDate >= calculationDate.Date, "CS_CallLog", "CS_CallLog.CS_CallType").ToList();
                }

                //RETRIEVES LIST OF CALL LOGS THAT HAVE A 'START STATUS', TRANSFORM AND ORDER THEM BY DATE
                List<DPICallLogVO> startCallLogs = GetDPICallLogTimesFromList(callLogs.Where(e => e.CS_CallLog.CS_CallType.DpiStatus == (int)Globals.DPI.CallTypeDpiStatus.Start).ToList(), calculationDate);

                //RETRIEVES LIST OF CALL LOGS THAT HAVE A 'END STATUS', TRANSFORM AND ORDER THEM BY DATE
                List<DPICallLogVO> endCallLogs = GetDPICallLogTimesFromList(callLogs.Where(e => e.CS_CallLog.CS_CallType.DpiStatus == (int)Globals.DPI.CallTypeDpiStatus.End).ToList(), calculationDate);

                callLogs = null;

                returnList[i] = CalculateHoursForResouce(returnList[i], jobEntity.EmergencyResponse, jobCallDate, startCallLogs, endCallLogs, calculationDate);

                if (dpiEntity.ProcessStatus == (int)Globals.DPI.DpiStatus.Pending)
                {
                    returnList[i].Total = Convert.ToDecimal(returnList[i].Rate * returnList[i].Hours);
                }
            }

            return returnList;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Generates the string to be used on notes field for the call log
        /// </summary>
        /// <returns></returns>
        public string GenerateDPIProcessNote(CS_DPI currentDPI)
        {
            StringBuilder sb = new StringBuilder();

            decimal previousTotal = GetPreviousTotal(currentDPI.JobID, currentDPI.Date);
            decimal currentTotal = previousTotal + currentDPI.Total;

            sb.Append(string.Format("DPI Date:<Text>{0}<BL>", currentDPI.Date.ToString("MM/dd/yyyy")));
            sb.Append(string.Format("Previous Total:<Text>{0}<BL>", string.Format("{0:C2}", previousTotal)));
            sb.Append(string.Format("New Revenue:<Text>{0}<BL>", string.Format("{0:C2}", currentDPI.Total)));
            sb.Append(string.Format("Current Total:<Text>{0}", string.Format("{0:C2}", currentTotal)));

            return sb.ToString();
        }
Ejemplo n.º 8
0
        private CS_DPIResource CreateAutomaticDPIObject(CS_DPI dpi, CS_Resource resource, DateTime calculationDate)
        {
            CS_DPIResource dpiResource = new CS_DPIResource();
            dpiResource.DPIID = dpi.ID;

            if (resource.EquipmentID.HasValue)
            {
                dpiResource.EquipmentID = resource.EquipmentID;

                if (resource.CS_Equipment.Seasonal && resource.CS_Equipment.ComboID.HasValue && resource.CS_Equipment.ID != resource.CS_Equipment.CS_EquipmentCombo.PrimaryEquipmentID && resource.CS_Equipment.DivisionID != resource.CS_Equipment.CS_EquipmentCombo.CS_Equipment_PrimaryEquipment.DivisionID)
                    dpiResource.DivisionID = resource.CS_Equipment.CS_EquipmentCombo.CS_Equipment_PrimaryEquipment.DivisionID;
                else
                    dpiResource.DivisionID = resource.CS_Equipment.DivisionID;
            }

            if (resource.EmployeeID.HasValue)
            {
                dpiResource.EmployeeID = resource.EmployeeID;
                dpiResource.DivisionID = resource.CS_Employee.DivisionID;
            }

            dpiResource.CalculationStatus = dpi.CalculationStatus;
            dpiResource.Hours = 0;
            dpiResource.IsContinuing = false;
            dpiResource.Rate = 0;
            dpiResource.HasHotel = false;
            dpiResource.Total = 0;
            dpiResource.CreatedBy = "System";
            dpiResource.CreationDate = calculationDate;
            dpiResource.ModifiedBy = "System";
            dpiResource.ModificationDate = calculationDate;
            dpiResource.Active = true;
            return dpiResource;
        }
Ejemplo n.º 9
0
        public void UpdateDPIToCalculateByResources(int jobID, IList<int> equipmentIDList, IList<int> employeeIDList)
        {
            IList<CS_DPI> dpiList = _dpiRepository.ListAll(e =>
                                                            e.JobID == jobID
                                                            && e.ProcessStatus != (short)Globals.DPI.DpiStatus.Approved
                                                            && e.Active
                                                            && !e.Calculate
                                                            && e.CS_DPIResource.Any(j => ((j.EquipmentID.HasValue && equipmentIDList.Contains(j.EquipmentID.Value)) ||
                                                                                          (j.EmployeeID.HasValue && employeeIDList.Contains(j.EmployeeID.Value)) &&
                                                                                          j.Active))
                                                        );

            IList<CS_DPI> updateList = new List<CS_DPI>();

            for (int i = 0; i < dpiList.Count; i++)
            {
                CS_DPI updateDPI = new CS_DPI()
                {
                    ID = dpiList[i].ID,
                    Date = dpiList[i].Date,
                    JobID = dpiList[i].JobID,
                    ProcessStatus = dpiList[i].ProcessStatus,
                    IsContinuing = dpiList[i].IsContinuing,
                    ProcessStatusDate = dpiList[i].ProcessStatusDate,
                    ApprovedBy = dpiList[i].ApprovedBy,
                    CalculationStatus = dpiList[i].CalculationStatus,
                    Calculate = true,
                    Total = dpiList[i].Total,
                    FirstETA = dpiList[i].FirstETA,
                    FirstATA = dpiList[i].FirstATA,
                    CreatedBy = dpiList[i].CreatedBy,
                    //CreationID =,
                    CreationDate = dpiList[i].CreationDate,
                    ModifiedBy = dpiList[i].ModifiedBy,
                    //ModificationID,
                    ModificationDate = DateTime.Now,
                    Active = true
                };

                updateList.Add(updateDPI);
            }

            _dpiRepository.UpdateList(updateList);
        }