protected override void Run()
        {
            var invalid = Path.GetInvalidFileNameChars();

            if (Name.Any(c => invalid.Contains(c)))
            {
                throw new PSArgumentException($"The file name '{Name}' contains invalid characters");
            }

            var organizer = new SnippetOrganizer(Options, FileAssociations);
            var package   = organizer.CreateCustomWorkspace(Name, Tags, Languages, OrderBy, SortDirection, HideMetaFiles);

            package.Publish(Options, Overwrite);

            var manifestGenerator = new ManifestGenerator();

            manifestGenerator.Add(package);
            var manifest = manifestGenerator.ToManifest(OrderBy, SortDirection);

            manifest.Publish(Options.WorkspacePath);

            if (Sync || Options.AutoSync)
            {
                CommitAndPush("New custom workspace");
            }
        }
Example #2
0
        /// <summary>
        /// Validates this setting
        /// </summary>
        public override void Validate()
        {
            ValidationException ex = null;

            if (Name == null)
            {
                ex = new ValidationException("Setting name can't be null.");
            }
            else if (Name.Any(m => Tools.ForbiddenNameChar.Contains(m)))
            {
                ex = new ValidationException("Forbidden character in setting name");
            }
            else if (Value == null)
            {
                ex = new ValidationException("Setting value can't be null.");
            }
            else if (Value.Any(m => Tools.ForbiddenValueChar.Contains(m)))
            {
                ex = new ValidationException("Forbidden character in setting value");
            }
            if (ex != null)
            {
                ex.Data.Add("Setting.Name", Name);
                ex.Data.Add("Setting.Value", Value);
                throw ex;
            }
        }
Example #3
0
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (Name.Any(c => char.IsDigit(c)))
     {
         yield return(new ValidationResult("Genre Name Cannot Contain numbers"));
     }
 }
        private void SetName()
        {
            if (Photos == null)
            {
                return;
            }

            if (String.IsNullOrEmpty(Name))
            {
                Name = "";
            }

            if (Name.Any(c => Path.GetInvalidFileNameChars().Contains(c)))
            {
                Messenger.Default.Send(new ShowMessageBoxMessage("Nanana! Folgende Zeichen darfst du nicht für den Namen benutzen:" + Environment.NewLine + "\" < > | : * ? \\ /", true));
                return;
            }

            foreach (var photo in Photos)
            {
                if (photo.IsSelected)
                {
                    photo.Name = Name;
                }
            }

            SelectNextPhoto();
        }
Example #5
0
 public void CreatePushButtonData()
 {
     if (Name.Any() && TextOnRibbon.Any() && _thisAssemblyPath.Any() && ClassName.Any())
     {
         _pushButtonData = new PushButtonData(Name, TextOnRibbon, _thisAssemblyPath, ClassName);
     }
 }
