Пример #1
0
        private void btnSaveToServer_Click(object sender, EventArgs e)
        {
            //we show where data will be saved to, prompt if there's need to chaneg the connection
            var serverConfig = new frmServerConfig()
            {
                StartPosition = FormStartPosition.CenterParent
            };

            if (serverConfig.ShowDialog() == DialogResult.OK)
            {
                //we get valuesDataset
                var ds = valuesDataset;
                if (ds.Tables.Count == 0)
                {
                    MessageBox.Show("Nothing to export");
                    return;
                }
                var tempTableName = new RandomTableNameGenerator().Execute();
                valuesDataset.Tables[0].TableName = tempTableName;

                var dataImporter = new SaveTableToDbCommand()
                {
                    TargetDataset = valuesDataset
                };
                dataImporter.Execute();

                //we start the merge
                var dataMerge = new DataMergeCommand()
                {
                    TempTableName    = tempTableName,
                    DestinationTable = "FacilityData"
                };

                // we save,
                dataMerge.Execute();

                EnableSaveButtons(false);
                lblSelectedFile.Text = "No file selected";

                //and show the confirmatin that the file has been saved
                //perhaps show a tick
                //MessageBox.Show("Merge completed");


                //we clear the grid
                ShowGridDisplayPort(null);
                //dataGridView1.DataSource = "";
            }
            else
            {
                btnSaveToCsv.EnableControl(true);
                btnSaveToServer.EnableControl(false);
            }
        }
Пример #2
0
 private void mnuStartServer_Click(object sender, EventArgs e)
 {
     if (InteropEmu.IsServerRunning())
     {
         Task.Run(() => InteropEmu.StopServer());
     }
     else
     {
         using (frmServerConfig frm = new frmServerConfig()) {
             if (frm.ShowDialog(sender, this) == System.Windows.Forms.DialogResult.OK)
             {
                 InteropEmu.StartServer(ConfigManager.Config.ServerInfo.Port, ConfigManager.Config.ServerInfo.Password, ConfigManager.Config.Profile.PlayerName);
             }
         }
     }
 }
Пример #3
0
 public static void ToggleServer()
 {
     if (NetplayApi.IsServerRunning())
     {
         Task.Run(() => NetplayApi.StopServer());
     }
     else
     {
         using (frmServerConfig frm = new frmServerConfig()) {
             if (frm.ShowDialog(frmMain.Instance) == DialogResult.OK)
             {
                 NetplayConfig cfg = ConfigManager.Config.Netplay;
                 NetplayApi.StartServer(cfg.ServerPort, cfg.ServerPassword, cfg.PlayerName);
             }
         }
     }
 }