Example #1
0
        private void createDiscussionBoxes(IEnumerable <Discussion> discussions)
        {
            foreach (Discussion discussion in discussions)
            {
                if (!SystemFilter.DoesMatchFilter(discussion))
                {
                    continue;
                }

                SingleDiscussionAccessor accessor = Shortcuts.GetSingleDiscussionAccessor(
                    _gitLabInstance, _modificationListener, _mergeRequestKey, discussion.Id);
                DiscussionBox box = new DiscussionBox(this, accessor, _git, _currentUser,
                                                      _mergeRequestKey.ProjectKey, discussion, _mergeRequestAuthor,
                                                      _diffContextDepth, _colorScheme,
                                                      // pre-content-change
                                                      (sender) =>
                {
                    SuspendLayout();
                    sender.Visible = false; // to avoid flickering on repositioning
                },
                                            // post-content-change
                                                      (sender, lite) =>
                {
                    // 'lite' means that there were no a preceding PreContentChange event, so we did not suspend layout
                    updateLayout(null, true, lite);
                    updateSearch();
                    _onDiscussionModified?.Invoke();
                }, sender => MostRecentFocusedDiscussionControl = sender)
                {
                    // Let new boxes be hidden to avoid flickering on repositioning
                    Visible = false
                };
                Controls.Add(box);
            }
        }
Example #2
0
        static async Task Scan(string originSystem, int scanRadius, bool plotJourney, bool includeBodies, TimeSpan cacheDuration, string[] filterSystem, string[] filterBody)
        {
            using var client = new EdsmClient(new SystemCache(cacheDuration));
            var foundSystems = await new SystemResolver(client).ResolveSystemsAround(originSystem, scanRadius);

            var filteredSystems = new SystemFilter(filterSystem, filterBody).Filter(foundSystems);

            var remainingSystems = foundSystems.Except(filteredSystems).ToArray();

            await new VisitedSystemIdsWriter().WriteVisitedSystems(originSystem, remainingSystems);

            var orderedPartialSystems = new SystemOrderer(filteredSystems, plotJourney).Order();

            await new SystemListWriter().WriteSystemList(originSystem, orderedPartialSystems, includeBodies, plotJourney);
        }
        private void InitializeAttributes()
        {
            if (memberInfo == null)
            {
                return;
            }

            _entryPointDefinitionAttribute = memberInfo.GetCustomAttribute <Definition>();
            if (_entryPointDefinitionAttribute != null)
            {
                _entryPointDefinitionAttribute.SupportTopicList = memberInfo.GetCustomAttributes <SupportTopic>();
            }

            _resourceFilter = memberInfo.GetCustomAttribute <ResourceFilterBase>();
            _systemFilter   = memberInfo.GetCustomAttribute <SystemFilter>();
        }
 public IActionResult Get([FromQuery] SystemFilter filter)
 {
     try
     {
         var systemList = _service.Get(filter);
         if (systemList == null || systemList.Count() == 0)
         {
             return(NotFound());
         }
         return(Ok(systemList));
     }
     catch (Exception e)
     {
         try { _logService.SendLogError(e); } catch (System.Exception ex) { return(StatusCode(503, ex.Message)); }
         return(StatusCode(503, e));
     }
 }
        public async void EntityInvoker_TestSystemFilterAttributeResolution()
        {
            Definition definitonAttribute = new Definition()
            {
                Id     = "TestId",
                Name   = "Test",
                Author = "User"
            };

            SystemFilter   filter   = new SystemFilter();
            EntityMetadata metadata = ScriptTestDataHelper.GetRandomMetadata();

            metadata.ScriptText = await ScriptTestDataHelper.GetSystemInvokerScript(definitonAttribute);

            using (EntityInvoker invoker = new EntityInvoker(metadata, ScriptHelper.GetFrameworkReferences(), ScriptHelper.GetFrameworkImports()))
            {
                await invoker.InitializeEntryPointAsync();

                Assert.True(invoker.IsCompilationSuccessful);
                Assert.NotNull(invoker.SystemFilter);
                Assert.Equal(filter, invoker.SystemFilter);
            }
        }
 public IActionResult Get(int id, string fields, string ref_fields)
 {
     try
     {
         SystemFilter filter = new SystemFilter()
         {
             ids        = id + "",
             fields     = fields,
             ref_fields = ref_fields
         };
         var systemList = _service.Get(filter);
         if (systemList == null || systemList.Count() == 0)
         {
             return(NotFound());
         }
         return(Ok(systemList));
     }
     catch (System.Exception e)
     {
         try { _logService.SendLogError(e); } catch (System.Exception ex) { return(StatusCode(503, ex.Message)); }
         return(StatusCode(503, e));
     }
 }