Example #6
0
        /// <summary>
        /// Generates the pivot table
        /// </summary>
        public DataTable GenerateTable()
        {
            if (Name.Any(c => c == ' '))
            {
                throw new ApsimXException(this, $"Invalid name: {Name}\nNames cannot contain spaces.");
            }

            // Find the data
            var storage = FindInScope <IDataStore>() ?? datastore;
            var report  = storage.Reader.GetData(Parent.Name);

            // Check sensibility
            if (report is null || Row is null || Column is null || Value is null || Aggregator is null)
            {
                return(null);
            }
            if (report.Columns.Count == 0)
            {
                return(null);
            }

            // Set up date handling
            bool isDate     = report.Columns[Column].DataType == typeof(DateTime);
            var  cs_format  = Time == "Year" ? "yyyy-01-01" : Time == "Month" ? "yyyy-MM-01" : "yyyy-MM-dd";
            var  sql_format = Time == "Year" ? "%Y-01-01" : Time == "Month" ? "%Y-%m-01" : "%Y-%m-%d";

            string test = isDate
                ? Time == "Day" ? $"[{Column}]" : $"datetime(strftime('{sql_format}', [{Column}]))"
                : $"[{Column}]";

            // Set up the columns in the pivot
            var cols = report
                       .AsEnumerable()
                       .Select(r => isDate ? ((DateTime)r[Column]).ToString(cs_format) : r[Column])
                       .Distinct()
                       .Select(o => $"{Aggregator}(CASE WHEN {test} == '{o}' THEN {Value} ELSE NULL END) AS '{o} {Value}'");

            // Set up the rows in the pivot
            var rows = $"[{Row}]";

            if (report.Columns[Row].DataType == typeof(DateTime))
            {
                rows = Time == "Day" ? $"[{Row}]" : $"datetime(strftime('{sql_format}', [{Row}]))";
            }

            // Construct the SQL statement
            var builder = new StringBuilder();

            builder.AppendLine($"SELECT {rows} AS {Row},");
            builder.AppendLine(string.Join(",\n", cols));
            builder.AppendLine($"FROM [{Parent.Name}] GROUP BY {rows}");

            // Execute the query
            SQL = builder.ToString();
            storage.Reader.ExecuteSql(SQL);
            storage.AddView($"{Name}", SQL);
            return(storage.Reader.GetDataUsingSql(SQL));
        }
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            //var myService = validationContext.GetRequiredService<IMyService>();

            if (!string.IsNullOrWhiteSpace(Name) && Name.Any(c => char.IsNumber(c)))
            {
                yield return(new ValidationResult("The name cannot contain numbers!", new[] { nameof(Name) }));
            }
        }
Example #8
0
        public override bool ProcessRecordAsync()
        {
            ValidateVersion(RequiredVersion);
            ValidateVersion(MinimumVersion);
            ValidateVersion(MaximumVersion);

            if (!AdminPrivilege.IsElevated && Scope.EqualsIgnoreCase("AllUsers"))
            {
                var pkgMgmtService = PackageManagementService as PackageManagementService;
                if (pkgMgmtService != null)
                {
                    Error(Constants.Errors.InstallRequiresCurrentUserScopeParameterForNonAdminUser, pkgMgmtService.SystemAssemblyLocation, pkgMgmtService.UserAssemblyLocation);
                }
                return(false);
            }

            if (!string.IsNullOrWhiteSpace(RequiredVersion))
            {
                if ((!string.IsNullOrWhiteSpace(MaximumVersion)) || (!string.IsNullOrWhiteSpace(MinimumVersion)))
                {
                    Error(Constants.Errors.VersionRangeAndRequiredVersionCannotBeSpecifiedTogether);
                    return(false);
                }
            }
            //Error out for the case where multiple provider names with any version specififed
            if (Name.IsNullOrEmpty())
            {
                if ((!string.IsNullOrWhiteSpace(RequiredVersion)) || (!string.IsNullOrWhiteSpace(MinimumVersion)) || (!string.IsNullOrWhiteSpace(MaximumVersion)))
                {
                    Error(Constants.Errors.MultipleNamesWithVersionNotAllowed);
                    return(false);
                }
            }
            else
            {
                if (Name.Any(each => each.ContainsWildcards()))
                {
                    Error(Constants.Errors.WildCardCharsAreNotSupported, Name.JoinWithComma());
                    return(false);
                }
                if ((Name.Length > 1) &&
                    ((!string.IsNullOrWhiteSpace(RequiredVersion)) || (!string.IsNullOrWhiteSpace(MinimumVersion)) || (!string.IsNullOrWhiteSpace(MaximumVersion))))
                {
                    Error(Constants.Errors.MultipleNamesWithVersionNotAllowed);
                    return(false);
                }
            }

            if (IsPackageByObject)
            {
                return(InstallPackages(InputObject));
            }

            // otherwise, just do the search right now.
            return(base.ProcessRecordAsync());
        }
        protected override void BeginProcessing()
        {
            Language = null;
            base.BeginProcessing();

            if (Name != null && Name.Any())
            {
                NameWildcardPatterns =
                    Name.Select(
                        name =>
                        new WildcardPattern(name, WildcardOptions.IgnoreCase | WildcardOptions.CultureInvariant))
                    .ToList();
            }
        }
