protected override bool PerformDeviceLoad(string deviceId) { DeviceWrapper device = null; using (MagnumProxy magnumProxy = new MagnumProxy()) { device = magnumProxy.Client.LoadDevice(deviceId, CurrentUser.AsRosettianUser().Name); } if (device != null) { AssignBaseProperties(device); AssociatedSubscriberId = device.Location.SubscriberId; } return device.DatabaseDataLoad; }
protected override bool PerformDeviceLoad(string deviceId) { string ontSerial = ""; // We can only build an ONT off of an ONT serial number or ONT Port serial number switch (DeviceLogic.GetDeviceTypeById(deviceId)) { case DeviceTypeEnum.ONT: ontSerial = deviceId; break; case DeviceTypeEnum.ONTPort: ontSerial = DeviceLogic.DetermineONTSerial(deviceId); break; default: throw new ArgumentException("OPDL139: Invalid ONT Id or ONT Port Id. Can't create object."); } // Now that we have the serial number, perform the magnum search for the ONT and related ports SearchWrapper s = new SearchWrapper(); s.SearchByDevice = new DeviceSearchWrapper(); s.SearchByDevice.DeviceId = ontSerial; s.SearchType = SearchTypeEnum.SearchByDevice; List<SearchWrapper> results = null; DeviceWrapper device = new DeviceWrapper() { DeviceId = ontSerial }; using (_magnumProxy = new MagnumProxy()) { results = _magnumProxy.Client.Search(s, CurrentUser.AsRosettianUser().Name).ToList(); } if (results.Count > 0) { // Using the results, assign values to the properties of our ONT object try { PopulateFromSearchResults(results); } catch (ArgumentException) { // do nothing (omits bad port from list of ports) } DeviceLoaded = true; } return DeviceLoaded; }
public bool SwapONT(string inONT, string outONT, out string errorMessage) { try { using (MagnumProxy _magnum = new MagnumProxy()) { MagnumApiServiceReference.Error err = _magnum.Client.SwapONTBasic(inONT, outONT, CurrentUser.AsRosettianUser().Name); errorMessage = MagnumApi.MagnumErrorHandler.ErrorFound(err); bool success = string.IsNullOrEmpty(errorMessage); if (success) { CurrentSubscriber.GetInstance().RemoveONTFromSub(outONT); } return success; } } catch (Exception ex) { errorMessage = ex.TargetSite + " " + ex.Message; return false; } }
public bool SwapONT(string inONT, string outONT, string outDeviceStatus, string outLocationId, out string errorMessage) { try { using (MagnumProxy _magnum = new MagnumProxy()) { MagnumApiServiceReference.Error err = _magnum.Client.SwapONT(inONT, outDeviceStatus, outLocationId, outONT, CurrentUser.AsRosettianUser().Name); errorMessage = MagnumApi.MagnumErrorHandler.ErrorFound(err); return string.IsNullOrEmpty(errorMessage); } } catch (Exception ex) { errorMessage = ex.TargetSite + " " + ex.Message; return false; } }
public void SwapTNPort(string subId, string portId1, string portId2) { /* Steps to swapping TN ports: * Considerations: Are both ports active? Both on same ONT? Both belong to same subscriber? * If statuses not equal, swap statuses * If ports do not have same subscriber * */ _magnumProxy = new MagnumProxy(); using (_magnumProxy) { SubscriberWrapper sub = _magnumProxy.Client.LoadSubscriber(subId, CurrentUser.AsRosettianUser().Name); // load sub wrapper from Magnum DeviceWrapperBase p1 = sub.DeviceList.FirstOrDefault(d => d.DeviceId == portId1); DeviceWrapperBase p2 = sub.DeviceList.FirstOrDefault(d => d.DeviceId == portId2); // if either of the following are null, it means there is no phone number currently assigned // to the port (portId1/portId2) and the port must be ACTIVATED in addition to having a number assigned to it PhoneWrapperBase tn1 = sub.PhoneList.FirstOrDefault(t => t.DeviceId == portId1); PhoneWrapperBase tn2 = sub.PhoneList.FirstOrDefault(t => t.DeviceId == portId2); // if either port ID is not assigned to subscriber, exit function if (p1 == null || p2 == null) { throw new ArgumentException("ONT Ports do not belong to the same subscriber."); } if (tn1 == null && tn2 == null) { throw new ArgumentException("Neither voice port has a TN assigned"); } // device ID must be moved from tn2 to tn1 if (tn1 == null && tn2 != null) { if (p1.DeviceStatus.ToUpper() != SIMPLDbEnums.ToTriadStatusString( SIMPLDbEnums.EquipStatusEnum.Active)) { ONTPortFactory.GetONTPort(p1).Activate(); } tn2.DeviceId = portId1; if (p2.DeviceStatus.ToUpper() == SIMPLDbEnums.ToTriadStatusString( SIMPLDbEnums.EquipStatusEnum.Active)) { ONTPortFactory.GetONTPort(p2).Deactivate(); } } // device ID must be moved from tn1 to tn2 else if (tn2 == null && tn1 != null) { if (p2.DeviceStatus.ToUpper() != SIMPLDbEnums.ToTriadStatusString( SIMPLDbEnums.EquipStatusEnum.Active)) { ONTPortFactory.GetONTPort(p2).Activate(); } tn1.DeviceId = portId2; if (p2.DeviceStatus.ToUpper() == SIMPLDbEnums.ToTriadStatusString( SIMPLDbEnums.EquipStatusEnum.Active)) { ONTPortFactory.GetONTPort(p1).Deactivate(); } } else { string tempId = tn1.DeviceId; tn1.DeviceId = tn2.DeviceId; tn2.DeviceId = tempId; } _magnumProxy.Client.SaveSubscriber(sub, CurrentUser.AsRosettianUser().Name); } }
protected void LoadAndSetPortsList(List<SearchWrapper> results = null) { Boolean proceed = false; List<ONTPort> portList = new List<ONTPort>(); // Create search objects //magnumHelper = new MagnumHelper(); SearchWrapper srch = new SearchWrapper(); srch.SearchByDevice = new DeviceSearchWrapper(); srch.SearchType = SearchTypeEnum.SearchByDevice; // Determine Root ONT Serial number switch (DeviceLogic.GetDeviceTypeById(SerialNumber)) { case DeviceTypeEnum.ONT: { proceed = true; // set proceed flag srch.SearchByDevice.DeviceId = SerialNumber + "%"; // search for all ports for this ONT break; } case DeviceTypeEnum.ONTPort: { proceed = true; // set proceed flag // get ONT serial from port ID, then get associated ports from Triad srch.SearchByDevice.DeviceId = DeviceLogic.DetermineONTSerial(SerialNumber + "%"); break; } default: break; } if (proceed) { // initialize individual portType lists (allows sorting into logical order --> voice, data, video List<ONTPort> voicePorts = new List<ONTPort>(); List<ONTPort> dataPorts = new List<ONTPort>(); List<ONTPort> mocaPorts = new List<ONTPort>(); List<ONTPort> videoPorts = new List<ONTPort>(); DeviceWrapper dev = new DeviceWrapper(); SubscriberWrapper sub = new SubscriberWrapper(); using (_magnumProxy = new MagnumProxy()) { // if no search wrapper was passed in, perform our own search if (results == null) { results = _magnumProxy.Client.Search(srch, CurrentUser.AsRosettianUser().Name).ToList(); } if (results.Count > 0) { dev = _magnumProxy.Client.LoadDevice(results[0].SearchByDevice.DeviceId, CurrentUser.AsRosettianUser().Name); } } // once we have a definite result set, parse out the ports, assign the type and property values // from the search results foreach (SearchWrapper wrapper in results) { ONTPort port = null; // double check that we are working with an ONT Port if (DeviceLogic.GetDeviceTypeById(wrapper.SearchByDevice.DeviceId) == DeviceTypeEnum.ONTPort) { // get new port from factory and add to correct type list port = ONTPortFactory.GetONTPort(wrapper.SearchByDevice); switch (port.PortType) { case ONTPortTypeEnum.Ethernet: dataPorts.Add(port); break; case ONTPortTypeEnum.Moca: mocaPorts.Add(port); break; case ONTPortTypeEnum.Video: videoPorts.Add(port); break; case ONTPortTypeEnum.Voice: voicePorts.Add(port); break; } } } // internally order all port lists voicePorts = voicePorts.OrderBy(p => p.SerialNumber).ToList(); dataPorts = dataPorts.OrderBy(p => p.SerialNumber).ToList(); videoPorts = videoPorts.OrderBy(p => p.SerialNumber).ToList(); mocaPorts = mocaPorts.OrderBy(p => p.SerialNumber).ToList(); // add to main list in order of precedence portList.AddRange(voicePorts); portList.AddRange(dataPorts); portList.AddRange(videoPorts); portList.AddRange(mocaPorts); } Ports = portList; }
/// <summary> /// /// </summary> /// <param name="locId"></param> /// <returns></returns> protected virtual Boolean PerformLocationChange(string locId) { DeviceWrapper device = null; using (_magnumProxy = new MagnumProxy()) { device = _magnumProxy.Client.LoadDevice(SerialNumber, CurrentUser.AsRosettianUser().Name); device.Location.LocationId = locId; device.ReloadDataAfterSave = true; _magnumProxy.Client.SaveDevice(device, DEVICE_WAIT_TIME, CurrentUser.AsRosettianUser().Name); } if (device.LocationId == locId) { LocationId = locId; if (MagnumEventLogger.LogDeviceAction(new MagnumEventLoggingArgs(this, SIMPLDbEnums.TransactionTypeEnum.LocationChange))) { LoadDevice(); return true; } } return false; }
protected virtual Boolean PerformDeviceLoad(string deviceId) { DeviceWrapper device = null; using (_magnumProxy = new MagnumProxy()) { device = _magnumProxy.Client.LoadDevice(deviceId, CurrentUser.AsRosettianUser().Name); } if (string.IsNullOrEmpty(device.DeviceModel)) { throw new ArgumentException("PDL134: Device does not exist in Triad"); } if (device != null) { this.SerialNumber = device.DeviceId; this.Model = device.DeviceModel; this.HeadendCode = device.Location.HeadendCode; this.Status = device.DeviceStatus; this.DeviceType = device.DeviceType; this.IsActive = device.DeviceStatus == "ACTIVE"; this.LocationId = device.LocationId; this._associatedSubscriberId = device.Location.SubscriberId; this.UnitAddress = device.UnitAddress; } return device.DatabaseDataLoad; }
public virtual bool ReturnToHeadend() { bool statSuccess = false; bool moveSuccess = false; using (_magnumProxy = new MagnumProxy()) { DeviceWrapper device = _magnumProxy.Client.LoadDevice(SerialNumber, CurrentUser.AsRosettianUser().Name); device.ReloadDataAfterSave = true; device.DeviceStatus = SIMPLDbEnums.ToTriadStatusString(SIMPLDbEnums.EquipStatusEnum.FieldReturn); statSuccess = device.DeviceStatus == SIMPLDbEnums.ToTriadStatusString(SIMPLDbEnums.EquipStatusEnum.FieldReturn); if (statSuccess) { MagnumEventLogger.LogDeviceAction(new MagnumEventLoggingArgs(this, SIMPLDbEnums.TransactionTypeEnum.StatusChange)); } } moveSuccess = this.MoveToLocation(DBCache.HeadEndCodes.First(h => h.headend_code == HeadendCode).location_id); return (statSuccess && moveSuccess); }
/// <summary> /// Public facing method to move a device to a location. Performs necessary validation before passing /// to protected method for actual device relocation in Triad. /// </summary> /// <param name="locId"></param> /// <returns>Returns true if successful</returns> public virtual Boolean MoveToLocation(string locId) { Boolean success = false; using (_magnumProxy = new MagnumProxy()) { SearchWrapper srch = new SearchWrapper(); srch.SearchByLocation = new LocationSearchWrapper(); srch.SearchByLocation.LocationId = locId; srch.SearchType = SearchTypeEnum.SearchByLocation; SearchWrapper[] results = _magnumProxy.Client.Search(srch, CurrentUser.AsRosettianUser().Name); if (results.Length == 1) // if and only if one result is returned, move the device { success = PerformLocationChange(locId); if (success) { LocationId = locId; } } } return success; }
public virtual Boolean Deactivate() { try { using (_magnumProxy = new MagnumProxy()) { DeviceWrapper device = _magnumProxy.Client.LoadDevice(SerialNumber, CurrentUser.AsRosettianUser().Name); this.Status = SIMPLDbEnums.ToTriadStatusString(SIMPLDbEnums.EquipStatusEnum.Disabled); device.DeviceStatus = this.Status; _magnumProxy.Client.SaveDevice(device, DEVICE_WAIT_TIME, CurrentUser.AsRosettianUser().Name); MagnumEventLogger.LogDeviceAction(new MagnumEventLoggingArgs(this, SIMPLDbEnums.TransactionTypeEnum.StatusChange)); } return true; } catch (Exception) { return false; } }