Пример #1
0
        static void Main(string[] args)
        {
            string arquivo;

            if (args != null && args.Count() > 0)
            {
                arquivo = args[0];
            }
            else
            {
                arquivo = "local.frameweb";
            }
            XmlDocument xmlDocument;

            xmlDocument = new XmlDocument();
            xmlDocument.Load(new StreamReader(arquivo));

            string[] nivel_1 = new string[] { "resultDependencyConstraint", "packagedElement" };
            string[] nivel_2 = new string[] { "ownedAttribute", "ownedEnd", "pageTagLib", "ownedOperation" };
            string[] nivel_3 = new string[] { "type" };

            XmlElement ele        = (XmlElement)xmlDocument.DocumentElement.SelectNodes("compose")[0];
            Componete  componente = CriarComponente(ele);

            foreach (XmlElement sub0 in ele.SelectNodes("packagedElement"))
            {
                var comp0 = CriarComponente(sub0);

                foreach (var niv in nivel_1)
                {
                    foreach (XmlElement sub1 in sub0.SelectNodes(niv))
                    {
                        var comp1 = CriarComponente(sub1);
                        comp0.Componentes.Add(comp1);

                        foreach (var niv2 in nivel_2)
                        {
                            foreach (XmlElement sub2 in sub1.SelectNodes(niv2))
                            {
                                var comp2 = CriarComponente(sub2);
                                comp1.Componentes.Add(comp2);

                                foreach (var niv3 in nivel_3)
                                {
                                    foreach (XmlElement sub3 in sub2.SelectNodes(niv3))
                                    {
                                        var comp3 = CriarComponente(sub3);
                                        comp2.Componentes.Add(comp3);
                                    }
                                }
                            }
                        }
                    }
                }

                componente.Componentes.Add(comp0);
            }

            GerarArquivos(componente);
        }
Пример #2
0
        static Componete CriarComponente(XmlElement elemento)
        {
            var comp = new Componete();

            comp.tag         = elemento.Name;
            comp.Componentes = new List <Componete>();
            ValorAtributo(elemento.Attributes, ref comp);
            return(comp);
        }
Пример #3
0
        public static Componete Create(XmlElement elemento)
        {
            var comp = new Componete();

            comp.tag         = elemento.Name;
            comp.Componentes = new List <Componete>();
            AttributeValue(elemento.Attributes, ref comp);
            return(comp);
        }
