Exemplo n.º 1
0
        public static IDoxSession CreateFromPassword(DoxApi api, string username, string password,
                                                     IApiHelper apiHelper = null)
        {
            if (apiHelper == null)
            {
                apiHelper = new ApiHelper();
            }
            string userId = null;
            string devicetoken = null;

            if (!api.RetryAction(() => apiHelper.Login(api.ServiceUrl, username, password, out userId, out devicetoken)))
            {
                return null;
            }
            api.ClearError();
            var credentials = new DoxCredentials
                {
                    //UserId = userId,
                    UserName = username,
                    DeviceToken = devicetoken
                };
            return new DoxSession(api, credentials, apiHelper);
        }
Exemplo n.º 2
0
        public static IDoxSession CreateFromDeviceToken(DoxApi api, string username, string deviceToken,
                                                        IApiHelper apiHelper = null)
        {
            if (apiHelper == null)
            {
                apiHelper = new ApiHelper();
            }

            IDoxUser user = null;

            if (!api.RetryAction(
                () => user = apiHelper.SetDeviceToken(api.ServiceUrl, deviceToken)))
            {
                return null;
            }

            var credentials = new DoxCredentials
                {
                    //UserId = user.Id,
                    UserName = username,
                    DeviceToken = deviceToken
                };

            var session = new DoxSession(api, credentials, apiHelper);
            session.CurrentUser = user;
            return session;
        }