Exemplo n.º 1
0
 private bool IsValid()
 {
     if (json == null)
     {
         throw new Exception($"{LOG} 'profile' not found: '{arguments.Profile}'. Please check DynamicsCrm.DevKit.Cli.json file.");
     }
     if (json.solution.Length == 0 || json.solution == "???")
     {
         throw new Exception($"{LOG} 'solution' 'empty' or '???'. Please check DynamicsCrm.DevKit.Cli.json file.");
     }
     if (json.datasource == null || json.datasource.Length == 0 || json.datasource == "???")
     {
         throw new Exception($"{LOG} 'datasource' 'empty' or '???'. Please check DynamicsCrm.DevKit.Cli.json file.");
     }
     if (!XrmHelper.IsExistSolution(crmServiceClient, json.solution, out var solutionId, out var prefix))
     {
         throw new Exception($"{LOG} solution '{json.solution}' not exist");
     }
     SolutionId     = solutionId;
     Prefix         = prefix;
     DataSourceName = json.datasource.ToLower().StartsWith(prefix.ToLower()) ? json.datasource : $"{Prefix}{json.datasource}";
     if (!XrmHelper.IsExistDataSource(crmServiceClient, $"{DataSourceName}"))
     {
         throw new Exception($"{LOG} name '{json.datasource}' not exist with prefix: {Prefix}");
     }
     return(true);
 }
Exemplo n.º 2
0
        private bool IsValid()
        {
            if (json == null)
            {
                throw new Exception($"{LOG} 'profile' not found: '{arguments.Profile}'. Please check DynamicsCrm.DevKit.Cli.json file.");
            }
            if (json.solution.Length == 0 || json.solution == "???")
            {
                throw new Exception($"{LOG} 'solution' 'empty' or '???'. Please check DynamicsCrm.DevKit.Cli.json file.");
            }
            if (json.displayname.Length == 0 || json.displayname == "???")
            {
                throw new Exception($"{LOG} 'displayname' 'empty' or '???'. Please check DynamicsCrm.DevKit.Cli.json file.");
            }
            if (json.pluralname.Length == 0 || json.pluralname == "???")
            {
                throw new Exception($"{LOG} 'pluralname' 'empty' or '???'. Please check DynamicsCrm.DevKit.Cli.json file.");
            }
            if (json.name.Length == 0 || json.name == "???")
            {
                throw new Exception($"{LOG} 'name' 'empty' or '???'. Please check DynamicsCrm.DevKit.Cli.json file.");
            }
            var regex = new Regex("^[a-zA-Z][_a-zA-Z0-9\\s,]*$");

            if (!regex.IsMatch(json.displayname))
            {
                throw new Exception($"{LOG} 'displayname' can only contain alpha-numeric and underscore characters.");
            }
            if (!regex.IsMatch(json.pluralname))
            {
                throw new Exception($"{LOG} 'pluralname' can only contain alpha-numeric and underscore characters.");
            }
            if (!regex.IsMatch(json.name))
            {
                throw new Exception($"{LOG} 'name' can only contain alpha-numeric and underscore characters.");
            }
            if (json.name.Contains(" "))
            {
                throw new Exception($"{LOG} 'name' can cannot contain space character.");
            }
            if (!XrmHelper.IsExistSolution(crmServiceClient, json.solution, out var solutionId, out var prefix))
            {
                throw new Exception($"{LOG} solution '{json.solution}' not exist");
            }
            //SolutionId = solutionId;
            Prefix         = prefix;
            DataSourceName = json.name.ToLower().StartsWith(prefix.ToLower()) ? json.name : $"{Prefix}{json.name}";
            if (XrmHelper.IsExistDataSource(crmServiceClient, DataSourceName))
            {
                throw new Exception($"{LOG} name '{DataSourceName}' exist");
            }
            return(true);
        }