コード例 #1
0
        public void GetOrganization()
        {
            moq::Mock <Organizations.OrganizationsClient> mockGrpcClient = new moq::Mock <Organizations.OrganizationsClient>(moq::MockBehavior.Strict);
            GetOrganizationRequest request = new GetOrganizationRequest
            {
                OrganizationName = gagr::OrganizationName.FromOrganization("[ORGANIZATION]"),
            };
            Organization expectedResponse = new Organization
            {
                OrganizationName    = gagr::OrganizationName.FromOrganization("[ORGANIZATION]"),
                DisplayName         = "display_name137f65c2",
                DirectoryCustomerId = "directory_customer_idde7714fb",
                State      = Organization.Types.State.Unspecified,
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                DeleteTime = new wkt::Timestamp(),
                Etag       = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetOrganization(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            OrganizationsClient client   = new OrganizationsClientImpl(mockGrpcClient.Object, null);
            Organization        response = client.GetOrganization(request.Name);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #2
0
        public async stt::Task GetOrganizationRequestObjectAsync()
        {
            moq::Mock <Organizations.OrganizationsClient> mockGrpcClient = new moq::Mock <Organizations.OrganizationsClient>(moq::MockBehavior.Strict);
            GetOrganizationRequest request = new GetOrganizationRequest
            {
                OrganizationName = gagr::OrganizationName.FromOrganization("[ORGANIZATION]"),
            };
            Organization expectedResponse = new Organization
            {
                OrganizationName    = gagr::OrganizationName.FromOrganization("[ORGANIZATION]"),
                DisplayName         = "display_name137f65c2",
                DirectoryCustomerId = "directory_customer_idde7714fb",
                State      = Organization.Types.State.Unspecified,
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                DeleteTime = new wkt::Timestamp(),
                Etag       = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetOrganizationAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Organization>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            OrganizationsClient client = new OrganizationsClientImpl(mockGrpcClient.Object, null);
            Organization        responseCallSettings = await client.GetOrganizationAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Organization responseCancellationToken = await client.GetOrganizationAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #3
0
 /// <summary>Snippet for GetOrganization</summary>
 public void GetOrganizationRequestObject()
 {
     // Snippet: GetOrganization(GetOrganizationRequest, CallSettings)
     // Create client
     OrganizationsClient organizationsClient = OrganizationsClient.Create();
     // Initialize request argument(s)
     GetOrganizationRequest request = new GetOrganizationRequest
     {
         OrganizationName = OrganizationName.FromOrganization("[ORGANIZATION]"),
     };
     // Make the request
     Organization response = organizationsClient.GetOrganization(request);
     // End snippet
 }
コード例 #4
0
        /// <summary>
        /// GetOrganization接口的同步版本,获取企业组织信息
        /// </summary>
        /// <param name="req">参考<see cref="GetOrganizationRequest"/></param>
        /// <returns>参考<see cref="GetOrganizationResponse"/>实例</returns>
        public GetOrganizationResponse GetOrganizationSync(GetOrganizationRequest req)
        {
            JsonResponseModel <GetOrganizationResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "GetOrganization");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <GetOrganizationResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
コード例 #5
0
        /// <summary>Snippet for GetOrganizationAsync</summary>
        public async Task GetOrganizationRequestObjectAsync()
        {
            // Snippet: GetOrganizationAsync(GetOrganizationRequest, CallSettings)
            // Additional: GetOrganizationAsync(GetOrganizationRequest, CancellationToken)
            // Create client
            OrganizationsClient organizationsClient = await OrganizationsClient.CreateAsync();

            // Initialize request argument(s)
            GetOrganizationRequest request = new GetOrganizationRequest
            {
                OrganizationName = OrganizationName.FromOrganization("[ORGANIZATION]"),
            };
            // Make the request
            Organization response = await organizationsClient.GetOrganizationAsync(request);

            // End snippet
        }
        private void HandleOutput(GetOrganizationRequest request)
        {
            var waiterConfig = new WaiterConfiguration
            {
                MaxAttempts           = MaxWaitAttempts,
                GetNextDelayInSeconds = (_) => WaitIntervalSeconds
            };

            switch (ParameterSetName)
            {
            case LifecycleStateParamSet:
                response = client.Waiters.ForOrganization(request, waiterConfig, WaitForLifecycleState).Execute();
                break;

            case Default:
                response = client.GetOrganization(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.Organization);
        }
コード例 #7
0
        public void Can_generate_CustomMethod()
        {
            var requestDto = new GetOrganizationRequest
            {
                Id = new Guid("ca61162b0c30491d8d91e74230f23a66"),
                IncludeAddresses = true
            };

            ServiceClientBase.GlobalRequestFilter = httpReq =>
            {
                httpReq.RequestUri.ToString().Print();
                Assert.That(httpReq.RequestUri.ToString(),
                            Is.EqualTo("http://www.google.com/organizations/ca61162b0c30491d8d91e74230f23a66?includeAddresses=True"));
            };

            var client = new JsonServiceClient("http://www.google.com/");

            try
            {
                client.CustomMethod("GET", requestDto);
            }
            catch (WebServiceException) { }

            try
            {
                client.CustomMethodAsync("GET", requestDto).Wait();
            }
            catch (AggregateException aex)
            {
                if (!(aex.UnwrapIfSingleException() is WebServiceException))
                {
                    throw;
                }
            }

            try
            {
                client.Get(requestDto);
            }
            catch (WebServiceException) { }
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetOrganizationRequest request;

            try
            {
                request = new GetOrganizationRequest
                {
                    OrganizationId = OrganizationId,
                    OpcRequestId   = OpcRequestId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
コード例 #9
0
        public void Can_generate_CustomMethod()
        {
            var requestDto = new GetOrganizationRequest
            {
                Id = new Guid("ca61162b0c30491d8d91e74230f23a66"),
                IncludeAddresses = true
            };

            ServiceClientBase.GlobalRequestFilter = httpReq =>
            {
                httpReq.RequestUri.ToString().Print();
                Assert.That(httpReq.RequestUri.ToString(),
                    Is.EqualTo("http://www.google.com/organizations/ca61162b0c30491d8d91e74230f23a66?includeAddresses=True"));
            };

            var client = new JsonServiceClient("http://www.google.com/");

            try
            {
                client.CustomMethod("GET", requestDto);
            }
            catch (WebServiceException) { }

            try
            {
                client.CustomMethodAsync("GET", requestDto).Wait();
            }
            catch (AggregateException aex)
            {
                if (!(aex.UnwrapIfSingleException() is WebServiceException))
                    throw;
            }

            try
            {
                client.Get(requestDto);
            }
            catch (WebServiceException) { }
        }
コード例 #10
0
ファイル: ProfilePage.xaml.cs プロジェクト: lap089/EVENeT
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            userName = e.Parameter.ToString();
            if (userName == DatabaseHelper.CurrentUser)
            {
                // Remove follow button
                FollowBtn.Visibility   = Visibility.Collapsed;
                UnfollowBtn.Visibility = Visibility.Collapsed;
            }
            else
            {
                // Remove setting button
                SettingBtn.Visibility = Visibility.Collapsed;
                if (await DatabaseHelper.Client.IsFollowingAsync(DatabaseHelper.CurrentUser, userName))
                {
                    FollowBtn.Visibility = Visibility.Collapsed;
                }
                else
                {
                    UnfollowBtn.Visibility = Visibility.Collapsed;
                }
            }

            userType = await DatabaseHelper.Client.UserTypeAsync(userName);

            //Get User following and follwers
            await followingListViewModel.getFollowingList(userName);

            await followerListViewModel.getFollowerList(userName);

            if (userType == 1)
            {
                GetIndividualRequest  a = new GetIndividualRequest(userName);
                GetIndividualResponse r = await DatabaseHelper.Client.GetIndividualAsync(a);

                Firstname.Text      = r.FirstName;
                AdditionalInfo.Text = userName;
                AddBasicInfoCard(userName, r);

                // Set profile picture
                StorageFile file;
                BitmapImage bmp;
                if (r.ProfilePic != null)
                {
                    file = await StorageFile.GetFileFromPathAsync(r.ProfilePic);

                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));

                    AvatarBrush.ImageSource = bmp;
                }

                // Set cover picture
                if (r.CoverPic != null)
                {
                    file = await StorageFile.GetFileFromPathAsync(r.CoverPic);

                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));

                    CoverImage.Source = bmp;
                }
            }
            else if (userType == 2)
            {
                GetOrganizationRequest  a = new GetOrganizationRequest(userName);
                GetOrganizationResponse r = await DatabaseHelper.Client.GetOrganizationAsync(a);

                Firstname.Text      = r.Name;
                AdditionalInfo.Text = r.Type;
                AddBasicInfoCard(userName, r);

                // Set profile picture
                StorageFile file;
                BitmapImage bmp;
                if (r.ProfilePic != null)
                {
                    file = await StorageFile.GetFileFromPathAsync(r.ProfilePic);

                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));

                    AvatarBrush.ImageSource = bmp;
                }

                // Set cover picture
                if (r.CoverPic != null)
                {
                    file = await StorageFile.GetFileFromPathAsync(r.CoverPic);

                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));

                    CoverImage.Source = bmp;
                }
            }
        }