Пример #4
0
        static void ReadFileAndProcess(string file)
        {
            XmlDocument xmlDocument;

            xmlDocument = new XmlDocument();
            xmlDocument.Load(new StreamReader(file));

            string[] nivel_1 = new string[] { "resultDependencyConstraint", "packagedElement" };
            string[] nivel_2 = new string[] { "ownedAttribute", "ownedEnd", "pageTagLib", "ownedOperation", "generalization" };
            string[] nivel_3 = new string[] { "type", "methodType", "ownedParameter" };

            foreach (XmlElement ele in xmlDocument.DocumentElement.SelectNodes("compose"))
            {
                Componete componente = ComponenteFactory.Create(ele);

                foreach (XmlElement sub0 in ele.SelectNodes("packagedElement"))
                {
                    var comp0 = ComponenteFactory.Create(sub0);

                    foreach (var niv in nivel_1)
                    {
                        foreach (XmlElement sub1 in sub0.SelectNodes(niv))
                        {
                            var comp1 = ComponenteFactory.Create(sub1);
                            comp0.Componentes.Add(comp1);

                            foreach (var niv2 in nivel_2)
                            {
                                foreach (XmlElement sub2 in sub1.SelectNodes(niv2))
                                {
                                    var comp2 = ComponenteFactory.Create(sub2);
                                    comp1.Componentes.Add(comp2);

                                    foreach (var niv3 in nivel_3)
                                    {
                                        foreach (XmlElement sub3 in sub2.SelectNodes(niv3))
                                        {
                                            var comp3 = ComponenteFactory.Create(sub3);
                                            comp2.Componentes.Add(comp3);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    componente.Componentes.Add(comp0);
                }

                componente.Process(config);
            }
        }
Пример #5
0
        static void ValorAtributo(XmlAttributeCollection itens, ref Componete filho)
        {
            foreach (XmlAttribute item in itens)
            {
                switch (item.Name)
                {
                case "xsi:type":
                    filho.xsi_type = item.Value;
                    break;

                case "name":
                    filho.name = item.Value;
                    break;

                case "type":
                    filho.type = item.Value;
                    break;

                case "association":
                    filho.association = item.Value;
                    break;

                case "memberEnd":
                    filho.memberEnd = item.Value;
                    break;

                case "href":
                    filho.href = item.Value;
                    break;

                case "client":
                    filho.client = item.Value;
                    break;

                case "supplier":
                    filho.supplier = item.Value;
                    break;

                case "resultMethod":
                    filho.resultMethod = item.Value;
                    break;

                case "methodType":
                    filho.methodType = item.Value;
                    break;

                case "parameterType":
                    filho.parameterType = item.Value;
                    break;
                }
            }
        }
        private void CreateInterfaces(Componete componente)
        {
            var daoInterfaces = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:DAOInterface").ToList();

            if (daoInterfaces != null && daoInterfaces.Count > 0)
            {
                // Copiar arquivos padrões
            }

            foreach (var _interface in daoInterfaces)
            {
                var tags_class = new Dictionary <string, string>();



                var daoRealizations = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:DAORealization" && y.getSupplier() == _interface.name).ToList();

                foreach (var realization in daoRealizations)
                {
                    tags_class = new Dictionary <string, string>();
                    tags_class.Add("FW_INTERFACE_NAME", _interface.name);
                    tags_class.Add("FW_INTERFACE_INFIX", _interface.infix);


                    // Gerando arquivos

                    var textInterface = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + _interface.getXsiTypeFile());
                    foreach (var item in tags_class)
                    {
                        textInterface = textInterface.Replace(item.Key, item.Value);
                    }

                    try
                    {
                        Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                    }
                    catch
                    {
                    }
                    File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, _interface.name + config.ext_class), textInterface);
                }
            }
        }
Пример #7
0
        static Componete criarCompose(Componete comp, XmlElement element, string[] nivel_1, string[] nivel_2, string[] nivel_3)
        {
            foreach (XmlElement sub0 in element.SelectNodes("packagedElement"))
            {
                var comp0 = CriarComponente(sub0);

                foreach (var niv in nivel_1)
                {
                    foreach (XmlElement sub1 in sub0.SelectNodes(niv))
                    {
                        var comp1 = CriarComponente(sub1);
                        comp0.Componentes.Add(comp1);

                        foreach (var niv2 in nivel_2)
                        {
                            foreach (XmlElement sub2 in sub1.SelectNodes(niv2))
                            {
                                var comp2 = CriarComponente(sub2);
                                comp1.Componentes.Add(comp2);

                                foreach (var niv3 in nivel_3)
                                {
                                    foreach (XmlElement sub3 in sub2.SelectNodes(niv3))
                                    {
                                        var comp3 = CriarComponente(sub3);
                                        comp2.Componentes.Add(comp3);
                                    }
                                }
                            }
                        }
                    }
                }

                comp.Componentes.Add(comp0);
            }

            return(comp);
        }
Пример #8
0
        static void Main(string[] args)
        {
            string arquivo;

            if (args != null && args.Count() > 0)
            {
                arquivo = args[0];
            }
            else
            {
                arquivo = "local.frameweb";
            }
            XmlDocument xmlDocument;

            xmlDocument = new XmlDocument();
            xmlDocument.Load(new StreamReader(arquivo));

            string[] nivel_1 = new string[] { "resultDependencyConstraint", "packagedElement" };
            string[] nivel_2 = new string[] { "ownedAttribute", "ownedEnd", "pageTagLib", "ownedOperation" };
            string[] nivel_3 = new string[] { "type" };

            XmlElement ele = (XmlElement)xmlDocument.DocumentElement.SelectNodes("compose")[0];
            /// GETTING ENTITY MODEL COMPONENT - Rodolfo Costa
            XmlElement ele_entity = (XmlElement)xmlDocument.DocumentElement.SelectNodes("compose")[1];

            Componete componente = CriarComponente(ele);

            componente = criarCompose(componente, ele, nivel_1, nivel_2, nivel_3);

            /// GETTING ENTITY MODEL COMPONENT - Rodolfo Costa
            Componete componente_entity = CriarComponente(ele_entity);

            componente_entity = criarCompose(componente_entity, ele_entity, nivel_1, nivel_2, nivel_3);

            GerarArquivos(componente, componente_entity);
        }
Пример #9
0
        public override void Execute(Componete componente)
        {
            /// DomainPackage
            var domainClass = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:ServiceClass").ToList();

            foreach (var _class in domainClass)
            {
                Componete generalization = null;
                var       tags_class     = new Dictionary <string, string>();
                tags_class.Add("FW_CLASS_NAME", _class.name);

                if (_class.Componentes != null)
                {
                    generalization = _class.Componentes.Where(x => x.tag == "generalization").FirstOrDefault();

                    if (_class.Componentes.Any(x => x.xsi_type == "frameweb:ServiceMethod" && x.isAbstract))
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public abstract");
                    }
                    else
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public");
                    }

                    if (generalization != null)
                    {
                        var _generalization     = generalization.generalizationSet.Split('/');
                        var _str_generalization = _generalization[_generalization.Length - 1];
                        if (_str_generalization.Contains('.'))
                        {
                            _str_generalization = _str_generalization.Split('.')[0];
                        }
                        tags_class.Add("FW_EXTENDS", "extends " + _str_generalization);
                    }
                    else
                    {
                        tags_class.Add("FW_EXTENDS", string.Empty);
                    }


                    var _class_propeties = _class.Componentes.Where(x => x.xsi_type == "frameweb:ServiceAttribute").ToList();

                    string properties = string.Empty;
                    foreach (var propertie in _class_propeties)
                    {
                        var text_parameter = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + propertie.getXsiTypeFile());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", propertie.GetTypeDomainAttribute());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(propertie.name));
                        text_parameter = text_parameter.Replace("FW_PARAMETER", propertie.name);
                        text_parameter = text_parameter.Replace("FW_VISIBILITY", propertie.visibility);

                        properties += text_parameter;
                    }

                    tags_class.Add("FW_CLASS_PARAMETERS", properties);

                    var class_methods = _class.Componentes.Where(x => x.xsi_type == "frameweb:ServiceMethod").ToList();

                    string methods = string.Empty;
                    foreach (var method in class_methods)
                    {
                        string text_method;
                        if (method.isAbstract)
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + "Abstract" + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public abstract");
                        }
                        else
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public");
                        }

                        var    methodParameters       = method.Componentes.Where(x => x.tag == "ownedParameter").ToList();
                        string text_method_parameters = string.Empty;
                        if (methodParameters != null && methodParameters.Count() > 0)
                        {
                            foreach (var methodParameter in methodParameters)
                            {
                                text_method_parameters += string.Format("{0} {1},", methodParameter.getType(), methodParameter.name);
                            }

                            text_method_parameters = text_method_parameters.Substring(0, text_method_parameters.Length - 1);
                        }

                        text_method = text_method.Replace("FW_METHOD_PARAMETERS", text_method_parameters);

                        text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.GetMethodTypeDomainAttribute());
                        text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                        methods += text_method;
                    }

                    tags_class.Add("FW_CLASS_METHOD", methods);
                }

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + _class.getXsiTypeFile());
                foreach (var item in tags_class)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, _class.name + config.ext_class), text);
            }

            //SECURED SERVICE CLASSES
            var securedServiceClasses = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:AuthServiceClass").ToList();

            foreach (var _class in securedServiceClasses)
            {
                Componete generalization = null;
                var       tags_class     = new Dictionary <string, string>();
                tags_class.Add("FW_CLASS_NAME", _class.name);
                tags_class.Add("FW_PERM_NAME_APP_CLASS", _class.permissionName);
                if (_class.Componentes != null)
                {
                    generalization = _class.Componentes.Where(x => x.tag == "generalization").FirstOrDefault();

                    if (_class.Componentes.Any(x => x.xsi_type == "frameweb:ServiceMethod" && x.isAbstract))
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public abstract");
                    }
                    else
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public");
                    }

                    if (generalization != null)
                    {
                        var _generalization     = generalization.generalizationSet.Split('/');
                        var _str_generalization = _generalization[_generalization.Length - 1];
                        if (_str_generalization.Contains('.'))
                        {
                            _str_generalization = _str_generalization.Split('.')[0];
                        }
                        tags_class.Add("FW_EXTENDS", "extends " + _str_generalization);
                    }
                    else
                    {
                        tags_class.Add("FW_EXTENDS", string.Empty);
                    }


                    var _class_propeties = _class.Componentes.Where(x => x.xsi_type == "frameweb:ServiceAttribute").ToList();

                    string properties = string.Empty;
                    foreach (var propertie in _class_propeties)
                    {
                        var text_parameter = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + propertie.getXsiTypeFile());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", propertie.GetTypeDomainAttribute());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(propertie.name));
                        text_parameter = text_parameter.Replace("FW_PARAMETER", propertie.name);
                        text_parameter = text_parameter.Replace("FW_VISIBILITY", propertie.visibility);

                        properties += text_parameter;
                    }

                    tags_class.Add("FW_CLASS_PARAMETERS", properties);

                    var class_methods = _class.Componentes.Where(x => x.xsi_type == "frameweb:ServiceMethod").ToList();

                    string methods = string.Empty;
                    foreach (var method in class_methods)
                    {
                        string text_method;
                        if (method.isAbstract)
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + "Abstract" + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public abstract");
                        }
                        else
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public");
                        }

                        var    methodParameters       = method.Componentes.Where(x => x.tag == "ownedParameter").ToList();
                        string text_method_parameters = string.Empty;
                        if (methodParameters != null && methodParameters.Count() > 0)
                        {
                            foreach (var methodParameter in methodParameters)
                            {
                                text_method_parameters += string.Format("{0} {1},", methodParameter.getType(), methodParameter.name);
                            }

                            text_method_parameters = text_method_parameters.Substring(0, text_method_parameters.Length - 1);
                        }

                        text_method = text_method.Replace("FW_METHOD_PARAMETERS", text_method_parameters);

                        text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.GetMethodTypeDomainAttribute());
                        text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                        methods += text_method;
                    }

                    //SECURED METHOD
                    var secured_class_methods = _class.Componentes.Where(x => x.xsi_type == "frameweb:AuthServiceMethod").ToList();

                    methods = string.Empty;
                    foreach (var method in secured_class_methods)
                    {
                        string text_method;
                        if (method.isAbstract)
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + "Abstract" + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public abstract");
                        }
                        else
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public");
                        }

                        var    methodParameters       = method.Componentes.Where(x => x.tag == "ownedParameter").ToList();
                        string text_method_parameters = string.Empty;
                        if (methodParameters != null && methodParameters.Count() > 0)
                        {
                            foreach (var methodParameter in methodParameters)
                            {
                                text_method_parameters += string.Format("{0} {1},", methodParameter.getType(), methodParameter.name);
                            }

                            text_method_parameters = text_method_parameters.Substring(0, text_method_parameters.Length - 1);
                        }

                        text_method = text_method.Replace("FW_METHOD_PARAMETERS", text_method_parameters);

                        text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.GetMethodTypeDomainAttribute());
                        text_method = text_method.Replace("FW_METHOD_NAME", method.name);
                        text_method = text_method.Replace("FW_PERM_NAME_APP_METHOD", method.permissionName);

                        methods += text_method;
                    }

                    tags_class.Add("FW_CLASS_METHOD", methods);
                }

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + _class.getXsiTypeFile());
                foreach (var item in tags_class)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, _class.name + config.ext_class), text);
            }

            // INTERFACE
            var interfaces = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:ServiceInterface").ToList();

            foreach (var _interface in interfaces)
            {
                var tags_interface = new Dictionary <string, string>();
                tags_interface.Add("FW_INTERFACE_NAME", _interface.name);

                var realizations = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:ServiceRealization" && y.supplier.EndsWith(_interface.name)).ToList();


                foreach (var realization in realizations)
                {
                    string methods = string.Empty;
                    var    list_class_realization = domainClass.Where(x => x.name == realization.getClient()).ToList();
                    foreach (var class_realization in list_class_realization)
                    {
                        var class_methods = class_realization.Componentes.Where(x => x.xsi_type == "frameweb:ServiceMethod").ToList();


                        foreach (var method in class_methods)
                        {
                            string text_method = "FW_METHOD_RETURN_TYPE FW_METHOD_NAME(FW_METHOD_PARAMETERS);\n";

                            var    methodParameters       = method.Componentes.Where(x => x.tag == "ownedParameter").ToList();
                            string text_method_parameters = string.Empty;
                            if (methodParameters != null && methodParameters.Count() > 0)
                            {
                                foreach (var methodParameter in methodParameters)
                                {
                                    text_method_parameters += string.Format("{0} {1},", methodParameter.getType(), methodParameter.name);
                                }

                                text_method_parameters = text_method_parameters.Substring(0, text_method_parameters.Length - 1);
                            }

                            text_method = text_method.Replace("FW_METHOD_PARAMETERS", text_method_parameters);
                            text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.GetMethodTypeDomainAttribute());
                            text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                            methods += text_method;
                        }
                    }
                    tags_interface.Add("FW_INTERFACE_METHOD", methods);
                }

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + _interface.getXsiTypeFile());
                foreach (var item in tags_interface)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, _interface.name + config.ext_class), text);

                realizations = null;

                //
            }
        }
