public static List<Widgets.GenericDevice> GetDeviceList(DeviceWrapperBase[] devList) { List<Widgets.GenericDevice> stbs = new List<Widgets.GenericDevice>(); foreach (DeviceWrapperBase device in devList) { DeviceTypeEnum devType = DeviceLogic.GetDeviceType(device); if (devType != DeviceTypeEnum.ONT && devType != DeviceTypeEnum.ONTPort) { // Check devices already in list so we do not add duplicate Boolean stbAlreadyInList = false; foreach (Widgets.GenericDevice stb in stbs) { if (stb.Serial == device.DeviceId) { stbAlreadyInList = true; } } // add ONT to list if not already present if (!stbAlreadyInList) { Widgets.GenericDevice stbToAdd = new Widgets.GenericDevice(device); stbs.Add(stbToAdd); } } } return stbs; }
//public static ONT GetONT(string id) //{ // if (DeviceLogic.GetDeviceTypeById(id) == DeviceTypeEnum.ONT) // { // switch (DeviceLogic.DetermineONTType(id)) // { // case ONTTypeEnum.SFU: return new SFUONT(id) { }; // case ONTTypeEnum.MDU: return new MDUONT() { SerialNumber = id }; // default: return null; // //TODO: Employ better construction encapsulation (i.e. common constructor args) // } // } // else // throw new ArgumentException("Not a valid ONT Id"); //} public static ONT GetONT(DeviceWrapperBase device, string subId) { string ontId = ""; switch (DeviceLogic.GetDeviceType(device)) { case DeviceTypeEnum.ONT: ontId = device.DeviceId; break; case DeviceTypeEnum.ONTPort: ontId = DeviceLogic.DetermineONTSerial(device); break; } if (!string.IsNullOrEmpty(ontId)) { switch (DeviceLogic.GetONTType(device)) { case ONTType.SFU: return new SFUONT(ontId) { SerialNumber = ontId, IsActive = device.DeviceStatus == "ACTIVE", Model = device.DeviceModel, DeviceType = device.DeviceType, Status = device.DeviceStatus, AssociatedSubscriberId = subId, DeviceLoaded = false, UnitAddress = device.UnitAddress }; case ONTType.MDU: return new MDUONT() { SerialNumber = ontId }; default: return null; //TODO: Employ better construction encapsulation (i.e. common constructor args) } } else throw new ArgumentException("GONT135: Not a valid ONT Id"); }
public static List<string> GetDeviceIdList(DeviceWrapperBase[] deviceList) { List<string> idList = new List<string>(); foreach (DeviceWrapperBase device in deviceList) { idList.Add(device.DeviceId); } return idList; }
public static ONTPort GetONTPort(DeviceWrapperBase device) { if (DeviceLogic.GetDeviceTypeById(device.DeviceId) == DeviceTypeEnum.ONTPort) { switch (DeviceLogic.GetONTPortType(device.DeviceId)) { case ONTPortTypeEnum.Ethernet: return new ONTDataPort() { PortType = ONTPortTypeEnum.Ethernet, SerialNumber = device.DeviceId, IsActive = device.DeviceStatus == "ACTIVE", DeviceLoaded = device.DatabaseDataLoad, Model = device.DeviceModel, DeviceType = device.DeviceType, Status = device.DeviceStatus, ONTSerialNumber = DeviceLogic.DetermineONTSerial(device.DeviceId), LocationId = device.LocationId, UnitAddress = device.UnitAddress }; case ONTPortTypeEnum.Moca: return new ONTMocaPort() { PortType = ONTPortTypeEnum.Moca, SerialNumber = device.DeviceId, IsActive = device.DeviceStatus == "ACTIVE", DeviceLoaded = device.DatabaseDataLoad, Model = device.DeviceModel, DeviceType = device.DeviceType, Status = device.DeviceStatus, ONTSerialNumber = DeviceLogic.DetermineONTSerial(device.DeviceId), LocationId = device.LocationId, UnitAddress = device.UnitAddress }; case ONTPortTypeEnum.Video: return new ONTVideoPort() { PortType = ONTPortTypeEnum.Video, SerialNumber = device.DeviceId, IsActive = device.DeviceStatus == "ACTIVE", DeviceLoaded = device.DatabaseDataLoad, Model = device.DeviceModel, DeviceType = device.DeviceType, Status = device.DeviceStatus, ONTSerialNumber = DeviceLogic.DetermineONTSerial(device.DeviceId), LocationId = device.LocationId, UnitAddress = device.UnitAddress }; case ONTPortTypeEnum.Voice: return new ONTVoicePort() { PortType = ONTPortTypeEnum.Voice, SerialNumber = device.DeviceId, IsActive = device.DeviceStatus == "ACTIVE", DeviceLoaded = device.DatabaseDataLoad, Model = device.DeviceModel, DeviceType = device.DeviceType, Status = device.DeviceStatus, ONTSerialNumber = DeviceLogic.DetermineONTSerial(device.DeviceId), AssignedTN = (device.DirectoryNum == null ? "None" : device.DirectoryNum.ToString()), LocationId = device.LocationId, UnitAddress = device.UnitAddress }; default: return null; } } else throw new ArgumentException("GOP140: Device is not an ONT Port"); }
//public static DeviceWrapperBase[] ToDeviceList(List<Widgets.GenericDevice> devices, List<Widgets.GenericOnt> onts) //{ // DeviceWrapperBase[] deviceList = new DeviceWrapperBase[devices.Count + onts.Count]; // int i = 0; // foreach (Widgets.GenericDevice dev in devices) // { // DeviceWrapperBase newWrapper = new DeviceWrapperBase(); // newWrapper.DeviceId = dev.Serial; // newWrapper.DeviceModel = dev.Model; // newWrapper.DeviceStatus = dev.Status; // deviceList[i] = newWrapper; // i++; // } // foreach (Widgets.GenericOnt dev in onts) // { // DeviceWrapperBase newWrapper = new DeviceWrapperBase(); // newWrapper.DeviceId = dev.SerialNumber; // newWrapper.DeviceModel = dev.OntModel; // newWrapper.DeviceType = dev.OntType; // newWrapper.DeviceStatus = dev.Status; // deviceList[i] = newWrapper; // i++; // } // return deviceList; //} public static List<ONT> GetOntList(DeviceWrapperBase[] devList, string subscriberId) { List<ONT> onts = new List<ONT>(); foreach (DeviceWrapperBase device in devList) { // if the device is an ONT DeviceTypeEnum devType = DeviceLogic.GetDeviceType(device); if (/*device.isONT ||*/ devType == DeviceTypeEnum.ONT || devType == DeviceTypeEnum.ONTPort) { // Check ONTs already in list do we do not add duplicate Boolean ontAlreadyInList = false; foreach (ONT ont in onts) { if (ont.SerialNumber == DeviceLogic.DetermineONTSerial(device.DeviceId)) { ontAlreadyInList = true; } } // add ONT to list if not already present if (!ontAlreadyInList) { ONT ontToAdd = ONTFactory.GetONT(device, subscriberId); ontToAdd.LoadDevice(); onts.Add(ontToAdd); } } } return onts; }
public static List<DeviceWrapperBase> ToDeviceList(List<Widgets.GenericDevice> devices, List<ONT> onts) { List<DeviceWrapperBase> deviceList = new List<DeviceWrapperBase>(); foreach (Widgets.GenericDevice dev in devices) { DeviceWrapperBase newWrapper = new DeviceWrapperBase(); newWrapper.DeviceId = dev.Serial; newWrapper.DeviceModel = dev.Model; newWrapper.DeviceStatus = dev.Status; deviceList.Add(newWrapper); } foreach (ONT dev in onts) { DeviceWrapperBase newWrapper = new DeviceWrapperBase(); newWrapper.DeviceId = dev.SerialNumber; newWrapper.DeviceModel = dev.Model; newWrapper.DeviceType = dev.DeviceType; newWrapper.DeviceStatus = dev.Status; deviceList.Add(newWrapper); } return deviceList; }
public SavedSerial(DeviceWrapperBase device) { Model = device.DeviceModel; Serial = device.DeviceId; }