コード例 #1
0
        private void Report_Modification(CrystalDecisions.CrystalReports.Engine.ReportDocument cryRpt)
        {
            CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc1 = cryRpt.ReportClientDocument;
            ReportDefController2 reportDef = rptClientDoc1.ReportDefController;

            ReportSectionController reportSectionController = rptClientDoc1.ReportDefController.ReportSectionController;

            CrystalDecisions.ReportAppServer.ReportDefModel.Section newsec;

            int index = reportDef.ReportDefinition.PageHeaderArea.Sections.Count;

            //  CrystalDecisions.ReportAppServer.ReportDefModel.PictureObject objPictureBox = new CrystalDecisions.ReportAppServer.ReportDefModel.PictureObject();
            if (index > 0)
            {
                // reportDef.ReportDefinition.PageHeaderArea.Sections.Add(reportDef.ReportDefinition.PageHeaderArea.Sections[index - 1]);
                newsec = reportDef.ReportDefinition.PageHeaderArea.Sections[index - 1];//reportDef.ReportDefinition.PageHeaderArea.Sections[index - 1];
            }
            else
            {
                index  = 0;
                newsec = reportDef.ReportDefinition.PageHeaderArea.Sections[index];
            }

            reportDef.ReportDefinition.PageHeaderArea.Sections.Insert(index, newsec);
            CrystalDecisions.ReportAppServer.ReportDefModel.Section sectionToAddTo = reportDef.ReportDefinition.PageHeaderArea.Sections[index];

            CrystalDecisions.ReportAppServer.ReportDefModel.SectionFormat newSectionFormat = sectionToAddTo.Format;
            newSectionFormat.EnableKeepTogether    = false;
            newSectionFormat.EnableSuppress        = false;
            newSectionFormat.EnableUnderlaySection = true;
            reportSectionController.SetProperty(sectionToAddTo, CrReportSectionPropertyEnum.crReportSectionPropertyFormat, newSectionFormat);
            reportDef.ReportObjectController.ImportPicture(AppDomain.CurrentDomain.BaseDirectory + @"IMAGE/AccessReportWatermarks1.png", sectionToAddTo, 500, 700);
        }
コード例 #2
0
        public void ReportSection_Controller_Put_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    ReportSectionController reportSectionController = new ReportSectionController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(reportSectionController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, reportSectionController.DatabaseType);

                    ReportSection reportSectionLast = new ReportSection();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        Query query = new Query();
                        query.Language = LanguageRequest;

                        ReportSectionService reportSectionService = new ReportSectionService(query, db, ContactID);
                        reportSectionLast = (from c in db.ReportSections select c).FirstOrDefault();
                    }

                    // ok with ReportSection info
                    IHttpActionResult jsonRet = reportSectionController.GetReportSectionWithID(reportSectionLast.ReportSectionID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <ReportSection> Ret = jsonRet as OkNegotiatedContentResult <ReportSection>;
                    ReportSection reportSectionRet = Ret.Content;
                    Assert.AreEqual(reportSectionLast.ReportSectionID, reportSectionRet.ReportSectionID);

                    BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest);

                    // Put to return success
                    IHttpActionResult jsonRet2 = reportSectionController.Put(reportSectionRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <ReportSection> reportSectionRet2 = jsonRet2 as OkNegotiatedContentResult <ReportSection>;
                    Assert.IsNotNull(reportSectionRet2);

                    BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest2);

                    // Put to return CSSPError because ReportSectionID of 0 does not exist
                    reportSectionRet.ReportSectionID = 0;
                    IHttpActionResult jsonRet3 = reportSectionController.Put(reportSectionRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    OkNegotiatedContentResult <ReportSection> reportSectionRet3 = jsonRet3 as OkNegotiatedContentResult <ReportSection>;
                    Assert.IsNull(reportSectionRet3);

                    BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult;
                    Assert.IsNotNull(badRequest3);
                }
            }
        }
コード例 #3
0
        public void ReportSection_Controller_GetReportSectionWithID_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    ReportSectionController reportSectionController = new ReportSectionController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(reportSectionController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, reportSectionController.DatabaseType);

                    ReportSection reportSectionFirst = new ReportSection();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        ReportSectionService reportSectionService = new ReportSectionService(new Query(), db, ContactID);
                        reportSectionFirst = (from c in db.ReportSections select c).FirstOrDefault();
                    }

                    // ok with ReportSection info
                    IHttpActionResult jsonRet = reportSectionController.GetReportSectionWithID(reportSectionFirst.ReportSectionID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <ReportSection> Ret = jsonRet as OkNegotiatedContentResult <ReportSection>;
                    ReportSection reportSectionRet = Ret.Content;
                    Assert.AreEqual(reportSectionFirst.ReportSectionID, reportSectionRet.ReportSectionID);

                    BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest);

                    // Not Found
                    IHttpActionResult jsonRet2 = reportSectionController.GetReportSectionWithID(0);
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <ReportSection> reportSectionRet2 = jsonRet2 as OkNegotiatedContentResult <ReportSection>;
                    Assert.IsNull(reportSectionRet2);

                    NotFoundResult notFoundRequest = jsonRet2 as NotFoundResult;
                    Assert.IsNotNull(notFoundRequest);
                }
            }
        }