Example #10
0
        public List <string> Validate()
        {
            var errors = new List <string>();

            if (Name.Any(char.IsLower))
            {
                errors.Add("Name should contain only Uppercase Letter ,numbers and symbols");
            }
            if (DistanceToEarth <= 4.369F)
            {
                errors.Add("The distance to earth must be at least 4.369 light years away( Alpha Centauri )");
            }
            return(errors);
        }
Example #11
0
        private bool ValidarNomeUsuario()
        {
            if (string.IsNullOrEmpty(Name) || string.IsNullOrWhiteSpace(Name) || Name.StartsWith(" ") || Name.EndsWith(" "))
            {
                return(false);
            }

            if (Name.Any(char.IsDigit) || Name.Any(char.IsSymbol) || Name.Any(char.IsNumber))
            {
                return(false);
            }

            return(true);
        }
Example #12
0
        private bool ValidateName()
        {
            if (string.IsNullOrEmpty(Name))
            {
                return(false);
            }

            if (Name.Any(x => !char.IsLetter(x)))
            {
                return(false);
            }

            return(true);
        }
Example #13
0
        IEnumerable <IPackageInfo> GetPackagesToLock(IPackageDescriptor descriptor, IEnumerable <IPackageInfo> allPackages)
        {
            var currentPackages = allPackages;
            var names           = Name.Any() ? Name : descriptor.Dependencies.Select(x => x.Name);

            if (names.Any())
            {
                var rootPackages = currentPackages.Where(_ => names.ContainsNoCase(_.Name));

                currentPackages = IgnoreDependencies
                    ? rootPackages
                    : currentPackages.AffectedPackages(rootPackages);
            }
            return(currentPackages);
        }
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            // add validation logic
            // strengh >= STRONG
            var fortaleza = VerificarFortaleza();

            if (fortaleza < (int)PasswordStrengh.STRONG)
            {
                yield return(new ValidationResult($"La contraseña es {(PasswordStrengh)fortaleza}, agrega mayúsculas, minúsculas, numeros y simbolos para reforzarla.", new[] { nameof(Password) }));
            }

            if (Name.Any(c => !char.IsLetter(c)))
            {
                yield return(new ValidationResult("El campo Name debe contenter solo letras.", new[] { nameof(Name) }));
            }
        }
Example #15
0
        IEnumerable <IPackageInfo> GetPackagesToUnlock()
        {
            var lockedPackages = _repositoryLock.LockedPackages[string.Empty];
            var allPackages    = _packageManager.ListProjectPackages(_environment.Descriptor.Lock(lockedPackages), _environment.ProjectRepository);
            var names          = Name.Any() ? Name : lockedPackages.Select(x => x.Name);

            if (!names.Any())
            {
                return(Enumerable.Empty <IPackageInfo>());
            }

            var rootPackages = lockedPackages.Where(_ => names.ContainsNoCase(_.Name));

            return(IgnoreDependencies
                       ? rootPackages
                       : allPackages.AffectedPackages(rootPackages).Where(lockedPackages.Contains));
        }
Example #16
0
        public override bool ProcessRecordAsync()
        {
            ValidateVersion(RequiredVersion);
            ValidateVersion(MinimumVersion);
            ValidateVersion(MaximumVersion);

            if (RequiredVersion != null)
            {
                if ((!string.IsNullOrWhiteSpace(MaximumVersion)) || (!string.IsNullOrWhiteSpace(MinimumVersion)))
                {
                    Error(Constants.Errors.VersionRangeAndRequiredVersionCannotBeSpecifiedTogether);
                    return(false);
                }
            }
            //Error out for the case where multiple provider names with any version specified
            if (Name.IsNullOrEmpty())
            {
                if ((!string.IsNullOrWhiteSpace(RequiredVersion)) || (!string.IsNullOrWhiteSpace(MinimumVersion)) || (!string.IsNullOrWhiteSpace(MaximumVersion)))
                {
                    Error(Constants.Errors.MultipleNamesWithVersionNotAllowed);
                    return(false);
                }
            }
            else
            {
                if (((Name.Length > 1) || Name.Any(each => each.ContainsWildcards())) &&
                    ((!string.IsNullOrWhiteSpace(RequiredVersion)) || (!string.IsNullOrWhiteSpace(MinimumVersion)) || (!string.IsNullOrWhiteSpace(MaximumVersion))))
                {
                    Error(Constants.Errors.MultipleNamesWithVersionNotAllowed);
                    return(false);
                }
            }
            if (AllVersions.IsPresent)
            {
                if ((!string.IsNullOrWhiteSpace(RequiredVersion)) || (!string.IsNullOrWhiteSpace(MinimumVersion)) || (!string.IsNullOrWhiteSpace(MaximumVersion)))
                {
                    Error(Constants.Errors.AllVersionsCannotBeUsedWithOtherVersionParameters);
                    return(false);
                }
            }

            base.ProcessRecordAsync();

            return(true);
        }