Пример #10
0
        public override void Execute(Componete componente)
        {
            /// DomainPackage
            var domainClass = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:DomainClass").ToList();

            //domainClass = domainClass.Where(x => x.name == "Person").ToList();

            foreach (var _class in domainClass)
            {
                Componete generalization = null;
                var       tags_class     = new Dictionary <string, string>();
                tags_class.Add("FW_CLASS_NAME", _class.name);

                if (_class.Componentes != null)
                {
                    generalization = _class.Componentes.Where(x => x.tag == "generalization").FirstOrDefault();

                    if (_class.Componentes.Any(x => x.xsi_type == "frameweb:DomainMethod" && x.isAbstract))
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public abstract");
                    }
                    else
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public");
                    }

                    if (generalization != null)
                    {
                        var _generalization     = generalization.generalizationSet.Split('/');
                        var _str_generalization = _generalization[_generalization.Length - 1];
                        if (_str_generalization.Contains('.'))
                        {
                            _str_generalization = _str_generalization.Split('.')[0];
                        }
                        tags_class.Add("FW_EXTENDS", "extends " + _str_generalization);
                    }
                    else
                    {
                        tags_class.Add("FW_EXTENDS", string.Empty);
                    }


                    var _class_propeties = _class.Componentes.Where(x => x.xsi_type == "frameweb:DomainAttribute").ToList();

                    string properties = string.Empty;
                    foreach (var propertie in _class_propeties)
                    {
                        var text_parameter = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + propertie.getXsiTypeFile());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", propertie.GetTypeDomainAttribute());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(propertie.name));
                        text_parameter = text_parameter.Replace("FW_PARAMETER", propertie.name);
                        text_parameter = text_parameter.Replace("FW_VISIBILITY", propertie.visibility);

                        properties += text_parameter;
                    }

                    tags_class.Add("FW_CLASS_PARAMETERS", properties);

                    var class_methods = _class.Componentes.Where(x => x.xsi_type == "frameweb:DomainMethod").ToList();

                    string methods = string.Empty;
                    foreach (var method in class_methods)
                    {
                        string text_method;
                        if (method.isAbstract)
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + "Abstract" + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public abstract");
                        }
                        else
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public");
                        }


                        text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.GetMethodTypeDomainAttribute());
                        text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                        methods += text_method;
                    }

                    tags_class.Add("FW_CLASS_METHOD", methods);
                }

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + _class.getXsiTypeFile());
                foreach (var item in tags_class)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, _class.name + config.ext_class), text);
            }
        }