Example #7
0
        private void createDiscussionBoxes(List <Discussion> discussions)
        {
            foreach (var discussion in discussions)
            {
                if (!SystemFilter.DoesMatchFilter(discussion))
                {
                    continue;
                }

                DiscussionEditor editor = _manager.GetDiscussionEditor(_mergeRequestDescriptor, discussion.Id);
                DiscussionBox    box    = new DiscussionBox(discussion, editor, _mergeRequestAuthor, _currentUser,
                                                            _diffContextDepth, _gitRepository, _colorScheme,
                                                            (sender) =>
                {
                    SuspendLayout();
                    sender.Visible = false; // to avoid flickering on repositioning
                }, (sender) => updateLayout(null))
                {
                    // Let new boxes be hidden to avoid flickering on repositioning
                    Visible = false
                };
                Controls.Add(box);
            }
        }
        public IActionResult GetSentenceBySystemFilter([FromQuery] string filter)
        {
            string entityAsJson = "";
            List <SentenceStatsEntity> systemSentenceStats = new List <SentenceStatsEntity>();

            try
            {
                _logger.LogInformation("CPAPI: Get Sentence Graph By Record Filter");

                // Deserialize the filter
                SystemFilter oFilter = new SystemFilter();
                if (filter != null && filter.Length > 0)
                {
                    _logger.LogDebug("Deserializing filter of length: " + filter.Length);
                    oFilter = JsonConvert.DeserializeObject <SystemFilter>(filter);
                }

                string storageAccountConnectionString = Utils.GetSecretOrEnvVar(ConfigurationProperties.AzureStorageAccountConnectionString, Configuration, _logger).Trim();
                // validate tika base address
                if (storageAccountConnectionString == "")
                {
                    _logger.LogWarning("Azure storage account connection string not set");
                    return(StatusCode((int)System.Net.HttpStatusCode.InternalServerError));
                }
                else
                {
                    _logger.LogDebug("Azure storage account connection string loaded");
                }

                // Get the key phrases for the record and for the record associations
                systemSentenceStats = GetSentenceStatsForSystem(oFilter);

                // Create the visualisation nodes
                grandparent gp = new grandparent("System");
                gp.label = "System";    //TODO: set as system label

                // Add sentence schema
                // TODO: support all RAs and/or ontologies
                parent p_sentence = new parent("AFDA");
                p_sentence.label = "AFDA";
                gp.children.Add(p_sentence);

                // Add sentence stats
                int i = 0;
                foreach (SentenceStatsEntity statEntity in systemSentenceStats)
                {
                    // Get the sentence stats for this system
                    List <SentenceStat> sentences = new List <SentenceStat>();
                    if (statEntity.JsonSentenceStats != null)
                    {
                        sentences = JsonConvert.DeserializeObject <List <SentenceStat> >(statEntity.JsonSentenceStats);
                    }
                    foreach (SentenceStat stat in sentences)
                    {
                        // Create a new child object for the class
                        child c = new child(stat.ClassNo, stat.NumEntries);
                        c.label = stat.Function;
                        p_sentence.children.Add(c);
                    }

                    i++;
                }


                // Serialize
                entityAsJson = JsonConvert.SerializeObject(gp, Formatting.None);
            }
            catch (Exception ex)
            {
                string exceptionMsg = "KeyPhrase GET exception: " + ex.Message;
                //log.Info("Exception occurred extracting text from uploaded file \r\nError: " + ex.Message);
                if (ex.InnerException != null)
                {
                    exceptionMsg = exceptionMsg + "[" + ex.InnerException.Message + "]";
                }

                _logger.LogError(exceptionMsg);
                return(StatusCode((int)System.Net.HttpStatusCode.InternalServerError));
            }

            ObjectResult result = new ObjectResult(entityAsJson);

            return(result);
        }
        private List <SentenceStatsEntity> GetSentenceStatsForSystem(SystemFilter oFilter)
        {
            List <SentenceStatsEntity> systemSentences = new List <SentenceStatsEntity>();

            CloudTable tRecordAssociationKeyphrases = Utils.GetCloudTable("stlpsystems", _logger);

            // Create a default query
            TableQuery <SentenceStatsEntity> query = new TableQuery <SentenceStatsEntity>();

            string systemFilter = "";

            // Add any record association filters
            if (oFilter.systems.Count > 0)
            {
                foreach (string sif in oFilter.systems)
                {
                    if (sif != null && sif != "")
                    {
                        // Validate the record filter
                        string cleanFilterPKey = Utils.CleanTableKey(sif);
                        if (cleanFilterPKey.EndsWith("|"))
                        {
                            cleanFilterPKey = cleanFilterPKey + "|";
                        }

                        string pkquery = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, cleanFilterPKey);
                        if (systemFilter != "")
                        {
                            systemFilter = TableQuery.CombineFilters(systemFilter, TableOperators.Or, pkquery);
                        }
                        else
                        {
                            systemFilter = pkquery;
                        }
                    }
                }
            }



            // Create final combined query
            query = new TableQuery <SentenceStatsEntity>().Where(systemFilter);


            TableContinuationToken token = null;

            var runningQuery = new TableQuery <SentenceStatsEntity>()
            {
                FilterString  = query.FilterString,
                SelectColumns = query.SelectColumns
            };

            do
            {
                runningQuery.TakeCount = query.TakeCount - systemSentences.Count;

                Task <TableQuerySegment <SentenceStatsEntity> > tSeg = tRecordAssociationKeyphrases.ExecuteQuerySegmentedAsync <SentenceStatsEntity>(runningQuery, token);
                tSeg.Wait();
                token = tSeg.Result.ContinuationToken;
                systemSentences.AddRange(tSeg.Result);
            } while (token != null && (query.TakeCount == null || systemSentences.Count < query.TakeCount.Value) && systemSentences.Count < 20000);    //!ct.IsCancellationRequested &&



            return(systemSentences);
        }