protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => Name) && Name != scriptParameter.Name)
                return ValidationMessage._0ShouldBe12.NiceToString(pi.NiceName(), ComparisonType.EqualTo.NiceToString(), scriptParameter.Name);

            if (pi.Is(() => Value))
            {
                return ScriptParameter.Valdidate(this.Value, this.ScriptParameter.GetToken(this.ParentChart));
            }

            return base.PropertyValidation(pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => EachMinutes))
            {
                if ((60 % EachMinutes) != 0)
                    return SchedulerMessage._0IsNotMultiple1.NiceToString().FormatWith(pi.NiceName(), 60);
            }

            return base.PropertyValidation(pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => Title) && string.IsNullOrEmpty(title))
            {
                if (content != null && content.RequiresTitle)
                    return DashboardMessage.DashboardDN_TitleMustBeSpecifiedFor0.NiceToString().FormatWith(content.GetType().NicePluralName());
            }

            return base.PropertyValidation(pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => Cultures))
            {
                var error = Cultures.GroupBy(a => a.Culture).Where(a => a.Count() > 1).ToString(a => a.Key.ToString(), ", ");

                if (error.HasText())
                    return TranslationMessage.RepeatedCultures0.NiceToString().FormatWith(error); 
            }

            return base.PropertyValidation(pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => RowId) && PropertyRoute != null)
            {
                if (RowId == null && PropertyRoute.Path.Contains("/"))
                    return "{0} should be set for route {1}".FormatWith(pi.NiceName(), PropertyRoute);

                if (RowId != null && !PropertyRoute.Path.Contains("/"))
                    return "{0} should be null for route {1}".FormatWith(pi.NiceName(), PropertyRoute);
            }

            return null;
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(()=>Holidays) && holidays != null)
            {
                string rep = (from h in holidays
                              group 1 by h.Date into g
                              where g.Count() > 2
                              select new { Date = g.Key, Num = g.Count() }).ToString(g => "{0} ({1})".FormatWith(g.Date, g.Num), ", ");

                if (rep.HasText())
                    return "Some dates have been repeated: " + rep;
            }

            return base.PropertyValidation(pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => Name) && Name.HasText())
            {
                try
                {
                    CultureInfo.GetCultureInfo(this.Name);
                }
                catch (CultureNotFoundException)
                {
                    return "'{0}' is not a valid culture name".FormatWith(Name);
                }
            }

            return base.PropertyValidation(pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => Text) && !EmailMasterTemplateEntity.MasterTemplateContentRegex.IsMatch(Text))
            {
                throw new ApplicationException(EmailTemplateMessage.TheTextMustContain0IndicatingReplacementPoint.NiceToString().FormatWith("@[content]"));
            }

            return base.PropertyValidation(pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => Token))
            {
                if (Token == null && emailAddress.IsNullOrEmpty())
                    return EmailTemplateMessage.TokenOrEmailAddressMustBeSet.NiceToString();

                if (Token != null && !emailAddress.IsNullOrEmpty())
                    return EmailTemplateMessage.TokenAndEmailAddressCanNotBeSetAtTheSameTime.NiceToString();

                if (Token != null && Token.Token.Type != typeof(EmailOwnerData))
                    return EmailTemplateMessage.TokenMustBeA0.NiceToString(typeof(EmailOwnerData).NiceName());
            }
            
            return null;
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => Token))
            {
                if (Token == null)
                    return !scriptColumn.IsOptional ? ChartMessage._0IsNotOptional.NiceToString().FormatWith(scriptColumn.DisplayName) : null;

                if (parentChart.GroupResults)
                {
                    if (scriptColumn.IsGroupKey)
                    {
                        if (Token.Token is AggregateToken)
                            return ChartMessage._0IsKeyBut1IsAnAggregate.NiceToString().FormatWith(scriptColumn.DisplayName, DisplayName);
                    }
                    else
                    {
                        if (!(Token.Token is AggregateToken))
                            return ChartMessage._0ShouldBeAnAggregate.NiceToString().FormatWith(scriptColumn.DisplayName, DisplayName);
                    }
                }
                else
                {
                    if (Token.Token is AggregateToken)
                        return ChartMessage._0IsAnAggregateButTheChartIsNotGrouping.NiceToString().FormatWith(DisplayName);
                }

                if (!ChartUtils.IsChartColumnType(token.Token, ScriptColumn.ColumnType))
                    return ChartMessage._0IsNot1.NiceToString().FormatWith(DisplayName, ScriptColumn.ColumnType);
            }

            return base.PropertyValidation(pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => Parameters) && Parameters != null && ChartScript != null)
            {
                try
                {
                    EnumerableExtensions.JoinStrict(
                        Parameters,
                        ChartScript.Parameters,
                        p => p.Name,
                        ps => ps.Name, 
                        (p, ps) => new { p, ps }, pi.NiceName());
                }
                catch (Exception e)
                {
                    return e.Message;
                }
            }

            return base.PropertyValidation(pi);
        }