Пример #11
0
        private static void GerarArquivos(Componete componente)
        {
            var dir_template     = ConfigurationManager.AppSettings["dir_template"];
            var projeto          = dir_template + "projeto\\" + ConfigurationManager.AppSettings["projeto"];
            var lang             = ConfigurationManager.AppSettings["lang"];
            var dir_output_web   = ConfigurationManager.AppSettings["dir_output_web"];
            var dir_output_class = ConfigurationManager.AppSettings["dir_output_class"];
            var ext_class        = ConfigurationManager.AppSettings["ext_class"];
            var dir_output       = "build\\";

            try
            {
                if (Directory.Exists(dir_output))
                {
                    Directory.Delete(dir_output, true);
                }
            }
            catch (Exception)
            {
                Log("Falha ao tentar remover o diretório destino, verifique se nenhum arquivo está em uso.");
                return;
            }

            Log("Removento build dir");
            Thread.Sleep(2000);
            Directory.CreateDirectory(dir_output);

            //Now Create all of the directories
            foreach (string dirPath in Directory.GetDirectories(projeto, "*",
                                                                SearchOption.AllDirectories))
            {
                Directory.CreateDirectory(dirPath.Replace(projeto, dir_output));
            }

            //Copy all the files & Replaces any files with the same name
            foreach (string newPath in Directory.GetFiles(projeto, "*.*",
                                                          SearchOption.AllDirectories))
            {
                File.Copy(newPath, newPath.Replace(projeto, dir_output), true);
            }

            /// CONTROLLER
            var controllers     = componente.Componentes.Where(x => x.xsi_type == "frameweb:ControllerPackage").ToList().SelectMany(x => x.Componentes).ToList();
            var tags_controller = new Dictionary <string, string>();

            foreach (var controller in controllers)
            {
                tags_controller.Add("FW_CLASS_NAME", controller.name);

                var frontControllerDependency = componente.Componentes.Where(x => x.xsi_type == "frameweb:FrontControllerDependency" && x.getSupplier() == controller.name).FirstOrDefault();
                tags_controller.Add("FW_BEAN_NAME", frontControllerDependency != null ? frontControllerDependency.getClient() : string.Empty);

                //tags_controller.Add("FW_BEAN_CLASS_NAME", "NNN");

                var controller_parameters = controller.Componentes.Where(x => x.xsi_type == "frameweb:IOParameter").ToList();

                string parameters = string.Empty;
                foreach (var parameter in controller_parameters)
                {
                    var text_parameter = File.ReadAllText(dir_template + lang + "\\" + parameter.getXsiTypeFile());
                    text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", parameter.parameterType);
                    text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", FirstCharToUpper(parameter.name));
                    text_parameter = text_parameter.Replace("FW_PARAMETER", parameter.name);

                    parameters += text_parameter;
                }

                tags_controller.Add("FW_FRONT_CONTROLLER_PARAMETERS", parameters);

                var controller_methods = controller.Componentes.Where(x => x.xsi_type == "frameweb:FrontControllerMethod").ToList();

                string methods = string.Empty;
                foreach (var method in controller_methods)
                {
                    var text_method = File.ReadAllText(dir_template + lang + "\\" + method.getXsiTypeFile());
                    text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.methodType);
                    text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                    methods += text_method;
                }

                tags_controller.Add("FW_FRONT_CONTROLLER_METHOD", methods);

                var text = File.ReadAllText(dir_template + lang + "\\" + controller.getXsiTypeFile());
                foreach (var item in tags_controller)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                File.WriteAllText(Path.Combine(dir_output, dir_output_class, controller.name + ext_class), text);
            }
            /// VIEW

            var views = componente.Componentes.Where(x => x.xsi_type == "frameweb:ViewPackage").ToList().SelectMany(x => x.Componentes).ToList();

            var views_pages = views.Where(x => x.xsi_type == "frameweb:Page").ToList();

            foreach (var page in views_pages)
            {
                string body = string.Empty;

                var componentes_dentro_pagina = page.Componentes.Where(x => x.xsi_type == "frameweb:NavigationCompositionWhole").ToList();
                foreach (Componete componente_pagina in componentes_dentro_pagina)
                {
                    var comp = views.Where(x => x.name == componente_pagina.getType()).FirstOrDefault();
                    if (comp != null)
                    {
                        string body_form = string.Empty;
                        if (comp.xsi_type == "frameweb:UIComponent")// Form
                        {
                            body_form = File.ReadAllText(dir_template + "framework\\" + comp.getXsiTypeFile());
                        }
                        string body_form_comp = string.Empty;
                        foreach (var item in comp.Componentes)
                        {
                            var field_template = File.ReadAllText(dir_template + "framework\\" + item.getXsiTypeFile());
                            field_template = field_template.Replace("FW_ID", item.name.Replace('.', '_'));
                            field_template = field_template.Replace("FW_VALUE", comp.name + "." + item.name);

                            body_form_comp += field_template;
                        }

                        body_form = body_form.Replace("FW_BODY", body_form_comp);
                        body_form = body_form.Replace("FW_ID", comp.name);
                        body     += body_form;
                    }
                }

                var text = File.ReadAllText(dir_template + "framework\\" + page.getXsiTypeFile());
                text = text.Replace("FW_BODY", body);

                File.WriteAllText(Path.Combine(dir_output, dir_output_web, page.name), text);
            }
            Process.Start("explorer.exe", dir_output);
        }
