Ejemplo n.º 1
0
        private void c1DockingTab1_TabClick(object sender, EventArgs e)
        {
            var flexViewer = c1DockingTab1.SelectedTab.Tag as C1FlexViewer ?? new C1FlexViewer()
            {
                Anchor   = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top,
                Dock     = DockStyle.Fill,
                ZoomMode = FlexViewerZoomMode.PageWidth,
                Parent   = c1DockingTab1.SelectedTab
            };

            if (flexViewer.DocumentSource == null)
            {
                flexViewer.Ribbon.Minimized = true;
                var      flexReport   = new C1FlexReport();
                var      reportStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DashboardWinForms.Reports." + _reps[c1DockingTab1.SelectedIndex]);
                string[] reports      = C1FlexReport.GetReportList(reportStream);
                if (reports.Count() == 0)
                {
                    return;
                }
                var reportName = reports[0];
                if (!string.IsNullOrEmpty(reportName))
                {
                    reportStream.Seek(0, SeekOrigin.Begin);
                    flexReport.Load(reportStream, reportName);
                    flexViewer.DocumentSource     = flexReport;
                    c1DockingTab1.SelectedTab.Tag = flexViewer;
                }
            }
        }
Ejemplo n.º 2
0
        private void UpdateReportsList()
        {
            string[] reports = null;
            // get list of reports from resource using stream
            Assembly asm = Assembly.GetExecutingAssembly();

            using (Stream stream = asm.GetManifestResourceStream("FlexReportSamples.Resources.FlexCommonTasks_XML.flxr"))
                reports = C1FlexReport.GetReportList(stream);

            //
            cbReport.Items.Clear();
            if (reports != null && reports.Length > 0)
            {
                foreach (string s in reports)
                {
                    cbReport.Items.Add(s);
                }
                cbReport.SelectedIndex = 0;
                btnPrint.IsEnabled     = !_report.IsBusy;
            }
            else
            {
                btnPrint.IsEnabled = false;
            }
        }
        public CategoryList(Stream stream)
        {
            _stream = stream;
            string[] reports = C1FlexReport.GetReportList(stream);

            using (C1FlexReport fr = new C1FlexReport())
            {
                foreach (string reportName in reports)
                {
                    stream.Seek(0, SeekOrigin.Begin);
                    fr.Load(stream, reportName);

                    string   keywords = fr.ReportInfo.Keywords;
                    string[] ss       = keywords.Split(new string[] { "\r\n" }, StringSplitOptions.None);
                    for (int i = 0; i < ss.Length; i++)
                    {
                        var categoryName = ss[i];

                        if (Contains(categoryName))
                        {
                            this[categoryName].AddReport(reportName);
                        }
                        else
                        {
                            var ci = new CategoryItem(categoryName);
                            ci.AddReport(reportName);
                            this.Add(ci);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        async void ViewerPage_Loaded(object sender, RoutedEventArgs e)
        {
            _asm = typeof(ViewerPage).GetTypeInfo().Assembly;
            await ExportPage.CopyC1NWind();

            string[] reports = null;

            // get list of reports from resource using stream
            using (Stream stream = _asm.GetManifestResourceStream("FlexReportSamples.Resources.FlexCommonTasks_UWP.flxr"))
                reports = C1FlexReport.GetReportList(stream);

            cbReport.Items.Clear();
            cbReport.SelectionChanged += CbReport_SelectionChanged;

            if (reports != null && reports.Length > 0)
            {
                foreach (string s in reports)
                {
                    cbReport.Items.Add(s);
                }
            }

            foreach (string s in _pdfs)
            {
                cbReport.Items.Add(s);
            }

            cbReport.SelectedIndex = 0;
        }
Ejemplo n.º 5
0
        private void LoadZip()
        {
            // locate zip file
            string strFile = Application.ExecutablePath;
            int    i       = strFile.IndexOf("\\bin");

            if (i > -1)
            {
                strFile = strFile.Substring(0, i);
            }
            strFile += "\\" + zipName;

            // open password-protected zip file
            C1ZipFile zip = new C1ZipFile();

            zip.Open(strFile);
            zip.Password = zipPwd;

            // load report definition XML document from compressed stream
            Stream stream = zip.Entries[0].OpenReader();

            _xmlDoc = new XmlDocument();
            _xmlDoc.PreserveWhitespace = true;
            _xmlDoc.Load(stream);
            stream.Close();
            //
            zip.Close();
            //
            _lbReports.Items.AddRange(C1FlexReport.GetReportList(_xmlDoc));
        }
        void OnLoaded(object sender, RoutedEventArgs rea)
        {
            Loaded -= OnLoaded;

            using (_reportStream = File.OpenRead("Assets/Reports/RegionWiseSalesData.flxr"))
            {
                string[] reports = C1FlexReport.GetReportList(_reportStream);
                fv.DocumentSource = null;
                _reportStream.Seek(0, SeekOrigin.Begin);
                _flexReport.Load(_reportStream, reports[0]);
                fv.DocumentSource = _flexReport;
            }
        }
Ejemplo n.º 7
0
        void LoadReportList()
        {
            _reportStream = new FileStream("Reports\\CurrentOpportunitiesData.flxr", FileMode.Open, FileAccess.Read);
            string[] reports = C1FlexReport.GetReportList(_reportStream);

            var docListCombo = fv.DocumentListCombo;
            var items        = docListCombo.Items;

            for (int i = 0; i < reports.Length; i++)
            {
                items.Add(reports[i]);
            }

            docListCombo.SelectionCommitted += ReportCombo_SelectionCommitted;
            docListCombo.SelectedIndex       = 0;
        }
        void LoadReportList()
        {
            string[] reports;
            _reportStream = Application.GetResourceStream(new Uri("/" + _asmName + ";component/FlexViewer/FlexCommonTasks_XML.flxr", UriKind.Relative)).Stream;
            reports       = C1FlexReport.GetReportList(_reportStream);

            var docListCombo = fv.DocumentListCombo;
            var items        = docListCombo.Items;

            for (int i = 0; i < reports.Length; i++)
            {
                items.Add(reports[i]);
            }

            docListCombo.SelectionCommitted += ReportCombo_SelectionCommitted;
            docListCombo.SelectedIndex       = 0;
        }
Ejemplo n.º 9
0
        private void BuildTopicBar()
        {
            // get list of the reports
            string fileName = @"..\..\" + c_FlexCommonTasks;

            string[] reports = C1FlexReport.GetReportList(fileName);

            // go over reports and get category from C1FlexReport.ReportInfo.Keywords
            using (C1FlexReport fr = new C1FlexReport())
            {
                List <Category> categories = new List <Category>();
                foreach (string reportName in reports)
                {
                    fr.Load(fileName, reportName);

                    string   keywords = fr.ReportInfo.Keywords;
                    string[] ss       = keywords.Split(new string[] { "\r\n" }, StringSplitOptions.None);
                    for (int i = 0; i < ss.Length; i++)
                    {
                        Category c = categories.Find((item) => string.Compare(item.Name, ss[i], true) == 0);
                        if (c == null)
                        {
                            c = new Category()
                            {
                                Name = ss[i]
                            };
                            categories.Add(c);
                        }
                        c.Reports.Add(reportName);
                    }
                }
                categories.Sort(CompareCategories);

                foreach (Category c in categories)
                {
                    // build items in the C1TopicBar
                    C1TopicPage tp = new C1TopicPage(c.Name);
                    foreach (string s in c.Reports)
                    {
                        C1TopicLink tl = new C1TopicLink(s);
                        tp.Links.Add(tl);
                    }
                    tbReports.Pages.Add(tp);
                }
            }
        }
Ejemplo n.º 10
0
        private async void UpdateReportsList()
        {
            string[]   reports = null;
            ReportItem ri      = tbReportFile.SelectedItem as ReportItem;

            if (ri.File == null && ri.Caption == c_Builtin)
            {
                // get list of reports from resource using stream
                Assembly asm = typeof(ExportPage).GetTypeInfo().Assembly;
                using (Stream stream = asm.GetManifestResourceStream("FlexReportSamples.Resources.FlexCommonTasks_UWP.flxr"))
                    reports = C1FlexReport.GetReportList(stream);
            }
            else
            {
                // get list of reports from a file
                if (ri.File != null)
                {
                    try
                    {
                        reports = await C1FlexReport.GetReportListAsync(ri.File);
                    }
                    catch
                    {
                    }
                }
            }

            //
            cbReport.Items.Clear();
            if (reports != null && reports.Length > 0)
            {
                foreach (string s in reports)
                {
                    cbReport.Items.Add(s);
                }
                cbReport.SelectedIndex = 0;
                btnPrint.IsEnabled     = !_report.IsBusy;
            }
            else
            {
                btnPrint.IsEnabled = false;
            }
        }
Ejemplo n.º 11
0
        void LoadReportList()
        {
            string[] reports;
            Assembly asm = Assembly.GetExecutingAssembly();

            _reportStream = asm.GetManifestResourceStream("FlexReportSamples.Resources.FlexCommonTasks_XML.flxr");
            reports       = C1FlexReport.GetReportList(_reportStream);

            var docListCombo = fv.DocumentListCombo;
            var items        = docListCombo.Items;

            for (int i = 0; i < reports.Length; i++)
            {
                items.Add(reports[i]);
            }

            docListCombo.SelectionCommitted += ReportCombo_SelectionCommitted;
            docListCombo.SelectedIndex       = 0;
        }
Ejemplo n.º 12
0
        private bool DoImport(string criName, bool useNewDomain)
        {
            string reportsFileName  = Path.GetTempFileName();
            string messagesFileName = Path.GetTempFileName();

            try
            {
                AppDomain domain;
                if (useNewDomain)
                {
                    var info = new AppDomainSetup();
                    domain = AppDomain.CreateDomain(criName, null, info);
                    domain.DoCallBack(LoadThisAssembly);
                }
                else
                {
                    domain = AppDomain.CurrentDomain;
                }

                var filter = domain.CreateInstanceAndUnwrap(criName, CrystalFilterType);
                var method = filter.GetType()
                             .GetMethod("Import", new[] { typeof(string), typeof(string), typeof(string) });
                var errorCode =
                    (int)method.Invoke(filter, new object[] { _crystalFileName, reportsFileName, messagesFileName });

                if (errorCode == CrystalImportErrorCodes.RASNotAvailable ||
                    errorCode == CrystalImportErrorCodes.CrystalNotInstalled)
                {
                    MessageForm.Error(Strings.CrystalFilter.ErrNoCrystalWithRAS);
                    return(false);
                }

                if (!File.Exists(reportsFileName) || new FileInfo(reportsFileName).Length == 0)
                {
                    // file with reports does not exist,  or it is empty
                    return(false);
                }

                // load reports
                try
                {
                    var doc = new XmlDocument();
                    doc.Load(reportsFileName);
                    string[] reportNames = C1FlexReport.GetReportList(doc);
                    if (reportNames == null)
                    {
                        return(false);
                    }

                    foreach (string name in reportNames)
                    {
                        try
                        {
                            var report = new C1FlexReport();
                            report.Load(doc, name);
                            _rptList.Add(report);
                            if (Loading != null)
                            {
                                Loading(this, EventArgs.Empty);
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                catch (Exception ex)
                {
                    // some internal error occurs show error message and exit
                    ShowInternalError(ex);
                    return(false);
                }

                // load messages
                if (errorCode != CrystalImportErrorCodes.ErrorSavingMessages && File.Exists(messagesFileName) &&
                    new FileInfo(reportsFileName).Length > 0)
                {
                    try
                    {
                        _messages.Load(messagesFileName);
                    }
                    catch
                    {
                    }
                }

                // looks like we have some reports now
                return(true);
            }
            finally
            {
                // delete temporary files
                try
                {
                    if (File.Exists(reportsFileName))
                    {
                        File.Delete(reportsFileName);
                    }
                    if (File.Exists(messagesFileName))
                    {
                        File.Delete(messagesFileName);
                    }
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 13
0
        bool OpenFile(string filePath, bool addToJumpList = true)
        {
            if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
            {
                using (OpenFileDialog dlg = new OpenFileDialog())
                {
                    dlg.DereferenceLinks = true;
                    dlg.Title            = OpenFileDlgTitle;
                    if (!string.IsNullOrEmpty(filePath))
                    {
                        if (!Directory.Exists(filePath))
                        {
                            filePath = Path.GetDirectoryName(filePath);
                        }
                        if (Directory.Exists(filePath))
                        {
                            dlg.InitialDirectory = filePath;
                        }
                    }
                    dlg.Filter      = FileOpenFilter;
                    dlg.FilterIndex = 0;
                    if (dlg.ShowDialog() != DialogResult.OK)
                    {
                        return(false);
                    }
                    filePath = dlg.FileName;
                }
                addToJumpList = true;
            }
            XmlDocument doc = null;

            AppDomain.CurrentDomain.SetData("DataDirectory", Path.GetDirectoryName(filePath));
            string ext = Path.GetExtension(filePath).ToLowerInvariant();

            try
            {
                if (ext == ".flxr" || ext == ".xml")
                {
                    doc = new XmlDocument();
                    doc.PreserveWhitespace = true;
                    doc.Load(filePath);
                }
                else
                {
                    MessageBox.Show("Can't open file with \"" + ext + "\" extension.", FormTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (doc != null)
            {
                Text = Path.GetFileNameWithoutExtension(filePath);
                if (addToJumpList)
                {
                    bool found = false;
                    for (int i = 0; i < _recentItems.Count; i++)
                    {
                        if (string.Compare(_recentItems[i], filePath, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        _recentItems.Add(filePath);
                    }
                }

                string[] reportList = C1FlexReport.GetReportList(doc);
                if (reportList == null || reportList.Length == 0)
                {
                    MessageBox.Show("The opened file does not contain any reports.", FormTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(false);
                }

                _doc = doc;

                var coll = _reportsCombo.Items;
                _reportsCombo.Items.ClearAndDisposeItems();
                for (int i = 0; i < reportList.Length; i++)
                {
                    coll.Add(new RibbonButton(reportList[i]));
                }
                UpdateEnabled();
                LoadReport(reportList[0]);
                _reportsCombo.SelectedIndex = 0;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 14
0
        public CommonReports()
        {
            InitializeComponent();
            C1Zoom.Target = null;

            // put C1TopicBur in the C1FlexViewer control
            tbReports.Parent = null;
            splitter1.Parent = null;

            var viewerControls = c1FlexViewer1.Controls;
            var c1             = viewerControls[0];
            var c2             = viewerControls[1];
            var c3             = viewerControls[2];

            viewerControls.Clear();

            viewerControls.Add(c1);
            viewerControls.Add(splitter1);
            viewerControls.Add(tbReports);
            viewerControls.Add(c2);
            viewerControls.Add(c3);

            // prepare the list of reports
            doc = new XmlDocument();
            doc.PreserveWhitespace = true;
            doc.LoadXml(ControlExplorer.Properties.Resources.FlexCommonTasks);

            // get the list of reports in the file
            string[] reports = C1FlexReport.GetReportList(doc);

            //
            // go over reports and get category from C1FlexReport.ReportInfo.Keywords
            using (C1FlexReport fr = new C1FlexReport())
            {
                foreach (string reportName in reports)
                {
                    fr.Load(doc, reportName);

                    string   keywords = fr.ReportInfo.Keywords;
                    string[] ss       = keywords.Split(new string[] { "\r\n" }, StringSplitOptions.None);
                    for (int i = 0; i < ss.Length; i++)
                    {
                        List <string> reps;
                        if (!categories.TryGetValue(ss[i], out reps))
                        {
                            reps = new List <string>();
                            categories.Add(ss[i], reps);
                        }
                        reps.Add(reportName);
                    }
                }

                // now categories dictionary contains list of categories and list of the reports in the each category
                // build content of the C1TopicBar
                foreach (KeyValuePair <string, List <string> > kvp in categories)
                {
                    C1TopicPage tp = new C1TopicPage(kvp.Key);
                    tp.ImageIndex = 0;
                    tp.ImageList  = imageList1;
                    foreach (string s in kvp.Value)
                    {
                        C1TopicLink tl = new C1TopicLink(s);
                        tp.Links.Add(tl);
                    }
                    tbReports.Pages.Add(tp);
                }
            }

            // add list of the reports to the ribbon

            var ribbon = c1FlexViewer1.Ribbon;

            tbMoreReports                 = new RibbonToggleButton();
            tbMoreReports.Pressed         = true;
            tbMoreReports.SmallImage      = ControlExplorer.Properties.Resources.MoreReports;
            tbMoreReports.Text            = "Reports panel";
            tbMoreReports.PressedChanged += MoreReports_PressedChanged;

            ribbon.QatItemsHolder.Insert(0, tbMoreReports);
            ribbon.Qat.Items.Insert(0, tbMoreReports);
            ribbon.Qat.MenuItems.Insert(0, tbMoreReports);

            comboReports = new RibbonComboBox();
            comboReports.GripHandleVisible     = true;
            comboReports.TextAreaWidth         = 170;
            comboReports.MaxDropDownItems      = 12;
            comboReports.DropDownStyle         = RibbonComboBoxStyle.DropDownList;
            comboReports.SelectedIndexChanged += comboReports_SelectedIndexChanged;

            var coll = comboReports.Items;

            foreach (string rn in reports)
            {
                coll.Add(new RibbonButton(rn));
            }

            ribbon.QatItemsHolder.Insert(0, comboReports);
            ribbon.Qat.ItemLinks.Insert(0, comboReports);

            var selReportLabel = new C1.Win.Ribbon.RibbonButton();

            ribbon.QatItemsHolder.Insert(0, selReportLabel);
            ribbon.Qat.ItemLinks.Insert(0, selReportLabel);
            selReportLabel.Text   = "Select Report:";
            selReportLabel.Click += selReportLabel_Click;

            report = new C1FlexReport();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Converts a single file which may contain multiple reports.
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        private ConvertFileItem ConvertFile(string fileName)
        {
            // Create a ConvertFileItem object which will hold the info about the file being converted.
            // If successuflly converted, that object will be passed to the method writing the .flxr file.
            ConvertFileItem convertFile = new ConvertFileItem();

            convertFile.InputFile  = fileName;
            convertFile.OutputFile = Path.ChangeExtension(fileName, ".flxr");
            if (!string.IsNullOrEmpty(_txtOutputFolder.Text))
            {
                convertFile.OutputFile = Path.Combine(_txtOutputFolder.Text, Path.GetFileName(convertFile.OutputFile));
            }

            // load XML document
            XmlDocument doc = new XmlDocument();

            doc.PreserveWhitespace = true;
            try
            {
                LogLine("Converting " + fileName + "...");
                doc.Load(fileName);
            }
            catch (Exception ex)
            {
                string msg = string.Format("Could not load file: {0}.", ex.Message);
                LogLine(msg);
                convertFile.Error = msg;
                LogLine("Converting " + fileName + " aborted.");
                return(convertFile);
            }

            // Get the list of reports in the file.
            string[] reports = C1FlexReport.GetReportList(doc);
            if (reports == null || reports.Length == 0)
            {
                string msg = "No reports found in file.";
                LogLine(msg);
                convertFile.Error = msg;
                LogLine("Converting " + fileName + " aborted.");
                return(convertFile);
            }

            // Loop through reports, loading them into C1FlexReport instances, thus performing the conversion.
            int cnt = reports.Length;

            for (int i = 0; i < cnt; ++i)
            {
                ConvertReportItem convertReport = new ConvertReportItem();
                C1FlexReport      flexReport    = new C1FlexReport();
                try
                {
                    bool converted;
                    flexReport.Load(doc, reports[i], out converted);
                    convertReport.Report = flexReport;
                    LogLine(string.Format("    Converted {0}", flexReport.ReportName));
                }
                catch (Exception x)
                {
                    string msg = string.Format("Failed to convert \"{0}\": {1}", reports[i], x.Message);
                    LogLine("    " + msg);
                    convertReport.Error = msg;
                }
                convertFile.ConvertReports.Add(convertReport);
            }

            // Done. The convertFile object contains the list of converted reports.
            LogLine(fileName + " done.");
            return(convertFile);
        }