Exemplo n.º 1
0
        public RESTStatus TestPaperTemplate(SQLLib sql, object dummy, NetworkConnectionInfo ni, string Paper)
        {
#if !TXTREPORT
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            if (string.IsNullOrWhiteSpace(Paper) == true)
            {
                ni.Error   = "Invalid data";
                ni.ErrorID = ErrorFlags.InvalidData;
                return(RESTStatus.Fail);
            }

            Paper = Paper.ToUpper().Trim();

            if (SupportedNames.Contains(Paper) == false)
            {
                ni.Error   = "Invalid data";
                ni.ErrorID = ErrorFlags.InvalidData;
                return(RESTStatus.Fail);
            }

            RetPaper      = new NetByte();
            RetPaper.Data = null;

            lock (ni.sqllock)
            {
                switch (Paper)
                {
                case "COMPUTERREPORT":
                    RetPaper.Data = RenderReport.RenderReportData(RenderReport.GetReportPaperData(sql, Paper, Resources.Computer_Report), new Dictionary <string, object>(), "PDF");
                    break;
                }
            }

            return(RESTStatus.Success);
#else
            ni.Error   = "Unsupported functionality";
            ni.ErrorID = ErrorFlags.SystemError;
            return(RESTStatus.Fail);
#endif
        }
Exemplo n.º 2
0
        public RESTStatus AddPaperTemplate(SQLLib sql, ReportPaper req, NetworkConnectionInfo ni)
        {
#if !TXTREPORT
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            if (req == null)
            {
                ni.Error   = "Invalid data";
                ni.ErrorID = ErrorFlags.InvalidData;
                return(RESTStatus.Fail);
            }

            if (string.IsNullOrWhiteSpace(req.Name) == true)
            {
                ni.Error   = "Invalid data";
                ni.ErrorID = ErrorFlags.InvalidData;
                return(RESTStatus.Fail);
            }

            req.Name = req.Name.ToUpper().Trim();

            if (SupportedNames.Contains(req.Name) == false)
            {
                ni.Error   = "Invalid data";
                ni.ErrorID = ErrorFlags.InvalidData;
                return(RESTStatus.Fail);
            }

            if (req.data == null)
            {
                lock (ni.sqllock)
                {
                    sql.ExecSQL("DELETE from ReportPapers WHERE ID=@id",
                                new SQLParam("@id", req.Name));
                }
                return(RESTStatus.Success);
            }
            else
            {
                if (RenderReport.RenderReportData(req.data, new Dictionary <string, object>()) == null)
                {
                    ni.Error   = "Rendering of report failed";
                    ni.ErrorID = ErrorFlags.InvalidData;
                    return(RESTStatus.Fail);
                }

                lock (ni.sqllock)
                {
                    if (sql.ExecSQL("if exists(select * from ReportPapers where [ID]=@ID) update ReportPapers set [Data]=@data,DT=getutcdate() where [ID]=@ID else insert into ReportPapers ([ID],[Data]) values(@ID,@data)",
                                    new SQLParam("@ID", req.Name),
                                    new SQLParam("@data", req.data)) == false)
                    {
                        ni.Error   = "SQL Error";
                        ni.ErrorID = ErrorFlags.SQLError;
                        return(RESTStatus.Fail);
                    }
                }
            }
            return(RESTStatus.Success);
#else
            ni.Error   = "Unsupported functionality";
            ni.ErrorID = ErrorFlags.SystemError;
            return(RESTStatus.Fail);
#endif
        }