public CollectionCreator(String settingsFile) #endif { try { csmManager = new CsmManager(); if (String.IsNullOrEmpty(settingsFile)) { settingsFile = CCUtils.GetSettingsFilePath(); } if (File.Exists(settingsFile)) { config = CCConfiguration.FromXml(settingsFile); } if (config == null) { String errMsg = String.Format("{0}: [{1}], error code [{2}]", CCConstants.E0100, settingsFile ?? String.Empty, (int)CCEnums.CCErrorCodes.E0100); throw new Exception(errMsg); } } catch (Exception ex) { ILog.LogError(ex); throw (ex); } }
public CCTimerSearch(ITisClientServicesModule oCSM, String configPath, String profileName) { try { CSM = oCSM; CollectionsCreator = new CCreator(); if (CSM != null) { CSM.Session.OnMessage += StationMessage; workDir = CSM.PathLocator.get_Path(CCEnums.CCFilesExt.TIF.ToString()); } //-- Initialize profile --\\ if (File.Exists(configPath ?? String.Empty)) { config = CCConfiguration.FromXml(configPath); } else { config = CCConfiguration.FromCSM(CSM); } //-- Initialize profile --\\ if (String.IsNullOrEmpty(profileName)) { profileName = CSM.Application.AppName; } currentProfile = config != null?config.GetConfiguration(profileName) : null; if (currentProfile == null) { currentProfile = new CCConfiguration.CCConfigurationData(); //-- create a default profile --\\ } //-- Define collections creator settings --\\ CollectionsCreator.CurrentProfile = currentProfile; //collectionsCreator.OnPostFileLock += PostFileLock; CollectionsCreator.OnCollectionCreated += CollectionCreated; if (SearchHandler == null) { SearchHandler = new CCSearchFiles(currentProfile); } SearchHandler.OnPostFileLock += PostFileLock; SearchHandler.OnPreFileLock += PreFileLock; PollingTimer.Enabled = currentProfile.SearchPaths != null && currentProfile.SearchPaths.Length > 0 && currentProfile.SearchExtensions != null && currentProfile.SearchExtensions.Length > 0; CreateEvent();//-- fire OnCreate event --\ } catch (Exception ex) { ILog.LogError(ex); } }
/// <summary> /// From XMl function, deserializes a profile from XML /// </summary> /// <param name="xmlPath">The XML file path</param> /// <param name="profileName">the profile name to load.</param> /// <returns>CCConfigurationData</returns> public static CCConfigurationData FromXml(String xmlPath, String profileName) { CCConfiguration.CCConfigurationData result = null; try { CCConfiguration cfg = CCConfiguration.FromXml(xmlPath); return(cfg.GetConfiguration(profileName)); } catch (Exception ex) { ILog.LogError(ex); if (result != null && result.ThrowAllExceptions) { throw ex; } } return(result); }
/// <summary> /// Receive and process station messages. /// </summary> /// <param name="message">The message sent by an eFlow application.</param> private void StationMessage(String message) { try { ILog.LogInfo("Received eflow system MESSAGE: [{0}]", message); if (Regex.IsMatch(message, @"(?i)Show\s?Config|Show\s?setting?s|Show\s?definitions?")) { CCConfigDialog dlg = new CCConfigDialog(); dlg.ShowDialog(config, CurrentProfile.Name, false); Match mtc = Regex.Match(message, @"(?i)(?<=(.+)lprofile:)[^\s]+"); if (mtc.Success && mtc.Length > 0) { CurrentProfile = config.GetConfiguration(mtc.Value); } } if (Regex.IsMatch(message, "(?i)Stop|Pause|Disable|End")) { Enabled = false; ILog.LogInfo("Received eflow system message: [{0}], file polling timer is: enabled", message); } if (Regex.IsMatch(message, "(?i)Continue|Play|Resume|Enabled|Start|Begin")) { Enabled = true; ILog.LogInfo("Received eflow system message: [{0}], file polling timer is: disbaled", message); } if (Regex.IsMatch(message, "(?i)Exit|Terminate|Close")) { Enabled = false; processing = true; Dispose(); ILog.LogInfo("Received eflow system message: [{0}], Colisng application down", message); this.ExitThread(); } if (Regex.IsMatch(message, "(?i)search|find")) { StartFileSearch(); ILog.LogInfo("Received eflow system message: [{0}], starting a search", message); } if (Regex.IsMatch(message, "(?i)((.+)?load:|config(uration):)") || Regex.IsMatch(message, @"(?i)(?<=(.+)lprofile:)[^\s]+")) { Match mtc = Regex.Match(message, @"(?i)(?<=(.+)load:|refresh:)[^\s]+"); if (mtc.Success && mtc.Length > 0 && File.Exists(mtc.Value)) { config = CCConfiguration.FromXml(message); } mtc = Regex.Match(message, @"(?i)(?<=(.+)lprofile:)[^\s]+"); if (mtc.Success && mtc.Length > 0) { CurrentProfile = config.GetConfiguration(mtc.Value); } } if (Regex.IsMatch(message, "(?i)((.+)?timer?:|interval:)")) { Match mtc = Regex.Match(message, @"(?i)(?<=(.+)timer:|interval:)[^\s]+"); if (mtc.Success && mtc.Length > 0) { int prs = -1; if (int.TryParse(mtc.Value, out prs)) { PollingTimer.Interval = Math.Max(int.MaxValue, prs * 1000); } } } if (Regex.IsMatch(message, "(?i)((.+)?max.?count:)")) { Match mtc = Regex.Match(message, @"(?i)(?<=(.+)max.?count)[^\s]+"); if (mtc.Success && mtc.Length > 0) { int prs = -1; if (int.TryParse(mtc.Value, out prs)) { CurrentProfile.MaxFilesLock = prs; } } } } catch (Exception ex) { ILog.LogError(ex); } }