예제 #1
0
        public string InsertSql(string[] fields, DBMotor db = DBDEFAULT, string[] fieldsReturn = null)
        {
            String post = "", server = "";

            ReturnField(db, fieldsReturn, ref post, ref server);

            return(string.Format("INSERT INTO {0} ({1}) {2} VALUES ({3}) {4}", table, JoinFields(fields), server, JoinFieldWithAt(fields), post));
        }
예제 #2
0
파일: CMTools.cs 프로젝트: Juan-Acuna/CMCS
        public static bool CreateCMFile(String ruta, DBMotor motor, Lenguaje lenguaje)
        {
            InstanciateArray();
            StreamReader sr        = null;
            String       extension = ".cs";
            String       NS        = "";

            switch (lenguaje)
            {
            case Lenguaje.CSharp:
                extension = ".cs";    //se reemplazan las cosas
                sr        = new StreamReader(CMConfig.CM_CS);
                NS        = CMConfig.CSNAMESPACE;
                NEW[0]    = DATA[0][(int)motor, 0];
                NEW[1]    = DATA[0][(int)motor, 1];
                NEW[2]    = DATA[0][(int)motor, 2];
                NEW[3]    = DATA[0][(int)motor, 3];
                break;

            case Lenguaje.Java:
                extension = ".java";    //se reemplazan las cosas
                sr        = new StreamReader(CMConfig.CM_JAVA);
                NS        = CMConfig.JAVANAMESPACE;
                NEW[0]    = DATA[1][(int)motor, 0];
                NEW[1]    = DATA[1][(int)motor, 1];
                NEW[2]    = DATA[1][(int)motor, 2];
                NEW[3]    = DATA[1][(int)motor, 3];
                break;

            case Lenguaje.Python3:
                extension = ".py";    //se reemplazan las cosas
                sr        = new StreamReader(CMConfig.CM_PY);
                NEW[0]    = DATA[2][(int)motor, 0];
                NEW[1]    = DATA[2][(int)motor, 1];
                NEW[2]    = DATA[2][(int)motor, 2];
                NEW[3]    = DATA[2][(int)motor, 3];
                break;
            }

            cont_CM = sr.ReadToEnd();
            cont_CM = cont_CM.Replace("CommandManager", motor.ToString() + "CommandManager");
            cont_CM = cont_CM.Replace("CUSTOMNAMESPACE", NS);
            cont_CM = cont_CM.Replace("IMPORTS", NEW[0]);
            cont_CM = cont_CM.Replace("MOTORCOMMAND", NEW[1]);
            cont_CM = cont_CM.Replace("MOTORCON", NEW[2]);
            cont_CM = cont_CM.Replace("DATAREADER", NEW[3]);
            StreamWriter sw = new StreamWriter(ruta + "\\" + motor.ToString() + "CommandManager" + extension);

            sw.Write(cont_CM);
            sr.Close();
            sw.Close();
            return(true);
        }
예제 #3
0
        /*
         * Método que se encarga de crear la sentencia de retorno de campos:
         * Ej: SqlServer: OUTPUT Inserted.id,Inserted.phone
         *   Postgresql: RETURNING id,phone
         */
        private void ReturnField(DBMotor db, String[] fields, ref String postg, ref String server)
        {
            if (fields == null)
            {
                return;
            }
            if (db == DBMotor.SqlServer)
            {
                server = string.Format("OUTPUT {0}", string.Join(",", fields.Select(i => string.Format("Inserted.{0}", i))));
            }

            if (db == DBMotor.Postgresql)
            {
                postg = string.Format("RETURNING {0}", string.Join(",", fields));
            }
        }