Exemplo n.º 1
0
 private static void GetLocationIdFromReturnToHeadend(object dtoObject, ref List<string> locationIdsToSync)
 {
     var serials = dtoObject as List<string>;
     var tempLocationsIdsToSync = locationIdsToSync;
     if (serials != null && serials.Count > 0)
     {
         try
         {
             Parallel.ForEach(serials, serial =>
             {
                 using (var client = new RosettianClient())
                 {
                     var equipments =
                         client.SearchEquipment(new SearchFieldsDto() { EquipmentId = serial },
                             new UserDto() { Name = "SIMPL" });
                     if (equipments != null && equipments.First() != null && equipments.Count > 0)
                     {
                         tempLocationsIdsToSync.Add(equipments.First().LocationId);
                     }
                 }
             });
         }
         catch (AggregateException fault)
         {
             var log = new ErrorLoggingService();
             log.LogErrorNoContext(fault);
         }
     }
     locationIdsToSync = tempLocationsIdsToSync;
 }
Exemplo n.º 2
0
        private static void GetLocationIdFromEquipmentCriteriaCollectionDto(object dtoObject, string methodName, ref List<string> locationIdsToSync)
        {
            var equipmentCollectionDto = dtoObject as EquipmentCriteriaCollectionDto;
            if (equipmentCollectionDto != null && equipmentCollectionDto.Count > 0)
            {
                foreach (var equipment in equipmentCollectionDto)
                {
                    if (equipment != null && !string.IsNullOrWhiteSpace(equipment.LocationId))
                    {
                        locationIdsToSync.Add(equipment.LocationId);
                    }
                }

                if (methodName != "ActivateONT") return ;
                try
                {
                    using (var client = new RosettianClient())
                    {
                        var baseOntSerial = (equipmentCollectionDto.First().SerialNumber.Count() > 12)
                            ? equipmentCollectionDto.First().SerialNumber.Substring(0, 12)
                            : equipmentCollectionDto.First().SerialNumber;
                        var equipments = client.SearchEquipment(
                            new SearchFieldsDto() { EquipmentId = baseOntSerial },
                            new UserDto() { Name = "SIMPL" });
                        if (equipments != null && equipments.FirstOrDefault() != null && equipments.Count > 0)
                        {
                            foreach (var equipment in equipments)
                            {
                                if (equipment != null && !string.IsNullOrWhiteSpace(equipment.LocationId))
                                {
                                    locationIdsToSync.Add(equipment.LocationId);
                                }
                            }
                        }
                    }
                }
                catch (FaultException<ValidationFault> fault)
                {
                    var log = new ErrorLoggingService();
                    log.LogErrorNoContext(fault);
                }
            }
        }
Exemplo n.º 3
0
        private static void GetLocationIdFromEquipmentDto(object dtoObject, string methodName, ref List<string> locationIdsToSync)
        {
            var equipementDto = (dtoObject.GetType().Name == "EquipmentDto")
                ? dtoObject as EquipmentDto
                : dtoObject as CableCardDto;
            if (equipementDto != null && !string.IsNullOrWhiteSpace(equipementDto.LocationId))
            {
                locationIdsToSync.Add(equipementDto.LocationId);

                if (methodName == "UpdateEquipment")
                {
                    try
                    {
                        using (var client = new RosettianClient())
                        {
                            var equipments = client.SearchEquipment(
                                new SearchFieldsDto() { EquipmentId = equipementDto.SerialNumber },
                                new UserDto() { Name = "SIMPL" });

                            if (equipments != null && equipments.FirstOrDefault() != null && equipments.Count > 0)
                            {
                                locationIdsToSync.Add(equipments.First().LocationId);
                            }
                        }
                    }
                    catch (FaultException<ValidationFault> fault)
                    {
                        var log = new ErrorLoggingService();
                        log.LogErrorNoContext(fault);
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// RestoreEquip - returns EquipmentCollectionDto - calls Rosettian UpdateEquipment method to reset data
        /// </summary>
        /// <param name="criteria"></param>
        /// <returns></returns>
        protected static EquipmentCollectionDto RestoreEquip(EquipmentCriteriaDto criteria)
        {
            using (var client = new RosettianClient())
            {
                if (!client.ONTExists(criteria.SerialNumber, user))
                {
                    client.CreateONT(criteria, user);
                }
                var equipList =
                    client.SearchEquipment(new SearchFieldsDto {EquipmentId = criteria.SerialNumber}, user)
                        .Where(x => x.SerialNumber.Substring(0, x.SerialNumber.Length - 3) == criteria.SerialNumber).ToList();

                foreach (var equip in equipList.Where(x => x.LocationId != criteria.LocationId || x.Status != criteria.Status || x.UnitAddress != criteria.UnitAddress))
                {
                    equip.LocationId = criteria.LocationId;
                    equip.Status = criteria.Status;
                    equip.UnitAddress = criteria.UnitAddress;
                    client.UpdateEquipment(equip, user);
                }
                return new EquipmentCollectionDto(equipList);
            }
        }