public void ValidateCallLogGridLinkButtonVisibility(CS_CallLog callLog)
 {
     try
     {
         _view.SetCallLogGridViewHyperLinkVisibility(!callLog.CS_CallType.IsAutomaticProcess, "hlUpdate");
     }
     catch (Exception ex)
     {
         Logger.Write(string.Format("There was an error validating the visibility for the Call log Grid Link Button!\n{0}\n{1}", ex.Message, ex.StackTrace));
         _view.DisplayMessage("There was an error loading the information! Please try again.", false);
     }
 }
        private string GenerateEmailSubjectForReservedResources(CS_CallLog callLogEntry)
        {
            StringBuilder subject = new StringBuilder();
            int jobID = callLogEntry.JobID;
            CS_Job job = _jobRepository.Get(e => e.ID == jobID, "CS_CustomerInfo", "CS_CustomerInfo.CS_Customer", "CS_JobInfo", "CS_JobInfo.CS_JobAction", "CS_LocationInfo", "CS_LocationInfo.CS_City", "CS_LocationInfo.CS_State");

            subject.Append(job.PrefixedNumber);
            subject.Append(", ");
            subject.Append(job.CS_CustomerInfo.CS_Customer.Name.Trim());
            subject.Append(", ");
            subject.Append(callLogEntry.CS_Job.CS_JobInfo.CS_JobAction.Description);

            if (job.ID != (int)Globals.GeneralLog.ID)
            {
                subject.Append(", ");
                subject.Append(callLogEntry.CS_Job.CS_LocationInfo.CS_City.Name);
                subject.Append(" ");
                subject.Append(callLogEntry.CS_Job.CS_LocationInfo.CS_State.Acronym);
            }

            subject.Append(", Reserved Resource");

            return subject.ToString();
        }
        /// <summary>
        /// Generates records for a FirstAlert Call Criteria Resources
        /// </summary>
        /// <param name="initialAdvise">Generated Initial Advise Call Log</param>
        private IList<EmailVO> SaveCallCriteriaFirstAlertResources(CS_CallLog firstAlert)
        {
            try
            {
                IList<CS_CallLogResource> saveList = new List<CS_CallLogResource>();
                IList<CS_CallLogCallCriteriaEmail> emailSaveList = new List<CS_CallLogCallCriteriaEmail>();

                IList<EmailVO> resourceList = _callCriteriaModel.ListReceiptsByCallLog(firstAlert.CallTypeID.ToString(), firstAlert.JobID, firstAlert);

                for (int i = 0; i < resourceList.Count; i++)
                {
                    // Because of the Type, we need to separate the PersonID in two different variables
                    int? employeeId = null;
                    int? contactId = null;
                    if (resourceList[i].Type == (int)Globals.CallCriteria.EmailVOType.Employee)
                        employeeId = resourceList[i].PersonID;
                    else
                        contactId = resourceList[i].PersonID;

                    CS_CallLogResource resource = new CS_CallLogResource()
                    {
                        CallLogID = firstAlert.ID,
                        EmployeeID = employeeId,
                        ContactID = contactId,
                        JobID = firstAlert.JobID,
                        Type = resourceList[i].Type,
                        CreatedBy = firstAlert.CreatedBy,
                        CreationDate = DateTime.Now,
                        ModifiedBy = firstAlert.ModifiedBy,
                        ModificationDate = DateTime.Now,
                        Active = true
                    };

                    saveList.Add(resource);

                    CS_CallLogCallCriteriaEmail emailResource = new CS_CallLogCallCriteriaEmail()
                    {
                        CallLogID = firstAlert.ID,
                        Name = resourceList[i].Name,
                        Email = resourceList[i].Email,
                        Status = (int)Globals.CallCriteria.CallCriteriaEmailStatus.Pending,
                        StatusDate = DateTime.Now,
                        //CreationID = ,
                        CreatedBy = firstAlert.CreatedBy,
                        CreationDate = DateTime.Now,
                        //ModificationID,
                        ModifiedBy = firstAlert.ModifiedBy,
                        ModificationDate = DateTime.Now,
                        Active = true
                    };

                    emailSaveList.Add(emailResource);
                }

                _callLogResourceRepository.AddList(saveList);

                _callLogCallCriteriaEmailRepository.AddList(emailSaveList);

                return resourceList;
            }
            catch (Exception ex)
            {
                throw new Exception("There was an error while trying to save the First Alert Resources.", ex);
            }
        }