コード例 #4
0
        private void Report_Modification(CrystalDecisions.CrystalReports.Engine.ReportDocument cryRpt)
        {
            CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc1 = cryRpt.ReportClientDocument;

            //ISCRParagraphTextElement paragraphTextElement = new ParagraphTextElementClass();
            //paragraphTextElement.Text = "DEMO VERSION";
            //paragraphTextElement.Kind = CrParagraphElementKindEnum.crParagraphElementKindText;

            //ParagraphElements paragraphElements = new ParagraphElementsClass();
            //paragraphElements.Add(paragraphTextElement);

            //Paragraph paragraph = new ParagraphClass();
            //paragraph.Alignment = CrAlignmentEnum.crAlignmentHorizontalCenter;
            //paragraph.ParagraphElements = paragraphElements;

            //Paragraphs paragraphs = new ParagraphsClass();
            //paragraphs.Add(paragraph);

            //ISCRTextObject textObject = new TextObjectClass();
            //textObject.Paragraphs = paragraphs;
            //textObject.FontColor.Font.Bold = true;
            //textObject.FontColor.Font.Size = 48;
            //textObject.FontColor.Font.Italic = true;
            //textObject.FontColor.Color = uint.Parse(ColorTranslator.ToOle(Color.Gray).ToString());
            //textObject.FontColor.Font.Charset = 30;
            //textObject.Height = 8000;
            //textObject.Top = this.Height;
            //textObject.Left = 5000;
            //textObject.Width = 1500;

            //textObject.Format.TextRotationAngle = CrTextRotationAngleEnum.crRotationAngleRotate90;

            //ISCRPictureObject imgObject = new PictureObjectClass();
            //imgObject.Kind = CrReportObjectKindEnum.crReportObjectKindPicture;



            //textObject.Format.HorizontalAlignment = CrAlignmentEnum.crAlignmentDecimal;

            ReportDefController2 reportDef = rptClientDoc1.ReportDefController;

            ReportSectionController reportSectionController = rptClientDoc1.ReportDefController.ReportSectionController;

            CrystalDecisions.ReportAppServer.ReportDefModel.Section newsec;

            int index = reportDef.ReportDefinition.PageHeaderArea.Sections.Count;

            //  CrystalDecisions.ReportAppServer.ReportDefModel.PictureObject objPictureBox = new CrystalDecisions.ReportAppServer.ReportDefModel.PictureObject();
            if (index > 0)
            {
                // reportDef.ReportDefinition.PageHeaderArea.Sections.Add(reportDef.ReportDefinition.PageHeaderArea.Sections[index - 1]);
                newsec = reportDef.ReportDefinition.PageHeaderArea.Sections[index - 1];//reportDef.ReportDefinition.PageHeaderArea.Sections[index - 1];
            }
            else
            {
                index  = 0;
                newsec = reportDef.ReportDefinition.PageHeaderArea.Sections[index];
            }

            reportDef.ReportDefinition.PageHeaderArea.Sections.Insert(index, newsec);

            //newsec.Name = "Z";
            //ISCRArea ar = reportDef.ReportDefinition.PageHeaderArea;
            //ar.Name = "PH";
            //reportSectionController.Add(newsec, ar, index - 1);

            CrystalDecisions.ReportAppServer.ReportDefModel.Section sectionToAddTo = reportDef.ReportDefinition.PageHeaderArea.Sections[index];

            CrystalDecisions.ReportAppServer.ReportDefModel.SectionFormat newSectionFormat = sectionToAddTo.Format;
            newSectionFormat.EnableKeepTogether    = false;
            newSectionFormat.EnableSuppress        = false;
            newSectionFormat.EnableUnderlaySection = true;
            reportSectionController.SetProperty(sectionToAddTo, CrReportSectionPropertyEnum.crReportSectionPropertyFormat, newSectionFormat);
            reportDef.ReportObjectController.ImportPicture(AppDomain.CurrentDomain.BaseDirectory + @"IMAGE/AccessReportWatermarks1.png", sectionToAddTo, 500, 700);


            //reportDef.ReportObjectController.Add(textObject, sectionToAddTo, 0);
            //reportDef.ReportObjectController.Add(imgObject, sectionToAddTo, 0);

            //ReportObjectControllerClass objPictureBox = new ReportObjectControllerClass();
            //objPictureBox.ImportPicture(AppDomain.CurrentDomain.BaseDirectory + @"IMAGE/AccessReportWatermarks1.png", sectionToAddTo, 20, 20);
            //rptClientDoc1.ReportDefController = reportDef;
            //cryRpt.ReportClientDocument = rptClientDoc1;
        }
