private void InitValues(ActiveMQSettings sett = null)
        {
            StoreEvents = sett != null ? sett.StoreEvents : false;
            CustomEventStoreLocation = sett != null ? sett.CustomEventStoreLocation : "";

            BrokerUri = sett != null ? sett.BrokerUri : "tcp://localhost:61616/";
            TopicNameKEUIPublishNewConcept = sett != null && !string.IsNullOrEmpty(sett.TopicNameKEUIPublishNewConcept) ? sett.TopicNameKEUIPublishNewConcept : "ALERT.KEUI.ConceptNew";
            TopicNameKEUIPublishResponse = sett != null && !string.IsNullOrEmpty(sett.TopicNameKEUIPublishResponse) ? sett.TopicNameKEUIPublishResponse : "ALERT.KEUI.Response";

            TopicNameForumSensorPublishForumPost = sett != null && !string.IsNullOrEmpty(sett.TopicNameForumSensorPublishForumPost) ? sett.TopicNameForumSensorPublishForumPost : "ALERT.ForumSensor.ForumPost";

            TopicNameConceptNew = sett != null && !string.IsNullOrEmpty(sett.TopicNameConceptNew) ? sett.TopicNameConceptNew : "ALERT.*.ConceptNew";
            TopicNameKEUIRequest = sett != null && !string.IsNullOrEmpty(sett.TopicNameKEUIRequest) ? sett.TopicNameKEUIRequest : "ALERT.*.KEUIRequest";
            TopicNameForumPost = sett != null && !string.IsNullOrEmpty(sett.TopicNameForumPost) ? sett.TopicNameForumPost : "ALERT.Metadata.ForumPostNew.Stored";
            TopicNameIssueNew = sett != null && !string.IsNullOrEmpty(sett.TopicNameIssueNew) ? sett.TopicNameIssueNew : "ALERT.Metadata.IssueNew.Stored";
            TopicNameIssueUpdate = sett != null && !string.IsNullOrEmpty(sett.TopicNameIssueUpdate) ? sett.TopicNameIssueUpdate : "ALERT.Metadata.IssueUpdate.Stored";
            TopicNameEmail = sett != null && !string.IsNullOrEmpty(sett.TopicNameEmail) ? sett.TopicNameEmail : "ALERT.Metadata.MailNew.Stored";
            TopicNameCommit = sett != null && !string.IsNullOrEmpty(sett.TopicNameCommit) ? sett.TopicNameCommit : "ALERT.Metadata.CommitNew.Stored";
            TopicNameWikiPostNew = sett != null && !string.IsNullOrEmpty(sett.TopicNameWikiPostNew) ? sett.TopicNameWikiPostNew : "ALERT.Metadata.ArticleAdded.Stored";
            TopicNameWikiPostModified = sett != null && !string.IsNullOrEmpty(sett.TopicNameWikiPostModified) ? sett.TopicNameWikiPostModified : "ALERT.Metadata.ArticleModified.Stored";
            TopicNameWikiPostDeleted = sett != null && !string.IsNullOrEmpty(sett.TopicNameWikiPostDeleted) ? sett.TopicNameWikiPostDeleted : "ALERT.Metadata.ArticleDeleted.Stored";
            TopicNameTextToAnnotate = sett != null && !string.IsNullOrEmpty(sett.TopicNameTextToAnnotate) ? sett.TopicNameTextToAnnotate : "ALERT.*.TextToAnnotate";

            TopicNameIdentitySnapshot = sett != null && !string.IsNullOrEmpty(sett.TopicNameIdentitySnapshot) ? sett.TopicNameIdentitySnapshot : "ALERT.*.IdentitySnapshot";

            TopicNameCustomItemToIndex = sett != null && !string.IsNullOrEmpty(sett.TopicNameCustomItemToIndex) ? sett.TopicNameCustomItemToIndex : "ALERT.*.CustomItemToIndex";

            TopicNameAnnotexPublishConceptNew = sett != null && !string.IsNullOrEmpty(sett.TopicNameAnnotexPublishConceptNew) ? sett.TopicNameAnnotexPublishConceptNew : "ALERT.Annotex.ConceptNew";
            TopicNameKEUIPublishForumPost = sett != null && !string.IsNullOrEmpty(sett.TopicNameKEUIPublishForumPost) ? sett.TopicNameKEUIPublishForumPost : "ALERT.KEUI.ForumPostNew.Annotated";
            TopicNameKEUIPublishBugPost = sett != null && !string.IsNullOrEmpty(sett.TopicNameKEUIPublishBugPost) ? sett.TopicNameKEUIPublishBugPost : "ALERT.KEUI.IssueNew.Annotated";
            TopicNameKEUIPublishBugComment = sett != null && !string.IsNullOrEmpty(sett.TopicNameKEUIPublishBugComment) ? sett.TopicNameKEUIPublishBugComment : "ALERT.KEUI.IssueUpdate.Annotated";
            TopicNameKEUIPublishEmail = sett != null && !string.IsNullOrEmpty(sett.TopicNameKEUIPublishEmail) ? sett.TopicNameKEUIPublishEmail : "ALERT.KEUI.MailNew.Annotated";
            TopicNameKEUIPublishCommit = sett != null && !string.IsNullOrEmpty(sett.TopicNameKEUIPublishCommit) ? sett.TopicNameKEUIPublishCommit : "ALERT.KEUI.CommitNew.Annotated";
            TopicNameKEUIPublishTextToAnnotate = sett != null && !string.IsNullOrEmpty(sett.TopicNameKEUIPublishTextToAnnotate) ? sett.TopicNameKEUIPublishTextToAnnotate : "ALERT.KEUI.TextToAnnotate.Annotated";

            TopicNameKEUIPublishWikiPostNew = sett != null && !string.IsNullOrEmpty(sett.TopicNameKEUIPublishWikiPostNew) ? sett.TopicNameKEUIPublishWikiPostNew : "ALERT.KEUI.ArticleAdded.Annotated";
            TopicNameKEUIPublishWikiPostModified = sett != null && !string.IsNullOrEmpty(sett.TopicNameKEUIPublishWikiPostModified) ? sett.TopicNameKEUIPublishWikiPostModified : "ALERT.KEUI.ArticleModified.Annotated";
        }
        public ProjectSpecificConcepts()
        {
            InitializeComponent();
            _relationToUri["linksTo"] = AnnotationOntology.RelLinksTo.Uri;
            _relationToUri["type"] = AnnotationOntology.RelRdfType.Uri;
            _relationToUri["sameAs"] = AnnotationOntology.RelOwlSameAs.Uri;
            _relationToUri["isPartOf"] = AnnotationOntology.RelPurlIsPartOf.Uri;
            _relationToUri["creator"] = AnnotationOntology.RelPurlCreator.Uri;

            this.Load += new EventHandler(ProjectSpecificConcepts_Load);
            this.FormClosed += new FormClosedEventHandler(ProjectSpecificConcepts_FormClosed);

            ListViewRelated.MouseUp += new MouseEventHandler(ListViewRelated_MouseUp);
            ListViewRelated.ItemCheck += new ItemCheckEventHandler(ListViewRelated_ItemCheck);

            ListViewCandidates.ItemCheck += new ItemCheckEventHandler(ListViewCandidates_ItemCheck);
            ListViewCandidates.ListViewItemSorter = new CandidateItemComparer();
            ListViewCandidates.Sorting = SortOrder.Descending;

            PopulateComboBoxRelations();
            UpdateGuiState();

            String AppName = "KEUIApp";
            String IndexingServerFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppName);
            _activeMQSettings = new ActiveMQSettings(Path.Combine(IndexingServerFolder, _fileNameActiveMQSettings));
        }
        public void LoadSettings()
        {
            //string currentFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            try {
                // modify the default template folder
                Defaults.TemplateFolder = Path.Combine(_forumSettingsFolder, "Event Templates");

                if (!Directory.Exists(_forumSettingsFolder))
                    Directory.CreateDirectory(_forumSettingsFolder);

                if (!Directory.Exists(Defaults.TemplateFolder))
                    ReportError(String.Format("The folder with templates ({0}) does not exist. Create it and put templates there.", Defaults.TemplateFolder));

                _activeMQSettings = new ActiveMQSettings(Path.Combine(_forumSettingsFolder, _fileNameActiveMQSettings));
                if (!string.IsNullOrEmpty(_activeMQSettings.LastInfo))
                    AddEvent("Error while loading Active MQ settings: " + _activeMQSettings.LastInfo);
                else
                    AddEvent("Active MQ settings loaded successfully.");

                _forumIdToImportedIdH = new Dictionary<int, HashSet<string>>();
                AccountInfoList = new List<AccountInfo>();

                if (File.Exists(Path.Combine(_forumSettingsFolder, _settingsFileName))) {
                    string text = File.ReadAllText(Path.Combine(_forumSettingsFolder, _settingsFileName));
                    HtmlAgilityPack.XmlDocument xmlDoc = new HtmlAgilityPack.XmlDocument();
                    xmlDoc.LoadXml(text);
                    var forumsNode = xmlDoc.DocumentNode.SelectSingleNode("/settings/forums");
                    CheckEveryMin = forumsNode.GetAttributeValue("checkEveryMin", 5);
                    SaveIdsEveryMin = forumsNode.GetAttributeValue("saveIdsEveryMin", 360);
                    StartOnStartup = forumsNode.GetAttributeValue("startOnStartup", true);
                    NrOfThreads = forumsNode.GetAttributeValue("nrOfThreads", 5);

                    foreach (var account in forumsNode.SelectNodes("./forum") ?? new HtmlNodeCollection(null)) {
                        int forumId = account.GetAttributeValue("forumId", -999);
                        string address = account.GetAttributeValue("address", "");
                        int checkBackDays = account.GetAttributeValue("checkBackDays", 1);
                        string forumName = account.GetAttributeValue("forumName", "");

                        if (forumId == -999) {
                            ReportError("No \"forumId\" value was specified for forum " + address + ". Since the attribute value is mandatory the forum is currently not being indexed.");
                            continue;
                        }

                        if (string.IsNullOrEmpty(address)) {
                            ReportError("The \"address\" value is not specified or contains an invalid value for forum with id " + forumId.ToString() + ". The forum is currently not being indexed.");
                            continue;
                        }

                        if (string.IsNullOrEmpty(forumName)) {
                            ReportError("The forumName value for forum " + address + " is empty. The value is mandatory so the forum is currently not being indexed.");
                            continue;
                        }
                        if (!(new[] { 0, 1, 7, 14, 30, 90, 180, 365 }).ToList().Contains(checkBackDays))
                            ReportError("The phpBB forum supports only a limited number of values for checkBackDays. These values are 0 (for whole history), 1, 7, 14, 30, 90, 180 and 365. Please specify in the settings one of these values otherwise the results could be unexpected.");

                        AccountInfoList.Add(new AccountInfo(forumId, forumName, address, checkBackDays));

                        // load the file with aleready imported forum post ids
                        lock (_postHashLock) {
                            string importedIdsFile = string.Format(_importedIdsFileTemplate, forumId);
                            if (File.Exists(Path.Combine(_forumSettingsFolder, importedIdsFile)))
                                _forumIdToImportedIdH[forumId] = new HashSet<string>(File.ReadAllLines(Path.Combine(_forumSettingsFolder, importedIdsFile)));
                            else
                                _forumIdToImportedIdH[forumId] = new HashSet<string>();
                        }
                    }

                    AddEvent(String.Format("The configuration file was read."));
                    AddEvent(String.Format("Data will be monitored on {0} sources.", AccountInfoList.Count));
                    AddEvent(String.Format("ActiveMQ Uri: {0}", _activeMQSettings.BrokerUri));
                }
                else
                    AddEvent("The configuration file was not found. No settings were loaded");
            }
            catch (Exception ex) {
                GenLib.Log.LogService.LogException("Settings. LoadSettings failed.", ex);
                AddEvent("Settings. LoadSettings failed." + ex.Message);
            }
        }