Ejemplo n.º 1
0
        /// <summary>
        /// 本地服务器-保存集群当前配置
        /// </summary>
        private void button_Cluster_SaveIni_Click(object sender, RoutedEventArgs e)
        {
            int    indexLocal = listBox_LocalServer_ClusterFile.SelectedIndex;
            string nameLocal  = ComboBox_LocalServer_SavesFolder.SelectedItem?.ToString();

            if (tabItem_LocalServer.IsSelected)
            {
                if (indexLocal == -1)
                {
                    return;
                }

                ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Local[indexLocal].ClusterSetting);
                SavesManager.SetClusterInfo(nameLocal, m_ClusterInfo_Local[indexLocal]);
            }

            SftpClient client     = ServersManager.GetExistSftp(m_ServerConnect, UI.Location, UI.Username, UI.Password);
            int        indexCloud = listBox_CloudServer_ClusterFile.SelectedIndex;
            string     nameCloud  = ComboBox_CloudServer_SavesFolder.SelectedItem?.ToString();

            if (tabItem_CloudServer.IsSelected)
            {
                if (indexCloud == -1)
                {
                    return;
                }
                if (client == null)
                {
                    return;
                }

                ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Cloud[indexCloud].ClusterSetting);
                SavesManager.SetClusterInfo(nameCloud, m_ClusterInfo_Cloud[indexCloud], client);
            }
        }
Ejemplo n.º 2
0
        private void button_CloudServer_AddCluster_Click(object sender, RoutedEventArgs e)
        {
            SftpClient client = ServersManager.GetExistSftp(m_ServerConnect, UI.Location, UI.Username, UI.Password);

            if (client == null)
            {
                return;
            }

            string userPath = (UI.Username == "root") ? "/root" : $"/home/{UI.Username}";

            try { client.CreateDirectory($"{userPath}/.klei/{textBox_CloudServer_ClusterSaveList_AddPath.Text}"); }
            catch (SshException) { }
            catch (Exception) { throw; };

            UI.SaveFolders_Cloud.Add(textBox_CloudServer_ClusterSaveList_AddPath.Text);
        }
Ejemplo n.º 3
0
        private void button_CloudServer_StartCluster_Click(object sender, RoutedEventArgs e)
        {
            SftpClient client         = ServersManager.GetExistSftp(m_ServerConnect, UI.Location, UI.Username, UI.Password);
            string     nameCloud      = ComboBox_CloudServer_SavesFolder.SelectedItem?.ToString();
            int        indexCloud     = listBox_CloudServer_ClusterFile.SelectedIndex;
            int        indexCloudFile = listBox_CloudServer_ClusterFile.SelectedIndex;

            if (client == null)
            {
                return;
            }

            ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Cloud[indexCloud].ClusterSetting);
            SavesManager.SetClusterInfo(nameCloud, m_ClusterInfo_Cloud[indexCloud], client);

            string confdir = ComboBox_CloudServer_SavesFolder.SelectedItem.ToString();
            string cluster = listBox_CloudServer_ClusterFile.SelectedItem.ToString();
            string exefile = (dataGrid_CloudServer_ServersPath.SelectedItem as DataRowView)[2].ToString();
            string exepath = exefile.Replace("/dontstarve_dedicated_server_nullrenderer", "");

            List <string> screenList = ServersManager.GetExistScreens(UI.Location, UI.Username, UI.Password);

            foreach (var server in m_ClusterInfo_Cloud[indexCloudFile].ClusterServers)
            {
                string shard = server.Setting.Shard_Master ? "Master" : "Caves";

                string parameter = ServersManager.CreatParameter(confdir, cluster, shard);

                string command    = string.Empty;
                string screenName = cluster + "_" + server.Folder;

                if (screenList.Contains(screenName))
                {
                    command = $"screen -xr {screenName}";
                }
                else
                {
                    command += $"cd {exepath}\r";
                    command += $"screen -S {screenName} {"./dontstarve_dedicated_server_nullrenderer"} {parameter}";
                }

                CreatNewScreens(UI.Location, UI.Username, UI.Password, command);
            }
        }
Ejemplo n.º 4
0
        private void textBox_CloudServer_ClusterSaveList_AddPath_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (UI == null)
            {
                return;
            }
            button_CloudServer_AddCluster.IsEnabled = false;

            SftpClient client = ServersManager.GetExistSftp(m_ServerConnect, UI.Location, UI.Username, UI.Password);

            if (client == null)
            {
                return;
            }
            if (UI.SaveFolders_Cloud.Contains(textBox_CloudServer_ClusterSaveList_AddPath.Text))
            {
                return;
            }

            button_CloudServer_AddCluster.IsEnabled = true;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 远程服务器-存档文件夹选择变化
        /// </summary>
        private void ComboBox_CloudServer_SavesFolder_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SftpClient client = ServersManager.GetExistSftp(m_ServerConnect, UI.Location, UI.Username, UI.Password);

            if (client == null)
            {
                return;
            }

            //获取集群信息
            string saveFolder = ComboBox_CloudServer_SavesFolder.SelectedItem?.ToString();

            if (saveFolder == string.Empty)
            {
                return;
            }
            RefreshClusterData(saveFolder, "Cluster", ref listBox_CloudServer_ClusterFile, client);
            m_ClusterInfo_Cloud = SavesManager.GetClusterInfo(saveFolder, "Cluster", client);
            if (listBox_CloudServer_ClusterFile.Items.Count != 0)
            {
                listBox_CloudServer_ClusterFile.SelectedIndex = 0;
            }
        }