예제 #1
0
        private void BT_ok_Click(object sender, EventArgs e)
        {
            string[] lista = retornaQueris();
            this.queryAccuracy  = lista[0];
            this.queryEficience = lista[1];
            Accuracy        accuracy     = new Accuracy(this);
            List <DBEntity> accuracyData = accuracy.getDataSource(this.queryAccuracy);

            //string folder = @"C:\Dados";

            if (!System.IO.File.Exists(nome_arquivo_accuracy))
            {
                System.IO.File.Create(nome_arquivo_accuracy).Close();
            }

            System.IO.TextWriter arquivo_accuracy = System.IO.File.AppendText(this.nome_arquivo_accuracy);
            arquivo_accuracy.Flush();
            arquivo_accuracy.WriteLine("");
            arquivo_accuracy.WriteLine("");
            arquivo_accuracy.WriteLine("Analise realizada em: " + DateTime.Now.ToString());
            arquivo_accuracy.WriteLine("");
            arquivo_accuracy.WriteLine("id_pergunta | media | moda | mediana | variancia | a_01 | a_50 | a_99 | b_01 | b_50 | b_99 | padrao_calibracao | sr_t_quadratico | sr_t_quadraticoOrdenado | sr_quadratico | sr_quadraticoOrdenado | sr_t_logaritimico | sr_t_logaritimicoOrdenado | sr_logaritimico | sr_logaritimicoOrdenado | sr_t_esferico | sr_t_esfericoOrdenado | sr_esferico | sr_esfericoOrdenado | sr_shiquadrado | sr_kullback | precision | bb_parameters | id_processos | id_especialista | idProject | idElicitationMethod | idTrainingMethod | idAnalyst | index_lastTrainingQuestion | index_lastElicitationQuestion | name_project | name_analyst | idExpert | intimityMath | intimityUncertainty | expertiseField | email | id_titulacao | titulacao | especialidade");//"(1)id_estatisticas | (2)media | (3)moda | (4)mediana | (5)variancia | (6)a_01 | (7)a_50 | (8)a_99 | (9)b_01 | (10)b_50 | (11)b_99 | (12)padrao_calibracao | (13)sr_t_quadratico | (14)sr_t_quadraticoOrdenado | (15)sr_quadratico | (16)sr_quadraticoOrdenado | (17)sr_t_logaritimico | (18)sr_t_logaritimicoOrdenado | (19)sr_logaritimico | (20)sr_logaritimicoOrdenado | (21)sr_t_esferico | (22)sr_t_esfericoOrdenado | (23)sr_esferico | (24)sr_esfericoOrdenado | (25)sr_shiquadrado | (26)sr_kullback | (27)id_processos | (28)id_especialista | (29)idProject | (30)idElicitationMethod | (31)idTrainingMethod | (32)idAnalyst | (33)index_lastTrainingQuestion | (34)index_lastElicitationQuestion | (35)name_project | (36)name_analyst | (37)idExpert | (38)intimityMath | (39)intimityUncertainty | (40)expertiseField | (41)email | (42)id_titulacao | (43)titulacao | (44)especialidade"
            //arquivo_accuracy.WriteLine ("");
            arquivo_accuracy.Flush();

            try{
                //for (int i = accuracyData.Count-1; i >0 ; i--) {
                //    Accuracy acc_i = (Accuracy )accuracyData[i];
                //    if(acc_i.id_pergunta == ((Accuracy)accuracyData[i-1]).id_pergunta)
                //        accuracyData.RemoveAt (i);
                //}
                for (int i = 0; i < accuracyData.Count; i++)
                {
                    Accuracy acc_i = (Accuracy )accuracyData[i];
                    arquivo_accuracy.Write(acc_i.id_pergunta.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.media.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.moda.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.mediana.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.variancia.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.a_01.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.a_50.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.a_99.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.b_01.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.b_50.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.b_99.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.padrao_calibracao.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_t_quadratico.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_t_quadraticoOrdenado.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_quadratico.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_quadraticoOrdenado.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_t_logaritimico.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_t_logaritimicoOrdenado.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_logaritimico.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_logaritimicoOrdenado.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_t_esferico.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_t_esfericoOrdenado.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_esferico.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_esfericoOrdenado.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_shiquadrado.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.sr_kullback.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.precision.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.bb_parameters.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.id_processos.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.id_especialista.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.idProject.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.idElicitationMethod.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.idTrainingMethod.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.idAnalyst + " | ");
                    arquivo_accuracy.Write(acc_i.index_lastTrainingQuestion + " | ");
                    arquivo_accuracy.Write(acc_i.index_lastElicitationQuestion + " | ");
                    arquivo_accuracy.Write(acc_i.name_project + " | ");
                    arquivo_accuracy.Write(acc_i.name_analyst + " | ");
                    arquivo_accuracy.Write(acc_i.idExpert.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.intimityMath.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.intimityUncertainty.ToString() + " | ");
                    arquivo_accuracy.Write(acc_i.expertiseField + " | ");
                    arquivo_accuracy.Write(acc_i.email + " | ");
                    arquivo_accuracy.Write(acc_i.id_titulacao + " | ");
                    arquivo_accuracy.Write(acc_i.titulacao + " | ");
                    arquivo_accuracy.Write(acc_i.especialidade);
                    arquivo_accuracy.WriteLine("");
                    arquivo_accuracy.Flush();
                }
            } catch (Exception exc) {
                MessageBox.Show(exc.ToString(), "ERROR: ACCURACY DATA");
            }
            arquivo_accuracy.Close();

            Efficiency      eficience      = new Efficiency(this);
            List <DBEntity> efficienceData = eficience.getDataSource(this.queryEficience);

            if (!System.IO.File.Exists(nome_arquivo_efficiency))
            {
                System.IO.File.Create(nome_arquivo_efficiency).Close();
            }
            this.tempo.Clear(); this.id_question.Clear();
            this.id_question.Add(-1);
            this.tempo.Add(-1);
            for (int i = 0; i < efficienceData.Count; i++) //extrair os tempos das datas
            {
                Efficiency eff_i = (Efficiency)efficienceData[i];
                if (eff_i.event_type == "QUESTION_IN")
                {
                    this.tmp  = 0;// this.tmp2 = 0;
                    this.tmp2 = eff_i.date.TimeOfDay.TotalMilliseconds + eff_i.mileseconds;
                }
                else if (eff_i.event_type == "PAUSE")
                {
                    this.tmp2 += eff_i.date.TimeOfDay.TotalMilliseconds + eff_i.mileseconds;
                }
                else if (eff_i.event_type == "CONTINUE")
                {
                    this.tmp += eff_i.date.TimeOfDay.TotalMilliseconds + eff_i.mileseconds;
                }
                //else if (eff_i.event_type == "SAVE_STARTING")
                //    this.tmp2 += eff_i.date.TimeOfDay.TotalMilliseconds + eff_i.mileseconds;
                //else if (eff_i.event_type == "SAVE_ENDING")
                //    this.tmp += eff_i.date.TimeOfDay.TotalMilliseconds + eff_i.mileseconds;
                else if (eff_i.event_type == "QUESTION_OUT")
                {
                    this.tmp += eff_i.date.TimeOfDay.TotalMilliseconds + eff_i.mileseconds;
                    this.tempo.Add((this.tmp - this.tmp2) / 1000);
                    this.id_question.Add(eff_i.id_pergunta);
                }
            }
            this.id_question.RemoveAt(0);
            this.tempo.RemoveAt(0);

            //this.tempo.Add(0.0); this.id_question.Add(-1);//adicionar doi elementos "trash" na lista para poder concluir a iteração

            System.IO.TextWriter arquivo_efficiency = System.IO.File.AppendText(this.nome_arquivo_efficiency);
            arquivo_efficiency.Flush();
            arquivo_efficiency.WriteLine("");
            arquivo_efficiency.WriteLine("");
            arquivo_efficiency.WriteLine("Analise realizada em: " + DateTime.Now.ToString());
            arquivo_efficiency.WriteLine("");
            arquivo_efficiency.WriteLine("tempo | id_pergunta | id_processos | id_especialista | idProject | idElicitationMethod | idTrainingMethod | idAnalyst | index_lastTrainingQuestion | index_lastElicitationQuestion | name_project | name_analyst | idExpert | intimityMath | intimityUncertainty | expertiseField | email | id_titulacao | titulacao | especialidade ");//"(1)tempo | (2)id_pergunta | (3)id_processos | (4)id_especialista | (5)idProject | (6)idElicitationMethod | (7)idTrainingMethod | (8)idAnalyst | (9)index_lastTrainingQuestion | (10)index_lastElicitationQuestion | (11)name_project | (12)name_analyst | (13)idExpert | (14)intimityMath | (15)intimityUncertainty | (16)expertiseField | (17)email | (18)id_titulacao | (19)titulacao | (20)especialidade "
            // arquivo_efficiency.WriteLine ("");
            arquivo_efficiency.Flush();
            this.id_question.Add(0);
            int j = 0;

            try {
                for (int i = 0; i < efficienceData.Count; i++)
                {
                    Efficiency eff_i = (Efficiency)efficienceData[i];
                    if (eff_i.id_pergunta == this.id_question[j])
                    {
                        arquivo_efficiency.Write(this.tempo[j].ToString() + " | ");
                        arquivo_efficiency.Write(eff_i.id_pergunta.ToString() + " | ");
                        arquivo_efficiency.Write(eff_i.id_processos.ToString() + " | ");
                        arquivo_efficiency.Write(eff_i.id_especialista.ToString() + " | ");
                        arquivo_efficiency.Write(eff_i.id_projeto.ToString() + " | ");
                        arquivo_efficiency.Write(eff_i.idElicitationMethod.ToString() + " | ");
                        arquivo_efficiency.Write(eff_i.idTrainingMethod.ToString() + " | ");
                        arquivo_efficiency.Write(eff_i.idAnalyst + " | ");
                        arquivo_efficiency.Write(eff_i.index_lastTrainingQuestion + " | ");
                        arquivo_efficiency.Write(eff_i.index_lastElicitationQuestion + " | ");
                        arquivo_efficiency.Write(eff_i.name_project + " | ");
                        arquivo_efficiency.Write(eff_i.name_analyst + " | ");
                        arquivo_efficiency.Write(eff_i.idExpert.ToString() + " | ");
                        arquivo_efficiency.Write(eff_i.intimityMath.ToString() + " | ");
                        arquivo_efficiency.Write(eff_i.intimityUncertainty.ToString() + " | ");
                        arquivo_efficiency.Write(eff_i.expertiseField + " | ");
                        arquivo_efficiency.Write(eff_i.email + " | ");
                        arquivo_efficiency.Write(eff_i.id_titulacao + " | ");
                        arquivo_efficiency.Write(eff_i.titulacao + " | ");
                        arquivo_efficiency.Write(eff_i.especialidade);
                        arquivo_efficiency.WriteLine("");
                        arquivo_efficiency.Flush();
                        j += 1;
                    }
                }
            } catch (Exception exc) {
                MessageBox.Show(exc.ToString(), "ERROR: TIME SPENT DATA");
            }
            arquivo_efficiency.Close();
            MessageBox.Show("Conjunto de dados gerado com sucesso!!");
            this.Close();
        }