Пример #12
0
 public abstract void Execute(Componete componente);
Пример #13
0
        static void AttributeValue(XmlAttributeCollection itens, ref Componete filho)
        {
            foreach (XmlAttribute item in itens)
            {
                switch (item.Name)
                {
                case "xsi:type":
                    filho.xsi_type = item.Value;
                    break;

                case "name":
                    filho.name = item.Value;
                    break;

                case "type":
                    filho.type = item.Value;
                    break;

                case "association":
                    filho.association = item.Value;
                    break;

                case "memberEnd":
                    filho.memberEnd = item.Value;
                    break;

                case "href":
                    filho.href = item.Value;
                    break;

                case "client":
                    filho.client = item.Value;
                    break;

                case "supplier":
                    filho.supplier = item.Value;
                    break;

                case "resultMethod":
                    filho.resultMethod = item.Value;
                    break;

                case "methodType":
                    filho.methodType = item.Value;
                    break;

                case "parameterType":
                    filho.parameterType = item.Value;
                    break;

                case "visibility":
                    filho.visibility = item.Value;
                    break;

                case "isAbstract":
                    filho.isAbstract = item.Value.ToString().ToLower().Equals("true");
                    break;

                case "generalizationSet":
                    filho.generalizationSet = item.Value;
                    break;

                case "infix":
                    filho.infix = item.Value;
                    break;

                case "permissionName":
                    filho.permissionName = item.Value;
                    break;
                }
            }
        }
        private void CreateClasses(Componete componente)
        {
            var daoClasses = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:DAOClass").ToList();

            if (daoClasses != null && daoClasses.Count > 0)
            {
                // Copiar arquivos padrões
            }

            foreach (var _class in daoClasses)
            {
                var tags_class = new Dictionary <string, string>();
                tags_class.Add("FW_CLASS_NAME", _class.name);


                Componete generalization = _class.Componentes.Where(x => x.tag == "generalization").FirstOrDefault();


                if (generalization != null)
                {
                    var _generalization     = generalization.generalizationSet.Split('/');
                    var _str_generalization = _generalization[_generalization.Length - 1];
                    if (_str_generalization.Contains('.'))
                    {
                        _str_generalization = _str_generalization.Split('.')[0];
                    }
                    tags_class.Add("FW_EXTENDS", "extends " + _str_generalization);
                }
                else
                {
                    tags_class.Add("FW_EXTENDS", string.Empty);
                }

                Componete realization = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:DAORealization" && y.getClient() == _class.name).FirstOrDefault();


                if (realization != null)
                {
                    tags_class.Add("FW_IMPLEMENTS", "implements " + realization.getSupplier());

                    Componete daoInterface = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:DAOInterface" && y.name == realization.getSupplier()).FirstOrDefault();

                    if (daoInterface != null)
                    {
                        tags_class.Add("FW_CLASS_IMPLEMENTS_INFIX", "implements " + realization.getSupplier());
                    }
                    else
                    {
                        tags_class.Add("FW_CLASS_IMPLEMENTS_INFIX", "set infix on interface");
                    }
                }
                else
                {
                    tags_class.Add("FW_IMPLEMENTS", string.Empty);
                }


                if (_class.Componentes != null)
                {
                    if (_class.Componentes.Any(x => x.xsi_type == "frameweb:DAOMethod" && x.isAbstract))
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public abstract");
                    }
                    else
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public");
                    }


                    var _class_propeties = _class.Componentes.Where(x => x.xsi_type == "frameweb:DAOAttribute").ToList();

                    string properties = string.Empty;
                    foreach (var propertie in _class_propeties)
                    {
                        var text_parameter = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + propertie.getXsiTypeFile());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", propertie.GetTypeDomainAttribute());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(propertie.name));
                        text_parameter = text_parameter.Replace("FW_PARAMETER", propertie.name);
                        text_parameter = text_parameter.Replace("FW_VISIBILITY", propertie.visibility);

                        properties += text_parameter;
                    }

                    tags_class.Add("FW_CLASS_PARAMETERS", properties);

                    var class_methods = _class.Componentes.Where(x => x.xsi_type == "frameweb:DAOMethod").ToList();

                    string methods = string.Empty;
                    foreach (var method in class_methods)
                    {
                        string text_method;
                        if (method.isAbstract)
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + "Abstract" + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public abstract");
                        }
                        else
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public");
                        }


                        text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.GetMethodTypeDomainAttribute());
                        text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                        methods += text_method;
                    }

                    tags_class.Add("FW_CLASS_METHOD", methods);
                }

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + _class.getXsiTypeFile());
                foreach (var item in tags_class)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, _class.name + config.ext_class), text);
            }
        }
 public override void Execute(Componete componente)
 {
     this.CreateInterfaces(componente);
     this.CreateClasses(componente);
 }
