private IList<CS_EquipmentWhiteLight> SetEquipmentComboWhiteLight()
        {
            IList<CS_EquipmentWhiteLight> comboWhiteLightEquipments = new List<CS_EquipmentWhiteLight>();

            CS_View_EquipmentInfo eqInfo = _equipmentModel.GetEquipmentInfoByEquipmentID(_view.EquipmentID);// _equipmentInfoRepository.Get(e => e.EquipmentID == _view.EquipmentID);
            if (eqInfo.IsPrimary == 1 && eqInfo.ComboID != null && eqInfo.ComboID.HasValue)
            {
                IList<CS_Equipment> equips = _equipmentModel.ListEquipmentsFromPrimaryEquipment(eqInfo.EquipmentID, eqInfo.ComboID.Value);
                for (int j = 0; j < equips.Count; j++)
                {
                    if (_view.EquipmentID != equips[j].ID)
                    {
                        CS_EquipmentWhiteLight equipmentWhiteLight = new CS_EquipmentWhiteLight();

                        equipmentWhiteLight.Active = true;
                        equipmentWhiteLight.CreatedBy = _view.Username;
                        equipmentWhiteLight.CreationDate = DateTime.Now;
                        //equipmentWhiteLight.CreationID
                        equipmentWhiteLight.EquipmentID = equips[j].ID;
                        equipmentWhiteLight.ModificationDate = DateTime.Now;
                        //equipmentWhiteLight.ModificationID
                        equipmentWhiteLight.ModifiedBy = _view.Username;
                        equipmentWhiteLight.WhiteLightStartDate = DateTime.Now;
                        equipmentWhiteLight.Notes = _view.WhiteLightNotes;

                        comboWhiteLightEquipments.Add(equipmentWhiteLight);
                    }
                }
            }
            return comboWhiteLightEquipments;
        }
        /// <summary>
        /// Set the values to be saved on entity CS_EquipmentWhiteLight on DB
        /// </summary>
        /// <returns></returns>
        private CS_EquipmentWhiteLight SetEquipmentWhiteLight()
        {
            CS_EquipmentWhiteLight equipmentWhiteLight = new CS_EquipmentWhiteLight();

            equipmentWhiteLight.Active = true;
            equipmentWhiteLight.CreatedBy = _view.Username;
            equipmentWhiteLight.CreationDate = DateTime.Now;
            //equipmentWhiteLight.CreationID
            equipmentWhiteLight.EquipmentID = _view.EquipmentID;
            equipmentWhiteLight.ModificationDate = DateTime.Now;
            //equipmentWhiteLight.ModificationID
            equipmentWhiteLight.ModifiedBy = _view.Username;
            equipmentWhiteLight.WhiteLightStartDate = DateTime.Now;
            equipmentWhiteLight.Notes = _view.WhiteLightNotes;

            return equipmentWhiteLight;
        }
