コード例 #1
0
        public int[] retornarIndicesEspecialsitas(string email)
        {
            CtrlConexao conexao = CtrlConexao.Instancia;

            int[] indices = new int[4];
            try
            {
                conexao.AbreConexaoMysql();
                MySqlDataReader reader = conexao.ExecutaSelecaoMysql(" Select * from especialistas where email ='" + email + "'");

                while (reader.Read())
                {
                    indices[0] = (Convert.ToInt16(reader["indiceUltimaQuestaoTreinamento"]));
                    indices[1] = (Convert.ToInt16(reader["indiceUltimaQuestaoEducao"]));
                    indices[2] = (Convert.ToInt16(reader["idMetodoTreinamento"]));
                    indices[3] = (Convert.ToInt16(reader["idMetodoEducao"]));
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }
            return(indices);
        }
コード例 #2
0
        public void inserirResposta(int id_pergunta, string resposta, double timeConsuption, double credibilidade)
        {
            CtrlConexao     conexao = CtrlConexao.Instancia;
            MySqlDataReader reader;

            conexao.AbreConexaoMysql();
            reader = conexao.ExecutaSelecaoMysql("Select MAX(idEspecialista) from especialistas");
            reader.Read();
            int id = Convert.ToInt16(reader[0]);

            reader.Close();

            try
            {
                conexao.AbreConexaoMysql();
                if (credibilidade == 0.0)
                {
                    conexao.ExecutaComandoMysql("INSERT INTO respostas(id_pergunta,id_especialista,resposta,tempoConsumido,credibilidade) VALUES ('" + id_pergunta + "', '" + id + "','" + resposta + "', '" + timeConsuption + "', NULL);");
                }
                else
                {
                    conexao.ExecutaComandoMysql("INSERT INTO respostas(id_pergunta,id_especialista,resposta,tempoConsumido,credibilidade) VALUES ('" + id_pergunta + "', '" + id + "','" + resposta + "', '" + timeConsuption + "', '" + credibilidade + "');");
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }
        }
コード例 #3
0
        public List <string> retornarEmails()
        {
            CtrlConexao   conexao   = CtrlConexao.Instancia;
            List <string> analistas = new List <string>();

            try
            {
                conexao.AbreConexaoMysql();
                MySqlDataReader reader = conexao.ExecutaSelecaoMysql("Select email from especialistas where indiceUltimaQuestaoTreinamento <100 or indiceUltimaQuestaoEducao < 53 order by email");
                int             i      = 0;

                while (reader.Read())
                {
                    analistas.Add(reader["email"].ToString()); i++;
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }
            return(analistas);
        }
コード例 #4
0
        private int getId(string sql, string idFild = "")
        {
            CtrlConexao     conexao = CtrlConexao.Instancia;
            MySqlDataReader reader;
            int             id = 0;

            try
            {
                conexao.AbreConexaoMysql();
                reader = conexao.ExecutaSelecaoMysql(sql);
                if (reader.Read())
                {
                    id = Convert.ToInt32(reader[0]);
                }
                conexao.FecharConexaoMysql();
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }
            return(id);
        }
コード例 #5
0
        public double removerPergunta()
        {
            CtrlConexao conexao = CtrlConexao.Instancia;

            try
            {
                conexao.AbreConexaoMysql();
                MySqlDataReader reader = conexao.ExecutaSelecaoMysql("Select MAX(idResposta), tempoConsumido from respostas");
                id    = 0;
                tempo = 0.0;

                if (reader.Read())
                {
                    id    = Convert.ToInt32(reader["MAX(idResposta)"].ToString());
                    tempo = Convert.ToDouble(reader["tempoConsumido"].ToString());
                }

                conexao.ExecutaComandoMysql("delete from respostas where idResposta = '" + id + "'");
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }

            return(tempo);
        }
コード例 #6
0
        public void inserirPergunta(string enunciado, string resposta, int ConhecimentoMatematico,
                                    int Ancoragem, int representatividade, int autoconfianca, int disponibilidade,
                                    int calibraFirmino, int calibraDireto, int calibraBissecao, int aplicaFirmino,
                                    int AplicaDireto, int AplicaBissecao, int aplicaScoringRules, int serahUsada,
                                    string distribuicao, string caminhoImagem, int variavelNominal, string comentarios)
        {
            CtrlConexao     conexao = CtrlConexao.Instancia;
            MySqlDataReader reader;

            try {
                conexao.AbreConexaoMysql();//gambiarra pois não estava conseguindo passar o id para auto incremental
                reader = conexao.ExecutaSelecaoMysql("Select MAX(id_pergunta) from pergunta");
                reader.Read();
                int id_pergunta = Convert.ToInt16(reader[0]);
                id_pergunta += 1;
                conexao.ExecutaComandoMysql("INSERT INTO `perguntas` (id_pergunta,ehVariavelNominal,serahUsada,distribuicao,enunciado, respostaCerta, conhecimentoMatematico, h_anc, h_represent, h_autoconfianca, h_dispon, calibraFirmino, calibraDireto, calibraBissecao, aplicaFirmino, aplicaDireto, aplicaBissecao, aplicaNossosSRs,comentarios, caminhoImagens) VALUES ('" +
                                            id_pergunta + "', '" + variavelNominal + "','" + serahUsada + "','" + distribuicao + "','" + enunciado + "', '" + resposta + "','" +
                                            ConhecimentoMatematico + "', '" + Ancoragem + "','" + representatividade + "','" +
                                            autoconfianca + "','" + disponibilidade + "','" + calibraFirmino + "','" + calibraDireto
                                            + "','" + calibraBissecao + "','" + aplicaFirmino + "','" + AplicaDireto + "','" +
                                            AplicaBissecao + "','" + aplicaScoringRules + "','" + comentarios + "','" + caminhoImagem + "')");
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }
        }
コード例 #7
0
        public List <string> retornarMetodos()
        {
            CtrlConexao   conexao = CtrlConexao.Instancia;
            List <string> metodos = new List <string>();

            try
            {
                conexao.AbreConexaoMysql();
                MySqlDataReader reader = conexao.ExecutaSelecaoMysql("select nome from metodos");
                int             i      = 0;

                while (reader.Read())
                {
                    metodos.Add(reader["nome"].ToString()); i++;
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }
            return(metodos);
        }
コード例 #8
0
        public void inserirAlternativas(string[] alternativas)
        {
            CtrlConexao     conexao = CtrlConexao.Instancia;
            MySqlDataReader reader;

            try
            {
                conexao.AbreConexaoMysql();
                reader = conexao.ExecutaSelecaoMysql("Select MAX(id_pergunta) from perguntas");
                reader.Read();
                int id = Convert.ToInt16(reader[0]);
                reader.Close();

                for (int i = 0; i < alternativas.Length; i++)
                {
                    string alternativa = alternativas[i];
                    conexao.ExecutaComandoMysql("INSERT INTO alternativa_resposta(id_pergunta, evento) VALUES ('"
                                                + id + "', '" + alternativa + "');");
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }
        }
コード例 #9
0
        public List<DBEntity> getDataSource()
        {

            MySqlDataReader reader;
            CtrlConexao conexao = CtrlConexao.Instancia;
            List<DBEntity> listDBEntity = new List<DBEntity>();
            string filter = null;
            //StringBuilder strIndexAlternativas = new StringBuilder ();
            //Hashtable hashIndiceDB = new Hashtable ();

            String query = "SELECT ";
            try
            {
                //conexao.AbreConexaoMysql();

                //int m = this.nColumns - 1; 
                //for (int i = 0; i < m; i++)
                //query += DBEntity.ST.DB_NAME + this.ST_TB_NAME + "." + this.columnNames[i] + ", ";
                //query += DBEntity.ST.DB_NAME + this.ST_TB_NAME + "." + this.columnNames[m];
                //query += " FROM " + DBEntity.ST.DB_NAME + this.ST_TB_NAME;
                //query += this.getFilter();

                conexao.AbreConexaoMysql();

                int m = this.nColumns - 1;
                for (int i = 0; i < m; i++)
                query += this.columnNames[i] + ", ";
                query += this.columnNames[m];
                query += " FROM " + this.ST_TB_NAME;
                //query += this.getFilter();

                reader = conexao.ExecutaSelecaoMysql(query);
                while (reader.Read())
                {
                    DBEntity dbe = this.getDBEntity(reader);
                    listDBEntity.Add(dbe);
                }
                reader.Close();

            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.StackTrace + "\n\n" + exc.Message);
            }

            //catch(Exception e){
            //    throw new Exception (">> Erro em  reader.Read: \n"+e.StackTrace+"\n provavelmente na query: \n"+query);
            //}
            finally
            {
                conexao.FecharConexaoMysql();
            }


            return listDBEntity;

        }
コード例 #10
0
 //public int getId(string filter, string ST_ID)
 //{
   //  string query = 
     //    " SELECT "+ST_ID+" FROM "+DBEntity.ST.DB_NAME + this.ST_TB_NAME;
 //    if(filter!="")
   //      query += " WHERE "+filter;
    // CtrlConexao conexao = CtrlConexao.Instancia;
   //  MySqlDataReader reader = conexao.ExecutaSelecaoMysql (query);
     //int id = -1;
     //if(reader.Read ()) 
       //  id = (int)reader[ST_ID];
     //reader.Close ();
     //return id;
 //}
 public int getId (string query) {
     CtrlConexao conexao = CtrlConexao.Instancia;
     MySqlDataReader reader = conexao.ExecutaSelecaoMysql (query);
     int id = -1;
     if(reader.Read ())
         id = (int)reader[ST_ID];
     reader.Close ();
     return id;
 }
コード例 #11
0
 public int getId(string filter, string ST_ID)
 {
     string query =
         " SELECT " + this.ST_TB_NAME + " FROM " + DBEntity.ST.DB_NAME;
     if(filter!="")
         query += " WHERE "+filter;
     CtrlConexao conexao = CtrlConexao.Instancia;
     MySqlDataReader reader = conexao.ExecutaSelecaoMysql (query);
     int id = -1;
     if(reader.Read ()) 
         id = (int)reader[ST_ID];
     reader.Close ();
     return id;
 }
コード例 #12
0
        internal void inseriProjetoPergunta(string projetoNome)  // vai vincular o projeto com a ultima pergunta inserida
        {
            CtrlConexao     conexao = CtrlConexao.Instancia;
            MySqlDataReader reader;

            try {
                conexao.AbreConexaoMysql();
                reader = conexao.ExecutaSelecaoMysql("Select MAX(id_pergunta) from perguntas");
                reader.Read();
                int id_pergunta = Convert.ToInt16(reader[0]);
                reader = conexao.ExecutaSelecaoMysql("Select id_projeto from projeto where nome = '" + projetoNome + "'");
                int id_projeto = Convert.ToInt16(reader[0]);

                reader.Close();
                conexao.ExecutaComandoMysql("INSERT INTO projeto_pergunta (id_projeto, id_pergunta) VALUES ('"
                                            + id_projeto + "', '" + id_pergunta + "');");
            }

            catch (Exception) {
            }
            finally {
                conexao.FecharConexaoMysql();
            }
        }
コード例 #13
0
        public void inserirProjeto(string nomeProjeto)
        {
            CtrlConexao     conexao = CtrlConexao.Instancia;
            MySqlDataReader reader;

            try {
                conexao.AbreConexaoMysql();//gambiarra pois não estava conseguindo passar o id para auto incremental
                reader = conexao.ExecutaSelecaoMysql("Select MAX(id_projeto) from projeto");
                reader.Read();
                int id_projeto = Convert.ToInt16(reader[0]);
                id_projeto += 1;
                conexao.AbreConexaoMysql();
                conexao.ExecutaComandoMysql("INSERT INTO projeto(id_projeto, nome) VALUES ('" + id_projeto + "','" + nomeProjeto + "');");
            }
            catch (Exception) {
            }

            finally {
                conexao.FecharConexaoMysql();
            }
        }
コード例 #14
0
        internal void removerResposta()
        {
            CtrlConexao conexao = CtrlConexao.Instancia;

            try
            {
                conexao.AbreConexaoMysql();
                MySqlDataReader reader = conexao.ExecutaSelecaoMysql("Select MAX(idResposta) from respostas");
                reader.Read();
                int id = Convert.ToInt16(reader[0]);
                conexao.FecharConexaoMysql();
                conexao.ExecutaComandoMysql("delete from respostas where idResposta = '" + id + "'");
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }
        }
コード例 #15
0
        public List<DBEntity> getDataSource(string selectFilter)
        {
            MySqlDataReader reader;
            CtrlConexao conexao = CtrlConexao.Instancia;
            List<DBEntity> listDBEntity = new List<DBEntity>();
            string filter = null;
            //StringBuilder strIndexAlternativas = new StringBuilder ();
            //Hashtable hashIndiceDB = new Hashtable ();

            String query = selectFilter;
            try
            {
                conexao.AbreConexaoMysql();
                query += this.getFilter();
                reader = conexao.ExecutaSelecaoMysql(query);
                while (reader.Read())
                {
                    DBEntity dbe = this.getDBEntity(reader);
                    listDBEntity.Add(dbe);
                }
                reader.Close();

            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.StackTrace + "\n\n" + exc.Message);
            }

            //catch(Exception e){
            //    throw new Exception (">> Erro em  reader.Read: \n"+e.StackTrace+"\n provavelmente na query: \n"+query);
            //}
            finally
            {
                conexao.FecharConexaoMysql();
            }


            return listDBEntity;

        }
コード例 #16
0
        public void InserirTitulação(string titulacao, string especialidade)
        {
            CtrlConexao     conexao = CtrlConexao.Instancia;
            MySqlDataReader reader;

            try
            {
                conexao.AbreConexaoMysql();
                reader = conexao.ExecutaSelecaoMysql("Select MAX(idEspecialista) from especialistas");
                reader.Read();
                int id = Convert.ToInt16(reader[0]);
                conexao.FecharConexaoMysql();
                conexao.ExecutaComandoMysql("INSERT INTO titulacao(id_especialista, titulacao, Especialidade) VALUES ( '" + id + "', '" + titulacao + "', '" + especialidade + "');");
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }
        }
コード例 #17
0
        public void inserirEstatistica(double media, double moda, double mediana, double variancia)
        {
            CtrlConexao     conexao = CtrlConexao.Instancia;
            MySqlDataReader reader;

            try
            {
                conexao.AbreConexaoMysql();
                reader = conexao.ExecutaSelecaoMysql("Select MAX(idResposta) from respostas");
                reader.Read();
                int id = Convert.ToInt16(reader[0]);
                conexao.FecharConexaoMysql();
                conexao.ExecutaComandoMysql("INSERT INTO estatisticas(idEstatisticas, id_Resposta, media, moda, mediana, variancia) VALUES (NULL, '" + id + "', '" + media + "', '" + moda + "', '" + mediana + "', '" + variancia + "');");
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }
        }
コード例 #18
0
        public Especialista  getEspecialista(string email)
        {
            MySqlDataReader reader;
            CtrlConexao     conexao = CtrlConexao.Instancia;
            Especialista    e       = new Especialista();

            try
            {
                conexao.AbreConexaoMysql();

                reader = conexao.ExecutaSelecaoMysql("SELECT idEspecialista, intimityMath, intimityUncertainty, areaDeAtuação, email, analista, indiceUltimaQuestaoTreinamento, indiceUltimaQuestaoEducao," +
                                                     " idMetodoTreinamento, idMetodoEducao FROM especialistas where email = '" + email + "'");

                int i = 1;

                while (reader.Read())
                {
                    e.id                  = (int)reader["idEspecialista"];
                    e.intimityMath        = (int)reader["intimityMath"];
                    e.intimityUncertainty = (int)reader["intimityUncertainty"];
                    //e.idMetodoEducao = (int)reader["areaDeAtuação"];//Este campo está gerando erro. Usar UTF-8
                    e.email    = reader["email"].ToString();
                    e.analista = reader["analista"].ToString();
                    e.indiceUltimaQuestaoTreinamento = (int)reader["indiceUltimaQuestaoTreinamento"];
                    e.indiceUltimaQuestaoEducao      = (int)reader["indiceUltimaQuestaoEducao"];
                    e.idMetodoTreinamento            = (int)reader["idMetodoTreinamento"];
                    e.idMetodoEducao = (int)reader["idMetodoEducao"];
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }

            return(e);
        }
コード例 #19
0
        public void inserirParesAcumulados(double[] x, double[] Fx, double[] FxReal)
        {
            CtrlConexao     conexao = CtrlConexao.Instancia;
            MySqlDataReader reader;

            try
            {
                conexao.AbreConexaoMysql();
                reader = conexao.ExecutaSelecaoMysql("Select MAX(idEstatisticas) from estatisticas");
                reader.Read();
                int id = Convert.ToInt16(reader[0]);
                reader.Close();
                string sx = Convert.ToString(x[0]), sFx = Convert.ToString(Fx[0]);
                for (int i = 1; i < x.Length; i++)
                {
                    sx  += ';' + Convert.ToString(x[i]);
                    sFx += ';' + Convert.ToString(Fx[i]);
                }
                string sfxr = null;
                if (FxReal != null)
                {
                    sfxr = Convert.ToString(FxReal[0]);
                    for (int i = 1; i < FxReal.Length; i++)
                    {
                        sfxr += ';' + Convert.ToString(FxReal[i]);
                    }
                }

                conexao.ExecutaComandoMysql("INSERT INTO pares_acumulados(idEstatistica, x, Fx_respondente,Fx_real) VALUES ('"
                                            + id + "', '" + sx + "', '" + sFx + "', '" + sfxr + "');");
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }
        }
コード例 #20
0
        public void atualizaIndiceTreinamento(int indice)
        {
            CtrlConexao     conexao = CtrlConexao.Instancia;
            MySqlDataReader reader;

            try
            {
                conexao.AbreConexaoMysql();
                reader = conexao.ExecutaSelecaoMysql("Select MAX(idEspecialista) from especialistas");
                reader.Read();
                int id = Convert.ToInt16(reader[0]);
                conexao.FecharConexaoMysql();
                conexao.ExecutaComandoMysql("UPDATE especialistas SET indiceUltimaQuestaoTreinamento = '" +
                                            indice + "' WHERE idEspecialista='" + id + "'");
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }
        }
コード例 #21
0
        public string retornarPergunta(int id)
        {
            string      pergunta = "";
            CtrlConexao conexao  = CtrlConexao.Instancia;

            try
            {
                conexao.AbreConexaoMysql();
                MySqlDataReader reader = conexao.ExecutaSelecaoMysql("Select enunciado from perguntas where  id_pergunta ='" + id + "' ");

                if (reader.Read())
                {
                    pergunta = reader["enunciado"].ToString();
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }
            return(pergunta);
        }
コード例 #22
0
        public ArrayList listaPerguntas(Boolean training, ElicitationMethod method)
        {
            MySqlDataReader reader;
            CtrlConexao     conexao              = CtrlConexao.Instancia;
            ArrayList       variableList         = new ArrayList();
            string          filter               = null;
            StringBuilder   strIndexAlternativas = new StringBuilder();
            Hashtable       hashIndiceDB         = new Hashtable();

            try
            {
                conexao.AbreConexaoMysql();

                String prefixo = "aplica";
                if (training)
                {
                    prefixo = "calibra";
                }

                if (method == ElicitationMethod.Firmino)
                {
                    filter = prefixo + "Firmino";
                }
                else if (method == ElicitationMethod.Bissecao)
                {
                    filter = prefixo + "Bissecao";
                }
                else
                {
                    filter = prefixo + "Direto";
                }

                reader = conexao.ExecutaSelecaoMysql("SELECT * FROM elicitation.perguntas where " + filter + " = 1 and serahUsada = 1 order by id_pergunta asc");

                int i = 1;

                while (reader.Read())
                {
                    int id = (int)reader["id_pergunta"];
                    strIndexAlternativas.Append(id.ToString() + " ,");
                    hashIndiceDB[reader.GetInt32("id_pergunta")] = i - 1;
                    Variable variable = new Variable();
                    variable.metodo        = method;// (ElicitationMethod)reader["idmetodo"];
                    variable.number        = i; i++;
                    variable.id            = id;
                    variable.statament     = reader["enunciado"].ToString();
                    variable.respostaCerta = reader["respostaCerta"].ToString();
                    variable.status        = false;
                    variable.imagePath     = reader["caminhoImagens"].ToString();
                    variableList.Add(variable);
                    variable.distribuicao = reader["distribuicao"].ToString();
                    variable.isNominal    = false;
                    if (int.Parse(reader["ehVariavelNominal"].ToString()) > 0)
                    {
                        variable.isNominal = true;
                    }
                }

                strIndexAlternativas.Remove(strIndexAlternativas.Length - 2, 2);
                conexao.FecharConexaoMysql();
                conexao.AbreConexaoMysql();
                reader = conexao.ExecutaSelecaoMysql("SELECT * FROM elicitation.alternativa_resposta where id_pergunta in (" + strIndexAlternativas + ")");

                while (reader.Read())
                {
                    i = (int)hashIndiceDB[reader["id_pergunta"]];
                    Variable tmpVariable = (Variable)variableList[i];
                    tmpVariable.alternativas.Add(new Alternativa(reader["alternativa"].ToString(), reader.GetInt32("id_pergunta")));
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                conexao.FecharConexaoMysql();
            }


            return(variableList);
        }