Пример #16
0
        public override void Execute(Componete componente)
        {
            /// CONTROLLER
            var controllers = componente.Componentes.Where(x => x.xsi_type == "frameweb:ControllerPackage").ToList().SelectMany(x => x.Componentes).ToList();

            foreach (var controller in controllers)
            {
                if (controller.getXsiTypeFile() == "ServiceControllerAssociation.txt")
                {
                    continue;
                }

                var tags_controller = new Dictionary <string, string>();

                tags_controller.Add("FW_CLASS_NAME", controller.name);

                var frontControllerDependency = componente.Componentes.Where(x => x.xsi_type == "frameweb:FrontControllerDependency" && x.getSupplier() == controller.name).FirstOrDefault();
                tags_controller.Add("FW_BEAN_NAME", frontControllerDependency != null ? frontControllerDependency.getClient() : string.Empty);

                //tags_controller.Add("FW_BEAN_CLASS_NAME", "NNN");

                var controller_parameters = controller.Componentes.Where(x => x.xsi_type == "frameweb:IOParameter").ToList();

                string parameters = string.Empty;
                foreach (var parameter in controller_parameters)
                {
                    var text_parameter = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + parameter.getXsiTypeFile());
                    text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", parameter.parameterType);
                    text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(parameter.name));
                    text_parameter = text_parameter.Replace("FW_PARAMETER", parameter.name);

                    parameters += text_parameter;
                }

                tags_controller.Add("FW_FRONT_CONTROLLER_PARAMETERS", parameters);

                var controller_methods = controller.Componentes.Where(x => x.xsi_type == "frameweb:FrontControllerMethod").ToList();

                string methods = string.Empty;
                foreach (var method in controller_methods)
                {
                    var text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                    text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.methodType);
                    text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                    methods += text_method;
                }

                tags_controller.Add("FW_FRONT_CONTROLLER_METHOD", methods);

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + controller.getXsiTypeFile());
                foreach (var item in tags_controller)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, controller.name + config.ext_class), text);
            }
            /// VIEW

            var views = componente.Componentes.Where(x => x.xsi_type == "frameweb:ViewPackage").ToList().SelectMany(x => x.Componentes).ToList();

            var views_pages = views.Where(x => x.xsi_type == "frameweb:Page").ToList();

            foreach (var page in views_pages)
            {
                string body = string.Empty;

                var componentes_dentro_pagina = page.Componentes.Where(x => x.xsi_type == "frameweb:NavigationCompositionWhole").ToList();
                foreach (Componete componente_pagina in componentes_dentro_pagina)
                {
                    var comp = views.Where(x => x.name == componente_pagina.getType()).FirstOrDefault();
                    if (comp != null)
                    {
                        string body_form = string.Empty;
                        if (comp.xsi_type == "frameweb:UIComponent")// Form
                        {
                            body_form = File.ReadAllText(config.dir_template + "framework" + Path.DirectorySeparatorChar + comp.getXsiTypeFile());
                        }
                        string body_form_comp = string.Empty;
                        foreach (var item in comp.Componentes)
                        {
                            // Get file path template for component UI (input, radio, ...)
                            var field_template = File.ReadAllText(item.getXsiTypeFile());
                            field_template = field_template.Replace("FW_ID", item.name.Replace('.', '_'));
                            field_template = field_template.Replace("FW_VALUE", comp.name + "." + item.name);

                            body_form_comp += field_template;
                        }

                        body_form = body_form.Replace("FW_BODY", body_form_comp);
                        body_form = body_form.Replace("FW_ID", comp.name);
                        body     += body_form;
                    }
                }

                var text = File.ReadAllText(config.dir_template + "framework" + Path.DirectorySeparatorChar + page.getXsiTypeFile());
                text = text.Replace("FW_BODY", body);

                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_web, page.name), text);
            }

            Utilities.Log("Code generated successfully.");
        }
