Exemplo n.º 1
0
        /// <summary>
        /// Load all user datas from the firebase db.
        /// </summary>
        /// <returns></returns>
        private async Task GetUserDataAsync()
        {
            try
            {
                try
                {
                    QUser inMemory = await BlobCache.UserAccount.GetObject <QUser>("user");

                    CurrentUser.Instance.User = inMemory;
                }
                catch
                {
                    await CurrentUser.Instance.LoadUser();
                }


                Header = "Welcome, " + CurrentUser.Instance.User?.Name;

                await CurrentUser.Instance.LoadNewStudies();

                Studies = CurrentUser.Instance.User.ActiveStudiesObjects;
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
Exemplo n.º 2
0
    //-----------------------------------------------------------------------
    public static QUser LoadUser(JObject jReply)
    {
        QUser res = new QUser();

        res.id                  = (string)jReply["user"]["id"];
        res.pcid                = (string)jReply["user"]["pcid"];
        res.usbId               = (string)jReply["user"]["usbId"];
        res.lvl                 = (string)jReply["user"]["lvl"];
        res.subscriptionDate    = (DateTime)jReply["user"]["subscriptionDate"];
        res.subscriptionExpDate = (DateTime)jReply["user"]["subscriptionExpDate"];
        res.active              = (bool)jReply["user"]["active"];
        res.trialUse            = (bool)jReply["user"]["trialUse"];
        res.trial               = (bool)jReply["user"]["trial"];
        res.unlimitedSub        = (bool)jReply["user"]["unlimitedSub"];
        res.hash                = (string)jReply["hash"];

        string checkHash = QExec.MD5Hash(res.pcid + '|'
                                         + res.subscriptionExpDate.ToString("dd.MM.yyyy") + '|'
                                         + res.unlimitedSub.ToString().ToLower() + '|'
                                         + res.trial.ToString().ToLower() + '|'
                                         + res.lvl + '|'
                                         + res.active.ToString().ToLower() + '|'
                                         + QExec.salt);

        res.isHashOk = (res.hash == checkHash);

        return(res);
    }
Exemplo n.º 3
0
 public void Setup()
 {
     oQUser      = new QUser();
     oUser       = new User();
     oUser.Id    = 80;
     oUser.Name  = "Linus torvalds";
     oUser.Email = "*****@*****.**";
 }
Exemplo n.º 4
0
    //-----------------------------------------------------------------------
    private static void GetUser()
    {
        Task <string> answ = HttpGetPost("/api/users/?userId=" + qId + "&hash=" + MD5Hash(qId + "|" + salt));

        answ.Wait();
        string  res    = answ.Result;
        JObject jReply = JObject.Parse(res);

        qUser = QUser.LoadUser(jReply);

        qUser.PrintUser();
    }
Exemplo n.º 5
0
        public void AddUserToQueue(string queueId, QUser quser)
        {
            var client = new HttpClient();
            var now    = DateTime.Now.ToString("s");

            client.BaseAddress = new Uri(_baseAddress);

            string format = "queues/{0}/users/{1}.json";

            string uri = String.Format(format, queueId, now);

            var json   = JsonConvert.SerializeObject(quser);
            var result = client.PutAsJsonAsync(uri, quser).Result;

            result.EnsureSuccessStatusCode();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Load all user relevant infos.
        /// </summary>
        /// <returns>Returns a task as this is a async method.</returns>
        private async Task LoadUserData()
        {
            try
            {
                var documents = await CrossCloudFirestore.Current
                                .Instance
                                .GetCollection(QUser.CollectionPath)
                                .WhereEqualsTo("Email", this._user.Email)
                                .GetDocumentsAsync();

                IEnumerable <QUser> myModel = documents.ToObjects <QUser>();
                _user = myModel.First();
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
Exemplo n.º 7
0
 public void Cleanup()
 {
     oQUser = null;
     oUser  = null;
 }