Exemple #1
0
        private static string GenMethodReturn(TableViewBase pTable, CodeGeneratorCommon.MethodActionType t)
        {
            StringBuilder wBuilderReturn = null;
            switch (t)
            {
                case CodeGeneratorCommon.MethodActionType.Insert:
                    {
                        Column pPK = FwkGenerator.GetPrimaryKey(pTable);
                        if (pPK != null)
                        {
                            wBuilderReturn = new StringBuilder(FwkGenerator.TemplateDocument.GetTemplate("InsertReturn").Content);
                            wBuilderReturn.Replace(CodeGeneratorCommon.CommonConstants.CONST_ENTITY_PROPERTY_NAME, pPK.Name);
                            wBuilderReturn.Replace(CodeGeneratorCommon.CommonConstants.CONST_TYPENAME, FwkGenerator.GetCSharpType(pPK));

                            return wBuilderReturn.ToString();
                        }
                        else
                            return "  wDataBase.ExecuteNonQuery(wCmd);";
                    }
                case CodeGeneratorCommon.MethodActionType.Update:
                    return "  wDataBase.ExecuteNonQuery(wCmd);";

                case CodeGeneratorCommon.MethodActionType.SearchByParam:

                    wBuilderReturn = new StringBuilder(FwkGenerator.TemplateDocument.GetTemplate("SearchReturn").Content);

                    return wBuilderReturn.ToString();
                case CodeGeneratorCommon.MethodActionType.Delete:
                    return "  wDataBase.ExecuteNonQuery(wCmd);";

            }

            return string.Empty;

        }
Exemple #2
0
 static string GenBatchMethod(TableViewBase pTable, CodeGeneratorCommon.MethodActionType t)
 {
     StringBuilder wMethod = new StringBuilder(FwkGenerator.TemplateDocument.GetTemplate("MethodBatch").Content);
     wMethod.Replace("[SummaryParams]", GenParametersSummary(t, pTable));
     wMethod.Replace("[ParamArgs]", GenMethodParameters(t, pTable));
     wMethod.Replace("[MethodName]", t.ToString());
     wMethod.Replace("[StoredProcedureName]", GetSPName(pTable, t));
     wMethod.Replace("[Parameters]", GenSPParameters_Batch(pTable, t));
     return wMethod.ToString();
 }
Exemple #3
0
 static string GenMethod(TableViewBase pTable, CodeGeneratorCommon.MethodActionType t)
 {
     StringBuilder wMethod = new StringBuilder(_Method_tt);
     wMethod.Replace("[SummaryParams]", GenParametersSummary(t, pTable));
     wMethod.Replace("[ParamArgs]", GenMethodParameters(t, pTable));
     wMethod.Replace("[MethodName]", t.ToString());
     wMethod.Replace("[RetType]", GetRetType(pTable, t));
     wMethod.Replace("[StoredProcedureName]", GetSPName(pTable, t));
     wMethod.Replace("[Parameters]", GenSPParameters(pTable, t));
     wMethod.Replace("[Declarations]", GenDeclaration(pTable, t));
     wMethod.Replace("[Return]", GenMethodReturn(pTable, t));
     return wMethod.ToString();
 }
Exemple #4
0
        private static string GenDeclaration(TableViewBase pTable, CodeGeneratorCommon.MethodActionType t)
        {

            switch (t)
            {
                case CodeGeneratorCommon.MethodActionType.GetByParam:
                case CodeGeneratorCommon.MethodActionType.SearchByParam:
                    {
                        return FwkGenerator.TemplateDocument.GetTemplate("EntityAnListDeclaration").Content;
                    }

            }

            return string.Empty;

        }
