Пример #1
0
        public async Task regMacToOmniEngine(RequestOmniModel objRequestOmniModel)
        {
            //ReturnData result = new ReturnData();
            string retResult = null;
            SecomRegisterDevice objSecomRegisterDevice = new SecomRegisterDevice();

            objSecomRegisterDevice.mac = objRequestOmniModel.MacAddress;
            objSecomRegisterDevice.station_info.device.id  = objRequestOmniModel.MacAddress;
            objSecomRegisterDevice.station_info.user.label = objRequestOmniModel.UserName;

            using (var objSecomClient = new SecomClient())
            {
                var jsonToken = await objSecomClient.GetSecomLoginToken();

                var token_details = JObject.Parse(jsonToken);
                var token         = token_details["jwt"].ToString();

                //Register the Mac
                retResult = await objSecomClient.RegisterDevice(objSecomRegisterDevice, token);

                //If the uniqueId is not retured try with GetDevice to get the uniqueId
                if (string.IsNullOrEmpty(retResult))
                {
                    retResult = await objSecomClient.GetDevice(objRequestOmniModel.MacAddress, token);
                }
                if (!string.IsNullOrEmpty(retResult))
                {
                    await objOmniDeviceMappingRepository.CreateMacUniqueId(objRequestOmniModel.MacAddress, retResult);
                }
            }
        }
Пример #2
0
        public async Task <HttpResponseMessage> SecomLogin()
        {
            try
            {
                using (SecomClient objsecomClient = new SecomClient())
                {
                    var _secomData = await objsecomClient.GetSecomLoginToken();

                    return(new HttpResponseMessage()
                    {
                        Content = new StringContent(_secomData, Encoding.UTF8, "application/json")
                    });
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Пример #3
0
        //DeleteDevices in OmniEngiene
        public async Task <bool> DeleteDevices(RequestOmniModel objRequestOmniModel)
        {
            ReturnData result = new ReturnData();


            using (var objSecomClient = new SecomClient())
            {
                //Get Token Through login
                var jsonToken = await objSecomClient.GetSecomLoginToken();

                var token_details = JObject.Parse(jsonToken);
                var token         = token_details["jwt"].ToString();
                //Get Unique Id from OmniMapping Table
                var UniqueId = objOmniDeviceMappingRepository.ReregisterGetUniqueId(objRequestOmniModel.MacAddress);
                //call for Delete device
                var _deleteDevice = await objSecomClient.DeleteDevice(token, UniqueId);

                return(true);
            }
        }
Пример #4
0
        //Reregister in OmniEngiene
        public async Task <bool> ReRegister(RequestOmniModel objRequestOmniModel)
        {
            ReturnData          result = new ReturnData();
            SecomRegisterDevice objSecomRegisterDevice = new SecomRegisterDevice();

            objSecomRegisterDevice.mac = objRequestOmniModel.MacAddress;
            objSecomRegisterDevice.station_info.device.id = objRequestOmniModel.MacAddress;

            using (var objSecomClient = new SecomClient())
            {
                //Get Token Through login
                var jsonToken = await objSecomClient.GetSecomLoginToken();

                var token_details = JObject.Parse(jsonToken);
                var token         = token_details["jwt"].ToString();
                //Get Unique Id from OmniMapping Table
                var UniqueId = objOmniDeviceMappingRepository.ReregisterGetUniqueId(objRequestOmniModel.MacAddress);
                //call for deregister mac
                var _reriegister = await objSecomClient.ReRegisterDevice(objSecomRegisterDevice, token, UniqueId);

                return(true);
            }
        }
Пример #5
0
        public async Task <HttpResponseMessage> RegisterDevice(SecomRegisterDevice _objSecomRegisterDevice)
        {
            string _registerSuccessData = null;

            using (SecomClient objsecomClient = new SecomClient())
            {
                //Call getToken method
                var _secomData = await objsecomClient.GetSecomLoginToken();


                var token_details = JObject.Parse(_secomData);
                var token         = token_details["jwt"].ToString();


                //Calling register device
                await objsecomClient.RegisterDevice(_objSecomRegisterDevice, token);
            }

            return(new HttpResponseMessage()
            {
                Content = new StringContent(_registerSuccessData, Encoding.UTF8, "application/json")
            });
        }