Example #17
0
        protected override IEnumerable <ICommandOutput> ExecuteCore()
        {
            var lockingRepo = _repository.Feature <ISupportLocking>();
            var allPackages = _packageManager.ListProjectPackages(_env.Descriptor.Lock(_repository), _repository);

            if (Name.Any())
            {
                var notFound = Name.Where(_ => allPackages.FirstOrDefault(package => package.Name.EqualsNoCase(_)) == null).ToList();
                if (notFound.Any())
                {
                    return(notFound.Select(x => new PackageNotFound(x)).Cast <ICommandOutput>());
                }
            }
            var currentPackages = GetPackagesToLock(_env.Descriptor, allPackages);

            lockingRepo.Lock(string.Empty, currentPackages);
            return(OutputLock(currentPackages));
        }
Example #18
0
        public string this[string columnName]
        {
            get
            {
                if (columnName.Equals(nameof(Name)) && String.IsNullOrEmpty(Name))
                {
                    return("Введите имя");
                }

                if (columnName.Equals(nameof(Name)) && Name.Any(c => Char.IsDigit(c)))
                {
                    return("Имя не должно содержать цифры");
                }

                if (columnName.Equals(nameof(Surename)) && String.IsNullOrEmpty(Surename))
                {
                    return("Введите фамилию");
                }

                if (columnName.Equals(nameof(Surename)) && Surename.Any(c => Char.IsDigit(c)))
                {
                    return("Фамилия не должна содержать цифры");
                }

                if (columnName.Equals(nameof(Sex)) && String.IsNullOrEmpty(Sex))
                {
                    return("Выберите пол");
                }

                if (columnName.Equals(nameof(Weight)) && Weight <= 5)
                {
                    return("Введите вес в килограммах");
                }

                if (columnName.Equals(nameof(Birthday)) &&
                    (Birthday <= DateTime.Now.AddYears(-100) || Birthday > DateTime.Now.AddYears(-1)))
                {
                    return("Введите дату рождения правильно");
                }

                return(String.Empty);
            }
        }
Example #19
0
 public string this[string columnName]
 {
     get
     {
         string err = "";
         switch (columnName)
         {
         case "Name":
         {
             if (Name.Any(x => !Char.IsLetter(x)))
             {
                 myError = "No correct name";
             }
             break;
         }
         }
         return(err);
     }
 }
Example #20
0
        internal virtual void ValidateFilters()
        {
            if (filters != null)
            {
                var safeProperties = new[]
                {
                    Property.ParentId
                };

                var fs = filters.Where(f => safeProperties.All(p => p != f.Property)).ToList();

                if (fs.Count == 1 && fs.Single().Property == Property.Name && Name != null)
                {
                    if (!Name.Any(n => n.Contains("*")))
                    {
                        fs.Single().Operator = FilterOperator.Equals;
                    }
                }
            }
        }
Example #21
0
        public override bool ProcessRecordAsync()
        {
            if (string.IsNullOrWhiteSpace(Path) && string.IsNullOrWhiteSpace(LiteralPath))
            {
                Error(Constants.Errors.DestinationOrLiteralPathNotSpecified);
                return(false);
            }

            if (IsPackageByObject)
            {
                return(DownloadPackage(InputObject));
            }

            if (Name.Any(each => each.ContainsWildcards()))
            {
                Error(Constants.Errors.WildCardCharsAreNotSupported, Name.JoinWithComma());
                return(false);
            }

            return(base.ProcessRecordAsync());
        }
