Example #1
0
        public string[] ExtractModelClass(bool serializable, bool validationReady, bool validationMsgReady, bool ropSqlReady, bool gzipReady, bool wcfReady, bool jsonMinReady, FuncionalityConfig funcConfig)
        {
            string[] result = new string[2];
            List<string> defaultNamespaces = new List<string>();

            defaultNamespaces.Add("using System;");
            Model modelPreConfig = new Model()
            {
                Serializable = serializable,
                ValidationEnable = validationReady || validationMsgReady,
                ValidationMsgEnable = validationMsgReady,
                RopSqlEnable = ropSqlReady,
                GzipEnable = gzipReady,
                WcfEnable = wcfReady,
                JsonMinEnable = jsonMinReady,
                NavMenu = (funcConfig != null),

                Namespaces = defaultNamespaces
            };

            if (modelPreConfig.NavMenu)
            {
                modelPreConfig.FuncionalityGroup = funcConfig.Group;
                modelPreConfig.FuncionalitySubGroup = funcConfig.SubGroup;
                modelPreConfig.FuncionalityAccess = funcConfig.Access;
            }

            result[0] = parseScript(modelPreConfig, scpContent);
            result[1] = modelPreConfig.EntityName;

            return result;
        }
Example #2
0
        static void Main(string[] args)
        {
            if (args.Length > 1)
            {
                var inputFile = args.First();
                var classNamespace = args[1];
                var excepDepth = args[2];
                var funcGroup = args[3];
                var funcSubGroup = args[4];

                var serialize = args.Contains("-s");
                var validate = args.Contains("-v");
                var valmsg = args.Contains("-vm");
                var ropsql = args.Contains("-r");
                var wcf = args.Contains("-w");
                var json = args.Contains("-j");
                var navmenu = args.Contains("-f");

                var controller = args.Contains("-c");
                var excepSafeController = args.Contains("-ce");
                var securController = args.Contains("-ca");
                var loggedController = args.Contains("-cl");
                var wkflowController = args.Contains("-cw");
                var gzip = args.Contains("-g");

                CultureInfo culture = new CultureInfo(ConfigurationSettings.AppSettings["Culture"]);
                Thread.CurrentThread.CurrentCulture = culture;
                Thread.CurrentThread.CurrentUICulture = culture;
                FuncionalityConfig funcConfig = null;

                if (navmenu)
                {
                    funcConfig = new FuncionalityConfig();
                    funcConfig.Group = funcGroup;
                    funcConfig.SubGroup = funcSubGroup;
                }

                var resultArray = new DBScriptExtractor(inputFile, classNamespace).ExtractModelClass(serialize, validate, valmsg, ropsql, gzip, wcf, json, funcConfig);
                var resultModel = resultArray.First();
                var modelName = resultArray.Last();

                var modelOutputFile = string.Concat(modelName, ".cs");
                writeFile(modelOutputFile, resultModel);
                Console.WriteLine(string.Concat("Model Class successfully extracted on ", modelOutputFile));

                var controllerOutputFile = string.Empty;
                if (controller || excepSafeController || securController || loggedController || wkflowController)
                {
                    var exDepth = !string.IsNullOrEmpty(excepDepth) ? int.Parse(excepDepth) : 0;
                    var resultController = new DBScriptExtractor(classNamespace).ExtractController(modelName,
                                                                                                   excepSafeController,
                                                                                                   securController,
                                                                                                   loggedController,
                                                                                                   wkflowController,
                                                                                                   gzip, exDepth);
                    controllerOutputFile = string.Concat(modelName, "Controller.cs");
                    writeFile(controllerOutputFile, resultController);
                    Console.WriteLine(string.Concat(Environment.NewLine, "Controller Class successfully extracted on ", controllerOutputFile));
                }

                Process.Start("Notepad.exe", modelOutputFile);
                Process.Start("Notepad.exe", controllerOutputFile);

                Console.Read();
            }
            else
                printHelp();
        }