Example #1
0
        private async void ConnectButtonClickHandler(object sender, RoutedEventArgs e)
        {
            this.gitlab = new Gitlab.Gitlab(this.url.Text);

            this.gitlab.ApiVersion = ApiVersionEnum.VERSION3;

            this.gitlab.ErrorAction = (Exception exception) =>
            {
                // TODO:例外発生時の処理
            };

            var ptr = Marshal.SecureStringToGlobalAllocUnicode(this.password.SecurePassword);

            try
            {
                // セキュア文字列を平文へ変換
                string password = Marshal.PtrToStringUni(ptr);

                // セッションの取得
                bool saccess = await this.gitlab.RequestSessionAsync(this.email.Text, password);

                if (saccess)
                {
                    List <Project> projects = await this.gitlab.RequestProjectsAsync();

                    if (projects.Count > 0)
                    {
                        // プロジェクトリスト取得
                        this.ReadProject(projects[0].Id);

                        // プロジェクトメンバーリスト取得
                        this.ReadProjectMember(projects[0].Id);
                    }

                    List <User> users = await this.gitlab.RequestUsersAsync();

                    if (users.Count > 0)
                    {
                        // ユーザーリスト取得
                        this.ReadUser(users[0].Id);
                    }
                }
            }
            finally
            {
                Marshal.ZeroFreeGlobalAllocUnicode(ptr);
            }
        }
        private async void ConnectButtonClickHandler(object sender, RoutedEventArgs e)
        {
            this.gitlab = new Gitlab.Gitlab(this.url.Text);

            this.gitlab.ApiVersion = ApiVersionEnum.VERSION3;

            this.gitlab.ErrorAction = (Exception exception) =>
                {
                    // TODO:例外発生時の処理
                };

            var ptr = Marshal.SecureStringToGlobalAllocUnicode(this.password.SecurePassword);

            try
            {
                // セキュア文字列を平文へ変換
                string password = Marshal.PtrToStringUni(ptr);

                // セッションの取得
                bool saccess = await this.gitlab.RequestSessionAsync(this.email.Text, password);

                if (saccess)
                {
                    List<Project> projects = await this.gitlab.RequestProjectsAsync();

                    if (projects.Count > 0)
                    {
                        // プロジェクトリスト取得
                        this.ReadProject(projects[0].Id);

                        // プロジェクトメンバーリスト取得
                        this.ReadProjectMember(projects[0].Id);
                    }

                    List<User> users = await this.gitlab.RequestUsersAsync();

                    if (users.Count > 0)
                    {
                        // ユーザーリスト取得
                        this.ReadUser(users[0].Id);
                    }
                }
            }
            finally
            {
                Marshal.ZeroFreeGlobalAllocUnicode(ptr);
            }
        }
        /// <summary>
        /// セッション取得
        /// </summary>
        /// <param name="host"></param>
        /// <param name="email"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public async Task<bool> OpenServerSession(string host, string email, string password, ApiVersionEnum version)
        {
            this.gitlab = new Gitlab(host);
            this.gitlab.ApiVersion = version;

            this.gitlab.ErrorAction = (Exception exception) =>
            {
                // TODO:例外発生時の処理
            };

            // セッションの取得
            bool saccess = await this.gitlab.RequestSessionAsync(email, password);

            if (saccess)
            {
                // TODO:成功
                return true;
            }
            return false;
        }