Ejemplo n.º 4
0
        private void SaveCloningCallLog(int cloningId, int newJobId)
        {
            CallLogModel model = new CallLogModel(_unitOfWork);

            CS_CallType callType = model.GetCallTypeByDescription("Job Cloning");
            CS_Job oldJob = _jobRepository.Get(e => e.ID == cloningId);

            CS_CallLog oldJobLog = new CS_CallLog()
            {
                JobID = cloningId,
                CallTypeID = callType.ID,
                PrimaryCallTypeId = callType.CS_PrimaryCallType_CallType.First(e => e.CallTypeID == callType.ID).PrimaryCallTypeID,
                CallDate = NewJob.CreationDate,
                Note = string.Format("Job # {0} has been cloned to Job # {1}", oldJob.NumberOrInternalTracking, NewJob.NumberOrInternalTracking),
                CreatedBy = NewJob.CreatedBy,
                CreationDate = NewJob.CreationDate,
                ModifiedBy = NewJob.ModifiedBy,
                ModificationDate = NewJob.ModificationDate,
                Active = true,
                ShiftTransferLog = false
            };

            _callLogRepository.Add(oldJobLog);

            CS_CallLog newJobLog = new CS_CallLog()
            {
                JobID = newJobId,
                CallTypeID = oldJobLog.CallTypeID,
                PrimaryCallTypeId = oldJobLog.PrimaryCallTypeId,
                CallDate = oldJobLog.CreationDate,
                Note = oldJobLog.Note,
                CreatedBy = oldJobLog.CreatedBy,
                CreationDate = oldJobLog.CreationDate,
                ModifiedBy = oldJobLog.ModifiedBy,
                ModificationDate = oldJobLog.ModificationDate,
                Active = true,
                ShiftTransferLog = false
            };

            _callLogRepository.Add(newJobLog);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create the Lapsed Preset Call Entry
        /// </summary>
        /// <param name="job"></param>
        public void SavelapsedPreset(CS_Job job)
        {
            try
            {
                CS_CallLog newCallEntry = new CS_CallLog();
                newCallEntry.JobID = job.ID;
                newCallEntry.CallTypeID = (int)Globals.CallEntry.CallType.LapsedPreset;
                newCallEntry.PrimaryCallTypeId = (int)Globals.CallEntry.PrimaryCallType.JobUpdateNotification;
                newCallEntry.CallDate = DateTime.Now;
                DateTimeOffset dateTimeOffset = DateTimeOffset.Now;
                newCallEntry.Xml = null;
                newCallEntry.Note = BuildlapsedPresetNote(job);
                newCallEntry.CreatedBy = "System";
                newCallEntry.CreationDate = DateTime.Now;
                newCallEntry.ModifiedBy = "System";
                newCallEntry.ModificationDate = DateTime.Now;
                newCallEntry.Active = true;
                newCallEntry.UserCall = true;

                _callLogRepository.Add(newCallEntry);
            }
            catch (Exception ex)
            {
                throw new Exception("There was an error while trying to save a new call entry of type Lapsed Preset.", ex);
            }
        }
Ejemplo n.º 6
0
        public void SaveCallCriteriaInitialAdviseCallCriteriaEmailResources(CS_CallLog initialAdvise)
        {
            try
            {
                IList<CS_CallLogCallCriteriaEmail> emailSaveList = new List<CS_CallLogCallCriteriaEmail>();

                IList<EmailVO> resourceList = _callCriteriaModel.ListReceiptsByCallLog(initialAdvise.CallTypeID.ToString(), initialAdvise.JobID, initialAdvise);

                for (int i = 0; i < resourceList.Count; i++)
                {
                    // Because of the Type, we need to separate the PersonID in two different variables
                    int? employeeId = null;
                    int? contactId = null;
                    if (resourceList[i].Type == (int)Globals.CallCriteria.EmailVOType.Employee)
                        employeeId = resourceList[i].PersonID;
                    else
                        contactId = resourceList[i].PersonID;

                    CS_CallLogCallCriteriaEmail emailResource = new CS_CallLogCallCriteriaEmail()
                    {
                        CallLogID = initialAdvise.ID,
                        Name = resourceList[i].Name,
                        Email = resourceList[i].Email,
                        Status = (int)Globals.CallCriteria.CallCriteriaEmailStatus.Pending,
                        StatusDate = DateTime.Now,
                        //CreationID = ,
                        CreatedBy = initialAdvise.CreatedBy,
                        CreationDate = DateTime.Now,
                        //ModificationID,
                        ModifiedBy = initialAdvise.ModifiedBy,
                        ModificationDate = DateTime.Now,
                        Active = true
                    };

                    emailSaveList.Add(emailResource);
                }

                _callLogCallCriteriaEmailRepository.AddList(emailSaveList);
            }
            catch (Exception ex)
            {
                throw new Exception("There was an error while trying to save the Initial Advise Resources.", ex);
            }
        }
        public IList<CS_Contact> VerifyHeavyEquipmentCallCriteria(List<CS_Contact> contactList, CS_CallLog callLog)
        {
            List<CS_Contact> returnList = new List<CS_Contact>();
            bool hasHeavyEquipment = false;
            bool hasNonHeavyEquipment = false;
            bool hasEquipment = false;

            if (callLog.CS_CallLogResource.Any(e => e.CS_Equipment != null && e.CS_Equipment.HeavyEquipment))
            {
                hasHeavyEquipment = true;
                hasEquipment = true;
            }

            if (callLog.CS_CallLogResource.Any(e => e.CS_Equipment != null && !e.CS_Equipment.HeavyEquipment))
            {
                hasNonHeavyEquipment = true;
                hasEquipment = true;
            }

            returnList.AddRange(contactList.FindAll(e => e.Active
                                    && ((e.CS_CallCriteria.FirstOrDefault
                                        (
                                        w => w.Active && w.ContactID == e.ID).CS_CallCriteriaValue.Any
                                        (
                                        h => h.Active
                                            && h.CallCriteriaTypeID == (int)Globals.CallCriteria.CallCriteriaType.HeavyEquipment
                                            && bool.Parse(h.Value)
                                            && hasHeavyEquipment))
                                    || (e.CS_CallCriteria.First
                                        (
                                        w => w.Active && w.ContactID == e.ID).CS_CallCriteriaValue).Any(
                                        h => h.Active
                                            && h.CallCriteriaTypeID == (int)Globals.CallCriteria.CallCriteriaType.HeavyEquipment) == false)));

            returnList.AddRange(contactList.FindAll(e => e.Active
                                    && ((e.CS_CallCriteria.FirstOrDefault
                                        (
                                        w => w.Active && w.ContactID == e.ID).CS_CallCriteriaValue.Any
                                        (
                                        h => h.Active
                                            && h.CallCriteriaTypeID == (int)Globals.CallCriteria.CallCriteriaType.NonHeavyEquipment
                                            && bool.Parse(h.Value)
                                            && hasNonHeavyEquipment))
                                    || (e.CS_CallCriteria.First
                                        (
                                        w => w.Active && w.ContactID == e.ID).CS_CallCriteriaValue).Any(
                                        h => h.Active
                                            && h.CallCriteriaTypeID == (int)Globals.CallCriteria.CallCriteriaType.NonHeavyEquipment) == false)));

            returnList.AddRange(contactList.FindAll(e => e.Active
                                    && ((e.CS_CallCriteria.FirstOrDefault
                                        (
                                        w => w.Active && w.ContactID == e.ID).CS_CallCriteriaValue.Any
                                        (
                                        h => h.Active
                                            && h.CallCriteriaTypeID == (int)Globals.CallCriteria.CallCriteriaType.AllEquipment
                                            && bool.Parse(h.Value)
                                            && hasEquipment))
                                    || (e.CS_CallCriteria.First
                                        (
                                        w => w.Active && w.ContactID == e.ID).CS_CallCriteriaValue).Any(
                                        h => h.Active
                                            && h.CallCriteriaTypeID == (int)Globals.CallCriteria.CallCriteriaType.AllEquipment) == false)));

            return returnList;
        }
Ejemplo n.º 8
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;
        }
        public void SendCallLogNotificationReservedEmails(CS_CallLog callLogEntry, List<CS_Reserve> resources)
        {
            try
            {
                EmailModel emailModel = new EmailModel(_unitOfWork);
                IList<CS_Email> emails = new List<CS_Email>();
                string receipts = string.Empty;

                //List receipts
                IList<EmailVO> receiptsEmail = _callCriteriaModel.ListReceiptsByCallLog(callLogEntry.CallTypeID.ToString(), callLogEntry.JobID, callLogEntry);

                if (receiptsEmail.Count > 0)
                {
                    for (int i = 0; i < receiptsEmail.Count; i++)
                        receipts += (i == 0) ? receiptsEmail[i].Email : string.Format(";{0}", receiptsEmail[i].Email);

                    //Body
                    string body = GenerateEmailBodyForReservedResources(callLogEntry, resources);

                    //Subject
                    string subject = GenerateEmailSubjectForReservedResources(callLogEntry);

                    //Save Email
                    emailModel.SaveEmailList(receipts, subject, body, "System", Globals.Security.SystemEmployeeID);

                    //Save Call Citeria
                    _callCriteriaModel.SendCallLogCriteriaEmails(callLogEntry);
                }
            }
            catch (Exception e)
            {
                throw new Exception("There was an error while trying to send added resources notification!", e);
            }
        }
 /// <summary>
 /// Saves CallCriteria Email for a callLog
 /// </summary>
 /// <param name="callLogEntry"></param>
 public void SendCallLogCriteriaEmails(CS_CallLog callLogEntry)
 {
     if (null != callLogEntry)
     {
         List<EmailVO> lstEmailVO = ListReceiptsByCallLog(callLogEntry.CallTypeID.ToString(), callLogEntry.JobID, callLogEntry).ToList();
         if (null != lstEmailVO && lstEmailVO.Count > 0)
             _callLogModel.SaveCallLogCallCriteriaEmail(lstEmailVO, callLogEntry);
     }
 }
        public virtual void GenerateAutomaticCallEntryReserve(int jobId, string userName, IList<CS_Reserve> reservedResourceList, DateTime callDate)
        {
            BuildReservedResourceNote(reservedResourceList, jobId);
            CS_CallLog addedResourceCallLogEntry = new CS_CallLog()
            {
                JobID = jobId,
                CallTypeID = (int)Globals.CallEntry.CallType.ReservedResource,
                PrimaryCallTypeId = (jobId == Globals.GeneralLog.ID ? (int)Globals.CallEntry.PrimaryCallType.ResourceUpdate : (int)Globals.CallEntry.PrimaryCallType.ResourceUpdateAddedResources),
                CallDate = callDate,
                Xml = null,
                Note = _reservedResourceBuilder.ToString(),
                CreatedBy = userName,
                CreationDate = DateTime.Now,
                ModifiedBy = userName,
                ModificationDate = DateTime.Now,
                Active = true,
                UserCall = true
            };

            addedResourceCallLogEntry = _callLogRepository.Add(addedResourceCallLogEntry);

            SendCallLogNotificationReservedEmails(addedResourceCallLogEntry, reservedResourceList.ToList());
        }
        public virtual void GenerateAutomaticCallEntryInitialAdvise(int jobId, string userName)
        {
            BuildInitialAdviseNote(jobId);
            CS_CallLog addedResourceCallLogEntry = new CS_CallLog()
            {
                JobID = jobId,
                CallTypeID = (int)Globals.CallEntry.CallType.InitialAdviseUpdate,
                PrimaryCallTypeId = (jobId == Globals.GeneralLog.ID ? (int)Globals.CallEntry.PrimaryCallType.NonJobUpdateNotification : (int)Globals.CallEntry.PrimaryCallType.JobUpdateNotification),
                CallDate = DateTime.Now,
                Xml = null,
                Note = _initialAdviseBuilder.ToString(),
                CreatedBy = userName,
                CreationDate = DateTime.Now,
                ModifiedBy = userName,
                ModificationDate = DateTime.Now,
                Active = true,
                UserCall = true
            };

            _callLogRepository.Add(addedResourceCallLogEntry);
        }
        public virtual void GenerateAutomaticCallEntryAdd(int jobId, string userName, IList<CS_Resource> addedResourceList, DateTime callDate)
        {
            List<int> employees = new List<int>();
            List<int> equipments = new List<int>();
            List<CS_CallLogResource> callLogResources = new List<CS_CallLogResource>();

            BuildAddedResourceNote(addedResourceList, jobId);
            CS_CallLog addedResourceCallLogEntry = new CS_CallLog()
            {
                JobID = jobId,
                CallTypeID = (int)Globals.CallEntry.CallType.AddedResource,
                PrimaryCallTypeId = (jobId == Globals.GeneralLog.ID ? (int)Globals.CallEntry.PrimaryCallType.ResourceUpdate : (int)Globals.CallEntry.PrimaryCallType.ResourceUpdateAddedResources),
                CallDate = callDate,
                Xml = null,
                Note = _addedResourceBuilder.ToString(),
                CreatedBy = userName,
                CreationDate = DateTime.Now,
                ModifiedBy = userName,
                ModificationDate = DateTime.Now,
                Active = true
            };

            _callLogRepository.Add(addedResourceCallLogEntry);

            foreach (CS_Resource resource in addedResourceList)
            {
                Globals.CallEntry.CallLogResourceType type = Globals.CallEntry.CallLogResourceType.Employee;
                switch ((Globals.ResourceAllocation.ResourceType)resource.Type)
                {
                    case Globals.ResourceAllocation.ResourceType.Employee:
                        type = Globals.CallEntry.CallLogResourceType.Employee;
                        break;
                    case Globals.ResourceAllocation.ResourceType.Equipment:
                        type = Globals.CallEntry.CallLogResourceType.Equipment;
                        break;
                }

                CS_CallLogResource addedResourceEntry = new CS_CallLogResource()
                {
                    CallLogID = addedResourceCallLogEntry.ID,
                    EmployeeID = resource.EmployeeID,
                    EquipmentID = resource.EquipmentID,
                    ContactID = null,
                    JobID = jobId,
                    Type = (int)type,
                    ActionDate = resource.StartDateTime,
                    CreatedBy = addedResourceCallLogEntry.CreatedBy,
                    CreationDate = addedResourceCallLogEntry.CreationDate,
                    ModifiedBy = addedResourceCallLogEntry.ModifiedBy,
                    ModificationDate = addedResourceCallLogEntry.ModificationDate,
                    Active = true,
                    CreationID = addedResourceCallLogEntry.CreationID,
                    ModificationID = addedResourceCallLogEntry.ModificationID
                };

                addedResourceEntry = _callLogResourceRepository.Add(addedResourceEntry);

                callLogResources.Add(addedResourceEntry);

                if (resource.EmployeeID.HasValue)
                    employees.Add(resource.EmployeeID.Value);
                else
                    equipments.Add(resource.EquipmentID.Value);

            }

            employees = addedResourceList.Where(e => e.EmployeeID.HasValue).Select(e => e.EmployeeID.Value).ToList();
            equipments = addedResourceList.Where(e => e.EquipmentID.HasValue).Select(e => e.EquipmentID.Value).ToList();

            SendCallLogNotificationAddedEmails(addedResourceCallLogEntry, callLogResources);

            _callLogModel.VerifyDPICalculate(addedResourceCallLogEntry, employees, equipments);
        }
        public void VerifyDPICalculateAdded()
        {
            //Arrange
            #region [ Variables ]

            DateTime now = DateTime.Now;
            DateTime startDateTime = new DateTime(2011, 08, 01, 12, 0, 0);
            DateTime startDateTime2 = startDateTime.AddDays(1);

            #endregion

            #region [ CallType Repository ]

            FakeObjectSet<CS_CallType> fakeCallTypeRepository = new FakeObjectSet<CS_CallType>();
            fakeCallTypeRepository.AddObject
                (
                    new CS_CallType()
                    {
                        ID = 27,
                        Description = "Added Resource",
                        Xml = string.Empty,
                        CallCriteria = true,
                        IsAutomaticProcess = true,
                        DpiStatus = 1,
                        Active = true
                    }
                );

            #endregion

            #region [ Resource Repository ]

            FakeObjectSet<CS_Resource> fakeResourceRepository = new FakeObjectSet<CS_Resource>();
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 1, EmployeeID = 1, EquipmentID = null, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true });
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 2, EmployeeID = null, EquipmentID = 1, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true });
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 3, EmployeeID = null, EquipmentID = 2, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true });
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 4, EmployeeID = null, EquipmentID = 3, JobID = 1, Duration = 1, StartDateTime = startDateTime2, Active = true });

            #endregion

            #region [ DPI Repository ]

            FakeObjectSet<CS_DPI> fakeDPIRepository = new FakeObjectSet<CS_DPI>();
            fakeDPIRepository.AddObject(new CS_DPI()
            {
                ID = 1,
                Date = startDateTime.Date,
                Calculate = false,
                ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved,
                JobID = 1,
                IsContinuing = true,
                ProcessStatusDate = DateTime.Now,
                CalculationStatus = (short)Globals.DPI.CalculationStatus.INSF,
                Total = 1000,
                CreatedBy = "System",
                //CreationID =,
                CreationDate = DateTime.Now,
                ModifiedBy = "System",
                //ModificationID,
                ModificationDate = DateTime.Now,
                Active = true,
                CS_DPIResource = new EntityCollection<CS_DPIResource>()
                {
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EmployeeID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 2,
                        Active = true,
                    }
                }
            });

            fakeDPIRepository.AddObject(new CS_DPI()
            {
                ID = 2,
                Date = startDateTime2.Date,
                Calculate = false,
                ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved,
                JobID = 1,
                IsContinuing = true,
                ProcessStatusDate = DateTime.Now,
                CalculationStatus = (short)Globals.DPI.CalculationStatus.INSF,
                Total = 1000,
                CreatedBy = "System",
                //CreationID =,
                CreationDate = DateTime.Now,
                ModifiedBy = "System",
                //ModificationID,
                ModificationDate = DateTime.Now,
                Active = true,
                CS_DPIResource = new EntityCollection<CS_DPIResource>()
                {
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EmployeeID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 2,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 3,
                        Active = true
                    }
                }
            });

            #endregion

            #region [ Parameters ]

            CS_CallLog callLog = new CS_CallLog()
            {
                CallTypeID = (int)Globals.CallEntry.CallType.AddedResource,
                CreationDate = now,
                CallDate = now,
                JobID = 1
            };

            List<int> employeeIDList = new List<int>() { 1 };
            List<int> equipmentIDList = new List<int>() { 1, 2 };

            #endregion

            #region [ Mock ]

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallType>()).Returns(fakeCallTypeRepository);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_Resource>()).Returns(fakeResourceRepository);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_DPI>()).Returns(fakeDPIRepository);
            CallLogModel model = new CallLogModel(mockUnitOfWork.Object);

            #endregion

            //Act
            model.VerifyDPICalculate(callLog, employeeIDList, equipmentIDList);

            //Assert
            CS_DPI dpi = fakeDPIRepository.FirstOrDefault(e => e.ID == 1);
            CS_DPI dpi2 = fakeDPIRepository.FirstOrDefault(e => e.ID == 2);
            Assert.IsTrue(dpi.Calculate, "Fail at Calculate True");
            Assert.IsFalse(dpi2.Calculate, "Fail at Calculate False");
        }
 public IList<EmailVO> ListReceiptsByCallLog(string callLogTypeId, int jobId, CS_CallLog callLog)
 {
     List<int> callCriteriaIDs = new List<int>();
     return ListReceiptsByCallLog(callLogTypeId, jobId, callLog, out callCriteriaIDs);
 }
        public void VerifyDPICalculateParked()
        {
            //Arrange
            #region [ Variables ]

            DateTime now = DateTime.Now;
            DateTime startDateTime = new DateTime(2011, 08, 01, 12, 0, 0);
            DateTime startDateTime2 = startDateTime.AddDays(1);

            #endregion

            #region [ CallType Repository ]

            FakeObjectSet<CS_CallType> fakeCallTypeRepository = new FakeObjectSet<CS_CallType>();
            fakeCallTypeRepository.AddObject
                (
                    new CS_CallType()
                    {
                        ID = (int)Globals.CallEntry.CallType.Parked,
                        Description = "Parked",
                        Xml = "<?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>        <IsValidEmpty>false</IsValidEmpty>        <EmptyValueMessage>The Parked Date field is required</EmptyValueMessage>        <InvalidValueMessage>Invalid Parked Date format</InvalidValueMessage>        <DateTimeFormat>Default</DateTimeFormat>        <ShowOn>Both</ShowOn>        <ValidationGroup>CallEntry</ValidationGroup>        <Label>          <Text>Parked Date:</Text>          <Css>dynamicLabel</Css>        </Label>      </DynamicControls>      <DynamicControls xsi:type=\"DynamicTimeXml\">        <Name>txtTime</Name>        <IsValidEmpty>false</IsValidEmpty>        <ValidationGroup>CallEntry</ValidationGroup>        <EmptyValueMessage>The Parked Time field is required.</EmptyValueMessage>        <InvalidValueMessage>The Parked Time field is invalid</InvalidValueMessage>        <MaskedType>Time</MaskedType>        <Mask>99:99</Mask>        <Label>          <Text>Parked Time:</Text>          <Css>dynamicLabel</Css>        </Label>      </DynamicControls>      <DynamicControls xsi:type=\"DynamicCountableTextBoxXml\">        <Name>txtNote</Name>        <IsRequired>false</IsRequired>        <MaxChars>255</MaxChars>        <MaxCharsWarning>250</MaxCharsWarning>        <TextMode>MultiLine</TextMode>        <Width>300</Width>        <Height>150</Height>        <Label>          <Text>Note:</Text>          <Css>dynamicLabel</Css>        </Label>      </DynamicControls>    </Controls>  </DynamicFieldsAggregator>",
                        CallCriteria = false,
                        IsAutomaticProcess = false,
                        DpiStatus = 2,
                        Active = true
                    }
                );

            #endregion

            #region [ Resource Repository ]

            FakeObjectSet<CS_Resource> fakeResourceRepository = new FakeObjectSet<CS_Resource>();
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 1, EmployeeID = 1, EquipmentID = null, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true });
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 2, EmployeeID = null, EquipmentID = 1, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true });
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 3, EmployeeID = null, EquipmentID = 2, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true });
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 4, EmployeeID = null, EquipmentID = 3, JobID = 1, Duration = 1, StartDateTime = startDateTime2, Active = true });

            #endregion

            #region [ DPI Repository ]

            FakeObjectSet<CS_DPI> fakeDPIRepository = new FakeObjectSet<CS_DPI>();
            fakeDPIRepository.AddObject(new CS_DPI()
            {
                ID = 1,
                Date = startDateTime.Date,
                Calculate = false,
                ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved,
                JobID = 1,
                IsContinuing = true,
                ProcessStatusDate = DateTime.Now,
                CalculationStatus = (short)Globals.DPI.CalculationStatus.INSF,
                Total = 1000,
                CreatedBy = "System",
                //CreationID =,
                CreationDate = DateTime.Now,
                ModifiedBy = "System",
                //ModificationID,
                ModificationDate = DateTime.Now,
                Active = true,
                CS_DPIResource = new EntityCollection<CS_DPIResource>()
                {
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EmployeeID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 2,
                        Active = true,
                    }
                }
            });

            fakeDPIRepository.AddObject(new CS_DPI()
            {
                ID = 2,
                Date = startDateTime2.Date,
                Calculate = false,
                ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved,
                JobID = 1,
                IsContinuing = true,
                ProcessStatusDate = DateTime.Now,
                CalculationStatus = (short)Globals.DPI.CalculationStatus.INSF,
                Total = 1000,
                CreatedBy = "System",
                //CreationID =,
                CreationDate = DateTime.Now,
                ModifiedBy = "System",
                //ModificationID,
                ModificationDate = DateTime.Now,
                Active = true,
                CS_DPIResource = new EntityCollection<CS_DPIResource>()
                {
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EmployeeID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 2,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 3,
                        Active = true
                    }
                }
            });

            #endregion

            #region [ Parameters ]

            CS_CallLog callLog = new CS_CallLog()
            {
                CallTypeID = (int)Globals.CallEntry.CallType.Parked,
                Xml = "<?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>Release Date:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>2011-08-01T00:00:00</Text><IsValidEmpty>false</IsValidEmpty><EmptyValueMessage>The Release Date field is required</EmptyValueMessage><InvalidValueMessage>Invalid Release Date format</InvalidValueMessage><DateTimeFormat>Default</DateTimeFormat><ShowOn>Both</ShowOn><ValidationGroup>CallEntry</ValidationGroup></DynamicControls><DynamicControls xsi:type=\"DynamicTimeXml\"><Name>txtTime</Name><Label><Text>Release Time:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>12:00</Text><Mask>99:99</Mask><MaskedType>Time</MaskedType><InputDirection>LeftToRight</InputDirection><IsValidEmpty>false</IsValidEmpty><ValidationGroup>CallEntry</ValidationGroup><InvalidValueMessage>The Release Time field is invalid</InvalidValueMessage><EmptyValueMessage>The Release Time field is required.</EmptyValueMessage></DynamicControls></Controls><Extenders /></DynamicFieldsAggregator>",
                CreationDate = now,
                CallDate = now,
                JobID = 1
            };

            List<int> employeeIDList = new List<int>() { 1 };
            List<int> equipmentIDList = new List<int>() { 1, 2, 3 };

            #endregion

            #region [ Mock ]

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallType>()).Returns(fakeCallTypeRepository);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_Resource>()).Returns(fakeResourceRepository);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_DPI>()).Returns(fakeDPIRepository);
            CallLogModel model = new CallLogModel(mockUnitOfWork.Object);

            #endregion

            //Act
            model.VerifyDPICalculate(callLog, employeeIDList, equipmentIDList);

            //Assert
            CS_DPI dpi = fakeDPIRepository.FirstOrDefault(e => e.ID == 1);
            CS_DPI dpi2 = fakeDPIRepository.FirstOrDefault(e => e.ID == 2);
            Assert.IsTrue(dpi.Calculate, "Fail at Calculate True");
            Assert.IsFalse(dpi2.Calculate, "Fail at Calculate False");
        }
        public IList<EmailVO> ListReceiptsByCallLog(string callLogTypeId, int jobId, CS_CallLog callLog, out List<int> callCriteriaIDs)
        {
            CS_Job job = new CS_Job();
            IList<CS_Employee> lstEmployee = new List<CS_Employee>();
            List<CS_Employee> lstEmployeeAux = new List<CS_Employee>();
            IList<CS_Contact> lstContacts = new List<CS_Contact>();
            IList<EmailVO> lstEmail = new List<EmailVO>();

            string emailDomain = string.Empty;

            SettingsModel model = new SettingsModel(_unitOfWork);
            emailDomain = model.GetDomain();

            CS_CallCriteriaRepository _rep = new CS_CallCriteriaRepository(_callCriteriaRepository, _callCriteriaRepository.UnitOfWork);

            int callLogID = 0;

            if (callLog != null)
                callLogID = callLog.ID;

            IList<CS_SP_CheckCallCriteria_Result> callCriteriaResult = _rep.CheckCallCriteria(callLogID, int.Parse(callLogTypeId), jobId);

            IList<int> result = new List<int>();

            for (int i = 0; i < callCriteriaResult.Count; i++)
            {
                result.Add(callCriteriaResult[i].CallCriteriaID.Value);
            }

            callCriteriaIDs = result.ToList();

            lstEmployee = _employeeRepository.ListAll(e => e.CS_CallCriteria.Any(f => result.Contains(f.ID) && f.Active)).ToList();

            lstContacts = _contactRepository.ListAll(e => e.CS_CallCriteria.Any(f => result.Contains(f.ID) && f.Active)).ToList();

            //OLD METHOD
            //job = _jobRepository.Get(e => e.ID == jobId, new string[] { "CS_JobDivision", "CS_CustomerInfo", "CS_JobInfo", "CS_LocationInfo", "CS_JobDescription" });

            //lstEmployee = ListEmployeeCriteriaByDivisionAndCustomer(job);

            //if (!job.ID.Equals(Globals.GeneralLog.ID))
            //    lstEmployeeAux = FilterEmployeeByCriteriaValue(lstEmployee, job).ToList();

            //if (null != callLog)
            //    lstEmployeeAux.AddRange(VerifyHeavyEquipmentCallCriteria(lstEmployee.ToList(), callLog));

            //lstEmployee = lstEmployeeAux.Distinct().ToList();

            //lstEmployee = ListEmployeeByCallLogCriteria(callLogTypeId, lstEmployee.ToList());

            //for (int i = 0; i < lstEmployee.Count; i++)
            //{

            //    CS_EmployeeOffCallHistory offCall = GetActiveOffCallByEmployeeID(lstEmployee[i].ID);

            //    if (null != offCall)
            //        lstEmployee[i] = offCall.CS_Employee_Proxy;
            //}

            //lstContacts = ListContactsCriteriaByDivisionAndCustomer(job);

            //if (!job.ID.Equals(Globals.GeneralLog.ID))
            //    lstContacts = FilterContactsByCriteriaValue(lstContacts, job);

            //lstContacts = ListCustomerContactByCallLogCriteria(callLogTypeId, lstContacts.ToList());

            //if (null != callLog)
            //    lstContacts = VerifyHeavyEquipmentCallCriteria(lstContacts.ToList(), callLog);

            for (int i = 0; i < lstEmployee.Count; i++)
            {
                if (!string.IsNullOrEmpty(lstEmployee[i].GetEmployeeEmail(emailDomain)))
                {
                    EmailVO email = new EmailVO();
                    email.PersonID = lstEmployee[i].ID;
                    email.Name = lstEmployee[i].FullName;
                    email.Email = lstEmployee[i].GetEmployeeEmail(emailDomain);
                    email.Type = (int)Globals.CallCriteria.EmailVOType.Employee;

                    if (!lstEmail.Contains(email, new Globals.EmailService.EmailVO_Comparer()))
                        lstEmail.Add(email);
                }
            }

            for (int i = 0; i < lstContacts.Count; i++)
            {
                if (!string.IsNullOrEmpty(lstContacts[i].Email))
                {
                    EmailVO email = new EmailVO();
                    email.PersonID = lstContacts[i].ID;
                    email.Name = lstContacts[i].FullName;
                    email.Email = lstContacts[i].Email;
                    email.Type = (int)Globals.CallCriteria.EmailVOType.Contact;

                    if (!lstEmail.Contains(email, new Globals.EmailService.EmailVO_Comparer()))
                        lstEmail.Add(email);
                }
            }

            return lstEmail;
        }
