Пример #1
0
        private void SendHumanScreenComplete(bool hire)
        {
            ApplicationServiceClient proxy = new ApplicationServiceClient();
            try
            {
                // Create the result
                HumanScreeningResult result = new HumanScreeningResult()
                {
                    AppID = Convert.ToInt32(LabelAppID.Text),
                    HiringApproved = hire,
                };

                // Wrap it in a request
                HumanScreeningCompletedRequest request =
                new HumanScreeningCompletedRequest(result);

                // Call the workflow service
                proxy.HumanScreeningCompleted(result);

                proxy.Close();
            }
            catch (Exception)
            {
                proxy.Abort();
                throw;
            }
        }
Пример #2
0
 static void WcfStyle()
 {
     ApplicationServiceClient appService = new ApplicationServiceClient();
     SslTest.ServiceReference1.ApplicationTypeData[] data = appService.GetApplicationTypes(new SslTest.ServiceReference1.RequestData());
     foreach (SslTest.ServiceReference1.ApplicationTypeData d in data)
     {
         Console.WriteLine(d.Description);
     }
     Console.ReadLine();
 }
Пример #3
0
 /// <summary>Snippet for CreateApplication</summary>
 public void CreateApplicationResourceNames()
 {
     // Snippet: CreateApplication(ProfileName, Application, CallSettings)
     // Create client
     ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.Create();
     // Initialize request argument(s)
     ProfileName parent      = ProfileName.FromProjectTenantProfile("[PROJECT]", "[TENANT]", "[PROFILE]");
     Application application = new Application();
     // Make the request
     Application response = applicationServiceClient.CreateApplication(parent, application);
     // End snippet
 }
Пример #4
0
 /// <summary>Snippet for CreateApplication</summary>
 public void CreateApplication()
 {
     // Snippet: CreateApplication(string, Application, CallSettings)
     // Create client
     ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.Create();
     // Initialize request argument(s)
     string      parent      = "projects/[PROJECT]/tenants/[TENANT]/profiles/[PROFILE]";
     Application application = new Application();
     // Make the request
     Application response = applicationServiceClient.CreateApplication(parent, application);
     // End snippet
 }
Пример #5
0
        /// <summary>Snippet for DeleteApplication</summary>
        public void DeleteApplicationResourceNames()
        {
            // Snippet: DeleteApplication(ApplicationName, CallSettings)
            // Create client
            ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.Create();
            // Initialize request argument(s)
            ApplicationName name = ApplicationName.FromProjectTenantProfileApplication("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]");

            // Make the request
            applicationServiceClient.DeleteApplication(name);
            // End snippet
        }
Пример #6
0
        /// <summary>Snippet for DeleteApplication</summary>
        public void DeleteApplication()
        {
            // Snippet: DeleteApplication(string, CallSettings)
            // Create client
            ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.Create();
            // Initialize request argument(s)
            string name = "projects/[PROJECT]/tenants/[TENANT]/profiles/[PROFILE]/applications/[APPLICATION]";

            // Make the request
            applicationServiceClient.DeleteApplication(name);
            // End snippet
        }
Пример #7
0
        /// <summary>Snippet for GetApplicationAsync</summary>
        public async Task GetApplicationAsync()
        {
            // Snippet: GetApplicationAsync(ApplicationName,CallSettings)
            // Additional: GetApplicationAsync(ApplicationName,CancellationToken)
            // Create client
            ApplicationServiceClient applicationServiceClient = await ApplicationServiceClient.CreateAsync();

            // Initialize request argument(s)
            ApplicationName name = new ApplicationName("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]");
            // Make the request
            Application response = await applicationServiceClient.GetApplicationAsync(name);

            // End snippet
        }
Пример #8
0
 /// <summary>Snippet for UpdateApplication</summary>
 public void UpdateApplication_RequestObject()
 {
     // Snippet: UpdateApplication(UpdateApplicationRequest,CallSettings)
     // Create client
     ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.Create();
     // Initialize request argument(s)
     UpdateApplicationRequest request = new UpdateApplicationRequest
     {
         Application = new Application(),
     };
     // Make the request
     Application response = applicationServiceClient.UpdateApplication(request);
     // End snippet
 }
 /// <summary>Snippet for GetApplication</summary>
 public void GetApplicationRequestObject()
 {
     // Snippet: GetApplication(GetApplicationRequest, CallSettings)
     // Create client
     ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.Create();
     // Initialize request argument(s)
     GetApplicationRequest request = new GetApplicationRequest
     {
         ApplicationName = ApplicationName.FromProjectTenantProfileApplication("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]"),
     };
     // Make the request
     Application response = applicationServiceClient.GetApplication(request);
     // End snippet
 }
        /// <summary>Snippet for UpdateApplicationAsync</summary>
        public async Task UpdateApplicationAsync()
        {
            // Snippet: UpdateApplicationAsync(Application, CallSettings)
            // Additional: UpdateApplicationAsync(Application, CancellationToken)
            // Create client
            ApplicationServiceClient applicationServiceClient = await ApplicationServiceClient.CreateAsync();

            // Initialize request argument(s)
            Application application = new Application();
            // Make the request
            Application response = await applicationServiceClient.UpdateApplicationAsync(application);

            // End snippet
        }
        /// <summary>Snippet for DeleteApplicationAsync</summary>
        public async Task DeleteApplicationAsync()
        {
            // Snippet: DeleteApplicationAsync(string, CallSettings)
            // Additional: DeleteApplicationAsync(string, CancellationToken)
            // Create client
            ApplicationServiceClient applicationServiceClient = await ApplicationServiceClient.CreateAsync();

            // Initialize request argument(s)
            string name = "projects/[PROJECT]/tenants/[TENANT]/profiles/[PROFILE]/applications/[APPLICATION]";
            // Make the request
            await applicationServiceClient.DeleteApplicationAsync(name);

            // End snippet
        }
        /// <summary>Snippet for DeleteApplicationAsync</summary>
        public async Task DeleteApplicationResourceNamesAsync()
        {
            // Snippet: DeleteApplicationAsync(ApplicationName, CallSettings)
            // Additional: DeleteApplicationAsync(ApplicationName, CancellationToken)
            // Create client
            ApplicationServiceClient applicationServiceClient = await ApplicationServiceClient.CreateAsync();

            // Initialize request argument(s)
            ApplicationName name = ApplicationName.FromProjectTenantProfileApplication("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]");
            // Make the request
            await applicationServiceClient.DeleteApplicationAsync(name);

            // End snippet
        }
