Exemplo n.º 1
0
 public void SaveSchema(ServiceParameters serviceParameters, HashSet <string> inputCheckedEntity, Dictionary <string, HashSet <string> > inputEntityRelationships, Dictionary <string, HashSet <string> > inputEntityAttributes, AttributeTypeMapping inputAttributeMapping, CrmSchemaConfiguration inputCrmSchemaConfiguration, TextBox schemaPathTextBox)
 {
     if (AreCrmEntityFieldsSelected(inputCheckedEntity, inputEntityRelationships, inputEntityAttributes, inputAttributeMapping, serviceParameters))
     {
         CollectCrmEntityFields(inputCheckedEntity, inputCrmSchemaConfiguration, inputEntityRelationships, inputEntityAttributes, inputAttributeMapping, serviceParameters);
         GenerateXMLFile(schemaPathTextBox, inputCrmSchemaConfiguration);
         inputCrmSchemaConfiguration.Entities.Clear();
     }
     else
     {
         serviceParameters.NotificationService.DisplayFeedback("Please select at least one attribute for each selected entity!");
     }
 }
Exemplo n.º 2
0
 public NonEoiNotPermittedFilterAttribute(
     ServiceParameters serviceParameters,
     IEncodingService encodingService,
     IMediator mediator,
     IExternalUrlHelper urlHelper,
     ILogger <NonEoiNotPermittedFilterAttribute> logger)
 {
     _serviceParameters = serviceParameters;
     _encodingService   = encodingService;
     _mediator          = mediator;
     _urlHelper         = urlHelper;
     _logger            = logger;
 }