Example #22
0
 /// <summary>
 /// Validates this section
 /// </summary>
 /// <remarks>
 /// Sections are allowed to have duplicate settings by default.
 /// Check for duplicates yourself if you don't want them.
 /// </remarks>
 public override void Validate()
 {
     if (Name != null && Name.Any(m => Tools.ForbiddenHeaderChar.Contains(m)))
     {
         var ex = new ValidationException("Forbidden character in section name");
         ex.Data.Add("Section", Name);
         throw ex;
     }
     foreach (var S in Settings)
     {
         try
         {
             S.Validate();
         }
         catch (ValidationException ex)
         {
             ex.Data.Add("Section", Name);
             throw ex;
         }
     }
 }
Example #23
0
        public override bool ProcessRecordAsync()
        {
            if (IsPackageByObject)
            {
                return(InstallPackages(InputObject));
            }
            if (MyInvocation.BoundParameters.Count == 0 || (MyInvocation.BoundParameters.Count == 1 && MyInvocation.BoundParameters.ContainsKey("ProviderName")))
            {
                // didn't pass in anything, (except maybe Providername)
                // that's no ok -- we need some criteria
                Error(Constants.Errors.MustSpecifyCriteria);
                return(false);
            }

            if (Name.Any(each => each.ContainsWildcards()))
            {
                Error(Constants.Errors.WildCardCharsAreNotSupported, Name.JoinWithComma());
                return(false);
            }
            // otherwise, just do the search right now.
            return(base.ProcessRecordAsync());
        }
Example #24
0
        public override bool ProcessRecordAsync()
        {
            if (string.IsNullOrWhiteSpace(Path) && string.IsNullOrWhiteSpace(LiteralPath))
            {
                Error(Constants.Errors.DestinationOrLiteralPathNotSpecified);
                return(false);
            }

            if (IsPackageByObject)
            {
                ProcessPackage(SelectProviders(InputObject.ProviderName).FirstOrDefault(), InputObject.Name.SingleItemAsEnumerable(), InputObject);
                return(true);
            }

            if (Name.Any(each => each.ContainsWildcards()))
            {
                Error(Constants.Errors.WildCardCharsAreNotSupported, Name.JoinWithComma());
                return(false);
            }

            return(base.ProcessRecordAsync());
        }
Example #25
0
        private void SaveView(IDataStore store)
        {
            if (Name.Any(c => c == ' '))
            {
                throw new Exception($"Invalid name: {Name}\nNames cannot contain spaces.");
            }

            try
            {
                if (SQL != null && SQL != "")
                {
                    (store.Reader as DataStoreReader).ExecuteSql(SQL);
                    store.AddView(Name, SQL);
                }
            }
            catch (Exception ex)
            {
                var msg = $"Invalid SQL: Unable to create query report [{Name}] using SQL provided" +
                          $"\r\nError: {ex.Message}" +
                          $"\r\nIf your SQL contains links to other ReportQueries you may need to run this Report after the others have been created by disabling it in the first run and then enabling again.";
                throw new ApsimXException(this, msg);
            }
        }
Example #26
0
        public override bool ProcessRecordAsync()
        {
            if (IsPackageByObject)
            {
                return(UninstallPackages(InputObject));
            }

            if (Name.Any(each => each.ContainsWildcards()))
            {
                Error(Constants.Errors.WildCardCharsAreNotSupported, Name.JoinWithComma());
                return(false);
            }

            if (Name.Any(each => string.IsNullOrWhiteSpace(each)))
            {
                Error(Constants.Errors.WhitespacesAreNotSupported, Name.JoinWithComma());
                return(false);
            }

            // otherwise do the same as get-package and collect the results for the EndProcessingAsync
            base.ProcessRecordAsync();

            return(true);
        }
 public AuthentificationDialog()
 {
     InitializeComponent();
     OkButtonClick  = new RelayCommand(() => DialogResult = true, () => Name.Any() && Password.Any());
     button.Command = OkButtonClick;
 }