public async Task <bool> TestConnection(string host)
        {
            // determine if sso is implemented in octane server
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(host + "/admin/server/version");

            httpWebRequest.Method      = RestConnector.METHOD_GET;
            httpWebRequest.ContentType = RestConnector.CONTENT_TYPE_JSON;

            httpWebRequest.Headers.Add("HPECLIENTTYPE", "HPE_CI_CLIENT");

            ResponseWrapper responseWrapper = new ResponseWrapper();

            using (var httpResponse = await httpWebRequest.GetResponseAsync().ConfigureAwait(RestConnector.AwaitContinueOnCapturedContext))
            {
                using (var reader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    responseWrapper.Data = reader.ReadToEnd();
                }
            }

            OctaneVersion octaneVersion = new OctaneVersion(jSerialiser.Deserialize <OctaneVersionMetadata>(responseWrapper.Data).display_version);

            if (octaneVersion.CompareTo(OctaneVersion.INTER_P2) < 0)
            {
                throw new Exception("Login with browser is only supported starting from Octane server version: " + OctaneVersion.INTER_P2);
            }
            else
            {
                return(true);
            }
        }
        private async void AddBddToCommentFieldsIfSupported()
        {
            // add bdd_spec field if the Octane version is greater than 15.1.4 (Coldplay P1)
            if (rest.IsConnected())
            {
                OctaneVersion octaneVersion = await GetOctaneVersion();

                if (octaneVersion.CompareTo(OctaneVersion.COLDPLAY_P1) > 0)
                {
                    commentFields.Add(Comment.OWNER_BDD_SPEC_FIELD);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Initialize detailed information about the cached entity
        /// </summary>
        public async Task InitializeAsync()
        {
            try
            {
                OctaneServices octaneService = OctaneServices.GetInstance();

                List <FieldMetadata> fields = await FieldsMetadataService.GetFieldMetadata(Entity);

                List <string> fieldNames = fields.Select(fm => fm.Name).ToList();

                OctaneServices _octaneService = OctaneServices.GetInstance();

                if (octaneVersion == null)
                {
                    octaneVersion = await _octaneService.GetOctaneVersion();
                }

                // client lock stamp was introduced in octane 12.55.8
                if (octaneVersion.CompareTo(OctaneVersion.FENER_P3) > 0)
                {
                    // add client lock stamp to the fields that we want to retrieve
                    fieldNames.Add(lockStamp);
                }

                Entity = await _octaneService.FindEntityAsync(Entity, fieldNames);

                await HandleImagesInDescription();

                _allEntityFields.Clear();

                var visibleFieldsHashSet = FieldsCache.Instance.GetVisibleFieldsForEntity(EntityType);
                var fieldsToHideHashSet  = FieldsCache.GetFieldsToHide(Entity);
                foreach (var field in fields.Where(f => !fieldsToHideHashSet.Contains(f.Name)))
                {
                    var fieldViewModel = new FieldViewModel(Entity, field, visibleFieldsHashSet.Contains(field.Name));
                    // add change handler to field view model
                    fieldViewModel.ChangeHandler += (sender, e) =>
                    {
                        SaveIsEnabled = true;
                    };
                    if (!string.Equals(fieldViewModel.Metadata.FieldType, "memo", StringComparison.OrdinalIgnoreCase))
                    {
                        _allEntityFields.Add(fieldViewModel);
                    }
                }
                if (EntitySupportsComments)
                {
                    await RetrieveComments();
                }

                var transitions = await octaneService.GetTransitionsForEntityType(EntityType);

                if (Entity.TypeName != "run" && Entity.TypeName != "run_manual" && Entity.TypeName != "run_suite")
                {
                    var phaseEntity      = Entity.GetValue(CommonFields.Phase) as BaseEntity;
                    var currentPhaseName = phaseEntity.Name;

                    _phaseTransitions.Clear();
                    SelectedNextPhase = null;

                    foreach (var transition in transitions.Where(t => t.SourcePhase.Name == currentPhaseName))
                    {
                        if (transition.IsPrimary)
                        {
                            _phaseTransitions.Insert(0, transition.TargetPhase);
                        }
                        else
                        {
                            _phaseTransitions.Add(transition.TargetPhase);
                        }
                    }
                    this._selectIsEnabled = _phaseTransitions.Count != 0;
                }
                Mode = WindowMode.Loaded;
            }
            catch (Exception ex)
            {
                Mode         = WindowMode.FailedToLoad;
                ErrorMessage = ex.Message;
            }
            NotifyPropertyChanged();
        }