public async Task <DataTransferObject <object> > RegisterDevice([FromBody] UserDeviceInfo input)
        {
            DataTransferObject <object> response = new DataTransferObject <object>();

            if (input == null)
            {
                throw new ApplicationException("Invalid object");
            }

            var IsSave = await _userDeviceInfoService.RegisterDevice(input);

            if (IsSave)
            {
                string serverAPIKey   = _configuration.GetSection(appSettings)["NMSAPPServerKey"];
                string BroadCastRoute = _configuration.GetSection(appSettings)["NMSAPPBroadCastRoute"];

                if (!string.IsNullOrEmpty(input.CategoryName))
                {
                    BroadCastRoute = input.CategoryName;
                }

                response.Data = await Helper.FireBaseNotificationHelper.Subscribe(input.DeviceToken, BroadCastRoute, serverAPIKey);
            }

            response.IsSuccess = true;
            return(response);
        }
        public async Task <bool> RegisterDevice(UserDeviceInfo input)
        {
            if (input == null)
            {
                throw new ApplicationException("Invalid Object");
            }

            if (string.IsNullOrEmpty(input.UserId))
            {
                throw new ApplicationException("UserId not found");
            }

            if (string.IsNullOrEmpty(input.DeviceId))
            {
                throw new ApplicationException("DeviceId not found");
            }

            if (string.IsNullOrEmpty(input.DeviceToken))
            {
                throw new ApplicationException("DeviceToken not found");
            }

            var responce = await _userDeviceInfoRepository.RegisterDevice(input);

            return(responce);
        }