Ejemplo n.º 18
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);
                        }
                    }
                }
            }
        }
        public void TestGenerateBodyCallLogEmail()
        {
            List<CS_CallLog> lstCallLog = new List<CS_CallLog>();

            CS_CallType callType = new CS_CallType { ID = 5, Active = true, Description = "Call Type 1" };

            DateTime dt = new DateTime(2011, 05, 10, 1, 11, 22);

            CS_CallLog callLog = new CS_CallLog
                                     {
                                         ID = 1,
                                         Active = true,
                                         CS_CallType = callType,
                                         CallDate = dt,
                                         Note = "Here is the field note."
                                     };

            lstCallLog.Add(callLog);

            //Arrange
            FakeObjectSet<CS_CallLog> fakeCallLog = new FakeObjectSet<CS_CallLog>();
            fakeCallLog.AddObject(callLog);

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_CallLog>()).Returns(fakeCallLog);
            CallCriteriaModel model = new CallCriteriaModel(mockUnitOfWork.Object);

            //Act
            string body = model.GenerateBodyCallLogEmail(lstCallLog);

            StringBuilder sb = new StringBuilder();
            sb.Append("<div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Call Type:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append("Call Type 1");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Call Date:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append("05/10/2011");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Call Time:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append("1:11");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Here is the field note.");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("</div>");

            //Assert
            Assert.AreEqual(sb.ToString(), body);
        }
 private CS_CallLog CreateDeleteCallLogEntity()
 {
     CS_CallLog oldCallLog = _callLogModel.GetCallLogById(_view.CallLogIdToDelete);
     CS_CallLog callLogToRemove = new CS_CallLog();
     callLogToRemove.ID = _view.CallLogIdToDelete;
     callLogToRemove.JobID = oldCallLog.JobID;
     callLogToRemove.CallTypeID = oldCallLog.CallTypeID;
     callLogToRemove.PrimaryCallTypeId = oldCallLog.PrimaryCallTypeId;
     callLogToRemove.CallDate = oldCallLog.CallDate;
     callLogToRemove.CalledInByEmployee = oldCallLog.CalledInByEmployee;
     callLogToRemove.CalledInByCustomer = oldCallLog.CalledInByCustomer;
     callLogToRemove.Xml = oldCallLog.Xml;
     callLogToRemove.Note = oldCallLog.Note;
     callLogToRemove.CreatedBy = oldCallLog.CreatedBy;
     callLogToRemove.CreationDate = oldCallLog.CreationDate;
     callLogToRemove.ModifiedBy = _view.UserName;
     callLogToRemove.ModificationDate = DateTime.Now;
     callLogToRemove.Active = false;
     return callLogToRemove;
 }
