public MvcHtmlString GetRuleDetails(RuleConfiguration rule) { switch (rule.Type) { case RuleType.DateRange: return(DateRangeDetails(rule as DateRangeRuleConfiguration)); case RuleType.EventDuration: return(EventDurationDetails(rule as EventDurationRuleConfiguration)); case RuleType.EventGroup: return(EventGroupDetails(rule as EventGroupRuleConfiguration)); case RuleType.MinimumDate: return(MinimumDateDetails(rule as MinimumDateRuleConfiguration)); case RuleType.Weekly: return(WeeklyDetails(rule as WeeklyRuleConfiguration)); case RuleType.BookingTimeOverride: return(BookingTimeOverrideDetails(rule as BookingTimeOverrideRuleConfiguration)); case RuleType.MultipleBooking: return(MultipleBookingDetails(rule as MultipleBookingRuleConfiguration)); default: throw new InvalidOperationException(String.Format("Rule of type '{0}' not yet configured!", rule.Type)); } }
public static IConfiguration ConvertToConfiguration(this SettingsConfigurationSection settings) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } var directories = new List <DirectoryConfiguration>(); foreach (DirectoryConfigurationElement settingsDirectory in settings.Directories) { directories.Add(new DirectoryConfiguration(settingsDirectory.Path)); } var rules = new List <RuleConfiguration>(); foreach (RuleConfigurationElement rule in settings.Rules) { rules.Add(new RuleConfiguration(rule.FilePattern, rule.DestinationDirectory, rule.SerialNumberEnable, rule.MovingDateEnable)); } var defaultRule = new RuleConfiguration("*", settings.Rules.DefaultDirectoryPath, true, true); return(new Config(settings.Culture, directories, rules, defaultRule)); }
public static RuleConfiguration FromRuleStorage(RuleStorage ruleStorage) { RuleConfiguration ruleConfiguration = new RuleConfiguration(ruleStorage.OrganizationalUnitRoot.ObjectGuid, ruleStorage.Id.ObjectGuid); UnifiedPolicyStorageFactory.CopyPropertiesFromStorage <RuleConfiguration>(ruleConfiguration, new TenantSettingFacade <RuleStorage>(ruleStorage)); return(ruleConfiguration); }
public TradeUtils(BrokerConfiguration brokerConfig, RuleConfiguration ruleConfig) { this.BrokerConfig = brokerConfig; TradeVolumeCalculator = new TradeVolumeCalculator(ruleConfig); OrderSpacingCalculator = new OrderSpacingCalculator(ruleConfig); }
public Task <FtpSummary> UploadDirectoryAsync( [NotNull] RuleConfiguration ruleConfiguration, [NotNull] DirectoryInfo sourceDirectory, [NotNull] DirectoryInfo baseDirectory, [NotNull] FtpPath basePath, CancellationToken cancellationToken) { if (ruleConfiguration == null) { throw new ArgumentNullException(nameof(ruleConfiguration)); } if (sourceDirectory == null) { throw new ArgumentNullException(nameof(sourceDirectory)); } if (baseDirectory == null) { throw new ArgumentNullException(nameof(baseDirectory)); } if (basePath == null) { throw new ArgumentNullException(nameof(basePath)); } return(UploadDirectoryInternalAsync(sourceDirectory, baseDirectory, basePath, cancellationToken)); }
public IActionResult Post(string jobId, [FromBody] RuleInModel value) { if (!String.IsNullOrEmpty(value.Id)) { return(BadRequest("You cannot provide Id with post")); } if (String.IsNullOrEmpty(value.Path)) { return(BadRequest("You have to provide a download path")); } if (String.IsNullOrEmpty(value.Regex)) { return(BadRequest("You have to provide a regex")); } RuleConfiguration newRule = new RuleConfiguration { Regex = value.Regex, Priority = value.Priority, Path = value.Path }; configurator.SetRule(jobId, newRule); return(Created(Url.Action("Get", new { jobId = jobId, id = newRule.Id }), mapper.Map <RuleOutModel>(newRule))); }
private async Task <FtpSummary> DeleteFilesAsync( RuleConfiguration ruleConfiguration, ImmutableArray <FtpPath> fileSystemItems, CancellationToken cancellationToken) { var deploymentChangeSummary = new FtpSummary(); foreach (var fileSystemItem in fileSystemItems .Where(fileSystemItem => fileSystemItem.Type == FileSystemType.File)) { if (ruleConfiguration.AppDataSkipDirectiveEnabled && fileSystemItem.IsAppDataDirectoryOrFile) { continue; } if (ruleConfiguration.Excludes.Any(value => fileSystemItem.Path.StartsWith(value, StringComparison.OrdinalIgnoreCase))) { deploymentChangeSummary.IgnoredFiles.Add(fileSystemItem.Path); continue; } await DeleteFileAsync(fileSystemItem, cancellationToken); deploymentChangeSummary.Deleted.Add(fileSystemItem.Path); } return(deploymentChangeSummary); }
public Task <DeploySummary> UploadDirectoryAsync( RuleConfiguration ruleConfiguration, DirectoryInfo sourceDirectory, DirectoryInfo baseDirectory, FtpPath basePath, CancellationToken cancellationToken) { if (ruleConfiguration is null) { throw new ArgumentNullException(nameof(ruleConfiguration)); } if (sourceDirectory is null) { throw new ArgumentNullException(nameof(sourceDirectory)); } if (baseDirectory is null) { throw new ArgumentNullException(nameof(baseDirectory)); } if (basePath is null) { throw new ArgumentNullException(nameof(basePath)); } return(UploadDirectoryInternalAsync(sourceDirectory, baseDirectory, basePath, cancellationToken)); }
private string CreateDestinationFilePath(RuleConfiguration rule, FileModel file) { var fileName = Path.GetFileNameWithoutExtension(file.Name); if (fileName == null) { throw new ArgumentException(string.Format(Translations.FileNameNotFound, file.FullPath), nameof(file)); } var builder = new StringBuilder(); var destinationFileName = Path.Combine(rule.DestinationDirectory, fileName); builder.Append(destinationFileName); if (rule.MovingDateEnable) { var currentDateTime = DateTime.UtcNow; builder.Append($"_{currentDateTime.ToLocalTime():yy-MM-dd}"); } if (rule.SerialNumberEnable) { var newGuid = Guid.NewGuid().ToString(); builder.Append($"_{newGuid}"); } var fileExtension = Path.GetExtension(file.FullPath); builder.Append(fileExtension); return(builder.ToString()); }
/// <summary> /// Applies transformation rules for detected file. /// </summary> /// <param name="fileName">The file name.</param> /// <param name="rule">The transformation rules.</param> /// <returns>The transformed name.</returns> private string TransformFileName(string fileName, RuleConfiguration rule) { if (string.IsNullOrWhiteSpace(fileName)) { throw new ArgumentException(Resources.Messages.EmptyFileName); } if (rule == null) { throw new ArgumentNullException(nameof(rule)); } string transformedName = GetFileName(fileName); if (rule.IsAddNumber) { transformedName = $"{transformedName}_{++_fileCounter}"; } if (rule.IsAddDate) { transformedName = $"{transformedName}_{DateTime.Now.ToShortDateString()}"; } return($"{transformedName}.{GetFileExtension(fileName)}"); }
public static bool GetRuleConfigStringParam(String ruleConfigParamName, RuleConfiguration ruleConfig, ref string stringValue) { if (!ruleConfig.Params.TryGetValue(ruleConfigParamName, out object paramStringObj)) { return(false); } stringValue = paramStringObj.ToString(); return(true); }
public static RuleStorage ToRuleStorage(RuleConfiguration rule) { RuleStorage ruleStorage = new RuleStorage(); ruleStorage[ADObjectSchema.OrganizationalUnitRoot] = new ADObjectId(rule.TenantId); ruleStorage.Name = rule.Name; ruleStorage.SetId((ADObjectId)DalHelper.ConvertFromStoreObject(rule.ObjectId, typeof(ADObjectId))); UnifiedPolicyStorageFactory.CopyPropertiesToStorage <RuleConfiguration>(new TenantSettingFacade <RuleStorage>(ruleStorage), rule); return(ruleStorage); }
private static string CreateDownloadPath(JobConfiguration jobConfig, RuleConfiguration rule, Match match) { var path = rule.Path; for (var i = 1; i < match.Groups.Count; i++) { path = path.Replace("{" + match.Groups[i].Name + "}", match.Groups[i].Value); } return($"{jobConfig.DownloadPath}{path}"); }
public static bool GetRuleConfigIntegerParam(String ruleConfigParamName, RuleConfiguration ruleConfig, ref int intValue) { if (ruleConfig.Params.TryGetValue(ruleConfigParamName, out object paramIntObj)) { if (!Int32.TryParse(paramIntObj.ToString(), out intValue)) { return(false); } } return(true); }
public static bool GetRuleConfigDoubleParam(String ruleConfigParamName, RuleConfiguration ruleConfig, ref double doubleValue) { if (ruleConfig.Params.TryGetValue(ruleConfigParamName, out object paramDoubleObj)) { if (!Double.TryParse(paramDoubleObj.ToString(), out doubleValue)) { return(false); } } return(true); }
public override void Init(RuleConfiguration ruleConfig) { ruleConfig.Params.TryGetValue("OpenTime", out string openTime); Utils.ParseStringToTimeSpan(openTime, ref OpenTime); ruleConfig.Params.TryGetValue("CloseTime", out string closeTime); UseCloseTime = Utils.ParseStringToTimeSpan(closeTime, ref CloseTime); ruleConfig.Params.TryGetValue("CloseAfter", out string closeAfter); Utils.ParseStringToTimeSpan(closeAfter, ref CloseAfter); }
public static bool GetRuleConfigBoolParam(String ruleConfigParamName, RuleConfiguration ruleConfig, ref bool boolValue) { boolValue = false; if (ruleConfig.Params.TryGetValue(ruleConfigParamName, out object paramBoolObj)) { if (!Boolean.TryParse(paramBoolObj.ToString(), out boolValue)) { return(false); } } return(true); }
public void FillControl(RuleConfiguration config) { checkBoxIsEnabled.Checked = config.IsRuleEnabled; radioButtonError.Checked = config.Severity == MessageSeverity.Error; radioButtonWarning.Checked = config.Severity == MessageSeverity.Warning; radioButtonInfo.Checked = config.Severity == MessageSeverity.Info; textBoxFriendlyName.Text = config.FriendlyName; textBoxCategory.Text = config.Category; textBoxDescription.Text = config.Description; comboBoxMinSqlVersion.Text = config.SupportedSqlVersions.MinSqlVersion?.ToString() ?? NullVersion; comboBoxMaxSqlVersion.Text = config.SupportedSqlVersions.MaxSqlVersion?.ToString() ?? NullVersion; }
public FileService(IConfiguration configuration, ILoggerService loggerService) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } _defaultRule = configuration.DefaultRule ?? throw new ArgumentException(Translations.DefaultRuleConfigurationNotFound, nameof(configuration)); _rulesConfiguration = configuration.Rules; _loggerService = loggerService ?? throw new ArgumentNullException(nameof(loggerService)); }
public static bool GetRuleConfigOrderSpacing(RuleConfiguration ruleConfig, ref OrderSpacingConfiguration orderSpacingConfig) { if (ruleConfig.Params.TryGetValue(RuleConfiguration.ORDERSPACING, out object paramObj)) { orderSpacingConfig = JsonConvert.DeserializeObject <OrderSpacingConfiguration>(paramObj.ToString()); if (orderSpacingConfig == null) { return(false); } } return(true); }
public static bool GetRuleConfigVolume(RuleConfiguration ruleConfig, ref VolumeConfiguration VolumeConfig) { if (ruleConfig.Params.TryGetValue(RuleConfiguration.VOLUME, out object paramObj)) { VolumeConfig = JsonConvert.DeserializeObject <VolumeConfiguration>(paramObj.ToString()); if (VolumeConfig == null) { return(false); } } return(true); }
public MqttItem(string topic, RuleConfiguration ruleConfiguration) { _ruleConfiguration = ruleConfiguration; Topic = topic; if (!HaveToIgnore()) { CreateJsonValueConverter(Topic); var measurementName = GetMeasurementName(); var type = GetMeasurementType(measurementName); _measurement = CreateMeasurement(measurementName, type); _measurement.RuleConfiguration = ruleConfiguration; } }
private bool IsActive = true; //Default state is active public IRule(StrategyConfiguration strategyConfig, RuleConfiguration ruleConfig) { this.StrategyConfig = strategyConfig; this.RuleConfig = ruleConfig; StrategyId = StrategyConfig.StrategyId; if (String.IsNullOrEmpty(StrategyId)) { IsInitialised = false; } ExchangeName = StrategyConfig.Exchange; if (String.IsNullOrEmpty(ExchangeName)) { IsInitialised = false; } BrokerId = StrategyConfig.BrokerId; if (String.IsNullOrEmpty(BrokerId)) { IsInitialised = false; } //Initialise TradeUtils for broker specific config TradeUtils = new TradeUtils(new BrokerConfiguration(BrokerId), ruleConfig); //Initialise a TradesPublisher TradePublisher = new TradePublisher(Publisher, TradeUtils, GetServiceName()); //Add Rule configuration to Firebase StateManager = new StateManager(StrategyId); if (StateManager == null) { IsInitialised = false; } StateManager.SetInitialStateAsync(RuleConfig.Params); //Manage State updates if subscribed to by the derived rule StateManager.StateUpdateReceived += OnStateEventUpdate; StateManager.SetActivationRulesAsync(GetServiceName(), RuleConfig.ActivateRules); StateManager.SetDeactivationRulesAsync(GetServiceName(), RuleConfig.DeactivateRules); //If this rule has activation rules default state IsActive = false if (RuleConfig.ActivateRules != null) { IsActive = false; } StateManager.UpdateRuleStatusAsync(GetServiceName(), RuleConfiguration.ISACTIVE, IsActive); }
private void LoadConfig() { var filePath = ConfigFilePath(); if (File.Exists(filePath)) { _ruleConfiguration = new JavaScriptSerializer(null, false, int.MaxValue, int.MaxValue, true, false).Deserialize <RuleConfiguration>(File.ReadAllText(filePath)); } else { LoadDefaultConfig(); SaveConfig(); } }
protected bool IsActive = true; //Default state is active public IRule(StrategyConfiguration strategyConfig, RuleConfiguration ruleConfig) { this.StrategyConfig = strategyConfig; this.RuleConfig = ruleConfig; if (!StrategyConfig.Config.TryGetValue(StrategyConfiguration.STRATEGYID, out StrategyId)) { IsInitialised = false; } if (!StrategyConfig.Config.TryGetValue(StrategyConfiguration.EXCHANGE, out ExchangeName)) { IsInitialised = false; } }
public static void getUnfinishedRequirements(AnalysisContext analysisContext) { //Get the rule settings RuleConfiguration ruleConfiguration = analysisContext.GetRuleConfiguration(cRuleId_getUnfinishedRequirements); //Only run if the rule is enabled if (ruleConfiguration.Enabled) { //Get the configuration data for this rule PropertyObject ruleData = analysisContext.GetRuleAnalysisData(cRuleId_getUnfinishedRequirements, RuleAnalysisDataScope.RuleAnalysisDataScope_File, GetRuleAnalysisDataOptions.GetRuleAnalysisDataOption_NoOptions); //Only run the analysis if the object we are analyzing contains a Requirements field PropertyObject requirements = getRequirementsObject(analysisContext); if (requirements != null) { if (requirements.GetNumElements() > 0) //Only do something if the object has requirements entered { int numberofRequirements = requirements.GetNumElements(); string currentRequirement; for (int idx = 0; idx < numberofRequirements; idx++) { currentRequirement = requirements.GetValStringByOffset(idx, 0); string[] requirementparts = currentRequirement.Split(','); if (requirementparts.Length != 3) { //Malformed Requirement Do nothing this should be handled as an error in the getMalformedRequirement Rule } else { if (requirementparts[2].Trim(' ') == "Done") { //Do nothing we only want the outstanding requirements } else { AnalysisMessage message = analysisContext.NewMessage(cRuleId_getUnfinishedRequirements, "Unfinished Requirement " + currentRequirement, analysisContext.Object); analysisContext.ReportMessage(message); } } } } } } }
private static bool KeepFile(FtpPath fileSystemItem, RuleConfiguration ruleConfiguration) { if (ruleConfiguration.AppDataSkipDirectiveEnabled && fileSystemItem.IsAppDataDirectoryOrFile) { return(true); } if (ruleConfiguration.Excludes.Any(value => fileSystemItem.Path.StartsWith(value, StringComparison.OrdinalIgnoreCase))) { return(true); } return(false); }
public void AddRule(string jobId, RuleConfiguration ruleConfiguration) { var job = ClientConfiguration.Jobs.FirstOrDefault(x => x.Id == jobId); if (job == null) { throw new JobNotFoundException(jobId); } var newRules = job.Rules.ToList(); newRules.Add(ruleConfiguration); job.Rules = newRules; WriteConfiguration(); }
private void LoadDefaultConfig() { _ruleConfiguration = new RuleConfiguration(); _ruleConfiguration.IgnoringRules.Add(new IgnoreRule("^OpenHAB.out.cb")); _ruleConfiguration.NamingRules.Add(new NamingRule("/", ".")); _ruleConfiguration.TypeRules.Add(new TypeRule(".State$", "byte")); _ruleConfiguration.TypeRules.Add(new TypeRule(".State$", "byte")); _ruleConfiguration.TextConverterRules.Add(new TextConverterRule("ON", "1")); _ruleConfiguration.TextConverterRules.Add(new TextConverterRule("OFF", "0")); _ruleConfiguration.TextConverterRules.Add(new TextConverterRule("OPEN", "1")); _ruleConfiguration.TextConverterRules.Add(new TextConverterRule("CLOSED", "0")); _ruleConfiguration.JsonConverterRules.Add(new JsonConverterRule("^hm/status/.*", "val")); _ruleConfiguration.RecordingRules.Add(new RecordingRule("testChange", "change")); _ruleConfiguration.RecordingRules.Add(new RecordingRule("testInterval", "10s")); _ruleConfiguration.RecordingRules.Add(new RecordingRule("State$", "change")); _ruleConfiguration.RecordingRules.Add(new RecordingRule(".*", "30s")); }
private bool Initilise(RuleConfiguration ruleConfig) { VolumeConfiguration VolumeConfiguration = null; if (Utils.GetRuleConfigVolume(ruleConfig, ref VolumeConfiguration)) { return(false); } this.EnableDynamicVolumeIncrease = VolumeConfiguration.EnableDynamicVolumeIncrease; this.Type = VolumeConfiguration.Type; this.VolumeBase = VolumeConfiguration.VolumeBase; this.VolumeMax = VolumeConfiguration.VolumeMax; this.IncreaseVolumeAfterOrders = VolumeConfiguration.IncreaseVolumeAfterOrders; this.VolumeIncreaseFactor = VolumeConfiguration.VolumeIncreaseFactor; return(true); }
/// <summary> /// Initializes a new instance of the <see cref="Rule" /> class from the supplied values. /// </summary> /// <param name="id"> /// An initialization value for the <see cref="P: Id" /> property. /// </param> /// <param name="name"> /// An initialization value for the <see cref="P: Name" /> property. /// </param> /// <param name="shortDescription"> /// An initialization value for the <see cref="P: ShortDescription" /> property. /// </param> /// <param name="fullDescription"> /// An initialization value for the <see cref="P: FullDescription" /> property. /// </param> /// <param name="messageFormats"> /// An initialization value for the <see cref="P: MessageFormats" /> property. /// </param> /// <param name="configuration"> /// An initialization value for the <see cref="P: Configuration" /> property. /// </param> /// <param name="defaultLevel"> /// An initialization value for the <see cref="P: DefaultLevel" /> property. /// </param> /// <param name="helpUri"> /// An initialization value for the <see cref="P: HelpUri" /> property. /// </param> /// <param name="properties"> /// An initialization value for the <see cref="P: Properties" /> property. /// </param> public Rule(string id, string name, string shortDescription, string fullDescription, IDictionary<string, string> messageFormats, RuleConfiguration configuration, ResultLevel defaultLevel, Uri helpUri, IDictionary<string, SerializedPropertyInfo> properties) { Init(id, name, shortDescription, fullDescription, messageFormats, configuration, defaultLevel, helpUri, properties); }
private void Init(string id, string name, string shortDescription, string fullDescription, IDictionary<string, string> messageFormats, RuleConfiguration configuration, ResultLevel defaultLevel, Uri helpUri, IDictionary<string, SerializedPropertyInfo> properties) { Id = id; Name = name; ShortDescription = shortDescription; FullDescription = fullDescription; if (messageFormats != null) { MessageFormats = new Dictionary<string, string>(messageFormats); } Configuration = configuration; DefaultLevel = defaultLevel; if (helpUri != null) { HelpUri = new Uri(helpUri.OriginalString, helpUri.IsAbsoluteUri ? UriKind.Absolute : UriKind.Relative); } if (properties != null) { Properties = new Dictionary<string, SerializedPropertyInfo>(properties); } }