Exemplo n.º 1
0
        Account IAccountHelper.CreateBy(Type connectionType, string connectionAccountName, string token)
        {
            //创建随机账号
            var account = new Account("a"
                + DateTime.Now.ToString("yyyyMMddHHmmss")
                + _rd.Next(10, 100));//TODO:随机数方式修改或改为guid
            this._accountService.Create(account);

            //创建连接
            AccountConnection connection = null;
            if (connectionType == typeof(GoogleConnection))
                connection = new GoogleConnection(connectionAccountName, token, account);
            else if (connectionType == typeof(GitHubConnection))
                connection = new GitHubConnection(connectionAccountName, token, account);
            else
                connection = this.GenerateConnection(account, connectionType, connectionAccountName, token);
            //指定令牌
            connection.SetToken(token);
            this._connectionService.Create(connection);

            if (this._log.IsInfoEnabled)
                this._log.InfoFormat("根据连接{0}|{1}创建账号#{2}"
                    , connectionType
                    , connectionAccountName
                    , account.ID);

            return account;
        }
Exemplo n.º 2
0
        void IAccountConnectionService.Delete(AccountConnection connection)
        {
            _repository.Remove(connection);

            if (this._log.IsInfoEnabled)
            {
                this._log.InfoFormat("删除连接{0}#{1}|{2}"
                                     , connection
                                     , connection.ID
                                     , connection.Name);
            }
        }
Exemplo n.º 3
0
        void IAccountConnectionService.Create(AccountConnection connection)
        {
            var t = connection.GetType();

            this._locker.Require(t);
            Assert.IsNull((this as IAccountConnectionService).GetConnection(t, connection.Name));
            _repository.Add(connection);

            if (this._log.IsInfoEnabled)
            {
                this._log.InfoFormat("为账号#{0}创建了外部连接{1}#{2}"
                                     , connection.AccountId
                                     , connection
                                     , connection.Name);
            }
        }
Exemplo n.º 4
0
 /// <summary>获取连接类型的文字描述
 /// </summary>
 /// <param name="connection"></param>
 /// <returns></returns>
 public static string ConnectionName(this Cooper.Model.Accounts.AccountConnection connection)
 {
     return(connection.GetType().Name.ConnectionName());
 }
Exemplo n.º 5
0
 void IAccountConnectionService.Update(AccountConnection connection)
 {
     Assert.Greater(connection.ID, 0);
     Assert.Greater(connection.AccountId, 0);
     _repository.Update(connection);
 }