Ejemplo n.º 3
0
        private string BuildWhiteLogNote(CS_EquipmentWhiteLight equipmentWhiteLight, bool add)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (add)
            {
                stringBuilder.Append("Start Date: ");
                stringBuilder.Append(" <Text>");

                stringBuilder.AppendFormat(" {0}<BL>", equipmentWhiteLight.WhiteLightStartDate.ToString("MM/dd/yyyy HH:mm"));
            }
            else
            {
                stringBuilder.Append("End Date: ");
                stringBuilder.Append(" <Text>");

                stringBuilder.AppendFormat(" {0}<BL>", equipmentWhiteLight.WhiteLightStartDate.ToString("MM/dd/yyyy HH:mm"));

                TimeSpan duration = equipmentWhiteLight.WhiteLightEndDate.Value.Subtract(equipmentWhiteLight.WhiteLightStartDate);

                stringBuilder.Append("Duration: ");
                stringBuilder.Append(" <Text>");

                stringBuilder.AppendFormat(" {0} days<BL>", ((int)duration.TotalDays).ToString());
            }

            if (!string.IsNullOrEmpty(equipmentWhiteLight.Notes))
            {
                stringBuilder.Append("Notes: ");
                stringBuilder.Append(" <Text>");

                stringBuilder.AppendFormat(" {0}<BL>", equipmentWhiteLight.Notes);
            }

            return stringBuilder.ToString();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Save the new object CS_EquipmentWhiteLight on the DB
        /// </summary>
        /// <param name="equipmentWhiteLight"></param>
        public void UpdateEquipmentWhiteLight(CS_EquipmentWhiteLight equipmentWhiteLight)
        {
            if (null == equipmentWhiteLight)
                throw new Exception("The equipmentWhiteLight object is null.");

            try
            {
                _equipmentWhiteLightRepository.Update(equipmentWhiteLight);

                int? jobId = this.GetJobIdAssignedToEquipment(equipmentWhiteLight.EquipmentID);

                if (jobId.HasValue)
                {
                    SaveWhiteLightCallLog(equipmentWhiteLight, jobId.Value, false);
                }
                else
                {
                    SaveWhiteLightCallLog(equipmentWhiteLight, Globals.GeneralLog.ID, false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error while trying to save the equipmentwhitelight object.", ex);
            }
        }
Ejemplo n.º 5
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.º 6
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.º 7
0
        public void SaveEquipment(CS_Equipment equipment, CS_EquipmentCoverage equipmentCoverage, CS_EquipmentWhiteLight equipmentWhiteLight, IList<CS_EquipmentWhiteLight> comboEquipmentsWhiteLight, CS_EquipmentDownHistory equipmentDownHistory, IList<CS_EquipmentDownHistory> equipmentComboDownHistory, bool isHeavyEquipment, bool isSeasonal, bool displayInResourceAllocation, bool replicateToCombo, bool IsEquipmentCoverage, bool IsEquipmentWhiteLight, string username)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                #region [ Equipment/EquipmentDown ]
                SaveEquipment(equipment, equipmentDownHistory, equipmentComboDownHistory, isHeavyEquipment, isSeasonal, displayInResourceAllocation, replicateToCombo);
                #endregion

                #region [ EquipmentCoverage ]

                CS_EquipmentCoverage eCoverage = GetEquipmentCoverage(equipment.ID);

                if (IsEquipmentCoverage)
                {
                    if (null != eCoverage)
                    {
                        eCoverage.CoverageStartDate = equipmentCoverage.CoverageStartDate;
                        eCoverage.DivisionID = equipmentCoverage.DivisionID;
                        eCoverage.Duration = equipmentCoverage.Duration;
                        eCoverage.ModifiedBy = equipmentCoverage.ModifiedBy;
                        eCoverage.ModificationDate = equipmentCoverage.ModificationDate;

                        //Update equipmentcoverage
                        UpdateEquipmentCoverage(eCoverage);
                    }
                    else
                    {
                        //Save equipmentcoverage
                        SaveEquipmentCoverage(equipmentCoverage);

                        using (_callLogModel = new CallLogModel())
                        {
                            _callLogModel.CreateCoverageCallLogs(equipment.ID, equipmentCoverage, username);
                        }
                    }
                }
                else
                {
                    if (null != eCoverage)
                    {
                        eCoverage.Active = false;
                        eCoverage.CoverageStartDate = equipmentCoverage.CoverageStartDate;
                        eCoverage.DivisionID = equipmentCoverage.DivisionID;
                        eCoverage.Duration = equipmentCoverage.Duration;
                        if (equipmentCoverage.CoverageEndDate.HasValue)
                        {
                            eCoverage.CoverageEndDate = equipmentCoverage.CoverageEndDate.Value;
                            eCoverage.ModificationDate = equipmentCoverage.CoverageEndDate.Value;
                        }
                        eCoverage.ModifiedBy = equipmentCoverage.ModifiedBy;

                        //Update equipmentcoverage when user uncheck the coverage checkbox
                        UpdateEquipmentCoverage(eCoverage);
                    }
                }

                #endregion

                #region [ WhiteLight ]

                CS_EquipmentWhiteLight eWhiteLight = GetEquipmentWhiteLight(equipment.ID);

                if (null != eWhiteLight)
                {
                    if (!IsEquipmentWhiteLight)
                    {
                        equipmentWhiteLight.ID = eWhiteLight.ID;
                        equipmentWhiteLight.WhiteLightEndDate = DateTime.Now;
                        equipmentWhiteLight.Active = false;
                        equipmentWhiteLight.ModificationDate = DateTime.Now;
                        equipmentWhiteLight.ModifiedBy = equipment.ModifiedBy;
                        if (!string.IsNullOrEmpty(equipmentWhiteLight.Notes))
                            equipmentWhiteLight.Notes = eWhiteLight.Notes + "\n" + equipmentWhiteLight.Notes;

                        UpdateEquipmentWhiteLight(equipmentWhiteLight);
                        if (replicateToCombo)
                        {
                            for (int i = 0; i < comboEquipmentsWhiteLight.Count; i++)
                            {
                                CS_EquipmentWhiteLight eWhiteLightCombo = GetEquipmentWhiteLight(comboEquipmentsWhiteLight[i].EquipmentID);
                                comboEquipmentsWhiteLight[i].ID = eWhiteLightCombo.ID;
                                comboEquipmentsWhiteLight[i].WhiteLightEndDate = DateTime.Now;
                                comboEquipmentsWhiteLight[i].Active = false;
                                comboEquipmentsWhiteLight[i].ModificationDate = DateTime.Now;
                                comboEquipmentsWhiteLight[i].ModifiedBy = equipment.ModifiedBy;
                                if (!string.IsNullOrEmpty(comboEquipmentsWhiteLight[i].Notes))
                                    comboEquipmentsWhiteLight[i].Notes = eWhiteLight.Notes + "\r\n" + comboEquipmentsWhiteLight[i].Notes;
                                UpdateEquipmentWhiteLight(comboEquipmentsWhiteLight[i]);
                            }
                        }
                    }
                }
                else
                {
                    if (IsEquipmentWhiteLight)
                    {
                        SaveEquipmentWhiteLight(equipmentWhiteLight);
                        if (replicateToCombo)
                        {
                            for (int i = 0; i < comboEquipmentsWhiteLight.Count; i++)
                            {
                                SaveEquipmentWhiteLight(comboEquipmentsWhiteLight[i]);
                            }
                        }
                    }
                }
                #endregion

                scope.Complete();
            }
        }