Beispiel #3
0
        private void QueueAppleNotifications(UserDeviceInfo lstSplit, string pMessage, ApnsServiceBroker push)
        {
            try
            {
                String jsonPayload = "{ \"aps\" : { \"alert\" : \"" + pMessage + "\",\"badge\" : 0 }}";

                _logger.Information("Inside QueueNotifications with message: " + pMessage);

                if (lstSplit.DeviceToken != null)
                {
                    if (lstSplit.DeviceToken.Length == 64)
                    {
                        _logger.Information("***INFO*** Queing notification for token :" + lstSplit.DeviceToken.ToString());
                        push.QueueNotification(new ApnsNotification()
                        {
                            DeviceToken = (lstSplit.DeviceToken),
                            Payload     = JObject.Parse(jsonPayload)
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("***Error***: " + this.GetType().Name + ", Method " + MethodBase.GetCurrentMethod().Name + "****** Error details :" + ex.Message);
                throw ex;
            }
        }
        private UserDeviceInfo UserDeviceInfoFromDataRow(SqlDataReader reader)
        {
            UserDeviceInfo UserDeviceInfo = new UserDeviceInfo();

            UserDeviceInfo.UserId      = (string)reader["UserId"];
            UserDeviceInfo.DeviceId    = (string)reader["DeviceId"];
            UserDeviceInfo.DeviceToken = (string)reader["CategoryId"];

            return(UserDeviceInfo);
        }
Beispiel #5
0
 public async Task <bool> UpdateUserDeviceInfo([FromBody] UserDeviceInfo deviceInfo)
 {
     try {
         return(await _ds.UploadStorageInfoAsync(
                    deviceInfo.UserId == null?Guid.NewGuid().ToString() : deviceInfo.UserId, JsonConvert.SerializeObject(deviceInfo)));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public async Task <IAccountResponse> AddOrUpdateDeviceInfoAsync(UserDeviceInfoViewModel model)
        {
            try
            {
                var userDevice = await _appDbContext.UserDeviceInfos.FirstOrDefaultAsync(k => k.DeviceId == model.DeviceId);

                if (userDevice != null)
                {
                    _appDbContext.UserDeviceInfos.Remove(userDevice);
                    await _appDbContext.SaveChangesAsync();
                }

                var data = await _appDbContext.UserDeviceInfos.FirstOrDefaultAsync(k => k.DeviceId == model.DeviceId);

                if (data == null)
                {
                    data = new UserDeviceInfo()
                    {
                        UserId     = model.UserId,
                        DeviceId   = model.DeviceId,
                        DeviceType = (byte)model.DeviceType,
                        IsActive   = model.IsActive,
                        CreatedOn  = DateTime.Now
                    };

                    await _appDbContext.UserDeviceInfos.AddAsync(data);

                    await _appDbContext.SaveChangesAsync();

                    return(new AccountResponse(model));
                }
                else
                {
                    data.DeviceId   = model.DeviceId;
                    data.DeviceType = (byte)model.DeviceType;
                    data.IsActive   = model.IsActive;
                    data.ModifiedOn = DateTime.Now;
                    await _appDbContext.SaveChangesAsync();
                }


                model.Success = true;
                model.Message = ClientMessageConstant.Success;

                return(new AccountResponse(model));
            }
            catch (Exception ex)
            {
                model.Success = false;
                model.Message = ClientMessageConstant.WeAreUnableToProcessYourRequest;
                return(new AccountResponse(model, ex));
            }
        }
        public async Task <bool> RegisterDevice(UserDeviceInfo input)
        {
            bool   IsSuccess = true;
            string sql       = "RegisterDevice";
            List <SqlParameter> parameters = new List <SqlParameter>()
            {
                new SqlParameter("@DeviceId", input.DeviceId),
                new SqlParameter("@DeviceToken", input.DeviceToken),
                new SqlParameter("@UserId", input.UserId),
            };

            var list = await ExecuteNonQuery(connectionString, System.Data.CommandType.StoredProcedure, sql, parameters.ToArray());

            return(IsSuccess);
        }
Beispiel #8
0
        void SendRegistrationToAppServer(string token)
        {
            UserDeviceInfo model = new UserDeviceInfo();

            model.UserID   = Core.Common.GlobalClass.UserID;
            model.DeviceID = token;

            var result = RestSharpCall.Put <JsonResult>(model, "User/SetDeviceID?id=" + model.UserID);

            if (result.Success)
            {
                Log.Debug("RegistrationIntentService", "Success");
                return;
            }
        }
    void Start()
    {
        UserDeviceInfo deviceInfo = new UserDeviceInfo();

        deviceInfo.m_deviceId       = SystemInfo.deviceUniqueIdentifier;
        deviceInfo.m_screenHeight   = Screen.height;
        deviceInfo.m_screenWidth    = Screen.width;
        deviceInfo.m_targetPlatform = Application.platform;
        deviceInfo.m_headset.m_virtualRealityType = GetVirtualRealityDeviceType();
        deviceInfo.m_headset.m_supportedDevices   = XRSettings.supportedDevices;
        deviceInfo.m_headset.loadedDeviceName     = XRSettings.loadedDeviceName;
        deviceInfo.m_headset.isActive             = XRSettings.isDeviceActive;
        deviceInfo.m_headset.isEnable             = XRSettings.enabled;
        deviceInfo.m_headset.eyeTextureWidth      = XRSettings.eyeTextureWidth;
        deviceInfo.m_headset.eyeTextureHeight     = XRSettings.eyeTextureHeight;

        string json = JsonUtility.ToJson(deviceInfo);
    }
Beispiel #10
0
        public async Task <JsonResult> UpdateDeviceID(UserDeviceInfo ud, string url)
        {
            JsonResult resp = null;

            try
            {
                resp = await call.Put <UserDeviceInfo>(ud, url);

                return(resp);
            }
            catch (Exception ex)
            {
                CR.Filename  = "CreateAccount";
                CR.Eventname = "UpdateDeviceID";
                CR.UserID    = "0";
                CR.ErrorMsg  = ex.Message + ex.StackTrace;
                await crashReport.PostCrashReport(CR);

                return(resp);
            }
        }
 public async Task <JsonResult> UpdateDeviceID(UserDeviceInfo info, string url)
 {
     return(await repo.UpdateDeviceID(info, url));
 }