public async Task <HttpResponseMessage> GetDevices(RequestLocationDataVM model) { MonitorDevices objMonitorDevice = new MonitorDevices(); //Notification objNotifications = new Notification(); using (RtlsConfigurationRepository objRtlsConfigurationRepository = new RtlsConfigurationRepository()) { Site objSite = objRtlsConfigurationRepository.GetAsPerSite(model.SiteId, model.SiteName); CommonHeaderInitializeHttpClient(objSite.RtlsConfiguration.EngageBaseAddressUri); ////Check the Parameter search or not,if it then add in the QueryParams,else keep as it is queryParams = new FormUrlEncodedContent(new Dictionary <string, string>() { { "sn", objSite.RtlsConfiguration.EngageSiteName }, { "bn", objSite.RtlsConfiguration.EngageBuildingName } //, //{"device_ids",String.Join(",",model.MacAddresses) } }).ReadAsStringAsync().Result; try { //var result = await httpClient.GetAsync(completeFatiAPI, new StringContent(queryParams, Encoding.UTF8, "application/x-www-form-urlencoded")); var result = await httpClient.GetAsync(completeFatiAPI); if (result.IsSuccessStatusCode) { String msg = ""; string resultContent = await result.Content.ReadAsStringAsync(); objMonitorDevice = JsonConvert.DeserializeObject <MonitorDevices>(resultContent); using (MacAddressRepository objMacRepo = new MacAddressRepository()) { msg = objMacRepo.CheckDeviceRegisted(objMonitorDevice, model.SiteId); } objMonitorDevice.result.errmsg = msg; } } catch (Exception ex) { log.Error(ex.Message); } } return(new HttpResponseMessage() { Content = new StringContent(JsonConvert.SerializeObject(objMonitorDevice), Encoding.UTF8, "application/json") //Content = new StringContent(JsonConvert.SerializeObject(objNotifications), Encoding.UTF8, "application/json") }); }
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") }); }
public async Task <bool> regMacToEngageEngine(RequestOmniModel objRequestOmniModel) { bool result = false; EngageRegisterDevice objEngageRegisterDevice = new EngageRegisterDevice(); using (RtlsConfigurationRepository objRtlsConfigurationRepository = new RtlsConfigurationRepository()) { var objSite = objRtlsConfigurationRepository.GetAsPerSite(objRequestOmniModel.SiteId); objEngageRegisterDevice.EngageBaseAddressUri = objSite.RtlsConfiguration.EngageBaseAddressUri; objEngageRegisterDevice.EngageSiteName = objSite.RtlsConfiguration.EngageSiteName; objEngageRegisterDevice.EngageBuildingName = objSite.RtlsConfiguration.EngageBuildingName; objEngageRegisterDevice.MacAddress = objRequestOmniModel.MacAddress; EngageEngineClient objEngageEngineClient = new EngageEngineClient(); if (await objEngageEngineClient.RegisterDevice(objEngageRegisterDevice)) { result = true; } else { result = false; } } return(result); }
public RtlsConfigurationApiController() { objRtlsConfigurationRepository = new RtlsConfigurationRepository(); objNetworkConfigurationRepository = new NetworkConfigurationRepository(); }
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") }); }
public RealTimeApiController() { objRtlsConfigurationRepository = new RtlsConfigurationRepository(); }
public async Task <HttpResponseMessage> DeRegisterDevices(RequestLocationDataVM model) { Notification objNotifications = new Notification(); HttpRequestMessage message = new HttpRequestMessage(); OmniEngineBusiness objOmniEngineBusiness = new OmniEngineBusiness(); RequestOmniModel objRequestOmniModel = new RequestOmniModel(); try { using (RtlsConfigurationRepository objRtlsConfigurationRepository = new RtlsConfigurationRepository()) { Site objSite = objRtlsConfigurationRepository.GetAsPerSite(model.SiteId, model.SiteName); if (objSite.RtlsConfiguration.RtlsEngineType == RtlsEngine.OmniEngine) { foreach (var item in model.MacAddresses) { objRequestOmniModel.MacAddress = item; var deregisterData = await objOmniEngineBusiness.DeregisterMacFromOmniEngine(objRequestOmniModel); } } else if (objSite.RtlsConfiguration.RtlsEngineType == RtlsEngine.EngageEngine) { CommonHeaderInitializeHttpClient(objSite.RtlsConfiguration.EngageBaseAddressUri); message = new HttpRequestMessage(new HttpMethod("DELETE"), "/api/engage/v1/device_monitors/"); var queryParams = new Dictionary <string, string>() { { "sn", objSite.RtlsConfiguration.EngageSiteName }, { "bn", objSite.RtlsConfiguration.EngageBuildingName }, { "device_ids", String.Join(",", model.MacAddresses) } }; message.Content = new FormUrlEncodedContent(queryParams); try { HttpResponseMessage httpResponseMessage = await httpClient.SendAsync(message); if (httpResponseMessage.EnsureSuccessStatusCode().IsSuccessStatusCode) { string resultContent = await httpResponseMessage.Content.ReadAsStringAsync(); objNotifications = JsonConvert.DeserializeObject <Notification>(resultContent); if (objNotifications.result.returncode == Convert.ToInt32(FatiApiResult.Success)) { using (MacAddressRepository objMacRepository = new MacAddressRepository()) { objMacRepository.DeRegisterListOfMacs(model.MacAddresses); } } } else { objNotifications.result.returncode = Convert.ToInt32(httpResponseMessage.StatusCode.ToString()); objNotifications.result.errmsg = "Some Problem Occured"; } } catch (Exception ex) { string errorType = ex.GetType().ToString(); string errorMessage = errorType + ": " + ex.Message; throw new Exception(errorMessage, ex.InnerException); } } } } 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") }); }
public async Task <HttpResponseMessage> DeleteDevices(RequestLocationDataVM model) { Notification objNotifications = new Notification(); DeviceAssociateSite deviceStatus = null; using (RtlsConfigurationRepository objRtlsConfigurationRepository = new RtlsConfigurationRepository()) { Site objSite = objRtlsConfigurationRepository.GetAsPerSite(model.SiteId); foreach (var item in model.MacAddresses) { // When Device is coming to delete in OmniEngiene int deviceId = _OmniDeviceMappingRepository.GetDeviceId(item); deviceStatus = objRtlsConfigurationRepository.DeviceAssociateSiteStatus(deviceId); if (deviceStatus.status == DeviceStatus.DeRegistered) { OmniEngineBusiness objOmniEngineBusiness = new OmniEngineBusiness(); RequestOmniModel objRequestOmniModel = new RequestOmniModel(); objRequestOmniModel.MacAddress = item; var returnStatus = await objOmniEngineBusiness.DeleteDevices(objRequestOmniModel); if (returnStatus == true) { try { //Delete Device ralated data DeviceAssociateSite _DeviceAssociateSite = db.DeviceAssociateSite.FirstOrDefault(k => k.DeviceId == deviceId); Device _Device = db.Device.FirstOrDefault(p => p.DeviceId == deviceId); NetWorkOfSite _NetworkOfSite = db.NetWorkOfSite.Where(p => p.SiteId == model.SiteId).Where(q => q.LocServiceTypeId != 0).FirstOrDefault(); OmniDeviceMapping _OmniDeviceMapping = db.OmniDeviceMapping.FirstOrDefault(k => k.DeviceId == deviceId); //If User registered from CaptivePortal if (_DeviceAssociateSite.IsRegisterInCaptivePortal == true) { WifiUserLoginCredential _WifiUserLoginCredential = db.WifiUserLoginCredential.Where(p => p.Device.DeviceId == deviceId).Where(q => q.NetWorkOfSiteId == _NetworkOfSite.NetWorkOfSiteId).FirstOrDefault(); WifiUser _WifiUser = db.WifiUser.Where(p => p.UserId == _WifiUserLoginCredential.WifiUserId).FirstOrDefault(); UsersAddress _UsersAddress = db.UsersAddress.Where(p => p.UserId == _WifiUser.UserId).FirstOrDefault(); db.UsersAddress.Remove(_UsersAddress); db.WifiUser.Remove(_WifiUser); db.WifiUserLoginCredential.Remove(_WifiUserLoginCredential); } db.DeviceAssociateSite.Remove(_DeviceAssociateSite); db.OmniDeviceMapping.Remove(_OmniDeviceMapping); db.Device.Remove(_Device); db.SaveChanges(); } catch (Exception ex) { log.Error(ex.Message); } } } } } return(new HttpResponseMessage() { Content = new StringContent(JsonConvert.SerializeObject(objNotifications), Encoding.UTF8, "application/json") }); }
public RtlsAreaApiController() { objRtlsAreaApiRepository = new RtlsAreaApiRepository(); objRtlsConfigurationRepository = new RtlsConfigurationRepository(); }
/// <summary> /// /// </summary> public SiteFloorsApiController() { _SiteFloorRepoSitory = new SiteFloorRepository(); _RrlsConfigurationRepository = new RtlsConfigurationRepository(); }