public void Execute(object state)
        {
            var logInfo = new LogInfo
            {
                MethodInstance = MethodBase.GetCurrentMethod(),
                ThreadInstance = Thread.CurrentThread
            };

            try
            {
                _log.Info("Scheduler Start: (SyncUsersWithWeChat)", logInfo);

                using (IRepository repo = new Repository())
                {
                    var list = repo.All <UserWeChat>();

                    if (list != null && list.Count > 0)
                    {
                        var auth = new AuthorizeManager();

                        foreach (var uw in list)
                        {
                            auth.SyncUserWithWeChat(uw.UserName);
                        }
                    }
                }

                _log.Info("Scheduler End: (SyncUsersWithWeChat)", logInfo);
            }
            catch (Exception ex)
            {
                _log.Warn(ex, logInfo);
            }
        }
예제 #2
0
        public void Test_SyncUsersWithWeChat()
        {
            IRepository repo = new Repository();

            var list = repo.All <UserWeChat>().Take(10).ToList();

            var auth = new AuthorizeManager();

            if (list.Count > 0)
            {
                foreach (var uw in list)
                {
                    var user = auth.SyncUserWithWeChat(uw.UserName);

                    Assert.IsNotNull(user);
                    Assert.AreEqual(user.ID, uw.ID);
                }
            }
        }
예제 #3
0
        public JsonResult SyncUser(string id)
        {
            Guid guid;

            if (!string.IsNullOrEmpty(id) && Guid.TryParse(id, out guid))
            {
                var uw = _repo.Single <UserWeChat>(guid);

                if (uw != null)
                {
                    var auth = new AuthorizeManager();

                    var user = auth.SyncUserWithWeChat(uw.UserName);

                    if (user.ID.Equals(guid))
                    {
                        return(Json("Success"));
                    }
                }
            }

            return(Json("Failed"));
        }