protected override IsValidResponse VerifyValueRequest(object value)
        {
            var response = new IsValidResponse();

            if (value != null && !string.IsNullOrWhiteSpace(value.ToString()))
            {
                //this needs to try parse and throw
                var intValue = int.Parse(value.ToString());
                if (intValue > MaxValue)
                {
                    response.AddInvalidReason(
                        string.Format("The entered value is greater than the maximum of {0}", MaxValue));
                }
                if (intValue < MinValue)
                {
                    response.AddInvalidReason(
                        string.Format("The entered value is less than the minimum of {0}", MinValue));
                }
            }
            else if (IsNotNullable && (value == null || string.IsNullOrWhiteSpace(value.ToString())))
            {
                response.AddInvalidReason(string.Format("A Value Is Required"));
            }
            return(response);
        }
Esempio n. 2
0
        public virtual IsValidResponse IsValidForNewType(string typeName)
        {
            var response = new IsValidResponse();

            response.AddInvalidReason(string.Format("New type name validations have not been implemented for the type {0}", GetType().Name));
            return(response);
        }
 public IsValidResponse Validate()
 {
     var service = new XrmService(this);
     var response = service.VerifyConnection();
     var actualResponse = new IsValidResponse();
     foreach (var item in response.InvalidReasons)
         actualResponse.AddInvalidReason(item);
     return actualResponse;
 }
Esempio n. 4
0
        public IsValidResponse Validate()
        {
            var response = new IsValidResponse();

            if (RecordsToExport == null || !RecordsToExport.Any(r => r.Selected))
            {
                response.AddInvalidReason("At Least One Record Type Must Be Included For Export");
            }
            return(response);
        }
        public override IsValidResponse VerifyConnection()
        {
            var response = new IsValidResponse();

            if (ObjectToEnter == null)
            {
                response.AddInvalidReason("The object to enter is null");
            }
            return(response);
        }
Esempio n. 6
0
        public IsValidResponse Validate()
        {
            var response = new IsValidResponse();

            if (!Directory.Exists(FolderPath))
            {
                response.AddInvalidReason("The Directory Does Not Exist");
            }
            return(response);
        }
Esempio n. 7
0
        protected override IsValidResponse ValidateExtention()
        {
            var record   = RecordForm.GetRecord();
            var response = new IsValidResponse();

            if (!PropertyValidator.IsValid(record.GetField(ChangedField.ReferenceName)))
            {
                response.AddInvalidReason(PropertyValidator.GetErrorMessage(RecordForm.RecordService.GetFieldMetadata(ChangedField.ReferenceName, RecordForm.GetRecordType()).DisplayName));
            }

            return(response);
        }
Esempio n. 8
0
        public override IsValidResponse IsValidForNewType(string typeName)
        {
            var response = new IsValidResponse();
            var objects  =
                ExecuteSelect("select name, type_desc from sys.objects where name =" + SqlProvider.ToSqlString(typeName));

            if (objects.Any())
            {
                response.AddInvalidReason(string.Format("There is already a '{0}' object in the database named {1}", objects.First().GetFieldAsString("type_desc"), typeName));
            }
            return(response);
        }
        public IsValidResponse Validate()
        {
            var service        = new XrmService(this);
            var response       = service.VerifyConnection();
            var actualResponse = new IsValidResponse();

            foreach (var item in response.InvalidReasons)
            {
                actualResponse.AddInvalidReason(item);
            }
            return(actualResponse);
        }
        public IsValidResponse Validate()
        {
            var response = new IsValidResponse();

            if (FolderPath != null && Directory.Exists(FolderPath.FolderPath))
            {
                if (FileUtility.GetFiles(FolderPath.FolderPath).Any(f => f.EndsWith("zip")))
                {
                    response.AddInvalidReason(string.Format("{0} Already Contains .ZIP files. Remove The .ZIP Files Or Select Another Folder", GetType().GetProperty(nameof(FolderPath)).GetDisplayName()));
                }
            }
            return(response);
        }
        public IsValidResponse Validate()
        {
            //lets just ensure at leats one valid oiton is selected
            var validProperties = new[] { nameof(Entities), nameof(Fields), nameof(FieldOptionSets), nameof(SharedOptionSets), nameof(Relationships), nameof(Solutions), nameof(Workflows), nameof(PluginAssemblies), nameof(SecurityRoles), nameof(FieldSecurityProfiles), nameof(Users), nameof(Teams), nameof(Reports), nameof(WebResources), nameof(PluginTriggers), nameof(FormsAndDashboards), nameof(RolesPrivileges) };
            var isOneSelected   = validProperties.Any(p => (bool)this.GetPropertyValue(p));
            var isValidResponse = new IsValidResponse();

            if (!isOneSelected)
            {
                var thisType = GetType();
                isValidResponse.AddInvalidReason($"At Least One Of {validProperties.Select(p => thisType.GetProperty(p).GetDisplayName()).JoinGrammarAnd()} Is Required To Be Selected");
            }
            return(isValidResponse);
        }
