예제 #1
0
 public void WaitOnComplete()
 {
     while (Documents.Any(d => d.Complete == false))
     {
         Thread.Sleep(250);
     }
 }
예제 #2
0
        public void JobChanged()
        {
            // Deselect document in listbox
            SelectedDocument = null;

            // Deselect all documents
            foreach (Document doc in Documents)
            {
                doc.Selected = false;
            }

            // Check boxes that are included
            if (SelectedJob != null)
            {
                foreach (string jdoc in SelectedJob.DocumentsIncluded)
                {
                    if (!Documents.Any(d => d.FullPath == jdoc))
                    {
                        Misc.Globals.ShowMsg($"This job's configuration includes a document that could not be found.\n\nJob:\n{SelectedJob.Name}\n\nDocument:\n{jdoc}",
                                             "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                    else
                    {
                        Documents.First(d => d.FullPath == jdoc).Selected = true;
                    }
                }
            }
        }
예제 #3
0
        private void InsertDocument(object obj)
        {
            if (UpsertedDocument != new Document())
            {
                UpsertedDocument.Violations = ChosenViolations.ToList();

                // Generate regNumber
                if (string.IsNullOrEmpty(UpsertedDocument.RegNumber))
                {
                    if (Documents.Any())
                    {
                        UpsertedDocument.RegNumber =
                            string.Format("{0} - {1}", Documents.FirstOrDefault(d => d.Id == Documents.Select(doc => doc.Id).Max()).Id, DateTime.Today.Date);
                    }
                }

                UpsertedDocument.Id = documentsService.InsertDocument(UpsertedDocument);
                if (UpsertedDocument.Id > 0)
                {
                    Documents.Add(UpsertedDocument);
                    Messenger.ShowMessage("Успешен запис", MessageType.Success);
                }
                else
                {
                    Messenger.ShowMessage("Неуспешен запис!", MessageType.Error);
                }

                ResetDocumentOnUpsert();
            }
            else
            {
                Messenger.ShowMessage("Липсва документ!", MessageType.Error);
            }
        }
예제 #4
0
        public bool CloseAll()
        {
            if (!CanDocumentsClose(Documents))
            {
                return(false);
            }

            ActiveDocument = null;
            while (Documents.Any())
            {
                fileService.RemoveDocument(Documents.First());
            }
            return(true);
        }
        internal override void Analyse(TextAnalyticsClient client)
        {
            if (!Documents.Any() || Documents.Any(d => d == null))
            {
                throw new InvalidOperationException("A document to analyse has not been provided");
            }

            if (string.IsNullOrEmpty(Document.Text))
            {
                throw new InvalidOperationException("Text has not been set for the Document");
            }

            Document.SetResults(client.AnalyzeSentiment(Document.Text));
        }
예제 #6
0
파일: SmartCrawler.cs 프로젝트: reilf/Hawk
 public override FreeDocument DictSerialize(Scenario scenario = Scenario.Database)
 {
     var dict = base.DictSerialize(scenario);
     dict.Add("URL", URL);
     dict.Add("RootXPath", RootXPath);
     dict.Add("IsMultiData", IsMultiData);
     dict.Add("HttpSet", Http.DictSerialize());
     dict.Add("URLFilter", URLFilter);
     dict.Add("ContentFilter", ContentFilter);
     dict.Add("Crawler", Crawler);
     dict.Children = new List<FreeDocument>();
     if (Documents.Any())
         dict.Add("Login", Documents[0].DictSerialize());
     dict.Children.AddRange(CrawlItems.Select(d => d.DictSerialize(scenario)));
     return dict;
 }
예제 #7
0
        private async Task LoadApplicationSettingsAsync()
        {
            try
            {
                var settings = ApplicationSettings.GetSetting("NSwagSettings", string.Empty);
                if (settings != string.Empty)
                {
                    var paths = JsonConvert.DeserializeObject <string[]>(settings)
                                .Where(File.Exists)
                                .ToArray();

                    if (paths.Length > 0)
                    {
                        foreach (var path in paths)
                        {
                            await OpenDocumentAsync(path);
                        }

                        if (Documents.Any())
                        {
                            SelectedDocument = Documents.Last();
                        }
                        else
                        {
                            CreateDocument();
                        }
                    }
                    else if (!Documents.Any())
                    {
                        CreateDocument();
                    }
                }
                else if (!Documents.Any())
                {
                    CreateDocument();
                }
            }
            catch
            {
                if (!Documents.Any())
                {
                    CreateDocument();
                }
            }

            SelectedDocument = Documents.First();
        }
예제 #8
0
        private bool CanSelectionMode()
        {
            switch (LastPivotIndex)
            {
            case 0:
                var audios = AudioGroup.FirstOrDefault(g => (string)g.Key == "audios");
                if (audios != null && audios.Any())
                {
                    return(true);
                }
                break;

            case 2:
                return(Documents != null && Documents.Any());
            }

            return(false);
        }
        internal override void Analyse(TextAnalyticsClient client)
        {
            if (!Documents.Any())
            {
                throw new InvalidOperationException("No documents have been added to the Batch Operation");
            }

            foreach (AnalyzeSentimentResult sentimentInDocument in client.AnalyzeSentimentBatch(Documents.Select(d => d.Text)).Value)
            {
                int index = int.Parse(sentimentInDocument.Id);

                if (sentimentInDocument.HasError)
                {
                    Documents[index].SetErrorMessage(sentimentInDocument.Error.Message);
                }
                else
                {
                    Documents[index].SetResults(sentimentInDocument.DocumentSentiment);
                }
            }
        }
예제 #10
0
        public Application AddFieldsFromTemplate(ApplicationTemplate template)
        {
            if (Degrees?.Any() != true)
            {
                Degrees = template.Degrees.Select(d => new ApplicationDegree
                {
                    Application = this,
                    Index       = d.Index,
                    Degree      = d.Name
                }).ToList();
            }

            if (Documents?.Any() != true)
            {
                Documents = template.Documents.Select(d => new ApplicationDocument
                {
                    Application = this,
                    Index       = d.Index,
                    Name        = d.Name,
                    Description = d.Description
                }).ToList();
            }

            if (References?.Any() != true)
            {
                References = new List <ApplicationReference>();
                for (int i = 0; i < template.NumberOfReferences; ++i)
                {
                    References.Add(new ApplicationReference
                    {
                        Application = this,
                        Index       = i
                    });
                }
            }

            return(this);
        }
예제 #11
0
 private bool CanRemoveDocuments()
 {
     return(Documents.Any(t => t.IsSelected));
 }
예제 #12
0
 public bool Any()
 {
     return(Documents.Any() || SupportingSQL.Any());
 }