Пример #13
0
        public IEnumerable<ApplicationDAO> GetApplicationsByApplicant(string by_applicant, string id)
        {
            ApplicationServiceClient client = new ApplicationServiceClient();

            try
            {
                IEnumerable<ApplicationDAO> result = client.GetApplicationsByApplicant(Convert.ToInt32(id));
                return result;
            }
            catch (FaultException<KaskServiceException> e)
            {
                throw new HttpException(e.Message);
            }
        }
Пример #14
0
        public IEnumerable<ApplicationDAO> GetApplications()
        {
            ApplicationServiceClient client = new ApplicationServiceClient();

            try
            {
                IEnumerable<ApplicationDAO> result = client.GetApplications();
                return result;
            }
            catch (FaultException<KaskServiceException> e)
            {
                throw new HttpException(e.Message);
            }
        }
Пример #15
0
        public ApplicationDAO GetApplication(int id)
        {
            ApplicationServiceClient client = new ApplicationServiceClient();

            try
            {
                ApplicationDAO result = client.GetApplicationByID(id);
                return result;
            }
            catch (FaultException<KaskServiceException> e)
            {
                throw new HttpException(e.Message);
            }
        }
Пример #16
0
 public void Disconnect(string reason)
 {
     if (_proxy != null)
     {
         lock (_sync)
         {
             if (_proxy != null)
             {
                 ReleaseChannel();
                 _proxy = null;
             }
         }
     }
 }
        /// <summary>Snippet for CreateApplicationAsync</summary>
        public async Task CreateApplicationAsync()
        {
            // Snippet: CreateApplicationAsync(string, Application, CallSettings)
            // Additional: CreateApplicationAsync(string, Application, CancellationToken)
            // Create client
            ApplicationServiceClient applicationServiceClient = await ApplicationServiceClient.CreateAsync();

            // Initialize request argument(s)
            string      parent      = "projects/[PROJECT]/tenants/[TENANT]/profiles/[PROFILE]";
            Application application = new Application();
            // Make the request
            Application response = await applicationServiceClient.CreateApplicationAsync(parent, application);

            // End snippet
        }
        /// <summary>Snippet for CreateApplicationAsync</summary>
        public async Task CreateApplicationResourceNamesAsync()
        {
            // Snippet: CreateApplicationAsync(ProfileName, Application, CallSettings)
            // Additional: CreateApplicationAsync(ProfileName, Application, CancellationToken)
            // Create client
            ApplicationServiceClient applicationServiceClient = await ApplicationServiceClient.CreateAsync();

            // Initialize request argument(s)
            ProfileName parent      = ProfileName.FromProjectTenantProfile("[PROJECT]", "[TENANT]", "[PROFILE]");
            Application application = new Application();
            // Make the request
            Application response = await applicationServiceClient.CreateApplicationAsync(parent, application);

            // End snippet
        }
