示例#1
0
        public async Task <HttpResponseMessage> AddDevice(RequestOmniModel objRequestOmniModel)
        {
            //objRequestOmniModel.MacAddress= "7z:c5:37:c0:83:y3";
            //create the RequestModel for secom api
            string result = null;

            try
            {
                using (RtlsConfigurationRepository objRtlsConfigurationRepository = new RtlsConfigurationRepository())
                {
                    //Get the EngageEngine Base Url as per SiteId
                    Site objSiteConfiguration = objRtlsConfigurationRepository.GetAsPerSite(objRequestOmniModel.SiteId);
                    if (objSiteConfiguration.RtlsConfiguration.RtlsEngineType == RtlsEngine.OmniEngine)
                    {
                        OmniEngineBusiness objOmniEngineBusiness = new OmniEngineBusiness();
                        await objOmniEngineBusiness.regMacToOmniEngine(objRequestOmniModel);

                        using (MacAddressRepository objMacAddressRepository = new MacAddressRepository())
                        {
                            objMacAddressRepository.UpdateLocationServiceTypeforMac(objRequestOmniModel, objSiteConfiguration.RtlsConfiguration.RtlsEngineType);
                        }
                        //string OmniBaseAddressUri = objSiteConfiguration.RtlsConfiguration.OmniBaseAddressUri;
                    }
                    if (objSiteConfiguration.RtlsConfiguration.RtlsEngineType == RtlsEngine.EngageEngine)
                    {
                        EngageEngineBusiness objEngageEngineBusiness = new EngageEngineBusiness();
                        if (await objEngageEngineBusiness.regMacToEngageEngine(objRequestOmniModel))
                        {
                            using (MacAddressRepository objMacAddressRepository = new MacAddressRepository())
                            {
                                objMacAddressRepository.UpdateLocationServiceTypeforMac(objRequestOmniModel, objSiteConfiguration.RtlsConfiguration.RtlsEngineType);
                            }
                        }
                        //string EngageBaseAddressUri = objSiteConfiguration.RtlsConfiguration.EngageBaseAddressUri;
                    }
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
                log.Error(ex.Message);
            }
            return(new HttpResponseMessage()
            {
                Content = new StringContent(JsonConvert.SerializeObject(result), Encoding.UTF8, "application/json")
            });
        }
示例#2
0
        public async Task <HttpResponseMessage> AddDevices(RequestLocationDataVM model)
        {
            Notification        objNotifications = new Notification();
            DeviceAssociateSite deviceid         = null;

            using (RtlsConfigurationRepository objRtlsConfigurationRepository = new RtlsConfigurationRepository())
            {
                Site objSite = objRtlsConfigurationRepository.GetAsPerSite(model.SiteId);

                foreach (var item in model.MacAddresses)
                {
                    // When Device is coming for reregister in OmniEngiene
                    int deviceId = _OmniDeviceMappingRepository.GetDeviceId(item);
                    deviceid = objRtlsConfigurationRepository.DeviceAssociateSiteStatus(deviceId);
                    if (deviceid.status == DeviceStatus.DeRegistered)
                    {
                        OmniEngineBusiness objOmniEngineBusiness = new OmniEngineBusiness();
                        RequestOmniModel   objRequestOmniModel   = new RequestOmniModel();
                        objRequestOmniModel.MacAddress = item;
                        await objOmniEngineBusiness.ReRegister(objRequestOmniModel);
                    }
                }
                //First time devive will store
                if (deviceid.status == DeviceStatus.None)
                {
                    try
                    {
                        if (objSite.RtlsConfiguration.RtlsEngineType == RtlsEngine.OmniEngine)
                        {
                            foreach (var item in model.MacAddresses)
                            {
                                OmniEngineBusiness objOmniEngineBusiness = new OmniEngineBusiness();
                                RequestOmniModel   objRequestOmniModel   = new RequestOmniModel();
                                objRequestOmniModel.MacAddress = item;

                                await objOmniEngineBusiness.regMacToOmniEngine(objRequestOmniModel);

                                objNotifications.result.returncode = Convert.ToInt32(FatiApiResult.Success);
                                using (MacAddressRepository objMacRepository = new MacAddressRepository())
                                {
                                    objMacRepository.RegisterListOfMacAddresses(model);
                                }
                            }
                        }
                        if (objSite.RtlsConfiguration.RtlsEngineType == RtlsEngine.EngageEngine)
                        {
                            foreach (var item in model.MacAddresses)
                            {
                                EngageEngineBusiness objEngageEngineBusiness = new EngageEngineBusiness();
                                RequestOmniModel     objRequestOmniModel     = new RequestOmniModel();
                                objRequestOmniModel.SiteId     = model.SiteId;
                                objRequestOmniModel.MacAddress = item;
                                if (await objEngageEngineBusiness.regMacToEngageEngine(objRequestOmniModel))
                                {
                                    objNotifications.result.returncode = Convert.ToInt32(FatiApiResult.Success);
                                    using (MacAddressRepository objMacRepository = new MacAddressRepository())
                                    {
                                        objMacRepository.RegisterListOfMacAddresses(model);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex.InnerException.Message);
                        objNotifications.result.returncode = -1;
                        objNotifications.result.errmsg     = ex.InnerException.Message;
                    }
                }
            }
            return(new HttpResponseMessage()
            {
                Content = new StringContent(JsonConvert.SerializeObject(objNotifications), Encoding.UTF8, "application/json")
            });
        }