Beispiel #12
0
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => State))
            {
                if (anulationDate != null && state != UserState.Disabled)
                    return AuthMessage.TheUserStateMustBeDisabled.NiceToString();
            }

            return base.PropertyValidation(pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => Template) && Template == null && Active)
                return ValidationMessage._0IsNotSet.NiceToString(pi.NiceName());

            return base.PropertyValidation(pi);
        }
        protected override string ChildPropertyValidation(ModifiableEntity sender, PropertyInfo pi)
        {
            if (sender is PanelPartEntity)
            {
                PanelPartEntity part = (PanelPartEntity)sender;

                if (pi.Is(() => part.StartColumn))
                {
                    if (part.StartColumn + part.Columns > 12)
                        return DashboardMessage.Part0IsTooLarge.NiceToString(part);

                    var other = parts.TakeWhile(p => p != part)
                        .FirstOrDefault(a => a.Row == part.Row && a.ColumnInterval().Overlap(part.ColumnInterval()));

                    if (other != null)
                        return DashboardMessage.Part0OverlapsWith1.NiceToString(part, other);
                }

                if (entityType != null && pi.Is(() => part.Content) && part.Content != null)
                {
                    var idents = GraphExplorer.FromRoot((Entity)part.Content).OfType<Entity>();

                    string errorsUserQuery = idents.OfType<IHasEntitytype>()
                        .Where(uc => uc.EntityType != null && !uc.EntityType.Is(EntityType))
                        .ToString(uc => DashboardMessage._0Is1InstedOf2In3.NiceToString(NicePropertyName(() => EntityType), uc.EntityType, entityType, uc),
                        "\r\n");

                    return errorsUserQuery.DefaultText(null);
                }
            }

            return base.ChildPropertyValidation(sender, pi);
        }
Beispiel #15
0
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => PostalCode))
            {
                if (string.IsNullOrEmpty(postalCode) && Country != "Ireland")
                    return Signum.Entities.ValidationMessage._0IsNotSet.NiceToString().FormatWith(pi.NiceName());
            }

            return null;
        }
Beispiel #16
0
        protected override string ChildPropertyValidation(ModifiableEntity sender, PropertyInfo pi)
        {
            OrderDetailsEntity details = sender as OrderDetailsEntity;

            if (details != null && !IsLegacy &&  pi.Is(() => details.Discount))
            {
                if ((details.Discount * 100.0m) % 5.0m != 0)
                    return OrderMessage.DiscountShouldBeMultpleOf5.NiceToString();
            }

            return base.ChildPropertyValidation(sender, pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => Token) && token != null && token.Token != null)
            {
                return QueryUtils.CanColumn(token.Token);
            }

            return base.PropertyValidation(pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => ElementsPerPage))
            {
                if (ElementsPerPage != null && !ShouldHaveElements)
                    return UserQueryMessage._0ShouldBeNullIf1Is2.NiceToString().FormatWith(pi.NiceName(), NicePropertyName(() => PaginationMode), PaginationMode.Try(pm=>pm.NiceToString()) ?? "" );

                if (ElementsPerPage == null && ShouldHaveElements)
                    return UserQueryMessage._0ShouldBeSetIf1Is2.NiceToString().FormatWith(pi.NiceName(), NicePropertyName(() => PaginationMode), PaginationMode.NiceToString());
            }

            if (pi.Is(() => Filters) && WithoutFilters && Filters.Any())
                return UserQueryMessage._0ShouldBeEmptyIf1IsSet.NiceToString().FormatWith(pi.NiceName(), ReflectionTools.GetPropertyInfo(() => WithoutFilters).NiceName());

            return base.PropertyValidation(pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => ExecutionStart) || pi.Is(() => ExecutionEnd))
            {
                if (this.ExecutionEnd < this.ExecutionStart)
                    return ProcessMessage.ProcessStartIsGreaterThanProcessEnd.NiceToString();

                if (this.ExecutionStart == null && this.ExecutionEnd != null)
                    return ProcessMessage.ProcessStartIsNullButProcessEndIsNot.NiceToString();
            }

            return stateValidator.Validate(this, pi) ?? base.PropertyValidation(pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Is(() => EmbeddedInEntity))
            {
                if (EmbeddedInEntity == null && EntityType != null)
                    return ValidationMessage._0IsNecessary.NiceToString(pi.NiceName());

                if (EmbeddedInEntity != null && EntityType == null)
                    return ValidationMessage._0IsNotAllowed.NiceToString(pi.NiceName());
            }

            return base.PropertyValidation(pi);
        }
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (token != null)
            {
                if (pi.Is(() => Token) && token.Token != null)
                {
                    return QueryUtils.CanFilter(token.Token);
                }

                if (pi.Is(() => Operation))
                {
                    FilterType? filterType = QueryUtils.TryGetFilterType(Token.Token.Type);

                    if (filterType == null)
                        return UserQueryMessage._0IsNotFilterable.NiceToString().FormatWith(token);

                    if (!QueryUtils.GetFilterOperations(filterType.Value).Contains(operation))
                        return UserQueryMessage.TheFilterOperation0isNotCompatibleWith1.NiceToString().FormatWith(operation, filterType);
                }

                if (pi.Is(() => ValueString))
                {
                    object val;
                    return FilterValueConverter.TryParse(ValueString, Token.Token.Type, out val, operation == FilterOperation.IsIn);
                }
            }

            return null;
        }