Esempio n. 1
0
        internal void LoadConfigFromJSON(string filename)
        {
            InitControls();

            linkOpenJson.Tag = filename;
            this.filename    = filename;
            ConsolePrintNet config = JsonConvert.DeserializeObject <ConsolePrintNet>(File.ReadAllText(filename));

            Helper.SetTextFromSettings(config.InstallDirectory, this.cbPath);
            Helper.SetTextFromSettings(config.OdbcDatasource, this.cbOdbcDatasource);
            Helper.SetTextFromSettings(config.DatabaseName, this.tbDbName);
            Helper.SetTextFromSettings(config.Basetype, this.cbDatabaseType);
            Helper.SetTextFromSettings(config.Login, this.tbLogin);
            Helper.SetTextFromSettings(config.Password, this.tbPassword);
            Helper.SetTextFromSettings(config.ReportFilename, this.cbReportName);
            Helper.SetTextFromSettings(config.ExportDirectory, this.cbExportDirectory);
            Helper.SetSafeComboBox(this.cbActions, SafeEnumParse(config.Action));
            Helper.SetSafeText(this.cbOutputFormat, config.OutputFormat);
            Helper.SetSafeCheck(this.cbOpenDocumentAfterGeneration, config.OpenGeneratedFile);

            if (config.Settings != null)
            {
                dgSettings.DataSource = config.Settings;
            }

            if (config.Parameters != null)
            {
                reportParametersGridView.DataSource = config.Parameters;
            }

            if (!configurationInfoInitialized && !GetConfigurationInfo())
            {
                string dirInstallPath = PrintServerHelper.GetPrintServerIntallPath();
                if (!string.IsNullOrEmpty(dirInstallPath))
                {
                    string adxSrvImp = Path.Combine(dirInstallPath, "AdxSrvImp.exe");
                    if (Directory.Exists(dirInstallPath) && File.Exists(adxSrvImp))
                    {
                        GetVersion(adxSrvImp, "/v");
                    }
                }
                else
                {
                    Logger.Log("Error: PrintServer IntallPath not found");
                }
                var subKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports");

                tbCRRuntime32Version.Text = $"{subKey.GetValue("CRRuntime32Version")}";

                foreach (string item in subKey.GetValueNames())
                {
                    tbSapCrystalReport.Text += $"{item}: {subKey.GetValue(item)} \r\n";
                }
                foreach (string item in subKey.GetSubKeyNames())
                {
                    tbSapCrystalReport.Text += $"{item} \r\n";
                }
                configurationInfoInitialized = true;
            }
        }
Esempio n. 2
0
        private void BuildCommand(out string exe, out string arguments)
        {
            var    conf           = GetConfigFromUI() as ConsolePrintNet;
            string dirInstallPath = string.IsNullOrEmpty(conf.InstallDirectory) ? PrintServerHelper.GetPrintServerIntallPath() : conf.InstallDirectory;

            exe       = $"{dirInstallPath}\\{ConsoleExeName}.exe";
            arguments = $" -connectioninfos:\"datasource={conf.OdbcDatasource};";
            if (!string.IsNullOrEmpty(conf.DatabaseName))
            {
                arguments += $"databasename={conf.DatabaseName};";
            }
            arguments += $"basetype ={conf.Basetype};userid={conf.Login};password={conf.Password};\" ";
            if (!string.IsNullOrEmpty(conf.ReportFilename))
            {
                arguments += $" -reportdirectory:\"{Path.GetDirectoryName(conf.ReportFilename)}\" ";
            }
            if (!string.IsNullOrEmpty(conf.ReportFilename))
            {
                arguments += $" -reportname:\"{Path.GetFileName(conf.ReportFilename)}\" ";
            }
            if (!string.IsNullOrEmpty(conf.Action))
            {
                arguments += $" -action:{conf.Action}";
            }
            if (!string.IsNullOrEmpty(conf.ExportDirectory))
            {
                arguments += $" -exportdirectory:\"{conf.ExportDirectory}\" ";
            }
            if (!string.IsNullOrEmpty(conf.OutputFormat))
            {
                arguments += $" -outputformat:\"{conf.OutputFormat}\" ";
            }
            if (conf.OpenGeneratedFile)
            {
                arguments += $" -opengeneratedfile ";
            }

            if (conf.Settings?.Length > 0)
            {
                arguments += $" -settings:\"";
                foreach (var item in conf.Settings)
                {
                    arguments += $"{item.Name}={item.Value};";
                }
                arguments += $"\"";
            }
            if (conf.Parameters?.Length > 0)
            {
                arguments += $" -reportparameters:\"";
                foreach (var item in conf.Parameters)
                {
                    arguments += $"{item.Name}={item.Value};";
                }
                arguments += $"\"";
            }
        }