Exemple #5
0
        static string GenSPParameters_Batch(TableViewBase pTable, CodeGeneratorCommon.MethodActionType pMethodActionType)
        {

            StringBuilder wParams = new StringBuilder();
            int i = 0;
            bool appendProperty = true;
            Column primaryKey = FwkGenerator.GetPrimaryKey(pTable);
            foreach (Column c in pTable.Columns)
            {
                i++;
                if (pMethodActionType == CodeGeneratorCommon.MethodActionType.Insert ||
                    pMethodActionType == CodeGeneratorCommon.MethodActionType.Update)
                {

                    if (primaryKey != null)
                        appendProperty = !(primaryKey == c && pMethodActionType == CodeGeneratorCommon.MethodActionType.Insert);

                    if (appendProperty)
                        //i == pTable.Columns.Count --> Fin de la coleccion
                        wParams.Append(Get_Property_Batch(c, (i == pTable.Columns.Count)));

                }


            }
            return wParams.ToString();
        }
Exemple #6
0
        static string GenSPParameters(TableViewBase pTable, CodeGeneratorCommon.MethodActionType pMethodActionType)
        {

            StringBuilder wParams = new StringBuilder();



            switch (pMethodActionType)
            {
                case CodeGeneratorCommon.MethodActionType.Insert:
                    foreach (Column c in pTable.Columns)
                    {
                        if (!FwkGenerator.NotSupportTypes_ToIncludeInBackEnd.Contains(c.DataType.SqlDataType.ToString().ToLower()))
                        {
                            if (c.InPrimaryKey)
                            {
                                wParams.Append(GetOutParameter(pTable, c));
                            }
                            else
                            {
                                wParams.Append(GetInParameter(pTable, c));
                            }
                        }
                    }
                    break;

                case CodeGeneratorCommon.MethodActionType.Update:
                    foreach (Column c in pTable.Columns)
                    {
                        if (!FwkGenerator.NotSupportTypes_ToIncludeInBackEnd.Contains(c.DataType.SqlDataType.ToString().ToLower()))
                        {
                            wParams.Append(GetInParameter(pTable, c));
                        }
                    }
                    break;
                case CodeGeneratorCommon.MethodActionType.Delete:

                    Column cPK = FwkGenerator.GetPrimaryKey(pTable);
                    if (cPK != null)
                        wParams.Append(GetInParameter(cPK.Name, FwkGenerator.GetDbType(cPK)));
                    else
                        wParams.Append(GetInParameter("Id", "System.Data.DbType.Int32"));

                    break;
                case CodeGeneratorCommon.MethodActionType.SearchByParam:

                    foreach (Column c in pTable.Columns)
                    {
                        if (FwkGenerator.GeColumnFindeable(c))
                            wParams.Append(GetInParameter(pTable, c));

                    }
                    break;
                case CodeGeneratorCommon.MethodActionType.Get:
                    wParams.Append(string.Empty);
                    break;

            }
            return wParams.ToString();
        }
Exemple #7
0
        /// <summary>
        /// Retorno del metodo
        /// </summary>
        /// <param name="pTable"></param>
        /// <param name="pMethodActionType"></param>
        /// <returns></returns>
        static string GetSPName(TableViewBase pTable, CodeGeneratorCommon.MethodActionType pMethodActionType)
        {
            String sufix = string.Empty;

            switch (pMethodActionType)
            {
                case CodeGeneratorCommon.MethodActionType.Insert:
                    sufix = "_i";
                    break;
                case CodeGeneratorCommon.MethodActionType.GetByParam:
                    sufix = "_gp";
                    break;
                case CodeGeneratorCommon.MethodActionType.Update:
                    sufix = "_u";
                    break;
                case CodeGeneratorCommon.MethodActionType.Delete:
                    sufix = "_d";
                    break;
                case CodeGeneratorCommon.MethodActionType.SearchByParam:

                    sufix = "_sp";
                    break;
                case CodeGeneratorCommon.MethodActionType.Get:
                    sufix = "_g";
                    break;

            }

            return string.Concat(pTable.Name, sufix);
        }