Пример #17
0
        private static void GerarArquivos(Componete componente, Componete componente_entity)
        {
            var dir_template       = ConfigurationManager.AppSettings["dir_template"];
            var projeto            = dir_template + "projeto\\" + ConfigurationManager.AppSettings["projeto"];
            var lang               = ConfigurationManager.AppSettings["lang"];
            var dir_output_web     = ConfigurationManager.AppSettings["dir_output_web"];
            var dir_output_class   = ConfigurationManager.AppSettings["dir_output_class"];
            var ext_class          = ConfigurationManager.AppSettings["ext_class"];
            var ext_auth_config    = ConfigurationManager.AppSettings["ext_auth_config"];
            var dir_in_auth_config = ConfigurationManager.AppSettings["dir_in_auth_config"];
            var auth_config_name   = ConfigurationManager.AppSettings["auth_config_name"];
            var dir_output         = "build\\";

            try
            {
                if (Directory.Exists(dir_output))
                {
                    Directory.Delete(dir_output, true);
                }
            }
            catch (Exception)
            {
                Log("Falha ao tentar remover o diretório destino, verifique se nenhum arquivo está em uso.");
                return;
            }

            Log("Removento build dir");
            Thread.Sleep(2000);
            Directory.CreateDirectory(dir_output);

            //Now Create all of the directories
            foreach (string dirPath in Directory.GetDirectories(projeto, "*",
                                                                SearchOption.AllDirectories))
            {
                Directory.CreateDirectory(dirPath.Replace(projeto, dir_output));
            }

            //Copy all the files & Replaces any files with the same name
            foreach (string newPath in Directory.GetFiles(projeto, "*.*",
                                                          SearchOption.AllDirectories))
            {
                File.Copy(newPath, newPath.Replace(projeto, dir_output), true);
            }

            /// CONTROLLER
            var controllers     = componente.Componentes.Where(x => x.xsi_type == "frameweb:ControllerPackage").ToList().SelectMany(x => x.Componentes).ToList();
            var tags_controller = new Dictionary <string, string>();

            foreach (var controller in controllers)
            {
                tags_controller.Add("FW_CLASS_NAME", controller.name);

                var frontControllerDependency = componente.Componentes.Where(x => x.xsi_type == "frameweb:FrontControllerDependency" && x.getSupplier() == controller.name).FirstOrDefault();
                tags_controller.Add("FW_BEAN_NAME", frontControllerDependency != null ? frontControllerDependency.getClient() : string.Empty);

                //tags_controller.Add("FW_BEAN_CLASS_NAME", "NNN");

                var controller_parameters = controller.Componentes.Where(x => x.xsi_type == "frameweb:IOParameter").ToList();

                string parameters = string.Empty;
                foreach (var parameter in controller_parameters)
                {
                    var text_parameter = File.ReadAllText(dir_template + lang + "\\" + parameter.getXsiTypeFile());
                    text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", parameter.parameterType);
                    text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", FirstCharToUpper(parameter.name));
                    text_parameter = text_parameter.Replace("FW_PARAMETER", parameter.name);

                    parameters += text_parameter;
                }

                tags_controller.Add("FW_FRONT_CONTROLLER_PARAMETERS", parameters);

                var controller_methods = controller.Componentes.Where(x => x.xsi_type == "frameweb:FrontControllerMethod").ToList();

                string methods = string.Empty;
                foreach (var method in controller_methods)
                {
                    var text_method = File.ReadAllText(dir_template + lang + "\\" + method.getXsiTypeFile());
                    text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.methodType);
                    text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                    methods += text_method;
                }

                tags_controller.Add("FW_FRONT_CONTROLLER_METHOD", methods);

                var text = File.ReadAllText(dir_template + lang + "\\" + controller.getXsiTypeFile());
                foreach (var item in tags_controller)
                {
                    text = text.Replace(item.Key, item.Value);
                }
                Directory.CreateDirectory(Path.Combine(dir_output, dir_output_class));

                File.WriteAllText(Path.Combine(dir_output, dir_output_class, controller.name + ext_class), text);
            }
            /// VIEW

            var views = componente.Componentes.Where(x => x.xsi_type == "frameweb:ViewPackage").ToList().SelectMany(x => x.Componentes).ToList();
            /// seleciona as Page e authPages - Rodolfo Costa do Prado
            var views_pages = views.Where(x => x.xsi_type == "frameweb:Page" || x.xsi_type == "frameweb:AuthPage").ToList();

            foreach (var page in views_pages)
            {
                string body = string.Empty;

                var componentes_dentro_pagina = page.Componentes.Where(x => x.xsi_type == "frameweb:NavigationCompositionWhole").ToList();
                foreach (Componete componente_pagina in componentes_dentro_pagina)
                {
                    var comp = views.Where(x => x.name == componente_pagina.getType()).FirstOrDefault();
                    if (comp != null)
                    {
                        string body_form = string.Empty;
                        if (comp.xsi_type == "frameweb:UIComponent")// Form
                        {
                            body_form = File.ReadAllText(dir_template + "framework\\" + comp.getXsiTypeFile());
                        }
                        string body_form_comp = string.Empty;
                        foreach (var item in comp.Componentes)
                        {
                            var field_template = File.ReadAllText(dir_template + "framework\\" + item.getXsiTypeFile());
                            field_template = field_template.Replace("FW_ID", item.name.Replace('.', '_'));
                            field_template = field_template.Replace("FW_VALUE", comp.name + "." + item.name);

                            body_form_comp += field_template;
                        }

                        body_form = body_form.Replace("FW_BODY", body_form_comp);
                        body_form = body_form.Replace("FW_ID", comp.name);
                        body     += body_form;
                    }
                }

                var text = File.ReadAllText(dir_template + "framework\\" + page.getXsiTypeFile());
                text = text.Replace("FW_BODY", body);

                File.WriteAllText(Path.Combine(dir_output, dir_output_web, page.name), text);
            }

            /// AUTH CONFIG - Rodolfo Costa do Prado

            var tags_authConfig = new Dictionary <string, string>();

            var login_page = views.Where(x => x.xsi_type == "frameweb:AuthPage").FirstOrDefault();

            tags_authConfig.Add("FW_AUTH_LOGIN_PAGE", login_page.name);

            foreach (var controller in controllers)
            {
                //assuming only one login proc method can be informed
                var auth_proc_method = controller.Componentes.Where(x => x.xsi_type == "frameweb:AuthProcessingMethod").FirstOrDefault();

                //USAR TAGLIB AQUI?
                tags_authConfig.Add("FW_AUTH_LOGIN_PROC_URL", auth_proc_method != null ? string.Concat(controller.name, "/", auth_proc_method.name) : string.Empty);
            }
            //GETTING THE SUCCESS AND FAILURE URL
            var authSuccessUrl = componente.Componentes.Where(x => x.xsi_type == "frameweb:AuthSuccessUrl").FirstOrDefault().supplier;
            var authFailureUrl = componente.Componentes.Where(x => x.xsi_type == "frameweb:AuthFailureUrl").FirstOrDefault().supplier;

            tags_authConfig.Add("FW_AUTH_LOGIN_SUCC_URL", authSuccessUrl);
            tags_authConfig.Add("FW_AUTH_LOGIN_FAIL_URL", authFailureUrl);

            //GETTING THE AUTH DOMAIN CLASSES
            var domain_classes = componente_entity.Componentes.Where(x => x.xsi_type == "frameweb:DomainPackage").FirstOrDefault();

            //assuming only one of each auth domain classes can be made
            var auth_user_class = domain_classes.Componentes.Where(x => x.xsi_type == "frameweb:AuthUser").FirstOrDefault();
            var auth_role_class = domain_classes.Componentes.Where(x => x.xsi_type == "frameweb:AuthRole").FirstOrDefault();
            var auth_perm_class = domain_classes.Componentes.Where(x => x.xsi_type == "frameweb:AuthPermission").FirstOrDefault();

            if (auth_user_class != null && auth_role_class != null && auth_perm_class != null)
            {
                tags_authConfig.Add("FW_AUTH_USER", auth_user_class.name.Replace(" ", "_"));
                tags_authConfig.Add("FW_AUTH_ROLE", auth_role_class.name.Replace(" ", "_"));
                tags_authConfig.Add("FW_AUTH_PERM", auth_perm_class.name.Replace(" ", "_"));
                //REPLACING USER COLUM NAMES
                tags_authConfig.Add("FW_USER_ID", auth_user_class.Componentes.Where(x => x.xsi_type == "frameweb:IdAttribute").FirstOrDefault().name);
                tags_authConfig.Add("FW_AUTHAT_USER_USERNAME", auth_user_class.Componentes.Where(x => x.xsi_type == "frameweb:AuthUserName").FirstOrDefault().name);
                tags_authConfig.Add("FW_AUTHAT_USER_PASSWORD", auth_user_class.Componentes.Where(x => x.xsi_type == "frameweb:AuthPassword").FirstOrDefault().name);
                //REPLACING ROLE COLUM NAMES
                tags_authConfig.Add("FW_AUTHAT_ROLE_ROLENAME", auth_role_class.Componentes.Where(x => x.xsi_type == "frameweb:AuthRoleName").FirstOrDefault().name);
                //REPLACING PERM COLUM NAMES
                tags_authConfig.Add("FW_AUTHAT_PERM_NAME", auth_perm_class.Componentes.Where(x => x.xsi_type == "frameweb:AuthPermName").FirstOrDefault().name);
            }


            var textConfig = File.ReadAllText(dir_template + dir_in_auth_config);

            foreach (var item in tags_authConfig)
            {
                textConfig = textConfig.Replace(item.Key, item.Value);
            }

            Directory.CreateDirectory(Path.Combine(dir_output, dir_output_web));

            File.WriteAllText(Path.Combine(dir_output, dir_output_web, auth_config_name + ext_auth_config), textConfig);


            Process.Start("explorer.exe", dir_output);
        }