Esempio n. 12
0
        public IsValidResponse Validate()
        {
            //lets just ensure at leats one valid oiton is selected
            var validProperties = new[] { nameof(Entities), nameof(Fields), nameof(Relationships), nameof(FieldOptionSets), nameof(SharedOptionSets), nameof(Views) };
            var isOneSelected   = validProperties.Any(p => (bool)this.GetPropertyValue(p));
            var isValidResponse = new IsValidResponse();

            if (!isOneSelected)
            {
                var thisType = GetType();
                isValidResponse.AddInvalidReason($"At Least One Of {validProperties.Select(p => thisType.GetProperty(p).GetDisplayName()).JoinGrammarAnd()} Is Required To Be Selected");
            }
            return(isValidResponse);
        }
Esempio n. 13
0
        protected override IsValidResponse VerifyValueRequest(object value)
        {
            var response = new IsValidResponse();

            if (value != null && !(value is Guid) && !string.IsNullOrEmpty(value.ToString()))
            {
                Guid dummy = Guid.Empty;
                if (!Guid.TryParse(value.ToString(), out dummy))
                {
                    response.AddInvalidReason("Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)");
                }
            }
            return(response);
        }
 public IsValidResponse Validate()
 {
     try
     {
         var service = new CsvRecordService(this);
         return(service.VerifyConnection());
     }
     catch (Exception ex)
     {
         var response = new IsValidResponse();
         response.AddInvalidReason("Error creating service: " + ex.DisplayString());
         return(response);
     }
 }
Esempio n. 15
0
        public override IsValidResponse VerifyConnection()
        {
            var response = new IsValidResponse();

            try
            {
                var dbExists = SqlProvider.DatabaseExists(Connection.SqlServer, Connection.Database);
                if (!dbExists)
                {
                    response.AddInvalidReason(string.Format("The database {0} could not be found on the server", Connection.Database));
                }
            }
            catch (Exception ex)
            {
                response.AddInvalidReason(string.Format("A connection to verify the database could not be made: {0}", ex.DisplayString()));
            }
            return(response);
        }
        public override IsValidResponse VerifyConnection()
        {
            var response = new IsValidResponse();

            try
            {
                var recordType         = GetRecordType();
                var fields             = this.GetFields(recordType);
                var invalidFieldStarts = string.Format("{0}#csv#", CsvNamePartNoExtention);
                var invalidFields      = fields.Where(s => s.StartsWith(invalidFieldStarts));
                if (invalidFields.Any())
                {
                    response.AddInvalidReason(string.Format("Invalid field names were found. Check the file for duplicate columns or rename these fields. The invalid columns names were {0}", string.Join(",", invalidFields)));
                }
            }
            catch (Exception ex)
            {
                response.AddInvalidReason("Error connecting to CSV file: " + ex.DisplayString());
            }
            return(response);
        }
Esempio n. 17
0
        protected override IsValidResponse ValidateExtention()
        {
            var response = new IsValidResponse();

            if (!(ChangedField is FieldViewModelBase))
            {
                throw new NotImplementedException(string.Format("This Form Of Validation Only Supported For {0} Objects", typeof(FieldViewModelBase).Name));
            }
            var fieldViewModel = (FieldViewModelBase)ChangedField;
            var value          = fieldViewModel.ValueObject;

            if (value != null)
            {
                if (!(value is IValidatableObject))
                {
                    throw new NotImplementedException(string.Format("Error Object Does Not Implement {0}", typeof(IValidatableObject).Name));
                }
                response = ((IValidatableObject)value).Validate();
            }
            return(response);
        }
Esempio n. 18
0
        public static IsValidResponse Validate(this IEnumerable <IMapSpreadsheetImport> imports, bool matchByName, bool updateOnly)
        {
            var response = new IsValidResponse();

            if (imports != null)
            {
                foreach (var item in imports.GroupBy(i => i.TargetType))
                {
                    if (item.Count() > 1 && item.Any(i => i.AltMatchKeys != null && i.AltMatchKeys.Any()))
                    {
                        response.AddInvalidReason($"There Are Multiple Maps To {item.First().TargetTypeLabel}. Multiple Imports To The Same Type Are Not Supported Where {typeof(IMapSpreadsheetImport).GetProperty(nameof(IMapSpreadsheetImport.AltMatchKeys)).GetDisplayName()} Are Used For That Type");
                    }
                }
                foreach (var map in imports)
                {
                    if (map.AltMatchKeys != null)
                    {
                        foreach (var key in map.AltMatchKeys)
                        {
                            if (map.FieldMappings == null || !map.FieldMappings.Any(fm => fm.TargetField == key.TargetField))
                            {
                                response.AddInvalidReason($"{key.TargetFieldLabel} Is Not Included In The {typeof(IMapSpreadsheetImport).GetProperty(nameof(IMapSpreadsheetImport.FieldMappings)).GetDisplayName()}. All {typeof(IMapSpreadsheetImport).GetProperty(nameof(IMapSpreadsheetImport.AltMatchKeys)).GetDisplayName()} Need To Be Included In The {typeof(IMapSpreadsheetImport).GetProperty(nameof(IMapSpreadsheetImport.FieldMappings)).GetDisplayName()}");
                            }
                        }
                    }
                }
            }
            if (updateOnly)
            {
                if (!matchByName &&
                    !imports.All(i => i.AltMatchKeys != null && i.AltMatchKeys.Any()))
                {
                    response.AddInvalidReason($"When Updates Only Either Match By Name Must Be Set Or All Mappings Must Have {typeof(IMapSpreadsheetImport).GetProperty(nameof(IMapSpreadsheetImport.AltMatchKeys)).GetDisplayName()} Defined");
                }
            }
            return(response);
        }