Пример #19
0
        /// <summary>Snippet for DeleteApplication</summary>
        public void DeleteApplication_RequestObject()
        {
            // Snippet: DeleteApplication(DeleteApplicationRequest,CallSettings)
            // Create client
            ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.Create();
            // Initialize request argument(s)
            DeleteApplicationRequest request = new DeleteApplicationRequest
            {
                ApplicationName = new ApplicationName("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]"),
            };

            // Make the request
            applicationServiceClient.DeleteApplication(request);
            // End snippet
        }
 /// <summary>Snippet for CreateApplication</summary>
 public void CreateApplicationRequestObject()
 {
     // Snippet: CreateApplication(CreateApplicationRequest, CallSettings)
     // Create client
     ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.Create();
     // Initialize request argument(s)
     CreateApplicationRequest request = new CreateApplicationRequest
     {
         ParentAsProfileName = ProfileName.FromProjectTenantProfile("[PROJECT]", "[TENANT]", "[PROFILE]"),
         Application         = new Application(),
     };
     // Make the request
     Application response = applicationServiceClient.CreateApplication(request);
     // End snippet
 }
        /// <summary>Snippet for ListApplicationsAsync</summary>
        public async Task ListApplicationsRequestObjectAsync()
        {
            // Snippet: ListApplicationsAsync(ListApplicationsRequest, CallSettings)
            // Create client
            ApplicationServiceClient applicationServiceClient = await ApplicationServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListApplicationsRequest request = new ListApplicationsRequest
            {
                ParentAsProfileName = ProfileName.FromProjectTenantProfile("[PROJECT]", "[TENANT]", "[PROFILE]"),
            };
            // Make the request
            PagedAsyncEnumerable <ListApplicationsResponse, Application> response = applicationServiceClient.ListApplicationsAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Application item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListApplicationsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Application item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <Application> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Application item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
Пример #22
0
        public int create(Resource res)
        {
            Console.WriteLine("ReverseProxy.create: {0} {1}", res.Uri, res.Value);
            ApplicationServiceClient client = new ApplicationServiceClient();

            ApplicationServiceReference.Resource resource = new ApplicationServiceReference.Resource();
            resource.Uri   = res.Uri;
            resource.Value = res.Value;

            int status = client.create(resource);

            client.Close();

            Console.WriteLine("ReverseProxy.create= {0}", status);
            return(status);
        }
Пример #23
0
 private void ReleaseChannel()
 {
     if (_proxy != null)
     {
         _proxy.InnerChannel.Opened       -= ConnectionOpened;
         _proxy.InnerChannel.Opening      -= OnChannelOpening;
         _proxy.ProcessMessagesCompleted  -= MessageSent;
         _proxy.StartApplicationCompleted -= StartApplicationCompleted;
         _proxy.StopApplicationCompleted  -= StopApplicationCompleted;
         _proxy.GetPendingEventCompleted  -= OnGetPendingEventCompleted;
         _proxy.InnerChannel.Faulted      -= OnChannelFaulted;
         _proxy.CloseAsync();
         _proxy            = null;
         _connectionOpened = false;
     }
 }
        /// <summary>Snippet for GetApplicationAsync</summary>
        public async Task GetApplicationRequestObjectAsync()
        {
            // Snippet: GetApplicationAsync(GetApplicationRequest, CallSettings)
            // Additional: GetApplicationAsync(GetApplicationRequest, CancellationToken)
            // Create client
            ApplicationServiceClient applicationServiceClient = await ApplicationServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetApplicationRequest request = new GetApplicationRequest
            {
                ApplicationName = ApplicationName.FromProjectTenantProfileApplication("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]"),
            };
            // Make the request
            Application response = await applicationServiceClient.GetApplicationAsync(request);

            // End snippet
        }
Пример #25
0
        /// <summary>Snippet for DeleteApplicationAsync</summary>
        public async Task DeleteApplicationAsync_RequestObject()
        {
            // Snippet: DeleteApplicationAsync(DeleteApplicationRequest,CallSettings)
            // Additional: DeleteApplicationAsync(DeleteApplicationRequest,CancellationToken)
            // Create client
            ApplicationServiceClient applicationServiceClient = await ApplicationServiceClient.CreateAsync();

            // Initialize request argument(s)
            DeleteApplicationRequest request = new DeleteApplicationRequest
            {
                ApplicationName = new ApplicationName("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]"),
            };
            // Make the request
            await applicationServiceClient.DeleteApplicationAsync(request);

            // End snippet
        }
Пример #26
0
        /// <summary>Snippet for UpdateApplicationAsync</summary>
        public async Task UpdateApplicationAsync_RequestObject()
        {
            // Snippet: UpdateApplicationAsync(UpdateApplicationRequest,CallSettings)
            // Additional: UpdateApplicationAsync(UpdateApplicationRequest,CancellationToken)
            // Create client
            ApplicationServiceClient applicationServiceClient = await ApplicationServiceClient.CreateAsync();

            // Initialize request argument(s)
            UpdateApplicationRequest request = new UpdateApplicationRequest
            {
                Application = new Application(),
            };
            // Make the request
            Application response = await applicationServiceClient.UpdateApplicationAsync(request);

            // End snippet
        }
Пример #27
0
        public bool DeleteApplication(int id)
        {
            try
            {
                bool result = false;
                ApplicationServiceClient client = new ApplicationServiceClient();

                if (client.DeleteApplication(id))
                    result = true;

                return result;
            }
            catch (FaultException<KaskServiceException> e)
            {
                throw new HttpException(e.Message);
            }
        }
Пример #28
0
        protected void ButtonApplyClick(object sender, EventArgs e)
        {
            var request = new SubmitJobApplicationRequest
                              {
                                  Resume = new ApplicantResume
                                               {
                                                   Name = txtName.Text,
                                                   Email = txtEmail.Text,
                                                   Education = ddEducation.Text,
                                               },
                                  RequestID = Guid.NewGuid()
                              };

            var proxy = new ApplicationServiceClient();
            var response = proxy.SubmitJobApplication(request);
            Session["SubmitAppResponse"] = response;
            Response.Redirect("SubmitAppResponse.aspx");
        }
        /// <summary>Snippet for CreateApplicationAsync</summary>
        public async Task CreateApplicationRequestObjectAsync()
        {
            // Snippet: CreateApplicationAsync(CreateApplicationRequest, CallSettings)
            // Additional: CreateApplicationAsync(CreateApplicationRequest, CancellationToken)
            // Create client
            ApplicationServiceClient applicationServiceClient = await ApplicationServiceClient.CreateAsync();

            // Initialize request argument(s)
            CreateApplicationRequest request = new CreateApplicationRequest
            {
                ParentAsProfileName = ProfileName.FromProjectTenantProfile("[PROJECT]", "[TENANT]", "[PROFILE]"),
                Application         = new Application(),
            };
            // Make the request
            Application response = await applicationServiceClient.CreateApplicationAsync(request);

            // End snippet
        }
        /// <summary>Snippet for ListApplications</summary>
        public void ListApplicationsResourceNames()
        {
            // Snippet: ListApplications(ProfileName, string, int?, CallSettings)
            // Create client
            ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.Create();
            // Initialize request argument(s)
            ProfileName parent = ProfileName.FromProjectTenantProfile("[PROJECT]", "[TENANT]", "[PROFILE]");
            // Make the request
            PagedEnumerable <ListApplicationsResponse, Application> response = applicationServiceClient.ListApplications(parent);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (Application item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListApplicationsResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Application item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <Application> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Application item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
Пример #31
0
        private void SetupChannel()
        {
            var binding       = GetChannelBinding();
            var remoteAddress = GetServerAddress();

            _proxy = new ApplicationServiceClient(binding, remoteAddress);

            _proxy.InnerChannel.Faulted += OnChannelFaulted;
            _proxy.InnerChannel.Opening += OnChannelOpening;
            _proxy.InnerChannel.Opened  += ConnectionOpened;

            _proxy.ProcessMessagesCompleted     += MessageSent;
            _proxy.StartApplicationCompleted    += StartApplicationCompleted;
            _proxy.StopApplicationCompleted     += StopApplicationCompleted;
            _proxy.InnerChannel.OperationTimeout = TimeSpan.FromMinutes(10);
            _proxy.GetPendingEventCompleted     += OnGetPendingEventCompleted;

            _connectionOpened = true;
        }
Пример #32
0
 private void ReleaseChannel()
 {
     if (_proxy != null)
     {
         _proxy.InnerChannel.Opened -= ConnectionOpened;
         _proxy.InnerChannel.Opening -= OnChannelOpening;
         _proxy.ProcessMessagesCompleted -= MessageSent;
         _proxy.StartApplicationCompleted -= StartApplicationCompleted;
         _proxy.StopApplicationCompleted -= StopApplicationCompleted;
         _proxy.GetPendingEventCompleted -= OnGetPendingEventCompleted;
         _proxy.InnerChannel.Faulted -= OnChannelFaulted;
         _proxy.CloseAsync();
         _proxy = null;
         _connectionOpened = false;
     }
 }
Пример #33
0
 public void Disconnect(string reason)
 {
     if (_proxy != null)
     {
         
         lock (_sync)
         {
             if (_proxy != null)
             {
                 ReleaseChannel();
                 _proxy = null;
             }
         }
     }
 }
Пример #34
0
        public bool PostApplication(ApplicationDAO app)
        {
            ApplicationServiceClient client = new ApplicationServiceClient();

            try
            {
                bool result = false;

                // are we editing or creating this item?
                if (app.ApplicationID > 0)
                    result = client.UpdateApplication(app);
                else
                    result = client.CreateApplication(app);
                return result;
            }
            catch (FaultException<KaskServiceException> e)
            {
                throw new HttpException(e.Message);
            }
        }
        public void EducationLevelMastersWhenSentShouldHireWhenHumanApproves()
        {
            const string ExpectedName = "test";
            const int ExpectedId = 123;
            var expectedResponse = string.Format(ServiceResources.JobApplicationProcessing, ExpectedName, ExpectedId);

            // XamlInjector will replace activities with Mocks suitable for testing
            var xamlInjector = new XamlInjector("SubmitApplication.xamlx");

            // The first phase builds a set of replacement rules
            xamlInjector.ReplaceAll(typeof(NotifyApplicant), typeof(MockNotifyApplicant));
            xamlInjector.ReplaceAll(typeof(RequestHumanScreening), typeof(MockRequestHumanScreening));
            xamlInjector.ReplaceAll(typeof(SaveJobApplication), typeof(MockSaveJobApplication));
            xamlInjector.ReplaceAll(typeof(UpdateHireApproved), typeof(MockUpdateHireApproved));
            xamlInjector.ReplaceAll(typeof(Delay), typeof(DelayStub));

            // Then we load the service and replace the activities with mocks
            var mockedService = xamlInjector.GetWorkflowService();

            // Setup the DelayStub timeout
            // Keep it short but long enough to receive the second message
            DelayStub.StubDuration = TimeSpan.FromSeconds(1);

            // Host the service
            using (var host = WorkflowServiceTestHost.Open(mockedService, this.serviceAddress))
            {
                // Arrange
                // Setup a proxy to use named pipes
                // Using the proxy generated by a service reference
                var proxy = new ApplicationServiceClient(this.binding, this.serviceAddress);

                try
                {
                    // Act
                    // When the the application is submitted to the service
                    var response = proxy.SubmitJobApplication(CreateApplicationRequest());

                    // Check that we got a response message
                    Assert.AreEqual(expectedResponse, response.ResponseText);

                    // When the Human approves the application
                    var result =
                        proxy.HumanScreeningCompleted(
                            new HumanScreeningResult { AppID = ExpectedId, HiringApproved = true });

                    // Check that the response was accepted
                    Assert.IsTrue(result.HasValue && result.Value);

                    proxy.Close();

                    // Close the host
                    host.Close();
                    Assert.IsTrue(host.WaitForHostClosed());

                    // Assert
                    // Assert that the Auto Screen Education activity returned EducationPassed = true
                    // 55: Activity [67] "Auto Screen Education" is Closed
                    // {
                    // Arguments
                    // EducationPassed: True
                    // Education: Masters
                    // }
                    host.Tracking.Assert.ExistsArgValue(
                        "Auto Screen Education", ActivityInstanceState.Closed, EducationpassedArgName, true);

                    // Assert that the Request Human Screening activity was invoked
                    // 69: Activity [60] "Request Human Screening" is Closed
                    // {
                    // Arguments
                    // ApplicationRequest: HRApplicationServices.Contracts.SubmitJobApplicationRequest
                    // RetryCount: 0
                    // ApplicationID: 123
                    // }
                    var requestHumanScreening = host.Tracking.Records.Find(
                        RequestHumanScreeningDisplayName, ActivityInstanceState.Closed);

                    Assert.IsNotNull(requestHumanScreening, "Could not find Request Human Screening");
                    Assert.AreEqual(
                        ExpectedId,
                        requestHumanScreening.GetArgument<int>(ApplicationidArgName),
                        "On first Human Screening Request Applicant ID does not match request");
                    Assert.AreEqual(
                        0,
                        requestHumanScreening.GetArgument<int>(RetrycountArgName),
                        "On first Human Screening Request RetryCount is not zero");

                    // Assert that the Update Hire activity was invoked
                    // 109: Activity [45] "Update Hire Approved" is Closed
                    // {
                    // Arguments
                    // ApplicantID: 123
                    // HireApproved: True
                    // }
                    host.Tracking.Assert.ExistsArgValue(
                        UpdateHireApprovedDisplayName, ActivityInstanceState.Closed, HireApprovedArgName, true);
                    host.Tracking.Assert.ExistsArgValue(
                        UpdateHireApprovedDisplayName, ActivityInstanceState.Closed, ApplicantidArgName, ExpectedId);

                    // Assert that the hire email notification was sent
                    // 140: Activity [4] "MockNotifyApplicant" is Closed
                    // {
                    // Arguments
                    // Cancel: False
                    // Hire: True
                    // Resume: HRApplicationServices.Contracts.ApplicantResume
                    // }
                    var notifyApplicant = host.Tracking.Records.Find(
                        "MockNotifyApplicant", ActivityInstanceState.Closed);
                    Assert.IsNotNull(notifyApplicant, "Could not find the MockNotifyApplication activity");
                    Assert.IsTrue(
                        notifyApplicant.GetArgument<bool>("Hire"),
                        "The applicant notify activity did not have argument Hire=true");
                    Assert.AreEqual(
                        "test",
                        notifyApplicant.GetArgument<ApplicantResume>("Resume").Name,
                        "The NotifyApplication activity did not have the correct applicant name");
                }
                finally
                {
                    host.Tracking.Trace();
                }
            }
        }
        public void ShouldCancelAfter2Nags()
        {
            const string expectedName = "test";
            const int expectedId = 123;
            var expectedResponse = string.Format(ServiceResources.JobApplicationProcessing, expectedName, expectedId);

            var xamlInjector = new XamlInjector("SubmitApplication.xamlx");
            xamlInjector.ReplaceAll(typeof(NotifyApplicant), typeof(MockNotifyApplicant));
            xamlInjector.ReplaceAll(typeof(RequestHumanScreening), typeof(MockRequestHumanScreening));
            xamlInjector.ReplaceAll(typeof(SaveJobApplication), typeof(MockSaveJobApplication));
            xamlInjector.ReplaceAll(typeof(Delay), typeof(FakeDelay));
            xamlInjector.ReplaceAll(typeof(UpdateHireApproved), typeof(MockUpdateHireApproved));

            SubmitJobApplicationResponse response = null;

            // Host the service);
            using (var testHost = WorkflowServiceTestHost.Open(xamlInjector.GetWorkflowService(), _serviceAddress))
            {
                // Setup a proxy to use named pipes
                var proxy = new ApplicationServiceClient(_binding, _serviceAddress);

                try
                {
                    // Submit an application
                    response = proxy.SubmitJobApplication(new SubmitJobApplicationRequest
                    {
                        RequestID = Guid.NewGuid(),
                        Resume = new ApplicantResume
                        {
                            Education = "Masters",
                            Email = "*****@*****.**",
                            Name = "test",
                            NumReferences = 0
                        }
                    });

                    // Check that we got a response message
                    Assert.AreEqual(expectedResponse, response.ResponseText);

                    // Take no further action - application should cancel

                    proxy.Close();
                }
                catch (Exception)
                {
                    testHost.Tracking.Trace();
                    proxy.Abort();
                    throw;
                }

                // The last thing to happen is for the Workflow Instance to be deleted from
                // the persistence store.
                // Wait for this before asserting tracking records
                Assert.IsTrue(WorkflowServiceTestHost.WaitForInstanceDeleted());

                // Close the host
                testHost.Close();
                Assert.IsTrue(WorkflowServiceTestHost.WaitForHostClosed());

                // Assert

                testHost.Tracking.Trace();

                // Find the cancel notification
                //Activity <MockNotifyApplicant> state is Closed
                //{
                //    Arguments
                //        Cancel: True
                //        Hire: False
                //        Resume: HRApplicationServices.Contracts.ApplicantResume
                //}

                var notifyApplicant = testHost.Tracking.Records.FindActivityState("MockNotifyApplicant",
                                                                                  ActivityInstanceState.Closed);
                Assert.IsNotNull(notifyApplicant);
                Assert.IsFalse(notifyApplicant.GetArgument<bool>("Hire"));
                Assert.IsTrue(notifyApplicant.GetArgument<bool>("Cancel"));
            }
        }
        public void ServiceShouldCancelAfter2Nags()
        {
            const string ExpectedName = "test";
            const int ExpectedId = 123;
            var expectedResponse = string.Format(ServiceResources.JobApplicationProcessing, ExpectedName, ExpectedId);

            var xamlInjector = new XamlInjector("SubmitApplication.xamlx");
            xamlInjector.ReplaceAll(typeof(NotifyApplicant), typeof(MockNotifyApplicant));
            xamlInjector.ReplaceAll(typeof(RequestHumanScreening), typeof(MockRequestHumanScreening));
            xamlInjector.ReplaceAll(typeof(SaveJobApplication), typeof(MockSaveJobApplication));
            xamlInjector.ReplaceAll(typeof(Delay), typeof(DelayStub));
            xamlInjector.ReplaceAll(typeof(UpdateHireApproved), typeof(MockUpdateHireApproved));

            // Host the service
            var address = ServiceTest.GetUniqueEndpointAddress();
            using (var host = WorkflowServiceTestHost.Open(xamlInjector.GetWorkflowService(), address))
            {
                // Setup a proxy to use named pipes
                var proxy = new ApplicationServiceClient(ServiceTest.Pipe, address);

                try
                {
                    var applicationRequest = CreateApplicationRequest();

                    // Submit an application
                    var response = proxy.SubmitJobApplication(applicationRequest);

                    // Check that we got a response message
                    Assert.AreEqual(expectedResponse, response.ResponseText);

                    // Take no further action - application should cancel
                    proxy.Close();

                    // Close the host
                    host.Close();

                    // Assert

                    // Find the first notification to the HR Administrator
                    // 69: Activity [60] "Request Human Screening" is Closed at 07:03:54.4424
                    // {
                    // Arguments
                    // ApplicationRequest: HRApplicationServices.Contracts.SubmitJobApplicationRequest
                    // RetryCount: 0
                    // ApplicationID: 123
                    // }
                    var request1 = host.Tracking.Records.Find(RequestHumanScreeningDisplayName, ActivityInstanceState.Closed);
                    Assert.IsNotNull(request1, "Could not find first request notification");
                    Assert.AreEqual(0, request1.GetArgument<int>(RetrycountArgName), "Retry count was not zero on first request");

                    // Find the second notification to the HR Administrator
                    // 115: Activity [60] "Request Human Screening" is Executing at 07:03:54.4454
                    // {
                    // Arguments
                    // ApplicationRequest: HRApplicationServices.Contracts.SubmitJobApplicationRequest
                    // RetryCount: 1
                    // ApplicationID: 123
                    // }
                    var request2 = host.Tracking.Records.Find(RequestHumanScreeningDisplayName, ActivityInstanceState.Closed, request1.RecordNumber + 1);
                    Assert.IsNotNull(request2, "Could not find second request notification");
                    Assert.AreEqual(1, request2.GetArgument<int>(RetrycountArgName), "Retry count was not one on second request");

                    // Find the cancel notification
                    // 167: Activity [4] "MockNotifyApplicant" is Closed at 07:03:54.4474
                    // {
                    // Arguments
                    // Cancel: True
                    // Hire: False
                    // Resume: HRApplicationServices.Contracts.ApplicantResume
                    // }
                    var notifyApplicant = host.Tracking.Records.Find("MockNotifyApplicant", ActivityInstanceState.Closed);
                    Assert.IsNotNull(notifyApplicant, "Could not find Cancel notification");
                    Assert.IsFalse(notifyApplicant.GetArgument<bool>("Hire"), "Hire argument was not false when the application was canceled");
                    Assert.IsTrue(notifyApplicant.GetArgument<bool>("Cancel"), "Cancel argument was not true");
                }
                finally
                {
                    host.Tracking.Trace();
                }
            }
        }
        public void ShouldHireEducationLevelMasters()
        {
            const string expectedName = "test";
            const int expectedId = 123;
            var expectedResponse = string.Format(ServiceResources.JobApplicationProcessing, expectedName, expectedId);

            var xamlInjector = new XamlInjector("SubmitApplication.xamlx");
            xamlInjector.ReplaceAll(typeof(NotifyApplicant), typeof(MockNotifyApplicant));
            xamlInjector.ReplaceAll(typeof(RequestHumanScreening), typeof(MockRequestHumanScreening));
            xamlInjector.ReplaceAll(typeof(SaveJobApplication), typeof(MockSaveJobApplication));
            xamlInjector.ReplaceAll(typeof(UpdateHireApproved), typeof(MockUpdateHireApproved));

            SubmitJobApplicationResponse response = null;

            // Host the service);
            using (var testHost = WorkflowServiceTestHost.Open(xamlInjector.GetWorkflowService(), _serviceAddress))
            {
                // Setup a proxy to use named pipes
                var proxy = new ApplicationServiceClient(_binding, _serviceAddress);

                try
                {
                    // Submit an application
                    response = proxy.SubmitJobApplication(new SubmitJobApplicationRequest
                                                              {
                                                                  RequestID = Guid.NewGuid(),
                                                                  Resume = new ApplicantResume
                                                                               {
                                                                                   Education = "Masters",
                                                                                   Email = "*****@*****.**",
                                                                                   Name = "test",
                                                                                   NumReferences = 0
                                                                               }
                                                              });

                    // Check that we got a response message
                    Assert.AreEqual(expectedResponse, response.ResponseText);

                    var result =
                        proxy.HumanScreeningCompleted(new HumanScreeningResult { AppID = expectedId, HiringApproved = true });
                    Assert.IsTrue(result.HasValue && result.Value);

                    proxy.Close();
                }
                catch (Exception)
                {
                    //testHost.Tracking.Trace();
                    proxy.Abort();
                    throw;
                }

                // The last thing to happen is for the Workflow Instance to be deleted from
                // the persistence store.
                // Wait for this before asserting tracking records
                Assert.IsTrue(WorkflowServiceTestHost.WaitForInstanceDeleted());

                // Close the host
                testHost.Close();
                Assert.IsTrue(WorkflowServiceTestHost.WaitForHostClosed());

                // Assert

                testHost.Tracking.Trace(1000);

                // Assert that the Auto Screen Education activity returned EducationPassed = false

                // Find this tracking record and assert the arguments
                //Activity <Auto Screen Education> state is Closed
                //{
                //    Arguments
                //        EducationPassed: True
                //        Education: Masters
                //}

                // After the autoscreen the EducationPassed argument should be true
                var autoScreenEducation = testHost.Tracking.Records.FindActivityState("Auto Screen Education",
                                                                                      ActivityInstanceState.Closed);
                Assert.IsTrue(autoScreenEducation.GetArgument<bool>("EducationPassed"));

                // Assert that the Request Human Screening activity was invoked
                //Activity <Request Human Screening> state is Closed
                //{
                //    Arguments
                //        ApplicationRequest: HRApplicationServices.Contracts.SubmitJobApplicationRequest
                //        ApplicationID: 123
                //}

                var requestHumanScreening = testHost.Tracking.Records.FindActivityState("Request Human Screening",
                                                                                        ActivityInstanceState.Closed);

                Assert.IsNotNull(requestHumanScreening, "Could not find Request Human Screening");
                Assert.AreEqual(expectedId, requestHumanScreening.GetArgument<int>("ApplicationID"));

                // Assert that the Update Hire activity was invoked

                // Find this activity state record
                //Activity <Update Hire Approved> state is Executing
                //{
                //    Arguments
                //        ApplicantID: 123
                //        HireApproved: True
                //}

                var updateHire = testHost.Tracking.Records.FindActivityState("Update Hire Approved",
                                                                             ActivityInstanceState.Closed);
                Assert.IsTrue(updateHire.GetArgument<bool>("HireApproved"));
                Assert.AreEqual(expectedId, updateHire.GetArgument<int>("ApplicantID"));

                // Assert that the hire email notification was sent

                // Find this activity state record
                //Activity <MockNotifyApplicant> state is Closed
                //{
                //    Arguments
                //        Hire: True
                //        Resume: HRApplicationServices.Contracts.ApplicantResume
                //}

                //var notifyApplicant = testHost.Tracking.Records.FindActivityState("MockNotifyApplicant",
                //                                                                  ActivityInstanceState.Closed);
                //Assert.IsNotNull(notifyApplicant);
                //Assert.IsTrue(notifyApplicant.GetArgument<bool>("Hire"));
                //Assert.AreEqual("test", notifyApplicant.GetArgument<ApplicantResume>("Resume").Name);
            }
        }
        public void ShouldNotHireEductionLevelNone()
        {
            const string ExpectedName = "test";
            const int ExpectedId = 123;
            var expectedResponse = string.Format(ServiceResources.JobApplicationProcessing, ExpectedName, ExpectedId);

            var xamlInjector = new XamlInjector("SubmitApplication.xamlx");
            xamlInjector.ReplaceAll(typeof(NotifyApplicant), typeof(MockNotifyApplicant));
            xamlInjector.ReplaceAll(typeof(RequestHumanScreening), typeof(MockRequestHumanScreening));
            xamlInjector.ReplaceAll(typeof(SaveJobApplication), typeof(MockSaveJobApplication));
            xamlInjector.ReplaceAll(typeof(UpdateHireApproved), typeof(MockUpdateHireApproved));

            // Host the service
            var address = ServiceTest.GetUniqueEndpointAddress();
            using (var host = WorkflowServiceTestHost.Open(xamlInjector.GetWorkflowService(), address))
            {
                // Setup a proxy to use named pipes
                var proxy = new ApplicationServiceClient(ServiceTest.Pipe, address);

                try
                {
                    // Submit an application
                    var response = proxy.SubmitJobApplication(CreateApplicationRequest("none"));

                    proxy.Close();

                    // The last thing to happen is for the Workflow Instance to be deleted from
                    // the persistence store.
                    // Wait for this before asserting tracking records
                    Assert.IsTrue(host.WaitForInstanceDeleted());

                    // Close the host
                    host.Close();

                    // Assert

                    // Check that we got a response message
                    Assert.AreEqual(expectedResponse, response.ResponseText);

                    host.Tracking.Trace();

                    // Assert that the Auto Screen Education activity returned EducationPassed = false

                    // Find this tracking record and assert the arguments
                    // Activity <Auto Screen Education> state is Closed
                    // {
                    // Arguments
                    // EducationPassed: False
                    // Education: None
                    // }

                    // After the autoscreen the EducationPassed argument should be false
                    var autoScreenEducation = host.Tracking.Records.Find("Auto Screen Education", ActivityInstanceState.Closed);

                    Assert.IsFalse(autoScreenEducation.GetArgument<bool>(EducationpassedArgName));

                    // Assert that the Update No Hire activity was invoked

                    // Find this activity state record
                    // Activity <Update No Hire> state is Closed
                    // {
                    // Arguments
                    // ApplicantID: 123
                    // HireApproved: False
                    // }
                    var updateNoHire = host.Tracking.Records.Find("Update No Hire", ActivityInstanceState.Closed);
                    Assert.IsFalse(updateNoHire.GetArgument<bool>(HireApprovedArgName));

                    // Assert that the no-hire email notification was sent

                    // Find this activity state record
                    // Activity <MockNotifyApplicant> state is Closed
                    // {
                    // Arguments
                    // Hire: False
                    // Resume: HRApplicationServices.Contracts.ApplicantResume
                    // }
                    var notifyApplicant = host.Tracking.Records.Find("MockNotifyApplicant", ActivityInstanceState.Closed);
                    Assert.IsFalse(notifyApplicant.GetArgument<bool>("Hire"));
                }
                catch (Exception)
                {
                    proxy.Abort();
                    throw;
                }
                finally
                {
                    host.Tracking.Trace();
                }
            }
        }
Пример #40
0
        private void SetupChannel()
        {
            var binding = GetChannelBinding();
            var remoteAddress = GetServerAddress();
            _proxy = new ApplicationServiceClient(binding, remoteAddress);

            _proxy.InnerChannel.Faulted += OnChannelFaulted;
            _proxy.InnerChannel.Opening += OnChannelOpening;
            _proxy.InnerChannel.Opened += ConnectionOpened;

            _proxy.ProcessMessagesCompleted += MessageSent;
            _proxy.StartApplicationCompleted += StartApplicationCompleted;
            _proxy.StopApplicationCompleted += StopApplicationCompleted;
            _proxy.InnerChannel.OperationTimeout = TimeSpan.FromMinutes(10);
            _proxy.GetPendingEventCompleted += OnGetPendingEventCompleted;

            _connectionOpened = true;
        }
        public void EducationLevelMastersWhenSentShouldHireWhenHumanApproves()
        {
            const string ExpectedName = "test";
            const int ExpectedId = 123;
            var expectedResponse = string.Format(ServiceResources.JobApplicationProcessing, ExpectedName, ExpectedId);

            var xamlInjector = new XamlInjector("SubmitApplication.xamlx");
            xamlInjector.ReplaceAll(typeof(NotifyApplicant), typeof(MockNotifyApplicant));
            xamlInjector.ReplaceAll(typeof(RequestHumanScreening), typeof(MockRequestHumanScreening));
            xamlInjector.ReplaceAll(typeof(SaveJobApplication), typeof(MockSaveJobApplication));
            xamlInjector.ReplaceAll(typeof(UpdateHireApproved), typeof(MockUpdateHireApproved));
            xamlInjector.ReplaceAll(typeof(Delay), typeof(DelayStub));
            DelayStub.StubDuration = TimeSpan.FromSeconds(5);

            // Host the service
            var address = ServiceTest.GetUniqueEndpointAddress();

            using (var host = WorkflowServiceTestHost.Open(xamlInjector.GetWorkflowService(), address))
            {
                // Setup a proxy to use named pipes
                var proxy = new ApplicationServiceClient(ServiceTest.Pipe, address);

                try
                {
                    // Submit an application
                    var response = proxy.SubmitJobApplication(CreateApplicationRequest());

                    // Check that we got a response message
                    Assert.AreEqual(expectedResponse, response.ResponseText);

                    var result = proxy.HumanScreeningCompleted(new HumanScreeningResult { AppID = ExpectedId, HiringApproved = true });
                    Assert.IsTrue(result.HasValue && result.Value);

                    proxy.Close();

                    // The last thing to happen is for the Workflow Instance to be deleted from
                    // the persistence store.
                    // Wait for this before asserting tracking records
                    Assert.IsTrue(host.WaitForInstanceDeleted());

                    // Close the host
                    host.Close();

                    // Assert
                    // Assert that the Auto Screen Education activity returned EducationPassed = true

                    // Find this tracking record and assert the arguments
                    // 55: Activity [67] "Auto Screen Education" is Closed at 09:05:14.1297
                    // {
                    // Arguments
                    // EducationPassed: True
                    // Education: Masters
                    // }
                    host.Tracking.Assert.ExistsArgValue("Auto Screen Education", ActivityInstanceState.Closed, EducationpassedArgName, true);

                    // Assert that the Request Human Screening activity was invoked

                    // 69: Activity [60] "Request Human Screening" is Closed at 09:05:14.1307
                    // {
                    // Arguments
                    // ApplicationRequest: HRApplicationServices.Contracts.SubmitJobApplicationRequest
                    // RetryCount: 0
                    // ApplicationID: 123
                    // }
                    var requestHumanScreening = host.Tracking.Records.Find(RequestHumanScreeningDisplayName, ActivityInstanceState.Closed);

                    Assert.IsNotNull(requestHumanScreening, "Could not find Request Human Screening");
                    Assert.AreEqual(ExpectedId, requestHumanScreening.GetArgument<int>(ApplicationidArgName), "On first Human Screening Request Applicant ID does not match request");
                    Assert.AreEqual(0, requestHumanScreening.GetArgument<int>(RetrycountArgName), "On first Human Screening Request RetryCount is not zero");

                    // Assert that the Update Hire activity was invoked

                    // Find this activity state record
                    // 109: Activity [45] "Update Hire Approved" is Closed at 09:05:14.1357
                    // {
                    // Arguments
                    // ApplicantID: 123
                    // HireApproved: True
                    // }
                    host.Tracking.Assert.ExistsArgValue(UpdateHireApprovedDisplayName, ActivityInstanceState.Closed, HireApprovedArgName, true);
                    host.Tracking.Assert.ExistsArgValue(UpdateHireApprovedDisplayName, ActivityInstanceState.Closed, ApplicantidArgName, ExpectedId);

                    // Assert that the hire email notification was sent

                    // Find this activity state record
                    // 140: Activity [4] "MockNotifyApplicant" is Closed at 09:05:14.1377
                    // {
                    // Arguments
                    // Cancel: False
                    // Hire: True
                    // Resume: HRApplicationServices.Contracts.ApplicantResume
                    // }
                    var notifyApplicant = host.Tracking.Records.Find("MockNotifyApplicant", ActivityInstanceState.Closed);
                    Assert.IsNotNull(notifyApplicant, "Could not find the MockNotifyApplication activity");
                    Assert.IsTrue(notifyApplicant.GetArgument<bool>("Hire"), "The applicant notify activity did not have argument Hire=true");
                    Assert.AreEqual("test", notifyApplicant.GetArgument<ApplicantResume>("Resume").Name, "The NotifyApplication activity did not have the correct applicant name");
                }
                finally
                {
                    host.Tracking.Trace();
                }
            }
        }