Ejemplo n.º 1
0
        private void btnAtuCubo_Click(object sender, EventArgs e)
        {
            try
            {
                string linha = "";
                lblTexto.Visible       = true;
                prgrsBrCarrega.Value   = 0;
                prgrsBrCarrega.Visible = true;
                tmrTempo.Enabled       = true;

                //Abrir o arquivo

                linha += "<Batch xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\"> " +
                         "<Parallel> " +
                         "<Process xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ddl2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2\" xmlns:ddl2_2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2/2\" xmlns:ddl100_100=\"http://schemas.microsoft.com/analysisservices/2008/engine/100/100\">  " +
                         "<Object> " +
                         "<DatabaseID>Comercial_Mart</DatabaseID> " +
                         "<DimensionID>Regiao</DimensionID> " +
                         "</Object> " +
                         "<Type>ProcessUpdate</Type> " +
                         "<WriteBackTableCreation>UseExisting</WriteBackTableCreation> " +
                         "</Process> " +
                         "<Process xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ddl2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2\" xmlns:ddl2_2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2/2\" xmlns:ddl100_100=\"http://schemas.microsoft.com/analysisservices/2008/engine/100/100\"> " +
                         "<Object> " +
                         "<DatabaseID>Comercial_Mart</DatabaseID> " +
                         "<CubeID>Vendas_Regiao_Produto</CubeID> " +
                         "</Object> " +
                         "<Type>ProcessFull</Type> " +
                         "<WriteBackTableCreation>UseExisting</WriteBackTableCreation> " +
                         "</Process> " +
                         "<Process xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ddl2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2\" xmlns:ddl2_2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2/2\" xmlns:ddl100_100=\"http://schemas.microsoft.com/analysisservices/2008/engine/100/100\"> " +
                         "<Object> " +
                         "<DatabaseID>Comercial_Mart</DatabaseID> " +
                         "<DimensionID>Produto</DimensionID> " +
                         "</Object> " +
                         "<Type>ProcessUpdate</Type> " +
                         "<WriteBackTableCreation>UseExisting</WriteBackTableCreation> " +
                         "</Process> " +
                         "<Process xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ddl2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2\" xmlns:ddl2_2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2/2\" xmlns:ddl100_100=\"http://schemas.microsoft.com/analysisservices/2008/engine/100/100\"> " +
                         "<Object> " +
                         "<DatabaseID>Comercial_Mart</DatabaseID> " +
                         "<DimensionID>Data</DimensionID> " +
                         "</Object> " +
                         "<Type>ProcessUpdate</Type> " +
                         "<WriteBackTableCreation>UseExisting</WriteBackTableCreation> " +
                         "</Process> " +
                         "</Parallel> " +
                         "</Batch>";
                //FileInfo x = new FileInfo(@"E:\Faculdade\Tcc_google\Prototipo\atucubo.txt");

                // StreamReader valor = x.OpenText();

                //while (valor.ReadLine() != null)
                // {
                // linha += valor.ReadLine();

                //}

                string c = ConfigurationManager.ConnectionStrings["Comercial.Properties.Settings.COMERCIALConnectionString_analysis"].ConnectionString;

                AdomdConnection conn = new AdomdConnection(c);
                conn.Open();
                AdomdCommand cmd = new AdomdCommand(linha, conn);
                cmd.Execute();
                conn.Close();



                COMERCIALDataSetTableAdapters.ATUCUBOTableAdapter atu = new Comercial.COMERCIALDataSetTableAdapters.ATUCUBOTableAdapter();
                DateTime data = Convert.ToDateTime(DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day);
                atu.Insert(_princ.usuarioLogado, data);

                preencheGrid();

                prgrsBrCarrega.Value = 100;
                tmrTempo.Enabled     = false;
                lblTexto.Visible     = false;
                MessageBox.Show("Processo executado com sucesso", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                pictureBox1.Visible = true;
                pictureBox2.Visible = true;
            }
            catch (Exception ex)
            {
                tmrTempo.Enabled       = false;
                lblTexto.Visible       = false;
                prgrsBrCarrega.Visible = false;
                MessageBox.Show("Houve um problema na execução da atualização!\nConsulte o DBA.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error);
                pictureBox1.Visible = false;
                pictureBox1.Visible = false;
            }
        }
Ejemplo n.º 2
0
        private void btnAtuCubo_Click(object sender, EventArgs e)
        {
            try
            {
                string linha = "";
                lblTexto.Visible = true;
                prgrsBrCarrega.Value = 0;
                prgrsBrCarrega.Visible = true;
                tmrTempo.Enabled = true;

                //Abrir o arquivo

                linha += "<Batch xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\"> " +
                         "<Parallel> " +
                         "<Process xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ddl2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2\" xmlns:ddl2_2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2/2\" xmlns:ddl100_100=\"http://schemas.microsoft.com/analysisservices/2008/engine/100/100\">  " +
                         "<Object> " +
                         "<DatabaseID>Comercial_Mart</DatabaseID> " +
                         "<DimensionID>Regiao</DimensionID> " +
                         "</Object> " +
                         "<Type>ProcessUpdate</Type> " +
                         "<WriteBackTableCreation>UseExisting</WriteBackTableCreation> " +
                         "</Process> " +
                         "<Process xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ddl2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2\" xmlns:ddl2_2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2/2\" xmlns:ddl100_100=\"http://schemas.microsoft.com/analysisservices/2008/engine/100/100\"> " +
                         "<Object> " +
                         "<DatabaseID>Comercial_Mart</DatabaseID> " +
                         "<CubeID>Vendas_Regiao_Produto</CubeID> " +
                         "</Object> " +
                         "<Type>ProcessFull</Type> " +
                         "<WriteBackTableCreation>UseExisting</WriteBackTableCreation> " +
                         "</Process> " +
                         "<Process xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ddl2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2\" xmlns:ddl2_2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2/2\" xmlns:ddl100_100=\"http://schemas.microsoft.com/analysisservices/2008/engine/100/100\"> " +
                         "<Object> " +
                         "<DatabaseID>Comercial_Mart</DatabaseID> " +
                         "<DimensionID>Produto</DimensionID> " +
                         "</Object> " +
                         "<Type>ProcessUpdate</Type> " +
                         "<WriteBackTableCreation>UseExisting</WriteBackTableCreation> " +
                         "</Process> " +
                         "<Process xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ddl2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2\" xmlns:ddl2_2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2/2\" xmlns:ddl100_100=\"http://schemas.microsoft.com/analysisservices/2008/engine/100/100\"> " +
                         "<Object> " +
                         "<DatabaseID>Comercial_Mart</DatabaseID> " +
                         "<DimensionID>Data</DimensionID> " +
                         "</Object> " +
                         "<Type>ProcessUpdate</Type> " +
                         "<WriteBackTableCreation>UseExisting</WriteBackTableCreation> " +
                         "</Process> " +
                         "</Parallel> " +
                         "</Batch>";
                //FileInfo x = new FileInfo(@"E:\Faculdade\Tcc_google\Prototipo\atucubo.txt");

                // StreamReader valor = x.OpenText();

                //while (valor.ReadLine() != null)
                // {
                // linha += valor.ReadLine();

                //}

                string c = ConfigurationManager.ConnectionStrings["Comercial.Properties.Settings.COMERCIALConnectionString_analysis"].ConnectionString;

                AdomdConnection conn = new AdomdConnection(c);
                conn.Open();
                AdomdCommand cmd = new AdomdCommand(linha, conn);
                cmd.Execute();
                conn.Close();

                COMERCIALDataSetTableAdapters.ATUCUBOTableAdapter atu = new Comercial.COMERCIALDataSetTableAdapters.ATUCUBOTableAdapter();
                DateTime data = Convert.ToDateTime(DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day);
                atu.Insert(_princ.usuarioLogado, data);

                preencheGrid();

                prgrsBrCarrega.Value = 100;
                tmrTempo.Enabled = false;
                lblTexto.Visible = false;
                MessageBox.Show("Processo executado com sucesso", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                pictureBox1.Visible = true;
                pictureBox2.Visible = true;

            }
            catch(Exception ex)
            {
                tmrTempo.Enabled = false;
                lblTexto.Visible = false;
                prgrsBrCarrega.Visible = false;
                MessageBox.Show("Houve um problema na execução da atualização!\nConsulte o DBA.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error);
                pictureBox1.Visible = false;
                pictureBox1.Visible = false;
            }
        }