Пример #1
0
        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));
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
        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);
        }
Пример #4
0
        /// <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);
        }
Пример #5
0
 internal void Renew(DeviceInfo deviceInfo, DeviceLocationInfo deviceLocationInfo = null)
 {
     Update(deviceInfo, deviceLocationInfo);
     Activate();
 }
Пример #6
0
        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);
        }