コード例 #11
0
ファイル: ProfilePage.xaml.cs プロジェクト: HuyTranQ/EVENeT
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            userName = e.Parameter.ToString();
            if (userName == DatabaseHelper.CurrentUser)
            {
                // Remove follow button
                FollowBtn.Visibility = Visibility.Collapsed;
                UnfollowBtn.Visibility = Visibility.Collapsed;
            }
            else
            {
                // Remove setting button
                SettingBtn.Visibility = Visibility.Collapsed;
                if (await DatabaseHelper.Client.IsFollowingAsync(DatabaseHelper.CurrentUser, userName))
                    FollowBtn.Visibility = Visibility.Collapsed;
                else
                    UnfollowBtn.Visibility = Visibility.Collapsed;
            }

            userType = await DatabaseHelper.Client.UserTypeAsync(userName);

            //Get User following and follwers
            await followingListViewModel.getFollowingList(userName);
            await followerListViewModel.getFollowerList(userName);

            if (userType == 1)
            {
                GetIndividualRequest a = new GetIndividualRequest(userName);
                GetIndividualResponse r = await DatabaseHelper.Client.GetIndividualAsync(a);

                Firstname.Text = r.FirstName;
                AdditionalInfo.Text = userName;
                AddBasicInfoCard(userName, r);

                // Set profile picture
                StorageFile file;
                BitmapImage bmp;
                if (r.ProfilePic != null)
                {
                    file = await StorageFile.GetFileFromPathAsync(r.ProfilePic);
                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));
                    AvatarBrush.ImageSource = bmp;
                }

                // Set cover picture
                if (r.CoverPic != null)
                {
                    file = await StorageFile.GetFileFromPathAsync(r.CoverPic);
                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));
                    CoverImage.Source = bmp;
                }
            }
            else if (userType == 2)
            {
                GetOrganizationRequest a = new GetOrganizationRequest(userName);
                GetOrganizationResponse r = await DatabaseHelper.Client.GetOrganizationAsync(a);

                Firstname.Text = r.Name;
                AdditionalInfo.Text = r.Type;
                AddBasicInfoCard(userName, r);

                // Set profile picture
                StorageFile file;
                BitmapImage bmp;
                if (r.ProfilePic != null)
                {
                    file = await StorageFile.GetFileFromPathAsync(r.ProfilePic);
                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));
                    AvatarBrush.ImageSource = bmp;
                }

                // Set cover picture
                if (r.CoverPic != null)
                {
                    file = await StorageFile.GetFileFromPathAsync(r.CoverPic);
                    bmp = new BitmapImage();
                    await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read));
                    CoverImage.Source = bmp;
                }
            }
        }
コード例 #12
0
ファイル: ProxyCode.cs プロジェクト: Brightspace/d2lws-sdk
 /// <remarks/>
 public void GetOrganizationAsync(GetOrganizationRequest GetOrganizationRequest, object userState)
 {
     if ((this.GetOrganizationOperationCompleted == null)) {
         this.GetOrganizationOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetOrganizationOperationCompleted);
     }
     this.InvokeAsync("GetOrganization", new object[] {
                 GetOrganizationRequest}, this.GetOrganizationOperationCompleted, userState);
 }
コード例 #13
0
ファイル: ProxyCode.cs プロジェクト: Brightspace/d2lws-sdk
 /// <remarks/>
 public void GetOrganizationAsync(GetOrganizationRequest GetOrganizationRequest)
 {
     this.GetOrganizationAsync(GetOrganizationRequest, null);
 }
コード例 #14
0
ファイル: ProxyCode.cs プロジェクト: Brightspace/d2lws-sdk
 /// <remarks/>
 public System.IAsyncResult BeginGetOrganization(GetOrganizationRequest GetOrganizationRequest, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("GetOrganization", new object[] {
                 GetOrganizationRequest}, callback, asyncState);
 }