Ejemplo n.º 21
0
        public void SaveWhiteLightCallLog(CS_EquipmentWhiteLight equipmentWhiteLight, int jobID, bool add)
        {
            try
            {

                string notes = BuildWhiteLogNote(equipmentWhiteLight, add);
                CS_CallLog newCallEntry = new CS_CallLog();
                newCallEntry.JobID = jobID;
                newCallEntry.CallTypeID = (int)Globals.CallEntry.CallType.WhiteLight;

                if (jobID == Globals.GeneralLog.ID)
                    newCallEntry.PrimaryCallTypeId = (int)Globals.CallEntry.PrimaryCallType.ResourceUpdate;
                else
                    newCallEntry.PrimaryCallTypeId = (int)Globals.CallEntry.PrimaryCallType.ResourceUpdateEventStatus;

                newCallEntry.CallDate = equipmentWhiteLight.CreationDate;
                DateTimeOffset dateTimeOffset = DateTimeOffset.Now;
                newCallEntry.Xml = null;
                newCallEntry.Note = notes;
                newCallEntry.CreatedBy = equipmentWhiteLight.CreatedBy;
                newCallEntry.CreationDate = DateTime.Now;
                newCallEntry.ModifiedBy = equipmentWhiteLight.CreatedBy;
                newCallEntry.ModificationDate = DateTime.Now;
                newCallEntry.Active = true;
                newCallEntry.UserCall = true;

                newCallEntry = _callLogRepository.Add(newCallEntry);

                SaveWhiteLightCallLogResources(newCallEntry, equipmentWhiteLight);
            }
            catch (Exception ex)
            {
                throw new Exception("There was an error while trying to save a new call entry.", ex);
            }
        }
