public static StiImportResult Import(byte[] dataBytes, byte[] memoBytes)
        {
            var currentCulture = Thread.CurrentThread.CurrentCulture;

            try
            {
                Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", false);

                DataTable visualFoxPro;
                using (var dataStream = new MemoryStream(dataBytes))
                {
                    if (memoBytes != null)
                    {
                        using (var memoStream = new MemoryStream(memoBytes))
                        {
                            visualFoxPro = StiDBaseHelper.GetTable(dataStream, memoStream, false, 0);
                        }
                    }
                    else
                    {
                        visualFoxPro = StiDBaseHelper.GetTable(dataStream, null, false, 0);
                    }
                }

                var convertor = new StiVisualFoxProHelper();
                var report    = convertor.Convert(visualFoxPro);

                return(new StiImportResult(report, null));
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = currentCulture;
            }
        }
Beispiel #2
0
        private void btnConvert_Click(object sender, System.EventArgs e)
        {
            if (!File.Exists(tbVisualFoxProFile.Text))
            {
                MessageBox.Show("Incorrect Visual FoxPro template file name",
                                null, MessageBoxButtons.OK, MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
            }
            else
            {
                StiTreeViewLog log = new StiTreeViewLog(this.treeViewLog);

                log.OpenLog("Initialize ...");
                Application.DoEvents();

                log.CurrentNode.Text += "OK";
                log.CloseLog();
                log.OpenLog("Open Visual FoxPro template file ...");
                Application.DoEvents();

                DataTable visualFoxPro = null;
                string    path         = tbVisualFoxProFile.Text;
                using (Stream data = new FileStream(path, FileMode.Open))
                {
                    string memoPath = Path.ChangeExtension(path, "frt");
                    if (File.Exists(memoPath))
                    {
                        using (Stream memo = new FileStream(memoPath, FileMode.Open))
                        {
                            visualFoxPro = StiDBaseHelper.GetTable(data, memo, false, 0);
                        }
                    }
                    else
                    {
                        visualFoxPro = StiDBaseHelper.GetTable(data, null, false, 0);
                    }
                }

                log.CurrentNode.Text += "OK";
                log.CloseLog();
                log.OpenLog("Converting ...");
                Application.DoEvents();

                StiVisualFoxProHelper convertor = new StiVisualFoxProHelper();
                TreeView       tv   = new TreeView();
                StiTreeViewLog log2 = new StiTreeViewLog(tv);
                //StiReport stimulReport = convertor.Convert(visualFoxPro, log2);
                StiReport stimulReport = convertor.Convert(visualFoxPro);

                log.CurrentNode.Text += "OK";
                log.CloseLog();
                log.OpenLog("Save Stimulsoft Reports template file ...");
                Application.DoEvents();
                stimulReport.Save(tbStimulReportFile.Text);

                log.CurrentNode.Text += "OK";

                MessageBox.Show("Conversion complete!");

                #if Test
                stimulReport.Design();
                #endif
            }
        }