internal View(Schema schema, string name, SqlNative definition, CheckOptions checkOptions) : base(schema, name) { columns = new PairedNodeCollection <View, ViewColumn>(this, "ViewColumns"); this.definition = definition; this.checkOptions = checkOptions; }
private void SetSiblingErrors() { TNode[] siblings = null; if (CheckOptions.HasFlag(ErrorCheckOptions.SiblingIdDuplicates)) { siblings = SelectSiblings().ToArray(); var existingIdMatch = siblings.FirstOrDefault(HasSameIdentityAs); if (existingIdMatch != null) { Error |= IdentityError.SiblingIdDuplicate; existingIdMatch.Error |= IdentityError.SiblingIdDuplicate; } } if (!CheckOptions.HasFlag(ErrorCheckOptions.SiblingAliasDuplicates)) { return; } siblings = siblings ?? SelectSiblings().ToArray(); var existingAliasMatch = siblings.FirstOrDefault(HasSameAliasAs); if (existingAliasMatch != null) { Error |= IdentityError.SiblingAliasDuplicate; existingAliasMatch.Error |= IdentityError.SiblingAliasDuplicate; } }
public string?Check(string key, Regex?regex = null, CheckOptions options = 0, string?message = null) { if (!dict.ContainsKey(key)) { if (!options.HasFlag(CheckOptions.Optional)) { errors?.Error($"Missing required column {key}", lineNumber, line); hadError = true; } return(null); } if (regex != null && !regex.IsMatch(dict[key])) { if (!options.HasFlag(CheckOptions.Warning)) { errors?.Error($"Unexpected value for {key}: '{dict[key]}'{message ?? ""}", lineNumber, line); hadError = true; } else { errors?.Warning($"Unexpected value for {key}: '{dict[key]}'{message ?? ""}", lineNumber, line); } } string value = dict[key]; if (options.HasFlag(CheckOptions.EmptyIfDash)) { value = EmptyIfDash(value); } return(value); }
static private int VerbCheck(CheckOptions opts) { string lFileName = Path.ChangeExtension(opts.XmlFileName, "xml"); Console.WriteLine("Reading and resolving xml file {0}", lFileName); ProcessInclude lResult = ProcessInclude.Factory(opts.XmlFileName, "", ""); lResult.LoadAdvanced(lFileName); return(ProcessSanityChecks(lResult.GetDocument()) ? 0 : 1); }
static public int Main(string[] args) { var t = Parser.Default.ParseArguments <CheckOptions, ErrorCodeOptions>(args) .MapResult( (CheckOptions opts) => CheckOptions.Run(opts, Console.Out), (ErrorCodeOptions opts) => ErrorCodeOptions.Run(opts), errs => Status.CommandLineError); return((int)t); }
protected IParameter addParameter(IParameter parameter, ISpectrum spectrum, CheckOptions co) { checkParameter(parameter, spectrum, co); if (parameter.HasReferenceValue) { return(parameter.ReferencedParameter); } else { return(parameter); } }
private void SetErrorsAfterAddingThis() { SetSiblingErrors(); if (CheckOptions.HasFlag(ErrorCheckOptions.CyclicIdDuplicates)) { SetCyclicIdErrors(); } if (IdentityTrackingIsTreeScope) { SetTreeScopeIdErrors(); } }
public void CanRunAsPublic() { var c = new CheckOptions(); c.CheckSchema = new List <string> { schemaFile }; c.InputSource = idsFIle; // to adjust once we fix the xml file in the other repo. var t = new StringWriter(); var ret = Run(c, t); Assert.Equal(Status.Ok, ret); }
private void btnCompileAndRun_Click(object sender, EventArgs e) { UpdateSettings(); var result = CheckOptions.Verify(Settings); if (result == null) { CompileBuildAndStart(); } else { UpdateStatusLabel("ERROR: " + result); AddOutput(result); } }
private void button1_Click(object sender, EventArgs e) { UpdateBuilderOptions(); var result = CheckOptions.Verify(Options); if (result == null) { CompileAndLaunch(); } else { UpdateStatusLabel("ERROR: " + result); AddOutput(result); } }
public string Check(string key, Regex regex = null, CheckOptions options = 0) { if (!dict.ContainsKey(key)) { if (!options.HasFlag(CheckOptions.Optional)) { if (errors != null) { errors.Error(string.Format("Missing required column {0}", key), lineNumber, line); } hadError = true; } return(null); } if (regex != null && !regex.IsMatch(dict[key])) { if (!options.HasFlag(CheckOptions.Warning)) { if (errors != null) { errors.Error(string.Format("Unexpected value for {0}: '{1}'", key, dict[key]), lineNumber, line); } hadError = true; } else { if (errors != null) { errors.Warning(string.Format("Unexpected value for {0}: '{1}'", key, dict[key]), lineNumber, line); } } } string value = dict[key]; if (options.HasFlag(CheckOptions.EmptyIfDash)) { value = EmptyIfDash(value); } return(value); }
public void DoesNotBlockFiles() { // prepare the file to delete in the end var tmp = Path.GetTempFileName(); File.Copy(idsFIle, tmp, true); var c = new CheckOptions(); c.CheckSchema = new List <string> { schemaFile }; c.InputSource = tmp; var t = new StringWriter(); var ret = Run(c, t); Assert.Equal(Status.Ok, ret); File.Delete(tmp); }
private void Run(CheckOptions o) { _exit = false; Log.Debug("Mode: check"); // Check for outdated packages Task.Run(() => { var pcks = Choco.OutdatedPackages(); Log.Debug("Choco found {PackageCount} outdated packages", pcks.Count); if (pcks.Count > 0) { try { ShowOutdatedNotification(pcks.Count, string.Join(", ", pcks.Select(p => p.Name))); } catch (Exception e) { Log.Error(e, "Error sending notification"); } } }); }
private void UpdateErrorsBeforeDetachingThis() { if (CheckOptions.HasFlag(ErrorCheckOptions.CyclicIdDuplicates)) { UpdateCyclicIdErrorsBeforeDetachingThis(); } if (CheckOptions.HasFlag(ErrorCheckOptions.SiblingAliasDuplicates) && Error.HasFlag(IdentityError.SiblingAliasDuplicate)) { UpdateSiblingAliasErrorsBeforeDetachingThis(); } if (CheckOptions.HasFlag(ErrorCheckOptions.SiblingIdDuplicates) && Error.HasFlag(IdentityError.SiblingIdDuplicate)) { UpdateSiblingIdErrorsBeforeDetachingThis(); } if (IdentityTrackingIsTreeScope) { UpdateTreeScopeIdErrorsBeforeDetachingThis(); } }
private void CheckPeopleSet(CheckOptions checkOptions = CheckOptions.None) { Assert.That(_httpPostEntries.Single().Endpoint, Is.EqualTo(EngageUrl)); var msg = ParseMessageData(_httpPostEntries.Single().Data); CheckPeopleSetJsonMessage(msg, checkOptions); }
private static void Main(string[] args) { var options = new CheckOptions(); bool showOptions = false; string showMsg = null; var optionSet = new OptionSet { { "help", "Show this help.", v => showOptions = v != null }, { "assembly=", "Assembly to check.", v => options.Assembly = v }, { "method=", "Method name (if you want to check only it).", v => options.Method = v }, { "debug=", "Show debug information", v => options.ShowDebug = v != null } }; try { optionSet.Parse(args); } catch (OptionException e) { showOptions = true; showMsg = e.Message; } if (showOptions) { Console.WriteLine("cccheck"); Console.WriteLine(); Console.WriteLine("Options:"); optionSet.WriteOptionDescriptions(Console.Out); Console.WriteLine(); if (showMsg != null) { Console.WriteLine(showMsg); Console.WriteLine(); } return; } CheckResults results = Checker.Check(options); Console.WriteLine(); if (results.AnyErrors) { foreach (string error in results.Errors) { Console.WriteLine("Error: " + error); } } if (results.AnyWarnings) { foreach (string warning in results.Warnings) { Console.WriteLine("Warning: " + warning); } } if (results.Results != null) { foreach (var methodValidationResults in results.Results) { string methodName = methodValidationResults.Key; Console.WriteLine("Method: " + methodName); foreach (string result in methodValidationResults.Value) { Console.WriteLine(" " + result); } Console.WriteLine(); } } Console.WriteLine(); Console.WriteLine("*** done ***"); }
private void CheckTrackDictionary(IDictionary<string, object> dic, CheckOptions checkOptions = CheckOptions.None) { Assert.That(dic.Count, Is.EqualTo(2)); Assert.That(dic[MixpanelProperty.TrackEvent], Is.EqualTo(Event)); Assert.That(dic[MixpanelProperty.TrackProperties], Is.TypeOf<Dictionary<string, object>>()); var props = (Dictionary<string, object>)dic[MixpanelProperty.TrackProperties]; Assert.That(props.Count, Is.EqualTo(GetPropsCount(checkOptions, normalCount: 6, superPropsCount: 8))); Assert.That(props[MixpanelProperty.TrackToken], Is.EqualTo(Token)); Assert.That(props[MixpanelProperty.TrackDistinctId], Is.EqualTo(GetDistinctId(checkOptions))); Assert.That(props[MixpanelProperty.TrackIp], Is.EqualTo(Ip)); Assert.That(props[MixpanelProperty.TrackTime], Is.EqualTo(TimeUnix)); Assert.That(props[StringPropertyName], Is.EqualTo(StringPropertyValue)); Assert.That(props[DecimalPropertyName], Is.EqualTo(DecimalPropertyValue)); if (checkOptions.HasFlag(CheckOptions.SuperPropsSet)) { Assert.That(props[DecimalSuperPropertyName], Is.EqualTo(DecimalSuperPropertyValue)); Assert.That(props[StringSuperPropertyName], Is.EqualTo(StringSuperPropertyValue)); } }
private void CheckAlias(CheckOptions checkOptions = CheckOptions.None) { Assert.That(_httpPostEntries.Single().Endpoint, Is.EqualTo(TrackUrl)); var msg = ParseMessageData(_httpPostEntries.Single().Data); Assert.That(msg.Count, Is.EqualTo(2)); Assert.That(msg[MixpanelProperty.TrackEvent].Value<string>(), Is.EqualTo(MixpanelProperty.TrackCreateAlias)); var props = (JObject)msg[MixpanelProperty.TrackProperties]; Assert.That(props.Count, Is.EqualTo(3)); Assert.That(props[MixpanelProperty.TrackToken].Value<string>(), Is.EqualTo(Token)); Assert.That( props[MixpanelProperty.TrackDistinctId].Value<string>(), Is.EqualTo(GetDistinctId(checkOptions))); Assert.That(props[MixpanelProperty.TrackAlias].Value<string>(), Is.EqualTo(Alias)); }
private int GetPropsCount(CheckOptions checkOptions, int normalCount, int superPropsCount) { if (checkOptions.HasFlag(CheckOptions.SuperPropsSet)) { return 8; } return 6; }
private void CheckTrack(CheckOptions checkOptions = CheckOptions.None) { Assert.That(_httpPostEntries.Single().Endpoint, Is.EqualTo(TrackUrl)); JObject msg = ParseMessageData(_httpPostEntries.Single().Data); CheckTrackJsonMessage(msg, checkOptions); }
public string Check(IEnumerable<string> keys, Regex regex = null, CheckOptions options = 0) { return Check(keys, value => regex == null || regex.IsMatch(value), options); }
private void CheckPeopleTrackCharge(CheckOptions checkOptions = CheckOptions.None) { Assert.That(_httpPostEntries.Single().Endpoint, Is.EqualTo(EngageUrl)); var msg = ParseMessageData(_httpPostEntries.Single().Data); Assert.That(msg.Count, Is.EqualTo(3)); Assert.That(msg[MixpanelProperty.PeopleToken].Value<string>(), Is.EqualTo(Token)); Assert.That( msg[MixpanelProperty.PeopleDistinctId].Value<string>(), Is.EqualTo(GetDistinctId(checkOptions))); var append = (JObject)msg[MixpanelProperty.PeopleAppend]; Assert.That(append.Count, Is.EqualTo(1)); var transactions = (JObject)append[MixpanelProperty.PeopleTransactions]; Assert.That(transactions.Count, Is.EqualTo(2)); Assert.That(transactions[MixpanelProperty.PeopleTime].Value<string>(), Is.EqualTo(TimeFormat)); Assert.That(transactions[MixpanelProperty.PeopleAmount].Value<decimal>(), Is.EqualTo(DecimalPropertyValue)); }
public IEnumerable <Result> Check(IEnumerable <Rule> rules, CheckOptions checkOptions, IEnumerable <string> contexts, IEnumerable checkables) { if (rules == null) { throw new ArgumentNullException("rules"); } foreach (object checkable in checkables) { var objectTypeId = GetObjectTypeId(checkable); // break things down to the rules for this object type IEnumerable <Rule> rulesToCheck = from r in rules where r.ObjectTypeId == objectTypeId select r; if ((checkOptions & CheckOptions.IgnoreContexts) == 0) { // contexts are relevant, so filter down the list of rules if (contexts == null || contexts.Count( ) == 0) { // filter down the list to those rules that don't have contexts assigned rulesToCheck = from r in rulesToCheck where (r.Contexts == null || r.Contexts.Count( ) == 0) select r; } else { // filter down the list to those rules that have any of the contexts // assigned that we're supposed to check rulesToCheck = from r in rulesToCheck where r.Contexts != null && r.Contexts.Intersect(contexts).Count( ) > 0 select r; } } foreach (var rule in rulesToCheck) { var results = rule.Check(checkable); foreach (var result in results) { // I'm not really happy with this check - shouldn't I *always* // get a result? I'm going to take it out and see what happens. //if (result != null) { if ((result.Status != ResultStatus.Pass) || ((checkOptions & CheckOptions.IncludePassResults) != 0)) { yield return(result); } // Hm, is this a bug... // it doesn't seem to make sense to have the check for IncludePassResults // in here - the first two lines say "if this is not a pass result and // we've been asked to stop after the first non-pass result" - that seems // to be sufficient reason to stop yielding now, regardless of whether // we're including pass results or not. //if ((result.Status != ResultStatus.Pass) && // ((checkOptions & CheckOptions.StopAfterFirstNonPass) != 0) && // ((checkOptions & CheckOptions.IncludePassResults) == 0)) if ((result.Status != ResultStatus.Pass) && ((checkOptions & CheckOptions.StopAfterFirstNonPass) != 0) /*&& * ((checkOptions & CheckOptions.IncludePassResults) == 0)*/ ) { yield break; } //} } } } }
public string Check(string key, Regex regex, CheckOptions options = 0) { if (!regex.IsMatch(dict[key])) { if (!options.HasFlag(CheckOptions.Warning)) { if (errors != null) errors.Error(String.Format("Unexpected value for {0}: '{1}'", key, dict[key]), lineNumber, line); hadError = true; } else { if (errors != null) errors.Warning(String.Format("Unexpected value for {0}: '{1}'", key, dict[key]), lineNumber, line); } } string value = dict[key]; if (options.HasFlag(CheckOptions.EmptyIfDash)) value = EmptyIfDash(value); return value; }
public IEnumerable <Result> Check(CheckOptions checkOptions, params object[] checkables) { return(Check(Rules, checkOptions, (IEnumerable <string>)null, (IEnumerable)checkables)); }
public IEnumerable <Result> Check(CheckOptions checkOptions, string context, params object[] checkables) { return(Check(Rules, checkOptions, new[] { context }, (IEnumerable)checkables)); }
// variations without explicit rules public IEnumerable <Result> Check(CheckOptions checkOptions, IEnumerable <string> contexts, IEnumerable checkables) { return(Check(Rules, checkOptions, contexts, (IEnumerable)checkables)); }
public IEnumerable <Result> Check(IEnumerable <Rule> rules, CheckOptions checkOptions, IEnumerable <string> contexts, params object[] checkables) { return(Check(rules, checkOptions, contexts, (IEnumerable)checkables)); }
public string Check(IEnumerable<string> keys, Func<string, bool> validate, CheckOptions options = 0) { foreach (var key in keys) { if (!dict.ContainsKey(key)) continue; string value = dict[key]; if (options.HasFlag(CheckOptions.EmptyIfDash)) value = EmptyIfDash(value); if (!validate(value)) { if (!options.HasFlag(CheckOptions.Warning)) { if (errors != null) errors.Error(String.Format("Unexpected value for {0}: '{1}'", key, value), lineNumber, line); hadError = true; } else { if (errors != null) errors.Warning(String.Format("Unexpected value for {0}: '{1}'", key, value), lineNumber, line); } } return value; } return null; }
private void CheckPeopleDeleteDictionary( IDictionary<string, object> dic, CheckOptions checkOptions = CheckOptions.None) { Assert.That(dic.Count, Is.EqualTo(3)); Assert.That(dic[MixpanelProperty.PeopleToken], Is.EqualTo(Token)); Assert.That( dic[MixpanelProperty.PeopleDistinctId], Is.EqualTo(GetDistinctId(checkOptions))); Assert.That(dic[MixpanelProperty.PeopleDelete], Is.Empty); }
public string?Check(ICollection <string> keys, Regex?regex = null, CheckOptions options = 0, string?message = null) => Check(keys, value => regex?.IsMatch(value) ?? true, options, message);
private void CheckPeopleTrackChargeDictionary( IDictionary<string, object> dic, CheckOptions checkOptions = CheckOptions.None) { Assert.That(dic.Count, Is.EqualTo(3)); Assert.That(dic[MixpanelProperty.PeopleToken], Is.EqualTo(Token)); Assert.That( dic[MixpanelProperty.PeopleDistinctId], Is.EqualTo(GetDistinctId(checkOptions))); Assert.That(dic[MixpanelProperty.PeopleAppend], Is.TypeOf<Dictionary<string, object>>()); var append = (Dictionary<string, object>)dic[MixpanelProperty.PeopleAppend]; Assert.That(append.Count, Is.EqualTo(1)); Assert.That(append[MixpanelProperty.PeopleTransactions], Is.TypeOf<Dictionary<string, object>>()); var transactions = (Dictionary<string, object>)append[MixpanelProperty.PeopleTransactions]; Assert.That(transactions.Count, Is.EqualTo(2)); Assert.That(transactions[MixpanelProperty.PeopleTime], Is.EqualTo(TimeFormat)); Assert.That(transactions[MixpanelProperty.PeopleAmount], Is.EqualTo(DecimalPropertyValue)); }
//public virtual void checkParameters(IParameterSet parameters, CheckOptions options) { public virtual void checkParameter(IParameter parameter, ISpectrum spectrum, CheckOptions options) { //foreach (IParameter parameter in parameters) { int groupKind; if (parameter.Parent.GetType() == typeof(ContributedGroup)) { groupKind = ((ContributedGroup)parameter.Parent).Definition.kind; } else { groupKind = ((IComponents)((IComponent)parameter.Parent).Parent).Parent.Definition.kind; } foreach (ParameterDefaultPattern pattern in _defaultPatterns) { if (pattern.name.Equals(parameter.Definition.Name) && pattern.groupKind == groupKind) { if ((parameter.Status & ParameterStatus.Free) > 0) { //default value if ((options & CheckOptions.SetDefaultValues) > 0) { if (pattern.positive) { parameter.Value = Math.Abs(parameter.Value); } if (pattern.defaultValue != Double.NaN) { if ((pattern.min > parameter.Value) || (pattern.max < parameter.Value)) { parameter.Value = pattern.defaultValue; } } } //delta if ((options & CheckOptions.RefreshDelta) > 0 && (!(parameter.HasReferenceValue && (options & CheckOptions.NoReferencedDelta) > 0) || (parameter.Status & ParameterStatus.Binding) > 0)) { if (parameter.Definition.Name.ToLower() == "shift") { parameter.Delta = spectrum.Constants[0] * 0.0001; //constants[0] = bs IComponent comp = (IComponent)parameter.Parent; if (((IComponents)comp.Parent).IndexOf(comp) == 0) { parameter.Delta *= 10; } } else { parameter.Delta = parameter.Value * pattern.multi + pattern.value; if (parameter.Definition.Name.ToLower().IndexOf("tau") != -1) { parameter.Delta += spectrum.Constants[0] * 0.005; } } if (parameter.ReferencedValues > 1) { parameter.Delta *= 5 * Math.Sqrt(parameter.ReferencedValues); } //if ((parameter.Status & ParameterStatus.Common) == ParameterStatus.Common) // parameter.Delta *= 10; } } else { parameter.Delta = parameter.Value * 5e-4; } break; } } //} }
private string GetDistinctId(CheckOptions checkOptions) { bool distinctIdSetFromSuperProps = checkOptions.HasFlag(CheckOptions.SuperPropsDistinctIdSet) && !checkOptions.HasFlag(CheckOptions.DistinctIdSet); if (distinctIdSetFromSuperProps) { return SuperDistinctId; } return DistinctId; }
public string Check(string key, Regex regex = null, CheckOptions options = 0) { if (!dict.ContainsKey(key)) { if (!options.HasFlag(CheckOptions.Optional)) { if (errors != null) errors.Error(string.Format("Missing required column {0}", key), lineNumber, line); hadError = true; } return null; } if (regex != null && !regex.IsMatch(dict[key])) { if (!options.HasFlag(CheckOptions.Warning)) { if (errors != null) errors.Error(string.Format("Unexpected value for {0}: '{1}'", key, dict[key]), lineNumber, line); hadError = true; } else { if (errors != null) errors.Warning(string.Format("Unexpected value for {0}: '{1}'", key, dict[key]), lineNumber, line); } } string value = dict[key]; if (options.HasFlag(CheckOptions.EmptyIfDash)) value = EmptyIfDash(value); return value; }
private void CheckTrackJsonMessage(JObject msg, CheckOptions checkOptions = CheckOptions.None) { Assert.That(msg.Count, Is.EqualTo(2)); Assert.That(msg[MixpanelProperty.TrackEvent].Value<string>(), Is.EqualTo(Event)); var props = (JObject)msg[MixpanelProperty.TrackProperties]; Assert.That(props.Count, Is.EqualTo(GetPropsCount(checkOptions, normalCount: 6, superPropsCount: 8))); Assert.That(props[MixpanelProperty.TrackToken].Value<string>(), Is.EqualTo(Token)); Assert.That(props[MixpanelProperty.TrackDistinctId].Value<string>(), Is.EqualTo(GetDistinctId(checkOptions))); Assert.That(props[MixpanelProperty.TrackIp].Value<string>(), Is.EqualTo(Ip)); Assert.That(props[MixpanelProperty.TrackTime].Value<long>(), Is.EqualTo(TimeUnix)); Assert.That(props[StringPropertyName].Value<string>(), Is.EqualTo(StringPropertyValue)); Assert.That(props[DecimalPropertyName].Value<decimal>(), Is.EqualTo(DecimalPropertyValue)); if (checkOptions.HasFlag(CheckOptions.SuperPropsSet)) { Assert.That(props[DecimalSuperPropertyName].Value<decimal>(), Is.EqualTo(DecimalSuperPropertyValue)); Assert.That(props[StringSuperPropertyName].Value<string>(), Is.EqualTo(StringSuperPropertyValue)); } }
public virtual List <IParameter> getParameters(ParameterStatus status, bool[] includeFlags, CheckOptions co) { List <IParameter> result = new List <IParameter>(); foreach (ISpectrum spectrum in Spectra) { result.AddRange(Model.getParameters(status, spectrum, includeFlags, co)); } return(result); }
private void CheckTrackMessage(MixpanelMessage msg, CheckOptions checkOptions = CheckOptions.None) { Assert.That(msg.Kind, Is.EqualTo(MessageKind.Track)); CheckTrackDictionary(msg.Data, checkOptions); }
private static void CheckAndDownload() { // call this method in a new thread // Checks for internet connection try { using (var client = new WebClient()) client.OpenRead(new Uri("https://github.com")); } catch { return; } Directory.CreateDirectory(Path.Combine(Application.StartupPath, "./SUCache")); // Creates dir for update cache var options = new CheckOptions { CheckOnly = true, CurrentVersion = _localLatestVersion, DownloadDir = Path.Combine(Application.StartupPath, "SUCache"), IncludePrerelease = true }; // Checks for update _updateAvailable = Updater.Run(options) == 200; if (!_updateAvailable) { return; } // Download options.CheckOnly = false; _updateDownloaded = Updater.Run(options) == 0; // Gets the latest downloaded version var downloadedPkgInfo = Directory.GetFiles(Path.Combine(Application.StartupPath, "SUCache")) .Where(file => Path.GetExtension(file) == ".json") .Where(file => Version.IsValidRawVersionString(Path.GetFileNameWithoutExtension(file) .Replace("package_info_", string.Empty))) .ToList(); _serverLatestVersion = new Version(Path.GetFileNameWithoutExtension(downloadedPkgInfo[0]) .Replace("package_info_", string.Empty)); for (var i = 1; i < downloadedPkgInfo.Count; i++) { var ver = new Version[] { new Version(Path.GetFileNameWithoutExtension(downloadedPkgInfo[i - 1]) .Replace("package_info_", "")), new Version(Path.GetFileNameWithoutExtension(downloadedPkgInfo[i]) .Replace("package_info_", "")) }; _serverLatestVersion = ver[1].IsNewerThan(ver[0]) ? ver[1] : _serverLatestVersion; } if (!_updateDownloaded) { return; // Exits if not downloaded } // Install update var installOpts = new InstallOptions { InstallDir = Application.StartupPath, PackagePath = Path.Combine(Application.StartupPath, "SUCache", $"package_info_{_serverLatestVersion.GetVersionString()}.json"), RemoveAfterInstall = false }; Updater.Run(installOpts); }
private void CheckAliasDictionary(IDictionary<string, object> dic, CheckOptions checkOptions = CheckOptions.None) { Assert.That(dic.Count, Is.EqualTo(2)); Assert.That(dic[MixpanelProperty.TrackEvent], Is.EqualTo(MixpanelProperty.TrackCreateAlias)); Assert.That(dic[MixpanelProperty.TrackProperties], Is.TypeOf<Dictionary<string, object>>()); var props = (Dictionary<string, object>)dic[MixpanelProperty.TrackProperties]; Assert.That(props.Count, Is.EqualTo(3)); Assert.That(props[MixpanelProperty.TrackToken], Is.EqualTo(Token)); Assert.That(props[MixpanelProperty.TrackDistinctId], Is.EqualTo(GetDistinctId(checkOptions))); Assert.That(props[MixpanelProperty.TrackAlias], Is.EqualTo(Alias)); }
//public virtual List<IParameter> getParameters(ParameterStatus status, IParameterSet parameters, bool[] includeFlags) { public virtual IEnumerable <IParameter> getParameters(ParameterStatus status, ISpectrum spectrum, bool[] includeFlags, CheckOptions co) { //List<IParameter> result = new List<IParameter>(); bool includeInts = includeFlags[0]; bool includeSourceContrib = includeFlags[1]; bool promptOnly = includeFlags[2]; //result.Add(null); IGroup group; //foreach (IGroup group in parameters) { int cid, pid; for (int gr = 1; gr < spectrum.Parameters.GroupCount; gr++) { group = spectrum.Parameters[gr]; if (promptOnly && group.Definition.kind != 3) { continue; } //foreach (IComponent component in group.Components) { for (cid = 0; cid < group.Components.Size; cid++) { //foreach (IParameter parameter in component) { for (pid = 0; pid < group.Components[cid].Size; pid++) { if (pid == 0 && cid == 0) { continue; } if ((group.Components[cid][pid].Definition.Properties & ParameterProperties.Unsearchable) == ParameterProperties.Unsearchable) { continue; } if (((group.Components[cid][pid].Status & status) == status) && !((group.Components[cid][pid].Definition.Name == "int") && (group.Components[cid][pid] == group.Components[0]))) { if (!includeInts && (group.Components[cid][pid].Definition.Name == "int") && !(group.Definition.kind == 3) && //prompt intensities are always put into Search parameters !(group.Components[cid][pid].Definition.Name == "int" && (status & ParameterStatus.Common) == ParameterStatus.Common)) //common intensities are also always put into search { continue; } switch (group.Definition.kind) { case 4: //ranges if (includeInts && (group.Components[cid][pid].Definition.Name == "background") && !group.Components[cid][pid].HasReferenceValue) { yield return(addParameter(group.Components[cid][pid], spectrum, co)); } break; default: yield return(addParameter(group.Components[cid][pid], spectrum, co)); //if (group.Definition.kind == 3 && cid > 0 && pid == 2) // group.Components[cid][pid].Delta /= 10; break; } } } } if (((group.Definition.Type & GroupType.Contributet) == GroupType.Contributet) && ((group.Definition.Type & GroupType.CalcContribution) != GroupType.CalcContribution) && (group.Components.Size > 0)) { IParameter contribution = ((ContributedGroup)group).contribution; if ((contribution.Status & status) == status) { switch (group.Definition.kind) { /*sample*/ case 1: yield return(addParameter(contribution, spectrum, co)); break; /*source*/ case 2: if (!((contribution.Status & ParameterStatus.Fixed) == ParameterStatus.Fixed)) { if (includeInts || (includeSourceContrib && ((contribution.Status & ParameterStatus.Common)) == ParameterStatus.Common)) { yield return(addParameter(contribution, spectrum, co)); } } break; } } } } }
private void CheckPeopleSetJsonMessage(JObject msg, CheckOptions checkOptions = CheckOptions.None) { Assert.That(msg.Count, Is.EqualTo(6)); Assert.That(msg[MixpanelProperty.PeopleToken].Value<string>(), Is.EqualTo(Token)); Assert.That( msg[MixpanelProperty.PeopleDistinctId].Value<string>(), Is.EqualTo(GetDistinctId(checkOptions))); Assert.That(msg[MixpanelProperty.PeopleIp].Value<string>(), Is.EqualTo(Ip)); Assert.That(msg[MixpanelProperty.PeopleTime].Value<long>(), Is.EqualTo(TimeUnix)); Assert.That(msg[MixpanelProperty.PeopleIgnoreTime].Value<bool>(), Is.EqualTo(IgnoreTime)); var set = (JObject)msg[MixpanelProperty.PeopleSet]; Assert.That(set.Count, Is.EqualTo(8)); Assert.That(set[MixpanelProperty.PeopleFirstName].Value<string>(), Is.EqualTo(FirstName)); Assert.That(set[MixpanelProperty.PeopleLastName].Value<string>(), Is.EqualTo(LastName)); Assert.That(set[MixpanelProperty.PeopleName].Value<string>(), Is.EqualTo(Name)); Assert.That(ToDateTimeString(set[MixpanelProperty.PeopleCreated]), Is.EqualTo(CreatedFormat)); Assert.That(set[MixpanelProperty.PeopleEmail].Value<string>(), Is.EqualTo(Email)); Assert.That(set[MixpanelProperty.PeoplePhone].Value<string>(), Is.EqualTo(Phone)); Assert.That(set[StringPropertyName].Value<string>(), Is.EqualTo(StringPropertyValue)); Assert.That(set[DecimalPropertyName].Value<decimal>(), Is.EqualTo(DecimalPropertyValue)); }
public string Check(ICollection<string> keys, Func<string, bool> validate, CheckOptions options = 0) { foreach (var key in keys) { if (!dict.ContainsKey(key)) continue; string value = dict[key]; if (options.HasFlag(CheckOptions.EmptyIfDash)) value = EmptyIfDash(value); if (!validate(value)) { if (!options.HasFlag(CheckOptions.Warning)) { if (errors != null) errors.Error(string.Format("Unexpected value for {0}: '{1}'", key, value), lineNumber, line); hadError = true; } else { if (errors != null) errors.Warning(string.Format("Unexpected value for {0}: '{1}'", key, value), lineNumber, line); } } return value; } if (!options.HasFlag(CheckOptions.Optional)) { if (errors != null) errors.Error(string.Format("Missing required column {0}", string.Join("/", keys)), lineNumber, line); hadError = true; } return null; }
public string Check(ICollection <string> keys, Regex regex = null, CheckOptions options = 0) { return(Check(keys, value => regex?.IsMatch(value) ?? true, options)); }
// variations with all parameters public IEnumerable <Result> Check(IEnumerable <Rule> rules, CheckOptions checkOptions, string context, IEnumerable checkables) { return(Check(rules, checkOptions, new[] { context }, (IEnumerable)checkables)); }
public string Check(ICollection <string> keys, Func <string, bool> validate, CheckOptions options = 0) { foreach (var key in keys) { if (!dict.ContainsKey(key)) { continue; } string value = dict[key]; if (options.HasFlag(CheckOptions.EmptyIfDash)) { value = EmptyIfDash(value); } if (!validate(value)) { if (!options.HasFlag(CheckOptions.Warning)) { if (errors != null) { errors.Error(string.Format("Unexpected value for {0}: '{1}'", key, value), lineNumber, line); } hadError = true; } else { if (errors != null) { errors.Warning(string.Format("Unexpected value for {0}: '{1}'", key, value), lineNumber, line); } } } return(value); } if (!options.HasFlag(CheckOptions.Optional)) { if (errors != null) { errors.Error(string.Format("Missing required column {0}", string.Join("/", keys)), lineNumber, line); } hadError = true; } return(null); }
private void CheckPeopleDelete(CheckOptions checkOptions = CheckOptions.None) { Assert.That(_httpPostEntries.Single().Endpoint, Is.EqualTo(EngageUrl)); var msg = ParseMessageData(_httpPostEntries.Single().Data); Assert.That(msg.Count, Is.EqualTo(3)); Assert.That(msg[MixpanelProperty.PeopleToken].Value<string>(), Is.EqualTo(Token)); Assert.That( msg[MixpanelProperty.PeopleDistinctId].Value<string>(), Is.EqualTo(GetDistinctId(checkOptions))); Assert.That(msg[MixpanelProperty.PeopleDelete].Value<string>(), Is.Empty); }
public string?Check(ICollection <string> keys, Func <string, bool> validate, CheckOptions options = 0, string?message = null) { foreach (var key in keys) { if (!dict.ContainsKey(key)) { continue; } string value = dict[key]; if (options.HasFlag(CheckOptions.EmptyIfDash)) { value = EmptyIfDash(value); } if (!validate(value)) { if (!options.HasFlag(CheckOptions.Warning)) { errors?.Error($"Unexpected value for {key}: '{value}'{message ?? ""}", lineNumber, line); hadError = true; } else { errors?.Warning($"Unexpected value for {key}: '{value}'{message ?? ""}", lineNumber, line); } } return(value); } if (!options.HasFlag(CheckOptions.Optional)) { errors?.Error($"Missing required column {string.Join("/", keys)}", lineNumber, line); hadError = true; } return(null); }
public static int Run(CheckOptions options) => StartUpdater(options.GetCmdArgs());