Ejemplo n.º 22
0
        public void SaveInitialAdvise(bool saveInitialEmailAdvise)
        {
            try
            {
                BuildInitialAdviseNote(false);
                CS_CallLog newCallEntry = new CS_CallLog();
                newCallEntry.JobID = NewJob.ID;
                newCallEntry.CallTypeID = (int)Globals.CallEntry.CallType.InitialLog;
                newCallEntry.PrimaryCallTypeId = (int)Globals.CallEntry.PrimaryCallType.ResourceUpdateAddedResources;
                newCallEntry.CallDate = NewJobInfo.InitialCallDate + NewJobInfo.InitialCallTime;
                DateTimeOffset dateTimeOffset = DateTimeOffset.Now;
                newCallEntry.Xml = null;
                newCallEntry.Note = _initialAdvise.ToString();
                newCallEntry.CreatedBy = NewJob.CreatedBy;
                newCallEntry.CreationDate = DateTime.Now;
                newCallEntry.ModifiedBy = NewJob.CreatedBy;
                newCallEntry.ModificationDate = DateTime.Now;
                newCallEntry.Active = true;
                newCallEntry.UserCall = true;

                _callLogRepository.Add(newCallEntry);

                if (saveInitialEmailAdvise)
                    SendCallCriteriaInitialAdvise(newCallEntry.ID);

                SaveCallCriteriaInitialAdviseResources(newCallEntry, saveInitialEmailAdvise);
            }
            catch (Exception ex)
            {
                throw new Exception("There was an error while trying to save a new call entry.", ex);
            }
        }