コード例 #5
0
        public void ReportSection_Controller_GetReportSectionList_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    ReportSectionController reportSectionController = new ReportSectionController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(reportSectionController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, reportSectionController.DatabaseType);

                    ReportSection reportSectionFirst = new ReportSection();
                    int           count = -1;
                    Query         query = new Query();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                    {
                        ReportSectionService reportSectionService = new ReportSectionService(query, db, ContactID);
                        reportSectionFirst = (from c in db.ReportSections select c).FirstOrDefault();
                        count = (from c in db.ReportSections select c).Count();
                        count = (query.Take > count ? count : query.Take);
                    }

                    // ok with ReportSection info
                    IHttpActionResult jsonRet = reportSectionController.GetReportSectionList();
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <List <ReportSection> > ret = jsonRet as OkNegotiatedContentResult <List <ReportSection> >;
                    Assert.AreEqual(reportSectionFirst.ReportSectionID, ret.Content[0].ReportSectionID);
                    Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count);

                    List <ReportSection> reportSectionList = new List <ReportSection>();
                    count = -1;
                    query = new Query();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                    {
                        ReportSectionService reportSectionService = new ReportSectionService(query, db, ContactID);
                        reportSectionList = (from c in db.ReportSections select c).OrderBy(c => c.ReportSectionID).Skip(0).Take(2).ToList();
                        count             = (from c in db.ReportSections select c).Count();
                    }

                    if (count > 0)
                    {
                        query.Skip = 0;
                        query.Take = 5;
                        count      = (query.Take > count ? query.Take : count);

                        // ok with ReportSection info
                        jsonRet = reportSectionController.GetReportSectionList(query.Language.ToString(), query.Skip, query.Take);
                        Assert.IsNotNull(jsonRet);

                        ret = jsonRet as OkNegotiatedContentResult <List <ReportSection> >;
                        Assert.AreEqual(reportSectionList[0].ReportSectionID, ret.Content[0].ReportSectionID);
                        Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count);

                        if (count > 1)
                        {
                            query.Skip = 1;
                            query.Take = 5;
                            count      = (query.Take > count ? query.Take : count);

                            // ok with ReportSection info
                            IHttpActionResult jsonRet2 = reportSectionController.GetReportSectionList(query.Language.ToString(), query.Skip, query.Take);
                            Assert.IsNotNull(jsonRet2);

                            OkNegotiatedContentResult <List <ReportSection> > ret2 = jsonRet2 as OkNegotiatedContentResult <List <ReportSection> >;
                            Assert.AreEqual(reportSectionList[1].ReportSectionID, ret2.Content[0].ReportSectionID);
                            Assert.AreEqual((count > query.Take ? query.Take : count), ret2.Content.Count);
                        }
                    }
                }
            }
        }
コード例 #6
0
        public void ReportSection_Controller_Post_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    ReportSectionController reportSectionController = new ReportSectionController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(reportSectionController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, reportSectionController.DatabaseType);

                    ReportSection reportSectionLast = new ReportSection();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        Query query = new Query();
                        query.Language = LanguageRequest;
                        query.Asc      = "";
                        query.Desc     = "";

                        ReportSectionService reportSectionService = new ReportSectionService(query, db, ContactID);
                        reportSectionLast = (from c in db.ReportSections select c).FirstOrDefault();
                    }

                    // ok with ReportSection info
                    IHttpActionResult jsonRet = reportSectionController.GetReportSectionWithID(reportSectionLast.ReportSectionID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <ReportSection> Ret = jsonRet as OkNegotiatedContentResult <ReportSection>;
                    ReportSection reportSectionRet = Ret.Content;
                    Assert.AreEqual(reportSectionLast.ReportSectionID, reportSectionRet.ReportSectionID);

                    BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest);

                    // Post to return CSSPError because ReportSectionID exist
                    IHttpActionResult jsonRet2 = reportSectionController.Post(reportSectionRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <ReportSection> reportSectionRet2 = jsonRet2 as OkNegotiatedContentResult <ReportSection>;
                    Assert.IsNull(reportSectionRet2);

                    BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult;
                    Assert.IsNotNull(badRequest2);

                    // Post to return newly added ReportSection
                    reportSectionRet.ReportSectionID           = 0;
                    reportSectionController.Request            = new System.Net.Http.HttpRequestMessage();
                    reportSectionController.Request.RequestUri = new System.Uri("http://localhost:5000/api/reportSection");
                    IHttpActionResult jsonRet3 = reportSectionController.Post(reportSectionRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    CreatedNegotiatedContentResult <ReportSection> reportSectionRet3 = jsonRet3 as CreatedNegotiatedContentResult <ReportSection>;
                    Assert.IsNotNull(reportSectionRet3);

                    BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest3);

                    IHttpActionResult jsonRet4 = reportSectionController.Delete(reportSectionRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet4);

                    OkNegotiatedContentResult <ReportSection> reportSectionRet4 = jsonRet4 as OkNegotiatedContentResult <ReportSection>;
                    Assert.IsNotNull(reportSectionRet4);

                    BadRequestErrorMessageResult badRequest4 = jsonRet4 as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest4);
                }
            }
        }