Exemplo n.º 1
0
        public List <ReportBrowser> WebRptBrowser(ReportBrowser _Browser)
        {
            var objDataEngine = new FleetDataEngine(AccessMode.CustomerService, DBType.Maint);

            try
            {
                objDataEngine.InitiateConnection();

                SqlParameter[] Parameters = new SqlParameter[2];

                Parameters[0] = new SqlParameter("@UserID", GetUserId);
                Parameters[1] = string.IsNullOrEmpty(_Browser.ReportDate) ? new SqlParameter("@RptDate", DBNull.Value) : new SqlParameter("@RptDate", ConvertDatetimeDB(_Browser.ReportDate));

                var execResult = objDataEngine.ExecuteCommand("WebRptBrowser", CommandType.StoredProcedure, Parameters);
                var _Reports   = new List <ReportBrowser>();

                while (execResult.Read())
                {
                    _Reports.Add(new ReportBrowser
                    {
                        FileName       = Convert.ToString(execResult["DiskFileName"]),
                        ReportCategory = Convert.ToString(execResult["RptCategory"]),
                        ReportName     = Convert.ToString(execResult["RptName"])
                    });
                }
                ;
                return(_Reports);
            }
            finally
            {
                objDataEngine.CloseConnection();
            }
        }
Exemplo n.º 2
0
        private void Vandalize()
        {
            var reader = new PdfReader(pdf_url);
            var size   = reader.GetPageSizeWithRotation(1);
            var doc    = new Document(size);

            // open the writer
            var fs     = new FileStream(newpdf_url, FileMode.Create, FileAccess.Write);
            var writer = PdfWriter.GetInstance(doc, fs);

            doc.Open();

            // pdf content
            var cb = writer.DirectContent;
            var bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            cb.SetColorFill(BaseColor.LIGHT_GRAY);
            cb.SetFontAndSize(bf, 8);
            // coordinates
            // write text
            cb.BeginText();
            string txt = "This is the method.";

            cb.ShowTextAligned(1, txt, 200, 200, 0);
            cb.ShowText("Show text only");
            cb.EndText();


            doc.Close();
            fs.Close();
            writer.Close();
            reader.Close();
            ReportBrowser.Navigate(newpdf_url);
        }
Exemplo n.º 3
0
        private void PrepareReport(AnalyzeResponce responce)
        {
            String path = Path.GetFullPath(SettingsHelper.ReportTemplate);
            var    doc  = new HtmlDocument();

            doc.Load(path);
            doc.GetElementbyId("SiteUrl").InnerHtml    = responce.Url;
            doc.GetElementbyId("LastUpdate").InnerHtml = responce.LastUpdate.ToShortDateString();
            doc.GetElementbyId("CY").InnerHtml         = responce.Results[RequestType.CY] != "" ? responce.Results[RequestType.CY] : "-";
            doc.GetElementbyId("PR").InnerHtml         = responce.Results[RequestType.PR] != "" ? responce.Results[RequestType.PR] : "-";
            doc.GetElementbyId("Links").InnerHtml      = responce.Results[RequestType.Links] != "" ? responce.Results[RequestType.Links] : "-";
            doc.GetElementbyId("Clients").InnerHtml    = responce.Results[RequestType.Customers] != "" ? responce.Results[RequestType.Customers] : "-";

            if (!Directory.Exists(SettingsHelper.TempFilesDirectory))
            {
                Directory.CreateDirectory(SettingsHelper.TempFilesDirectory);
            }

            string fileName = responce.LastUpdate.ToShortDateString();

            fileName = PrepareFileName(fileName);

            //String tmpFile = String.Format(@"{0}\{1}{2}.html", SettingsHelper.TempFilesDirectory, responce.Url, responce.LastUpdate.ToShortDateString());
            String tmpFile = String.Format(@"{0}\{1}{2}.html", SettingsHelper.TempFilesDirectory, responce.Url, fileName);

            doc.Save(tmpFile, Encoding.Unicode);

            ReportBrowser.Navigate(Path.GetFullPath(tmpFile));
        }
Exemplo n.º 4
0
        private void SetupPDFPage()
        {
            //var document = new Document(PageSize.LETTER, 50, 50, 25, 25);
            //var output = new MemoryStream();
            //var writer = PdfWriter.GetInstance(document, output);
            //// -- open document to begin writing
            //document.Open();
            //// -- create the fonts

            pdf_url    = string.Format("{0}{1}", Application.StartupPath, @"\Reports\pdfs\sampler.pdf");
            newpdf_url = string.Format("{0}{1}", Application.StartupPath, @"\Reports\pdfs\sampler2.pdf");
            Console.WriteLine(pdf_url);
            ReportBrowser.Navigate(pdf_url);
        }
Exemplo n.º 5
0
        public ActionResult Post(string module)
        {
            try
            {
                var files = ReportBrowser.GetFiles(this.Tenant, module);

                string json = JsonConvert.SerializeObject(files, Formatting.None, new JsonSerializerSettings {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                });
                return(this.Content(json, "application/json"));
            }
            catch (ReportBrowserException ex)
            {
                return(this.Failed(ex.Message, HttpStatusCode.BadRequest));
            }
            catch
            {
                //Todo: localize the error message
                return(this.Failed("An error was encountered while performing the requested task.", HttpStatusCode.InternalServerError));
            }
        }