Ejemplo n.º 23
0
        public void SaveWhiteLightCallLogResources(CS_CallLog newCallLog, CS_EquipmentWhiteLight equipmentWhiteLight)
        {
            try
            {
                IList<CS_CallLogResource> saveList = new List<CS_CallLogResource>();
                IList<CS_CallLogCallCriteriaEmail> emailSaveList = new List<CS_CallLogCallCriteriaEmail>();

                int? employeeId = null;
                int? contactId = null;

                CS_CallLogResource resource = new CS_CallLogResource()
                {
                    CallLogID = newCallLog.ID,
                    EmployeeID = employeeId,
                    ContactID = contactId,
                    EquipmentID = equipmentWhiteLight.EquipmentID,
                    JobID = newCallLog.JobID,
                    Type = 3,
                    CreatedBy = newCallLog.CreatedBy,
                    CreationDate = DateTime.Now,
                    ModifiedBy = newCallLog.ModifiedBy,
                    ModificationDate = DateTime.Now,
                    Active = true
                };

                resource = _callLogResourceRepository.Add(resource);

                SendNotificationWhiteLight(newCallLog, resource);
            }
            catch (Exception ex)
            {
                throw new Exception("There was an error while trying to save the White Light Resources.", ex);
            }
        }
Ejemplo n.º 24
0
        public void UpdateInitialAdvise()
        {
            try
            {
                // Verify if one of these fields changed, to generate a new initial advise
                // Customer
                // Division
                // Preset Date
                // State
                // City
                // # Of Engines
                // # Of Loads
                // # of Empties
                // Hazmat
                // Scope of Work
                if (_generatesInitialAdvise)
                {
                    BuildInitialAdviseNote(true);
                    CS_CallLog newCallEntry = new CS_CallLog();
                    newCallEntry.JobID = NewJob.ID;
                    newCallEntry.CallTypeID = (int)Globals.CallEntry.CallType.InitialAdviseUpdate;
                    newCallEntry.PrimaryCallTypeId = (int)Globals.CallEntry.PrimaryCallType.JobUpdateNotification;
                    newCallEntry.CallDate = DateTime.Now;
                    DateTimeOffset dateTimeOffset = DateTimeOffset.Now;
                    newCallEntry.Xml = null;
                    newCallEntry.Note = _initialAdvise.ToString();
                    newCallEntry.CreatedBy = NewJob.ModifiedBy;
                    newCallEntry.CreationDate = NewJob.ModificationDate;
                    newCallEntry.ModifiedBy = NewJob.ModifiedBy;
                    newCallEntry.ModificationDate = NewJob.ModificationDate;
                    newCallEntry.Active = true;
                    newCallEntry.UserCall = true;

                    _callLogRepository.Add(newCallEntry);

                    SendCallCriteriaInitialAdvise(newCallEntry.ID);
                    SaveCallCriteriaInitialAdviseResources(newCallEntry, true);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("There was an error while trying to save a new call entry.", ex);
            }
        }
Ejemplo n.º 25
0
        public void SendNotificationWhiteLight(CS_CallLog callentry, CS_CallLogResource resource)
        {
            _emailModel = new EmailModel();

            IList<CS_Email> emails = new List<CS_Email>();
            string receipts = string.Empty;

            //List receipts
            IList<EmailVO> receiptsEmail = _callCriteriaModel.ListReceiptsByCallLog(callentry.CallTypeID.ToString(), callentry.JobID, callentry);

            if (receiptsEmail.Count > 0)
            {
                for (int i = 0; i < receiptsEmail.Count; i++)
                    receipts += (i == 0) ? receiptsEmail[i].Email : string.Format(";{0}", receiptsEmail[i].Email);

                //Body
                string body = GenerateEmailBodyForWhiteLight(resource);

                //Subject
                string subject = GenerateEmailSubjectForWhiteLight(callentry, resource);

                emails = _emailModel.SaveEmailList(receipts, subject, body, "System", Globals.Security.SystemEmployeeID);

                _callCriteriaModel.SendCallLogCriteriaEmails(callentry);
            }
        }
Ejemplo n.º 26
0
        public ActionResult Generate(TicketViewModel ticketViewModel)
        {
            CS_Ticket    ticketObj = new CS_Ticket();
            CS_Log       logObj    = new CS_Log();
            CS_EmailLink linkObj   = new CS_EmailLink();

            ticketObj.CreatedOn   = DateTime.Now;
            ticketObj.EmployeeId  = GetEmployeeId();
            ticketObj.Description = ticketViewModel.Description;
            ticketObj.CustomerId  = ticketViewModel.CustomerId;
            ticketObj.SLAId       = ticketViewModel.IDSLA;
            ticketObj.Title       = ticketViewModel.Title;
            ticketObj.ProjectId   = ticketViewModel.ProjectId;
            ticketObj.StatusId    = 1;
            ticketObj.LastComment = "";
            _objTicket.Insert(ticketObj);

            // To add entry in Log table
            int ticketid = _dbContext.CS_Ticket.Max(item => item.TicketId);

            logObj.TicketId     = ticketid;
            logObj.Title        = ticketViewModel.Title;
            logObj.Comment      = "Ticket Created";
            logObj.CreatedOn    = ticketObj.CreatedOn;
            logObj.EmployeeId   = ticketObj.EmployeeId;
            logObj.CustumerId   = ticketObj.CustomerId;
            logObj.StatusId     = 1;
            logObj.PriorityName = FindPriorityBySLAId(ticketObj.SLAId);

            _objLog.Insert(logObj);
            string ReadUrl = ReadURL();
            bool   result  = (ReadUrl.All(Char.IsDigit) && ReadUrl.Length > 0);

            // Update Ticket generated In calllog table
            if (result == true)
            {
                int callLogid = Convert.ToInt32(ReadUrl);
                //// CS_CallLog callObj = new CS_CallLog();
                //var row = (from u in _dbContext.CS_CallLog
                //           where u.CallLogId == callLogid
                //           select u);

                //foreach (var entity in row)
                //{
                //    callObj = entity;
                //    callObj.IsTicketGenerated = true;
                //}
                CS_CallLog callObj = _objCallLog.FindById(callLogid);

                callObj.IsTicketGenerated = true;
                callObj.TicketId          = ticketObj.TicketId;
                _objCallLog.Update(callObj);
            }

            //Fetch customer email id
            string emailFrom = _dbContext.Customer.Where(e => e.Id == ticketObj.CustomerId).Select(a => a.Email).SingleOrDefault();
            //Fetch status name
            string status = _dbContext.CS_Status.Where(s => s.StatusId == ticketObj.StatusId).Select(a => a.Status).SingleOrDefault();
            //Fetch priority name
            string priority = _dbContext.CS_SLA.Where(p => p.SLAId == ticketObj.SLAId).Select(a => a.PriorityName).SingleOrDefault();
            //Fetch ticket number
            string ticketNumber = _dbContext.CS_Ticket.Where(t => t.TicketId == ticketObj.TicketId).Select(a => a.TicketNumber).SingleOrDefault();
            //Fectch employee email
            string employeeEmail = _dbContext.Employee.Where(e => e.Id == ticketObj.EmployeeId).Select(a => a.Email_Official).SingleOrDefault();

            linkObj.TicketId = ticketObj.TicketId;
            linkObj.Link     = Utility.GenerateLink(linkObj.TicketId);
            _objLink.Insert(linkObj);
            string employeeBody = EmailContent.EmployeeBody(linkObj.Link);

            Thread AcknowledgeCustomer = new Thread(() => SendMail.SendAcknowledgement(emailFrom, EmailContent.CustomerSubject, EmailContent.CustomerBody, ticketNumber, priority, status));
            Thread NotifyEmployee      = new Thread(() => SendMail.SendAcknowledgement(employeeEmail, EmailContent.EmployeeSubject, employeeBody, ticketNumber, priority, status));

            AcknowledgeCustomer.Start();
            NotifyEmployee.Start();

            return(RedirectToAction(ActionName.TicketIndex, ControllerName.Ticket));
        }
Ejemplo n.º 27
0
        private string GenerateEmailSubjectForWhiteLight(CS_CallLog callLog, CS_CallLogResource resource)
        {
            StringBuilder subject = new StringBuilder();
            int jobID = callLog.JobID;
            CS_Job job = _jobRepository.Get(e => e.ID == jobID, "CS_CustomerInfo", "CS_CustomerInfo.CS_Customer", "CS_JobInfo", "CS_JobInfo.CS_JobAction", "CS_LocationInfo", "CS_LocationInfo.CS_City", "CS_LocationInfo.CS_State");

            subject.Append(job.PrefixedNumber);
            subject.Append(", ");

            if (callLog.CS_Job.ID != (int)Globals.GeneralLog.ID)
            {
                subject.Append(job.CS_CustomerInfo.CS_Customer.Name.Trim());
                subject.Append(", ");
                subject.Append(job.CS_JobInfo.CS_JobAction.Description);
                subject.Append(", ");
                subject.Append(job.CS_LocationInfo.CS_City.Name);
                subject.Append(" ");
                subject.Append(job.CS_LocationInfo.CS_State.Acronym);
            }

            else
            {
                subject.Append(resource.CS_Equipment.CS_Division.Name);
                subject.Append(", ");
                subject.Append(resource.CS_Equipment.CS_Division.CS_State.Name);

            }

            subject.Append(", White Light");

            return subject.ToString();
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Create the Lapsed Preset Call Entry
        /// </summary>
        /// <param name="job"></param>
        private void SaveFirstAlertCallLog(CS_FirstAlert firstAlert, bool isGeneralLog)
        {
            try
            {
                CS_CallLog newCallEntry = new CS_CallLog();

                if (isGeneralLog)
                    newCallEntry.JobID = Globals.GeneralLog.ID;
                else
                    newCallEntry.JobID = firstAlert.JobID;
                newCallEntry.CallTypeID = (int)Globals.CallEntry.CallType.FirstAlert;
                if (isGeneralLog)
                    newCallEntry.PrimaryCallTypeId = (int)Globals.CallEntry.PrimaryCallType.NonJobUpdateNotification;
                else
                    newCallEntry.PrimaryCallTypeId = (int)Globals.CallEntry.PrimaryCallType.JobUpdateNotification;
                newCallEntry.CallDate = DateTime.Now;
                DateTimeOffset dateTimeOffset = DateTimeOffset.Now;
                newCallEntry.Xml = null;
                newCallEntry.Note = BuildFirstAlertNote(firstAlert);
                newCallEntry.CreatedBy = "System";
                newCallEntry.CreationDate = DateTime.Now;
                newCallEntry.ModifiedBy = "System";
                newCallEntry.ModificationDate = DateTime.Now;
                newCallEntry.Active = true;
                newCallEntry.UserCall = true;

                _callLogRepository.Add(newCallEntry);

                IList<EmailVO> callCriteriaList = SaveCallCriteriaFirstAlertResources(newCallEntry);

                if (!isGeneralLog)
                    SaveFirstAlertContactPersonal(firstAlert, callCriteriaList);
            }
            catch (Exception ex)
            {
                throw new Exception("There was an error while trying to save a new call entry of type First Alert.", ex);
            }
        }
        private string GenerateEmailBodyForReservedResources(CS_CallLog callEntry, List<CS_Reserve> resources)
        {
            StringBuilder body = new StringBuilder();

            body.AppendLine("<div>");

            body.AppendLine("<div style='width: 100%; display: inline-block;'>");
            body.AppendLine("<div style='text-align: right; width: 30%; height: 100%; display: inline-block; float: left'>");
            body.AppendLine("<b>Resources Reserved</b>");
            body.AppendLine("</div><div style='text-align: left; width: 68%; height: 100%; display: inline-block; float: right'></div>");
            body.AppendLine("</div>");

            for (int i = 0; i < resources.Count; i++)
            {
                string division = string.Empty;
                string description = string.Empty;
                string date = string.Empty;
                string time = string.Empty;
                string duration = string.Empty;

                if (resources[i].EmployeeID.HasValue)
                {
                    int reserveID = resources[i].ID;
                    CS_Reserve resource = _reserveRepository.Get(e => e.ID == reserveID, "CS_Employee", "CS_Employee.CS_Division");
                    division = resource.CS_Employee.CS_Division.Name;
                    description = resource.CS_Employee.FullName;
                    date = callEntry.CallDate.ToString("MM/dd/yyyy");
                    time = callEntry.CallDate.ToShortTimeString();
                    duration = resource.Duration.ToString();
                }
                else
                {
                    int reserveID = resources[i].ID;
                    CS_Reserve resource = _reserveRepository.Get(e => e.ID == reserveID && e.Active, "CS_EquipmentType", "CS_Division");
                    division = resource.CS_Division.Name;
                    description = resource.CS_EquipmentType.Name;
                    date = callEntry.CallDate.ToString("MM/dd/yyyy");
                    time = callEntry.CallDate.ToShortTimeString();
                    duration = resource.Duration.ToString();
                }

                //Division
                body.AppendLine("<div style='width: 100%; display: inline-block;'>");
                body.AppendLine("<div style='text-align: right; width: 30%; height: 100%; display: inline-block; float: left'>");
                body.AppendLine("<b>Division: </b>");
                body.AppendLine("</div><div style='text-align: left; width: 68%; height: 100%; display: inline-block; float: right'>");
                body.AppendLine(division);
                body.AppendLine("</div>");
                body.AppendLine("</div>");

                //Description
                body.AppendLine("<div style='width: 100%; display: inline-block;'>");
                body.AppendLine("<div style='text-align: right; width: 30%; height: 100%; display: inline-block; float: left'>");
                body.AppendLine("<b>Description: </b>");
                body.AppendLine("</div><div style='text-align: left; width: 68%; height: 100%; display: inline-block; float: right'>");
                body.AppendLine(description);
                body.AppendLine("</div>");
                body.AppendLine("</div>");

                //Date
                body.AppendLine("<div style='width: 100%; display: inline-block;'>");
                body.AppendLine("<div style='text-align: right; width: 30%; height: 100%; display: inline-block; float: left'>");
                body.AppendLine("<b>Date: </b>");
                body.AppendLine("</div><div style='text-align: left; width: 68%; height: 100%; display: inline-block; float: right'>");
                body.AppendLine(date);
                body.AppendLine("</div>");
                body.AppendLine("</div>");

                //Time
                body.AppendLine("<div style='width: 100%; display: inline-block;'>");
                body.AppendLine("<div style='text-align: right; width: 30%; height: 100%; display: inline-block; float: left'>");
                body.AppendLine("<b>Time: </b>");
                body.AppendLine("</div><div style='text-align: left; width: 68%; height: 100%; display: inline-block; float: right'>");
                body.AppendLine(time);
                body.AppendLine("</div>");
                body.AppendLine("</div>");

                //Duration
                body.AppendLine("<div style='width: 100%; display: inline-block;'>");
                body.AppendLine("<div style='text-align: right; width: 30%; height: 100%; display: inline-block; float: left'>");
                body.AppendLine("<b>Duration: </b>");
                body.AppendLine("</div><div style='text-align: left; width: 68%; height: 100%; display: inline-block; float: right'>");
                body.AppendLine(duration);
                body.AppendLine("</div>");
                body.AppendLine("</div>");
            }

            body.AppendLine("</div>");

            return body.ToString();
        }