Exemple #8
0
        /// <summary>
        /// Retorno del metodo
        /// </summary>
        /// <param name="pTable"></param>
        /// <param name="pMethodActionType"></param>
        /// <returns></returns>
        static string GetRetType(TableViewBase pTable, CodeGeneratorCommon.MethodActionType pMethodActionType)
        {
            String wBuilder = string.Empty;
            Column c = FwkGenerator.GetPrimaryKey(pTable);
            switch (pMethodActionType)
            {
                case CodeGeneratorCommon.MethodActionType.Insert:

                case CodeGeneratorCommon.MethodActionType.Update:
                case CodeGeneratorCommon.MethodActionType.Delete:
                    wBuilder = "void";
                    break;
                case CodeGeneratorCommon.MethodActionType.SearchByParam:
                    wBuilder = string.Concat(pTable.Name, "List");
                    break;
                case CodeGeneratorCommon.MethodActionType.GetByParam:
                    wBuilder = pTable.Name;
                    break;
            }
            return wBuilder;
        }
Exemple #9
0
        /// <summary>
        /// Genera código de parámetros de llamado a un método.
        /// </summary>
        /// <param name="CodeGeneratorCommon.MethodActionType">información sobre el método a generar.</param>
        /// <param name="pTable">tabla.</param>
        /// <returns>Código que representa los parámetros para ejecutar el método.</returns>
        /// <author>Marcelo Oviedo</author>
        static string GenMethodParameters(CodeGeneratorCommon.MethodActionType pMethodActionType, TableViewBase pTable)
        {
            String wBuilder = string.Empty;
            switch (pMethodActionType)
            {
                case CodeGeneratorCommon.MethodActionType.Insert:
                case CodeGeneratorCommon.MethodActionType.Update:
                case CodeGeneratorCommon.MethodActionType.GetByParam:
                case CodeGeneratorCommon.MethodActionType.SearchByParam:

                    wBuilder = string.Concat(pTable.Name, " p", pTable.Name);
                    break;
                case CodeGeneratorCommon.MethodActionType.Delete:
                    Column pPK = FwkGenerator.GetPrimaryKey(pTable);
                    if (pPK != null)
                    {
                        FwkGenerator.GetCSharpType(pPK);
                        wBuilder = String.Concat(FwkGenerator.GetCSharpType(pPK), " p", pPK.Name);
                    }
                    else
                    {
                        wBuilder = String.Concat("int pId");
                    }

                    break;
            }
            return wBuilder;


        }
Exemple #10
0
        /// <summary>
        /// Genera comentarios sobre los parámetros de un método.
        /// </summary>
        /// <param name="pMethodInfo">información sobre el método a generar.</param>
        /// <returns>Comentarios sobre los parámetros.</returns>
        /// <author>Marcelo Oviedo</author>
        static string GenParametersSummary(CodeGeneratorCommon.MethodActionType pMethodActionType, TableViewBase pTable)
        {
            StringBuilder wBuilder = new StringBuilder(FwkGenerator.TemplateDocument.GetTemplate("ParameterSummary").Content);



            switch (pMethodActionType)
            {
                case CodeGeneratorCommon.MethodActionType.Insert:
                case CodeGeneratorCommon.MethodActionType.Update:
                case CodeGeneratorCommon.MethodActionType.GetByParam:
                case CodeGeneratorCommon.MethodActionType.SearchByParam:

                    wBuilder.Replace("[MethodParameterName]", pTable.Name);
                    wBuilder.Replace("[ParameterName]", pTable.Name);
                    break;
                case CodeGeneratorCommon.MethodActionType.Delete:
                    Column pPK = FwkGenerator.GetPrimaryKey(pTable);
                    if (pPK != null)
                    {
                        wBuilder.Replace("[MethodParameterName]", pPK.Name);
                    }
                    else
                    {
                        wBuilder.Replace("[MethodParameterName]", "pId");
                    }
                    wBuilder.Replace("[ParameterName]", string.Concat("Id por el cual realizar la busqueda de registros a eliminar de tabla ", pTable.Name));
                    break;
            }
            return wBuilder.ToString();




        }