Exemplo n.º 3
0
        public async Task And_Is_Provider_Then_Executes_Action(
            [Frozen] ServiceParameters serviceParameters,
            [ArrangeActionContext] ActionExecutingContext context,
            Mock <ActionExecutionDelegate> mockNext,
            NonEoiNotPermittedFilterAttribute filter)
        {
            serviceParameters.AuthenticationType = AuthenticationType.Provider;

            await filter.OnActionExecutionAsync(context, mockNext.Object);

            mockNext.Verify(next => next(), Times.Once);
            context.Result.Should().Be(null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Validate the CancelRequest()
        /// </summary>
        /// <param name="nodeName">xml node name</param>
        void ValidateCancelRequest(string nodeName)
        {
            // Read input from config file
            string filepath = Utility._xmlUtil.GetTextValue(nodeName,
                                                            Constants.FilePathNode);
            string emailId = Utility._xmlUtil.GetTextValue(nodeName,
                                                           Constants.EmailIDNode);
            string clusterOption = Utility._xmlUtil.GetTextValue(nodeName,
                                                                 Constants.ClusterOptionNode);
            string actionAlign = Utility._xmlUtil.GetTextValue(nodeName,
                                                               Constants.ActionAlignNode);

            ClustalWParameters parameters = new ClustalWParameters();

            parameters.Values[ClustalWParameters.Email]         = emailId;
            parameters.Values[ClustalWParameters.ClusterOption] = clusterOption;
            parameters.Values[ClustalWParameters.ActionAlign]   = actionAlign;

            // Get the input sequences
            FastaParser       parser   = new FastaParser();
            IList <ISequence> sequence = parser.Parse(filepath);

            // Submit job and cancel job
            // Validate cancel job is working as expected
            ConfigParameters configparams  = new ConfigParameters();
            ClustalWParser   clustalparser = new ClustalWParser();

            configparams.UseBrowserProxy = true;
            TestIClustalWServiceHandler handler =
                new TestIClustalWServiceHandler(clustalparser, configparams);
            ServiceParameters svcparams = handler.SubmitRequest(sequence, parameters);
            bool result = handler.CancelRequest(svcparams);

            Assert.IsTrue(result);
            Console.WriteLine(string.Concat("JobId:", svcparams.JobId));
            ApplicationLog.WriteLine(string.Concat("JobId:", svcparams.JobId));
            Assert.IsNotEmpty(svcparams.JobId);
            foreach (string key in svcparams.Parameters.Keys)
            {
                Assert.IsNotEmpty(svcparams.Parameters[key].ToString());
                Console.WriteLine(string.Format("{0} : {1}",
                                                key, svcparams.Parameters[key].ToString()));
                ApplicationLog.WriteLine(string.Format("{0} : {1}",
                                                       key, svcparams.Parameters[key].ToString()));
            }

            Console.WriteLine(
                "ClustalWServiceHandler BVT : Cancel job is submitted as expected");
            ApplicationLog.WriteLine(
                "ClustalWServiceHandler BVT : Cancel job is submitted as expected");
        }
Exemplo n.º 5
0
        /// <summary>
        /// CreateJob() to get job id and control id and Submit job
        /// using input sequence with job id and control id
        /// </summary>
        /// <param name="sequence">input sequences</param>
        /// <param name="parameters">input params</param>
        /// <returns>result params with job id and control id</returns>
        public ServiceParameters SubmitRequest(IList <ISequence> sequence, ClustalWParameters parameters)
        {
            ServiceParameters result = new ServiceParameters();

            // ClusterOption = biosim cbsum1 cbsum2k8 cbsusrv05 cbsum2 or Auto
            string[] output = _baseClient.CreateJob(tAppId.P_CLUSTALW, "test_BioHPC_Job", "1", parameters.Values[ClustalWParameters.Email].ToString(),
                                                    string.Empty, parameters.Values[ClustalWParameters.ClusterOption].ToString());

            if (!output[0].Contains(ERROR))
            {
                result.JobId = output[1];
                result.Parameters.Add(CONTROLID, output[2]);

                AppInputData   inputData     = _baseClient.InitializeApplicationParams(tAppId.P_CLUSTALW, "test_BioHPC_Job");
                FastaFormatter formatter     = new FastaFormatter();
                StringBuilder  inputSequence = new StringBuilder();
                foreach (ISequence seq in sequence)
                {
                    inputSequence.AppendLine(formatter.FormatString(seq));
                }

                //formatter.Format(sequence, "temp");
                //StreamReader reader = new StreamReader("temp");
                inputData.clustalw.inputsource = QuerySrcType.paste;
                inputData.clustalw.inputstring = inputSequence.ToString();
                inputData.clustalw.isDNA       = false;
                inputData.clustalw.action      = (ClwActions)Enum.Parse(typeof(ClwActions),
                                                                        parameters.Values[ClustalWParameters.ActionAlign].ToString());
                inputData.clustalw.email_notify = true;

                _baseClient.SubmitJob(result.JobId, result.Parameters[CONTROLID].ToString(), inputData);
                result.Parameters.Add(SUBMISSONRESULT, SUCCESS);

                // Only if the event is registered, invoke the thread
                if (null != RequestCompleted)
                {
                    // Start the BackGroundThread to check the status of job
                    _workerThread = new BackgroundWorker();
                    _workerThread.WorkerSupportsCancellation = true;
                    _workerThread.DoWork             += new DoWorkEventHandler(ProcessRequestThread);
                    _workerThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedRequestThread);
                    _workerThread.RunWorkerAsync(result);
                }
            }
            else
            {
                result.Parameters.Add(SUBMISSONRESULT, output[0]);
            }

            return(result);
        }
Exemplo n.º 6
0
 public void OpenMappingForm(ServiceParameters serviceParameters, IWin32Window owner, List <EntityMetadata> inputCachedMetadata, Dictionary <string, Dictionary <string, List <string> > > inputLookupMaping, string inputEntityLogicalName)
 {
     using (var mappingDialog = new MappingListLookup(inputLookupMaping, serviceParameters.OrganizationService, inputCachedMetadata, inputEntityLogicalName, serviceParameters.MetadataService, serviceParameters.ExceptionService)
     {
         StartPosition = FormStartPosition.CenterParent
     })
     {
         if (owner != null)
         {
             mappingDialog.ShowDialog(owner);
         }
         mappingDialog.RefreshMappingList();
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Validate submit job and Get Results using event handler
        /// </summary>
        /// <param name="nodeName">xml node name</param>
        void ValidateFetchResultsUsingEvent(string nodeName)
        {
            // Read input from config file
            string filepath = utilityObj.xmlUtil.GetTextValue(nodeName,
                                                              Constants.FilePathNode);
            string emailId = utilityObj.xmlUtil.GetTextValue(nodeName,
                                                             Constants.EmailIDNode);
            string clusterOption = utilityObj.xmlUtil.GetTextValue(nodeName,
                                                                   Constants.ClusterOptionNode);
            string actionAlign = utilityObj.xmlUtil.GetTextValue(nodeName,
                                                                 Constants.ActionAlignNode);

            ClustalWParameters parameters = new ClustalWParameters();

            parameters.Values[ClustalWParameters.Email]         = emailId;
            parameters.Values[ClustalWParameters.ClusterOption] = clusterOption;
            parameters.Values[ClustalWParameters.ActionAlign]   = actionAlign;

            IEnumerable <ISequence> sequence = null;

            // Get the input sequences
            using (FastAParser parser = new FastAParser(filepath))
            {
                sequence = parser.Parse();

                // Register event and submit request
                ConfigParameters configparams  = new ConfigParameters();
                ClustalWParser   clustalparser = new ClustalWParser();
                configparams.UseBrowserProxy = true;
                TestIClustalWServiceHandler handler =
                    new TestIClustalWServiceHandler(clustalparser, configparams);
                handler.RequestCompleted +=
                    new EventHandler <ClustalWCompletedEventArgs>(handler_RequestCompleted);
                ServiceParameters svcparams  = handler.SubmitRequest(sequence.ToList(), parameters);
                WaitHandle[]      aryHandler = new WaitHandle[1];
                aryHandler[0] = _resetEvent;
                WaitHandle.WaitAny(aryHandler);

                // Validate the submit job results
                Assert.IsFalse(string.IsNullOrEmpty(svcparams.JobId));
                foreach (string key in svcparams.Parameters.Keys)
                {
                    Assert.IsFalse(string.IsNullOrEmpty(svcparams.Parameters[key].ToString()));
                }

                _resetEvent.Close();
                _resetEvent.Dispose();
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Validate submit job and Get Results using event handler
        /// </summary>
        /// <param name="nodeName">xml node name</param>
        void ValidateFetchResultsUsingEvent(string nodeName)
        {
            // Read input from config file
            string filepath = Utility._xmlUtil.GetTextValue(nodeName,
                                                            Constants.FilePathNode);
            string emailId = Utility._xmlUtil.GetTextValue(nodeName,
                                                           Constants.EmailIDNode);
            string clusterOption = Utility._xmlUtil.GetTextValue(nodeName,
                                                                 Constants.ClusterOptionNode);
            string actionAlign = Utility._xmlUtil.GetTextValue(nodeName,
                                                               Constants.ActionAlignNode);

            ClustalWParameters parameters = new ClustalWParameters();

            parameters.Values[ClustalWParameters.Email]         = emailId;
            parameters.Values[ClustalWParameters.ClusterOption] = clusterOption;
            parameters.Values[ClustalWParameters.ActionAlign]   = actionAlign;

            // Get the input sequences
            FastaParser       parser   = new FastaParser();
            IList <ISequence> sequence = parser.Parse(filepath);

            // Register event and submit request
            ConfigParameters configparams  = new ConfigParameters();
            ClustalWParser   clustalparser = new ClustalWParser();

            configparams.UseBrowserProxy = true;
            TestIClustalWServiceHandler handler =
                new TestIClustalWServiceHandler(clustalparser, configparams);

            handler.RequestCompleted +=
                new EventHandler <ClustalWCompletedEventArgs>(handler_RequestCompleted);
            ServiceParameters svcparams = handler.SubmitRequest(sequence, parameters);

            WaitHandle[] aryHandler = new WaitHandle[1];
            aryHandler[0] = _resetEvent;
            WaitHandle.WaitAny(aryHandler);

            // Validate the submit job results
            Assert.IsNotEmpty(svcparams.JobId);
            Console.WriteLine("JobId:" + svcparams.JobId);
            foreach (string key in svcparams.Parameters.Keys)
            {
                Assert.IsNotEmpty(svcparams.Parameters[key].ToString());
                Console.WriteLine(string.Format("{0} : {1}",
                                                key, svcparams.Parameters[key].ToString()));
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Process the request. This method takes care of executing the rest of the steps
        /// to complete the blast search request in a background thread. Which involves
        /// 1. Submit the job to server
        /// 2. Ping the service with the request identifier to get the status of request.
        /// 3. Repeat step 1, at "RetryInterval" for "RetryCount" till a "success"/"failure"
        ///     status.
        /// 4. If the status is a "failure" raise an completed event to notify the user
        ///     with appropriate details.
        /// 5. If the status "success". Get the output of search from server in xml format.
        /// 6. Parse the xml and the framework object model.
        /// 7. Raise the completed event and notify user with the output.
        /// </summary>
        /// <param name="sender">Client request Azure Blast search</param>
        /// <param name="e">Thread event argument</param>
        private void ProcessRequestThread(object sender, DoWorkEventArgs e)
        {
            ServiceParameters          serviceParameters = (ServiceParameters)e.Argument;
            IList <ISequenceAlignment> alignments        = null;

            if (ERROR != serviceParameters.Parameters[SUBMISSONRESULT].ToString())
            {
                int retrycount = 0;
                ServiceRequestInformation info;
                do
                {
                    info = GetRequestStatus(serviceParameters);
                    if (info.Status == ServiceRequestStatus.Ready)
                    {
                        break;
                    }
                    retrycount++;
                }while (retrycount < 10);

                if (_workerThread.CancellationPending)
                {
                    e.Cancel = true;
                }
                else
                {
                    ClustalWCompletedEventArgs eventArgument = null;

                    if (info.Status == ServiceRequestStatus.Ready)
                    {
                        string output = _baseClient.GetOutputAsString(serviceParameters.JobId, serviceParameters.Parameters["ControldId"].ToString());
                        using (StringReader reader = new StringReader(output))
                        {
                            alignments = _ClustalWParser.Parse(reader);
                        }

                        eventArgument = new ClustalWCompletedEventArgs(
                            serviceParameters,
                            true,
                            new ClustalWResult(alignments[0]),
                            null,
                            string.Empty,
                            _workerThread.CancellationPending);

                        e.Result = eventArgument;
                    }
                }
            }
        }
Exemplo n.º 10
0
        public async Task AndIsProvider_ThenContinuesToAction(
            [Frozen] ServiceParameters serviceParameters,
            [ArrangeActionContext] ActionExecutingContext context,
            [Frozen] Mock <ActionExecutionDelegate> nextMethod,
            LevyNotPermittedFilter filter)
        {
            //Arrange
            serviceParameters.AuthenticationType = AuthenticationType.Provider;

            //Act
            await filter.OnActionExecutionAsync(context, nextMethod.Object);

            //Assert
            nextMethod.Verify(x => x(), Times.Once);
            Assert.Null(context.Result);
        }
Exemplo n.º 11
0
        public async Task And_No_EmployerId_Then_Redirect_To_Error(
            [Frozen] ServiceParameters serviceParameters,
            [ArrangeActionContext] ActionExecutingContext context,
            Mock <ActionExecutionDelegate> mockNext,
            NonEoiNotPermittedFilterAttribute filter)
        {
            serviceParameters.AuthenticationType = AuthenticationType.Employer;
            context.HttpContext = new DefaultHttpContext();

            await filter.OnActionExecutionAsync(context, mockNext.Object);

            mockNext.Verify(next => next(), Times.Never());
            var result = context.Result as RedirectToRouteResult;

            result.RouteName.Should().Be(RouteNames.Error500);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Cancel the submitted job
        /// </summary>
        /// <param name="serviceParameters">job id, control id</param>
        /// <returns>Job is cancelled or not</returns>
        public bool CancelRequest(ServiceParameters serviceParameters)
        {
            if (_workerThread != null)
            {
                _workerThread.CancelAsync();
            }

            if (null == serviceParameters)
            {
                throw new ArgumentNullException("serviceParameters");
            }

            string errorresult = _baseClient.CancelJob(serviceParameters.JobId, serviceParameters.Parameters[CONTROLID].ToString());

            return(errorresult.ToUpper(CultureInfo.CurrentCulture).Contains(STOPPED.ToUpper(CultureInfo.CurrentCulture)));
        }
Exemplo n.º 13
0
        private void ServiceContextActionButton_Click(object sender, EventArgs e)
        {
            ServiceParameters ServiceParams = new ServiceParameters();

            ServiceParams.ServiceName = SelectedService;
            NetworkParameters NetParams = new NetworkParameters();

            NetParams.RemoteSystemName = MachineName;
            RemoteExecutionManager RemoteExec = new RemoteExecutionManager();

            if (ServiceAction == ServiceActionType.StartService)
            {
                StartService Start = new StartService();
                Start.ServiceParameters = ServiceParams;

                RemoteExec.Command   = Start;
                RemoteExec.NetParams = NetParams;
                IResult StartResult = RemoteExec.Execute();
                if (StartResult.Result == ExecutionResultType.Passed)
                {
                    MessageBox.Show(SelectedService + " has been successfully started on the remote machine " + MachineName, "Start Service", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    RefreshServiceList();
                }
                else
                {
                    MessageBox.Show("Failed to start the service " + SelectedService + " on the remote machine " + MachineName + " due to the following reason : " + StartResult.FailureException.Message, "Start Service", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            if (ServiceAction == ServiceActionType.StopService)
            {
                StopService Stop = new StopService();
                Stop.ServiceParameters = ServiceParams;
                RemoteExec.Command     = Stop;
                RemoteExec.NetParams   = NetParams;
                IResult StopResult = RemoteExec.Execute();
                if (StopResult.Result == ExecutionResultType.Passed)
                {
                    MessageBox.Show(SelectedService + " has been successfully stopped on the remote machine " + MachineName, "Stop Service", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    RefreshServiceList();
                }
                else
                {
                    MessageBox.Show("Failed to stop the service " + SelectedService + " on the remote machine " + MachineName + " due to the following reason : " + StopResult.FailureException.Message, "Stop Service", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 14
0
        private void ManageService(string serviceName, string command, string login, string password)
        {
            Logger.EnteringMethod();
            prgBrSearch.Value   = 0;
            prgBrSearch.Maximum = dtGrdVResult.SelectedRows.Count;
            prgBrSearch.Refresh();
            ChangeUIAccess(false);
            ServiceParameters serviceParams = new ServiceParameters();

            serviceParams.ServiceName = serviceName;
            serviceParams.Command     = command;
            serviceParams.Login       = login;
            serviceParams.Password    = password;

            System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(StartManageService));
            t.Start(serviceParams);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Get the alignment results
        /// </summary>
        /// <param name="serviceParameters">job id, control id</param>
        /// <returns>alignment</returns>
        public ClustalWResult FetchResultsAsync(ServiceParameters serviceParameters)
        {
            IList <ISequenceAlignment> alignments = null;

            if (null == serviceParameters)
            {
                throw new ArgumentNullException("Parameters");
            }
            string output = _baseClient.GetOutputAsString(serviceParameters.JobId, serviceParameters.Parameters[CONTROLID].ToString());

            using (StringReader reader = new StringReader(output))
            {
                alignments = _ClustalWParser.Parse(reader);
            }

            return(new ClustalWResult(alignments[0]));
        }
Exemplo n.º 16
0
        private void SaveAllToolStripMenuItemClick(object sender, EventArgs e)
        {
            var controller = new ConfigurationController();

            controller.GenerateImportConfigFile(NotificationService, tbImportConfig, mapper);
            controller.GenerateExportConfigFile(tbExportConfig, tbSchemaPath, filterQuery, lookupMaping, NotificationService);

            var serviceParameters = new ServiceParameters(OrganizationService, MetadataService, NotificationService, ExceptionService);
            var entityController  = new EntityController();

            entityController.CollectCrmEntityFields(checkedEntity, crmSchemaConfiguration, entityRelationships, entityAttributes, attributeMapping, serviceParameters);

            var schemaController = new SchemaController();

            schemaController.GenerateXMLFile(tbSchemaPath, crmSchemaConfiguration);
            crmSchemaConfiguration.Entities.Clear();
        }
Exemplo n.º 17
0
        public async Task And_Employer_Is_Non_Levy_And_Not_EOI_Then_Show_EOI_Holding_View(
            [ArrangeActionContext] ActionExecutingContext context,
            string employerAccountId,
            long decodedEmployerAccountId,
            string homeUrl,
            GetLegalEntitiesResponse legalEntitiesResponse,
            Mock <ActionExecutionDelegate> mockNext,
            [Frozen] ServiceParameters serviceParameters,
            [Frozen] Mock <IEncodingService> mockEncodingService,
            [Frozen] Mock <IMediator> mockMediator,
            [Frozen] Mock <IExternalUrlHelper> mockUrlHelper,
            NonEoiNotPermittedFilterAttribute filter)
        {
            serviceParameters.AuthenticationType = AuthenticationType.Employer;
            context.HttpContext = new DefaultHttpContext();
            context.RouteData.Values.Add("employerAccountId", employerAccountId);
            foreach (var accountLegalEntity in legalEntitiesResponse.AccountLegalEntities)
            {
                accountLegalEntity.IsLevy        = false;
                accountLegalEntity.AgreementType = AgreementType.Levy;
            }
            mockEncodingService
            .Setup(service => service.Decode(
                       context.RouteData.Values["employerAccountId"].ToString(),
                       EncodingType.AccountId))
            .Returns(decodedEmployerAccountId);
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetLegalEntitiesQuery>(query => query.AccountId == decodedEmployerAccountId),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(legalEntitiesResponse);
            mockUrlHelper
            .Setup(helper => helper.GenerateDashboardUrl(employerAccountId))
            .Returns(homeUrl);

            await filter.OnActionExecutionAsync(context, mockNext.Object);

            mockNext.Verify(next => next(), Times.Never());
            var result = context.Result as ViewResult;

            result.ViewName.Should().Be("NonEoiHolding");
            var model = result.Model as NonEoiHoldingViewModel;

            model.HomeLink.Should().Be(homeUrl);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Cancel the submitted job
        /// </summary>
        /// <param name="serviceParameters">job id, control id</param>
        /// <returns>Job is cancelled or not</returns>
        public bool CancelRequest(ServiceParameters serviceParameters)
        {
            if (_workerThread != null)
            {
                _workerThread.CancelAsync();
            }
            string errorresult = _baseClient.CancelJob(serviceParameters.JobId, serviceParameters.Parameters[CONTROLID].ToString());

            Console.WriteLine(errorresult);
            if (errorresult.ToUpper(CultureInfo.CurrentCulture).Contains(STOPPED.ToUpper(CultureInfo.CurrentCulture)))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 19
0
        public async Task And_Employer_Is_Non_Levy_And_Not_EOI_And_Has_TransferSenderId_In_Request_Then_Continues_To_Select_Action(
            [Frozen] ServiceParameters serviceParameters,
            [ArrangeActionContext] ActionExecutingContext context,
            Mock <ActionExecutionDelegate> mockNext,
            NonEoiNotPermittedFilterAttribute filter)
        {
            serviceParameters.AuthenticationType = AuthenticationType.Employer;
            context.HttpContext = new DefaultHttpContext();

            context.HttpContext.Request.Path  = PathString.FromUriComponent(new Uri("https://test.com/selectreservation/selectreservation"));
            context.HttpContext.Request.Query = new QueryCollection(new Dictionary <string, StringValues> {
                { "transferSenderId", "123RED" }
            });
            context.RouteData.Values.Add("controller", "SelectReservations");
            context.RouteData.Values.Add("action", "SelectReservation");

            await filter.OnActionExecutionAsync(context, mockNext.Object);

            mockNext.Verify(next => next(), Times.Once);
            context.Result.Should().Be(null);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Get the status of job using job id and control id after submitting the job
        /// </summary>
        /// <param name="parameters">job id, control id</param>
        /// <returns>result with status of job</returns>
        public MBF.Web.ServiceRequestInformation GetRequestStatus(ServiceParameters parameters)
        {
            string jobStatus = _baseClient.GetJobInfo(parameters.JobId, parameters.Parameters[CONTROLID].ToString());

            string[] statusArray           = jobStatus.Split('|');
            ServiceRequestInformation info = new ServiceRequestInformation();

            switch (statusArray[6])
            {
            case "FINISHED":
                info.Status = ServiceRequestStatus.Ready;
                break;

            case "ERROR":
                info.Status = ServiceRequestStatus.Error;
                break;

            default:
                break;
            }

            return(info);
        }
        public async Task Then_If_Provider_Adds_The_ProviderId_To_The_ViewBag_Data(
            uint ukprn,
            [Frozen] ServiceParameters serviceParameters,
            [ArrangeActionContext] ActionExecutingContext context,
            [Frozen] Mock <ActionExecutionDelegate> nextMethod,
            GoogleAnalyticsFilter filter)
        {
            //Arrange
            context.RouteData.Values.Add("ukPrn", ukprn);
            serviceParameters.AuthenticationType = AuthenticationType.Provider;

            //Act
            await filter.OnActionExecutionAsync(context, nextMethod.Object);

            //Assert
            var actualController = context.Controller as Controller;

            Assert.IsNotNull(actualController);
            var viewBagData = actualController.ViewBag.GaData as GaData;

            Assert.IsNotNull(viewBagData);
            Assert.AreEqual(ukprn.ToString(), viewBagData.UkPrn);
        }
Exemplo n.º 22
0
        public async Task And_Employer_Is_Non_Levy_And_Is_EOI_Then_Executes_Action(
            [ArrangeActionContext] ActionExecutingContext context,
            string employerAccountId,
            long decodedEmployerAccountId,
            GetLegalEntitiesResponse legalEntitiesResponse,
            Mock <ActionExecutionDelegate> mockNext,
            [Frozen] ServiceParameters serviceParameters,
            [Frozen] Mock <IEncodingService> mockEncodingService,
            [Frozen] Mock <IMediator> mockMediator,
            NonEoiNotPermittedFilterAttribute filter)
        {
            context.Result      = null;
            context.HttpContext = new DefaultHttpContext();

            serviceParameters.AuthenticationType = AuthenticationType.Employer;
            context.RouteData.Values.Add("employerAccountId", employerAccountId);
            foreach (var accountLegalEntity in legalEntitiesResponse.AccountLegalEntities)
            {
                accountLegalEntity.IsLevy        = false;
                accountLegalEntity.AgreementType = AgreementType.NonLevyExpressionOfInterest;
            }
            mockEncodingService
            .Setup(service => service.Decode(
                       context.RouteData.Values["employerAccountId"].ToString(),
                       EncodingType.AccountId))
            .Returns(decodedEmployerAccountId);
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetLegalEntitiesQuery>(query => query.AccountId == decodedEmployerAccountId),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(legalEntitiesResponse);

            await filter.OnActionExecutionAsync(context, mockNext.Object);

            mockNext.Verify(next => next(), Times.Once);
            context.Result.Should().Be(null);
        }
        public async Task Then_If_User_Is_Not_Logged_In_Then_Empty_ViewBag_Data_Is_Returned(
            long accountId,
            [Frozen] ServiceParameters serviceParameters,
            [ArrangeActionContext] ActionExecutingContext context,
            [Frozen] Mock <ActionExecutionDelegate> nextMethod,
            GoogleAnalyticsFilter filter)
        {
            //Arrange
            context.HttpContext.User             = new ClaimsPrincipal(new ClaimsIdentity());
            serviceParameters.AuthenticationType = AuthenticationType.Employer;

            //Act
            await filter.OnActionExecutionAsync(context, nextMethod.Object);

            //Assert
            var actualController = context.Controller as Controller;

            Assert.IsNotNull(actualController);
            var viewBagData = actualController.ViewBag.GaData as GaData;

            Assert.IsNotNull(viewBagData);
            Assert.IsNull(viewBagData.Acc);
            Assert.IsNull(viewBagData.UserId);
        }
Exemplo n.º 24
0
        public async Task AndIsALevyEmployer_ThenRedirectsToAccessDeniedPage(
            [Frozen] ServiceParameters serviceParameters,
            [Frozen] Mock <IMediator> mockMediator,
            GetLegalEntitiesResponse legalEntitiesResponse,
            IEnumerable <AccountLegalEntity> legalEntities,
            string employerAccountId,
            long decodedId,
            [Frozen] Mock <IEncodingService> mockEncodingService,
            [ArrangeActionContext] ActionExecutingContext context,
            [Frozen] Mock <ActionExecutionDelegate> nextMethod,
            LevyNotPermittedFilter filter)
        {
            //Arrange
            serviceParameters.AuthenticationType       = AuthenticationType.Employer;
            legalEntitiesResponse.AccountLegalEntities = legalEntities;
            context.RouteData.Values.Add("employerAccountId", employerAccountId);
            foreach (var legalEntity in legalEntitiesResponse.AccountLegalEntities)
            {
                legalEntity.IsLevy = true;
            }
            mockEncodingService
            .Setup(x => x.TryDecode(employerAccountId, EncodingType.AccountId, out decodedId))
            .Returns(true);
            mockMediator
            .Setup(x => x.Send(It.Is <GetLegalEntitiesQuery>(y => y.AccountId == decodedId), It.IsAny <CancellationToken>()))
            .ReturnsAsync(legalEntitiesResponse);

            //Act
            await filter.OnActionExecutionAsync(context, nextMethod.Object);

            //Assert
            Assert.NotNull(context.Result);
            Assert.True(context.Result is RedirectToRouteResult);
            Assert.AreEqual((context.Result as RedirectToRouteResult).RouteName, RouteNames.Error403);
            nextMethod.Verify(x => x(), Times.Never);
        }
Exemplo n.º 25
0
        private void ChangeServiceState(object parameters)
        {
            ServiceParameters serviceParams = (ServiceParameters)parameters;

            object[] args = new object[3];
            args[0] = resMan.GetString("FailedToSendCommand");
            args[1] = serviceParams.RowIndex;
            args[2] = "ServiceStatus";

            if (!_closing && !_aborting && !_wrongCrendentialsWatcher.IsAbortRequested)
            {
                lock (_ChangeServiceStateLocker)
                {
                    try
                    {
                        if (!_closing && !_aborting && !_wrongCrendentialsWatcher.IsAbortRequested)
                        {
                            ADComputer computer = new ADComputer(dtGrdVResult.Rows[serviceParams.RowIndex].Cells["ComputerName"].Value.ToString());
                            bool       result   = false;
                            if (serviceParams.Command == "RestartService")
                            {
                                computer.ManageService(serviceParams.ServiceName, "StopService", serviceParams.Login, serviceParams.Password);
                                result  = computer.ManageService(serviceParams.ServiceName, "StartService", serviceParams.Login, serviceParams.Password);
                                args[0] = result ? resMan.GetString("Running") : resMan.GetString("Failed");
                            }
                            else
                            {
                                result  = computer.ManageService(serviceParams.ServiceName, serviceParams.Command, serviceParams.Login, serviceParams.Password);
                                args[0] = result ? ((serviceParams.Command == "StartService") ? resMan.GetString("Running") : resMan.GetString("Stopped")) : resMan.GetString("Failed");
                            }
                        }
                        else
                        {
                            args[0] = resMan.GetString("Aborted");
                        }
                    }
                    catch (UnauthorizedAccessException)
                    {
                        _wrongCrendentialsWatcher.IsWrongCredentials = true;

                        if (!_wrongCrendentialsWatcher.ContinueWithFailedCredentials)
                        {
                            if (MessageBox.Show(resMan.GetString("CredentialFailed"), resMan.GetString("FailedToConnect"), MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
                            {
                                Logger.Write("interrupt on failed credentials.");
                                _wrongCrendentialsWatcher.IsAbortRequested = true;
                                args[0] = resMan.GetString("Aborted");
                            }
                            else
                            {
                                Logger.Write("Continue with bad credentials.");
                                _wrongCrendentialsWatcher.ContinueWithFailedCredentials = true;
                                args[0] = resMan.GetString("FailedToConnect");
                            }
                        }
                        else
                        {
                            args[0] = resMan.GetString("FailedToConnect");
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Write(ex.Message);
                        args[0] = resMan.GetString("FailedToSendCommand");
                    }
                }
            }
            else
            {
                args[0] = resMan.GetString("Aborted");
            }

            UpdateRow(args);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Validate Submit Job and Fetch ResultSync() using multiple input sequences
        /// </summary>
        /// <param name="nodeName">xml node name</param>
        void ValidateFetchResultSync(string nodeName)
        {
            // Read input from config file
            string filepath = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FilePathNode);
            string emailId = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.EmailIDNode);
            string clusterOption = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ClusterOptionNode);
            string actionAlign = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ActionAlignNode);

            // Initialize with parser and config params
            ConfigParameters configparams  = new ConfigParameters();
            ClustalWParser   clustalparser = new ClustalWParser();

            configparams.UseBrowserProxy = true;
            TestIClustalWServiceHandler handler =
                new TestIClustalWServiceHandler(clustalparser, configparams);
            ClustalWParameters parameters = new ClustalWParameters();

            parameters.Values[ClustalWParameters.Email]         = emailId;
            parameters.Values[ClustalWParameters.ClusterOption] = clusterOption;
            parameters.Values[ClustalWParameters.ActionAlign]   = actionAlign;

            IEnumerable <ISequence> sequence = null;

            // Get the input sequences
            using (FastAParser parser = new FastAParser(filepath))
            {
                sequence = parser.Parse();

                // Submit job and validate it returned valid job id and control id
                ServiceParameters svcparameters =
                    handler.SubmitRequest(sequence.ToList(), parameters);
                Assert.IsFalse(string.IsNullOrEmpty(svcparameters.JobId));
                Console.WriteLine(string.Concat("JobId", svcparameters.JobId));
                ApplicationLog.WriteLine(string.Concat("JobId", svcparameters.JobId));
                foreach (string key in svcparameters.Parameters.Keys)
                {
                    Assert.IsFalse(string.IsNullOrEmpty(svcparameters.Parameters[key].ToString()));
                    Console.WriteLine(string.Format((IFormatProvider)null, "{0}:{1}",
                                                    key, svcparameters.Parameters[key].ToString()));
                    ApplicationLog.WriteLine(string.Format((IFormatProvider)null, "{0}:{1}",
                                                           key, svcparameters.Parameters[key].ToString()));
                }

                // Get the results and validate it is not null.
                ClustalWResult result = handler.FetchResultsSync(svcparameters);
                Assert.IsNotNull(result);
                Assert.IsNotNull(result.SequenceAlignment);
                foreach (IAlignedSequence alignSeq in result.SequenceAlignment.AlignedSequences)
                {
                    Console.WriteLine("Aligned Sequence Sequences :");
                    ApplicationLog.WriteLine("Aligned Sequence Sequences :");
                    foreach (ISequence seq in alignSeq.Sequences)
                    {
                        Console.WriteLine(string.Concat("Sequence:", seq.ToString()));
                        ApplicationLog.WriteLine(string.Concat("Sequence:", seq.ToString()));
                    }
                }
            }
            Console.WriteLine(@"ClustalWServiceHandler BVT : Submit job and Get Results is successfully completed using FetchResultSync()");
            ApplicationLog.WriteLine(@"ClustalWServiceHandler BVT : Submit job and Get Results is successfully completed using FetchResultSync()");
        }
Exemplo n.º 27
0
        /// <summary>
        /// Validate submit job and FetchResultAsync() using multiple input sequences
        /// </summary>
        /// <param name="nodeName">xml node name</param>
        void ValidateFetchResultAsync(string nodeName)
        {
            // Read input from config file
            string filepath = _utilityObj._xmlUtil.GetTextValue(
                nodeName, Constants.FilePathNode);
            string emailId = _utilityObj._xmlUtil.GetTextValue(
                nodeName, Constants.EmailIDNode);
            string clusterOption = _utilityObj._xmlUtil.GetTextValue(
                nodeName, Constants.ClusterOptionNode);
            string actionAlign = _utilityObj._xmlUtil.GetTextValue(
                nodeName, Constants.ActionAlignNode);

            ConfigParameters configparams  = new ConfigParameters();
            ClustalWParser   clustalparser = new ClustalWParser();

            configparams.UseBrowserProxy = true;
            TestIClustalWServiceHandler handler =
                new TestIClustalWServiceHandler(clustalparser, configparams);

            ClustalWParameters parameters = new ClustalWParameters();

            parameters.Values[ClustalWParameters.Email]         = emailId;
            parameters.Values[ClustalWParameters.ClusterOption] = clusterOption;
            parameters.Values[ClustalWParameters.ActionAlign]   = actionAlign;

            IList <ISequence> sequence = null;

            // Get input sequences
            using (FastaParser parser = new FastaParser())
            {
                sequence = parser.Parse(filepath);
            }

            // Submit job and validate it returned valid job id and control id
            ServiceParameters svcparameters = handler.SubmitRequest(sequence, parameters);

            Assert.IsTrue(string.IsNullOrEmpty(svcparameters.JobId));
            Console.WriteLine(string.Concat("JobId:", svcparameters.JobId));
            foreach (string key in svcparameters.Parameters.Keys)
            {
                Assert.IsTrue(string.IsNullOrEmpty(svcparameters.Parameters[key].ToString()));
                Console.WriteLine(string.Format((IFormatProvider)null, "{0}:{1}",
                                                key, svcparameters.Parameters[key].ToString()));
            }

            // Get the results and validate it is not null.
            ClustalWResult            result     = null;
            int                       retrycount = 0;
            ServiceRequestInformation info;

            do
            {
                info = handler.GetRequestStatus(svcparameters);
                if (info.Status == ServiceRequestStatus.Ready)
                {
                    break;
                }

                Thread.Sleep(
                    info.Status == ServiceRequestStatus.Waiting ||
                    info.Status == ServiceRequestStatus.Queued ?
                    Constants.ClusterRetryInterval * retrycount : 0);

                retrycount++;
            }while (retrycount < 10);

            if (info.Status == ServiceRequestStatus.Ready)
            {
                result = handler.FetchResultsAsync(svcparameters);
            }
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.SequenceAlignment);
            foreach (IAlignedSequence alignSeq in result.SequenceAlignment.AlignedSequences)
            {
                Console.WriteLine("Aligned Sequence Sequences : ");
                ApplicationLog.WriteLine("Aligned Sequence Sequences : ");
                foreach (ISequence seq in alignSeq.Sequences)
                {
                    Console.WriteLine(string.Concat("Sequence:", seq.ToString()));
                    ApplicationLog.WriteLine(string.Concat("Sequence:", seq.ToString()));
                }
            }
            Console.WriteLine(@"ClustalWServiceHandler BVT : Submit job and Get Results is 
      successfully completed using FetchResultAsync()");
            ApplicationLog.WriteLine(@"ClustalWServiceHandler BVT : Submit job and Get Results 
      is successfully completed using FetchResultAsync()");
        }
Exemplo n.º 28
0
        private static void StartServiceBackround(object parameters)
        {
            ServiceParameters param = (ServiceParameters)parameters;

            StartService(param.serviceName, param.timeout);
        }
Exemplo n.º 29
0
 /// <summary>
 /// Initializes a new instance of the ClustalWThreadContext class.
 /// </summary>
 /// <param name="parameters">ClustalW Service</param>
 public ClustalWThreadContext(
     ServiceParameters parameters)
 {
     _parameters = parameters;
 }
Exemplo n.º 30
0
 public GoogleAnalyticsFilter(ServiceParameters serviceParameters)
 {
     _serviceParameters = serviceParameters;
 }