Esempio n. 3
0
        private void cbOdbcDatasource_SelectedIndexChanged(object sender, EventArgs e)
        {
            string dbName = PrintServerHelper.GetDatabaseName(cbOdbcDatasource.Text);

            if (!string.IsNullOrEmpty(dbName))
            {
                tbDbName.Text = dbName;
            }

            string serverName = PrintServerHelper.GetDbServerName(cbOdbcDatasource.Text);

            if (!string.IsNullOrEmpty(serverName))
            {
                tbDbServer.Text = serverName;
            }
        }
Esempio n. 4
0
        private void btTestConnection_Click(object sender, EventArgs e)
        {
            string dsn      = cbOdbcDatasource.Text;
            string userid   = tbLogin.Text;
            string password = tbPassword.Text;
            bool   result   = PrintServerHelper.TestSqlConnection(dsn, userid, password);

            if (result)
            {
                MessageBox.Show($"Connection to {dsn} OK", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show($"Error while connecting to {dsn}", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
0
        private void InitControls()
        {
            cbActions.DataSource            = Enum.GetValues(typeof(ActionAsked));
            cbOutputFormat.DataSource       = Enum.GetValues(typeof(OutputFormatEnum));
            cbOdbcDatasource.DataSource     = PrintServerHelper.EnumDsn();
            dgSettings.ContextMenuStrip.Tag = dgSettings;
            reportParametersGridView.ContextMenuStrip.Tag = reportParametersGridView;
            tbInstallPath.Text = PrintServerHelper.GetPrintServerIntallPath();
            if (string.IsNullOrEmpty(cbPath.Text))
            {
                cbPath.Text = tbInstallPath.Text;
            }
            if (string.IsNullOrEmpty(cbExportDirectory.Text))
            {
                string tempDir = System.IO.Path.GetTempPath();
                if (tempDir.EndsWith("\\")) // to avoid issues while launching command line
                {
                    tempDir = tempDir.Substring(0, tempDir.Length - 1);
                }
                cbExportDirectory.Text = tempDir;
            }

            if (!string.IsNullOrEmpty(tbInstallPath.Text))
            {
                string editionServerConfigXml = Path.Combine(tbInstallPath.Text, "Config", "adxeditionserverconfig.xml");
                if (File.Exists(editionServerConfigXml))
                {
                    linkLabelEditionServerConfigXml.Tag = editionServerConfigXml;
                }

                string editionServerSolutionsXml = Path.Combine(tbInstallPath.Text, "Config", "adxeditionserversolutions.xml");
                if (File.Exists(editionServerSolutionsXml))
                {
                    linkLabelEditionServerSolutionsXml.Tag = editionServerSolutionsXml;
                }

                string adxOdbcConfigXml = Path.Combine(tbInstallPath.Text, "Config", "AdxOdbcConfig.xml");
                if (File.Exists(adxOdbcConfigXml))
                {
                    linkLabelOdbcConfigXml.Tag = adxOdbcConfigXml;
                }
            }
        }
Esempio n. 6
0
 private void btDetectInstall_Click(object sender, EventArgs e)
 {
     cbPath.Text = PrintServerHelper.GetPrintServerIntallPath();
 }
Esempio n. 7
0
 internal void OnDeserializedMethod(StreamingContext context)
 {
     Password = PrintServerHelper.DecodePasswordFromCryptedString(Password);
 }
Esempio n. 8
0
 internal void OnSerializingMethod(StreamingContext context)
 {
     Password = PrintServerHelper.EncodePasswordToCryptedtring(Password);
 }