Пример #18
0
        public override void Execute(Componete componente)
        {
            /// CONTROLLER
            var controllers = componente.Componentes.Where(x => x.xsi_type == "frameweb:ControllerPackage").ToList().SelectMany(x => x.Componentes).ToList();

            foreach (var controller in controllers)
            {
                if (controller.getXsiTypeFile() == "ServiceControllerAssociation.txt")
                {
                    continue;
                }

                var tags_controller = new Dictionary <string, string>();

                tags_controller.Add("FW_CLASS_NAME", controller.name);

                var frontControllerDependency = componente.Componentes.Where(x => x.xsi_type == "frameweb:FrontControllerDependency" && x.getSupplier() == controller.name).FirstOrDefault();
                tags_controller.Add("FW_BEAN_NAME", frontControllerDependency != null ? frontControllerDependency.getClient() : string.Empty);

                //tags_controller.Add("FW_BEAN_CLASS_NAME", "NNN");

                var controller_parameters = controller.Componentes.Where(x => x.xsi_type == "frameweb:IOParameter").ToList();

                string parameters = string.Empty;
                foreach (var parameter in controller_parameters)
                {
                    var text_parameter = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + parameter.getXsiTypeFile());
                    text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", parameter.parameterType);
                    text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(parameter.name));
                    text_parameter = text_parameter.Replace("FW_PARAMETER", parameter.name);

                    parameters += text_parameter;
                }

                tags_controller.Add("FW_FRONT_CONTROLLER_PARAMETERS", parameters);

                var controller_methods = controller.Componentes.Where(x => x.xsi_type == "frameweb:FrontControllerMethod").ToList();

                string methods = string.Empty;
                foreach (var method in controller_methods)
                {
                    var text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                    text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.methodType);
                    text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                    methods += text_method;
                }

                //ADD LOGIN PROCESSING METHOD
                var auth_proc_method = controller.Componentes.Where(x => x.xsi_type == "frameweb:AuthProcessingMethod").ToList();
                foreach (var method in auth_proc_method)
                {
                    var text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                    text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.methodType);
                    text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                    methods += text_method;
                }

                tags_controller.Add("FW_FRONT_CONTROLLER_METHOD", methods);

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + controller.getXsiTypeFile());
                foreach (var item in tags_controller)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, controller.name + config.ext_class), text);
            }
            /// VIEW

            var views = componente.Componentes.Where(x => x.xsi_type == "frameweb:ViewPackage").ToList().SelectMany(x => x.Componentes).ToList();

            var views_pages = views.Where(x => x.xsi_type == "frameweb:Page" ||
                                          x.xsi_type == "frameweb:AuthPage").ToList();

            foreach (var page in views_pages)
            {
                string body = string.Empty;

                var componentes_dentro_pagina = page.Componentes.Where(x => x.xsi_type == "frameweb:NavigationCompositionWhole").ToList();
                foreach (Componete componente_pagina in componentes_dentro_pagina)
                {
                    var comp = views.Where(x => x.name == componente_pagina.getType()).FirstOrDefault();
                    if (comp != null)
                    {
                        string body_form = string.Empty;
                        if (comp.xsi_type == "frameweb:UIComponent")// Form
                        {
                            body_form = File.ReadAllText(config.dir_template + "framework" + Path.DirectorySeparatorChar + comp.getXsiTypeFile());
                        }
                        else
                        {
                            if (comp.xsi_type == "frameweb:AuthForm")// Form
                            {
                                //USES A LOGIN FORM TEMPLATE INSTEAD
                                body_form = File.ReadAllText(config.dir_template + "framework" + Path.DirectorySeparatorChar + comp.getXsiTypeFile());
                            }
                        }
                        string body_form_comp = string.Empty;
                        foreach (var item in comp.Componentes)
                        {
                            // Get file path template for component UI (input, radio, ...)
                            var field_template = File.ReadAllText(item.getXsiTypeFile());
                            field_template = field_template.Replace("FW_ID", item.name.Replace('.', '_'));
                            field_template = field_template.Replace("FW_VALUE", comp.name + "." + item.name);

                            body_form_comp += field_template;
                        }

                        body_form = body_form.Replace("FW_BODY", body_form_comp);
                        body_form = body_form.Replace("FW_ID", comp.name);
                        body     += body_form;
                    }
                }

                var text = File.ReadAllText(config.dir_template + "framework" + Path.DirectorySeparatorChar + page.getXsiTypeFile());
                text = text.Replace("FW_BODY", body);

                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_web, page.name), text);
            }

            var login_page = views.Where(x => x.xsi_type == "frameweb:AuthPage").FirstOrDefault();

            if (login_page != null)
            {
                //DICTIONARY FOR THE SECURITY FILE
                var tags_class_sec = new Dictionary <string, string>();
                tags_class_sec.Add("FW_AUTH_LOGIN_PAGE", login_page.name);

                var login_form = views.Where(x => x.xsi_type == "frameweb:AuthPage").FirstOrDefault();

                //GETTING THE SUCCESS AND FAILURE URL
                var authSuccessUrl = componente.Componentes.Where(x => x.xsi_type == "frameweb:AuthSuccessUrl").FirstOrDefault().getSupplier();
                var authFailureUrl = componente.Componentes.Where(x => x.xsi_type == "frameweb:AuthFailureUrl").FirstOrDefault().getSupplier();

                tags_class_sec.Add("FW_AUTH_LOGIN_SUCC_URL", authSuccessUrl);
                tags_class_sec.Add("FW_AUTH_LOGIN_FAIL_URL", authFailureUrl);

                var text_sec = "";

                try
                {
                    text_sec = File.ReadAllText(Path.Combine(config.dir_output, "src\\sec-config.txt"));
                }
                catch
                {
                    text_sec = File.ReadAllText(config.dir_template_sec_config);
                }

                foreach (var item in tags_class_sec)
                {
                    text_sec = text_sec.Replace(item.Key, item.Value);
                }

                try
                {
                    // Directory.CreateDirectory(Path.Combine(config.dir_output,"src\\sec-config.txt"));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, "src\\sec-config.txt"), text_sec);
            }

            Utilities.Log("Code generated successfully.");
        }