Пример #1
0
        private void barBtnViewAttach_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (gridViewAnexos.IsSelectOneRowWarning())
            {
                var row = gridViewAnexos.GetFocusedRow <AnexoPackage>();

                if (row != null)
                {
                    //evita um nome duplicado
                    string file = FileManagerIts.GetTempFile(row.PathFile);
                    FileManagerIts.DeleteFile(file);
                    FileManagerIts.WriteBytesToFile(file, row.DataFile);

                    if (file.EndsWith(".sql"))
                    {
                        var high = new XFrmHighlighting(file, ScintillaNET.Lexer.Sql);
                        high.ShowDialog();

                        if (high.IsTextSave)
                        {
                            row.DataFile = FileManagerIts.GetBytesFromFile(file);
                        }
                    }
                    else
                    {
                        //deixe o sistema se virar
                        FileManagerIts.OpenFromSystem(file);
                    }
                }
            }
        }
Пример #2
0
        private void btnSelecionarUpdateFile_Click(object sender, EventArgs e)
        {
            var op = openFilePkg.ShowDialog();

            if (op == DialogResult.OK)
            {
                string pkgFile = openFilePkg.FileName;
                txtUpdateFile.Text = pkgFile;

                try
                {
                    var bytesFile = FileManagerIts.GetBytesFromFile(openFilePkg.FileName);
                    this._pacote = SerializeIts.DeserializeObject <Package>(bytesFile);
                    loadPackage(this._pacote);
                }
                catch (Exception ex)
                {
                    string msg = "O pacote de atualização informado é inválido!"
                                 + "\n\nContate o administrador para aplicar atualização.";

                    XMessageIts.ExceptionMessageDetails(ex, msg, "Atenção");

                    LoggerUtilIts.GenerateLogs(ex, msg);
                }
            }
        }
Пример #3
0
        public static void ImportReportFromFiles(params string[] filesReports)
        {
            using (var ctx = new ReportContext())
            {
                try
                {
                    Dictionary <string, bool> importados = new Dictionary <string, bool>();

                    foreach (var file in filesReports)
                    {
                        var bytesFile        = FileManagerIts.GetBytesFromFile(file);
                        var rptDeserializado = SerializeIts.DeserializeObject <ReportImage>(bytesFile);

                        var rptCreateUpdate = ctx.ReportImageDao.Where(r =>
                                                                       r.ReportName == rptDeserializado.ReportName)
                                              .FirstOrDefault();

                        //relatorio ja existe
                        if (rptCreateUpdate != null)
                        {
                            var msg     = "O relatório selecionado já existe, deseja atualiza-lo?";
                            var confirm = XMessageIts.Confirmacao(msg);
                            if (confirm == DialogResult.Yes)
                            {
                                rptCreateUpdate.Update(rptDeserializado);

                                var traUpd = ctx.ReportImageDao.Update(rptCreateUpdate);
                                if (traUpd)
                                {
                                    XMessageIts.Mensagem("Relatório atualizado com sucesso!");
                                }
                            }
                        }
                        //relatorio nao existe, entao vai criar
                        else
                        {
                            var newReport = new ReportImage();
                            newReport.IdGrpReport       = rptDeserializado.IdGrpReport;
                            newReport.ReportDescription = rptDeserializado.ReportDescription;
                            newReport.ReportImageData   = rptDeserializado.ReportImageData;
                            newReport.ReportName        = rptDeserializado.ReportName;
                            importados.Add(newReport.ReportName, ctx.ReportImageDao.Save(newReport));
                        }
                    }
                    if (importados.Where(i => i.Value == false).Count() == 0)
                    {
                        XMessageIts.Mensagem("Relatórios importado com sucesso!");
                    }
                    else
                    {
                        XMessageIts.Advertencia("Ocorreram erros ao importar o(s) dashboard(s) !");
                    }
                }
                catch (Exception ex)
                {
                    XMessageIts.ExceptionMessageDetails(ex, "Falha ao importar o relatório");
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Atualiza o dashboard existente no banco
        /// </summary>
        /// <param name="dashboardDesigner">Designer do dashboard</param>
        /// <param name="dash">Dashboard a ser persistido</param>
        /// <returns>O Dashboard persistido no banco ou null</returns>
        public bool UpdateDashboard(DashboardDesigner dashboardDesigner, DashboardImage dash)
        {
            try
            {
                using (var ctx = new ReportContext())
                {
                    //nome padrão
                    dash.DefaultName = dashboardDesigner.ActiveControl.Name;

                    //gera um nome aleatorio utilizando o nome setado no dashboard
                    string dashPath = generatePath(dash, ctx);
                    // using (MemoryStream ms = new MemoryStream())

                    //objeto designer do dashboard
                    var designer = dashboardDesigner.Dashboard;

                    FileManagerIts.DeleteFile(dashPath);
                    //salva o layout em memoria
                    //designer.SaveToXml(ms);

                    //salva o dashboard no disco em formato xml
                    designer.SaveToXml(dashPath);

                    var bytes = FileManagerIts.GetBytesFromFile(dashPath); //ms.GetBuffer();

                    //passando objeto pro contexto
                    var current = ctx.DashboardImageDao.Find(dash.IdReport);

                    //atualiza o dashboard
                    current.Update(dash);

                    //garante a atualização
                    current.ReportImageData = bytes;

                    //efetiva no banco
                    return(ctx.DashboardImageDao.Update(current));
                }
            }
            catch (Exception ex)
            {
                XMessageIts.Advertencia("Houve um erro na atualização do dashboard.\n\n"
                                        + ex.Message);

                LoggerUtilIts.GenerateLogs(ex);
                return(false);
            }
        }
Пример #5
0
        public AbstractAttach(string path)
        {
            try
            {
                this.DataAnexo = DateTime.Now;
                this.PathFile  = path;

                //a extensao eh obtida a partir do PathFile
                this.FileName = Path.GetFileName(path);

                if (File.Exists(PathFile))
                {
                    this.DataFile = FileManagerIts.GetBytesFromFile(path);

                    //por padrao eh o nome do arquivo sem a extensao
                    //a extensao eh obtida a partir do PathFile
                    this.IdentificacaoAnexo = Path.GetFileNameWithoutExtension(path);
                }
            }
            catch (Exception ex)
            {
                XMessageIts.ExceptionJustMessage(ex, "Falha na criação do anexo");
            }
        }