public PracticeActivation ActivateDevice(DeviceInfo deviceInfo, DeviceLocationInfo deviceLocationInfo = null) { if (IsDeviceActivated(deviceInfo.Serial)) { return(Activations.FirstOrDefault(x => x.IsActive())); } if (IsDeviceExpired(deviceInfo.Serial)) { var expiredDevice = Activations.FirstOrDefault(x => x.IsExpired()); expiredDevice.Renew(deviceInfo, deviceLocationInfo); return(expiredDevice); } return(PracticeActivation.Create(Id, deviceInfo, deviceLocationInfo)); }
private void Update(DeviceInfo deviceInfo, DeviceLocationInfo deviceLocationInfo = null) { Model = deviceInfo.Model; DeviceCode = deviceInfo.Code; if (null != deviceLocationInfo) { IPAddress = deviceLocationInfo.IPAddress; Lng = deviceLocationInfo.Lng; Lat = deviceLocationInfo.Lat; } else { IPAddress = string.Empty; Lng = Lat = null; } }
public string GetActivationCode(string code, DeviceInfo info, DeviceLocationInfo locationInfo = null) { var practice = _practiceRepository.GetByCode(code); if (null == practice) { throw new ArgumentException("Facility Code Not found"); } var activation = practice.ActivateDevice(info, locationInfo); if (null == activation) { throw new ArgumentException("Actrivation not possible"); } _practiceActivationRepository.InsertOrUpdate(activation); _practiceRepository.Save(); return(activation.ActivationCode); }
/// <summary> /// Inserts the Device and location info /// </summary> /// <param name="xmlData">The XmlDocument which is provided in the partner api</param> /// <returns>The ID of the inserted row</returns> public static int SaveInfo(XmlDocument xmlData) { DeviceLocationInfo deviceLocation = new DeviceLocationInfo(); if (xmlData != null) { string mobileNumber, latLong, location, IP, IEMEIID, OS, App, capability; XmlNode parentItem = xmlData.GetElementsByTagName("Device").Item(0); XmlNodeList itemList = parentItem.SelectNodes("Tag"); mobileNumber = itemList.Item(0).Attributes["value"].Value; latLong = itemList.Item(1).Attributes["value"].Value; location = itemList.Item(2).Attributes["value"].Value; IP = itemList.Item(3).Attributes["value"].Value; IEMEIID = itemList.Item(4).Attributes["value"].Value; OS = itemList.Item(5).Attributes["value"].Value; App = itemList.Item(6).Attributes["value"].Value; capability = itemList.Item(7).Attributes["value"].Value; deviceLocation.MobileNumber = mobileNumber; deviceLocation.LatLong = latLong; deviceLocation.Location = location; deviceLocation.IP = IP; deviceLocation.IEMEIID = IEMEIID; deviceLocation.OS = OS; deviceLocation.App = App; deviceLocation.Capability = capability; deviceLocation.EntityState = EntityState.Added; using (BusinessLayer businessLayer = new BusinessLayer()) { businessLayer.AddDeviceLocationInfo(deviceLocation); } } return(deviceLocation.Id); }
internal void Renew(DeviceInfo deviceInfo, DeviceLocationInfo deviceLocationInfo = null) { Update(deviceInfo, deviceLocationInfo); Activate(); }
public static PracticeActivation Create(Guid practiceId, DeviceInfo deviceInfo, DeviceLocationInfo deviceLocationInfo = null, bool activate = true) { PracticeActivation activation = null; if (null != deviceLocationInfo) { activation = new PracticeActivation(practiceId, deviceInfo.Serial, deviceInfo.Model, deviceInfo.Code, deviceLocationInfo.IPAddress, deviceLocationInfo.Lng, deviceLocationInfo.Lat); } else { activation = new PracticeActivation(practiceId, deviceInfo.Serial, deviceInfo.Model, deviceInfo.Code); } if (activate) { activation.Activate(); } return(activation); }