예제 #1
0
        private void OnFileTcpButtonChecked(object sender, RoutedEventArgs e)
        {
            try
            {
                if (SecUtil.ProtCheck() != 0)
                {
                    return;
                }

                if (_inTcp)
                {
                    SaveFile();
                    ManageButtons(true);
                    return;
                }
                else
                {
                    ManageButtons(false);
                }

                var dlg = new SettingsDialog
                {
                    Owner   = this,
                    FtpHost = Properties.Settings.Default.FtpHost,
                    Title   = "Realtime Server"
                };

                if (dlg.ShowDialog() != true)
                {
                    return;
                }

                var host = dlg.FtpHost.Trim();
                Properties.Settings.Default.FtpHost = host;
                Properties.Settings.Default.Save();


                var filename = FileUtil.GetTcpFile();
                var service  = new DataService
                {
                    ServiceType = DataServiceType.Tcp,

                    DataFile   = filename,
                    HeaderFile = FileUtil.GetConfigFile(filename),
                    ResultFile = FileUtil.GetResultFile(),

                    TcpHost             = host,
                    TcpPort             = int.Parse(ConfigurationManager.AppSettings.Get("TcpPort")),
                    TcpHeatbeatMessage  = ConfigurationManager.AppSettings.Get("TcpHeatbeatMessage"),
                    TcpHeatbeatInterval = int.Parse(ConfigurationManager.AppSettings.Get("TcpHeatbeatInterval"))
                };

                ProcessFile(service);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
                ManageButtons(true);
            }
        }
예제 #2
0
        private void OnFileOpenButtonChecked(object sender, RoutedEventArgs e)
        {
            if (SecUtil.ProtCheck() != 0)
            {
                return;
            }

            SaveFile();

            var filename = FileUtil.OpenFile();

            if (string.IsNullOrEmpty(filename))
            {
                return;
            }


            var service = new DataService
            {
                ServiceType = DataServiceType.File,
                DataFile    = filename,

                HeaderFile = FileUtil.GetConfigFile(filename),
                ResultFile = FileUtil.GetResultFile(),
            };

            ProcessFile(service);
        }
예제 #3
0
        private void OnFileFtpButtonChecked(object sender, RoutedEventArgs e)
        {
            try
            {
                if (SecUtil.ProtCheck() != 0)
                {
                    return;
                }

                SaveFile();

                var dlg = new SettingsDialog
                {
                    Owner   = this,
                    FtpHost = Properties.Settings.Default.FtpHost,
                    Title   = "FTP Server"
                };

                if (dlg.ShowDialog() != true)
                {
                    return;
                }

                var host = dlg.FtpHost.Trim();
                Properties.Settings.Default.FtpHost = host;
                Properties.Settings.Default.Save();

                var filename = FileUtil.GetFtpFile();
                var service  = new DataService
                {
                    ServiceType = DataServiceType.Ftp,

                    DataFile   = filename,
                    HeaderFile = FileUtil.GetConfigFile(filename),
                    ResultFile = FileUtil.GetResultFile(),


                    FtpUrl = FileUtil.GetFtpUrl(host),

                    FtpUser       = ConfigurationManager.AppSettings.Get("FtpUser"),
                    FtpPassword   = ConfigurationManager.AppSettings.Get("FtpPassword"),
                    FtpUsePassive = bool.Parse(ConfigurationManager.AppSettings.Get("FtpUsePassive")),
                    FtpTimeout    = int.Parse(ConfigurationManager.AppSettings.Get("FtpTimeout"))
                };

                ProcessFile(service);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
            }
        }