private void ClusterCommand(ClusterCommandType ccType, List <string> nodes) { // get all nodes address if (nodes.Count == 0) { return; } // gen.command for cluster nodes string clusterCmd = ""; switch (ccType) { case ClusterCommandType.Run: clusterCmd = cCmdStart + commandLine; break; case ClusterCommandType.Kill: clusterCmd = cCmdKill + selectedApplication; break; case ClusterCommandType.Status: clusterCmd = cCmdStatus; break; } // send cmd for each node AppLogger.Add("Command for client is : " + clusterCmd); foreach (string node in nodes) { SendDaemonCommand(node, clusterCmd); } }
//Implementation IDataErrorInfo methods for validation public virtual string this[string columnName] { get { string error = String.Empty; if (columnName == "id" || columnName == validationName) { if (!ValidationRules.IsName(id)) { error = "Input ID should contain only letters, numbers and _"; AppLogger.Add("ERROR! " + error); } } if (columnName == "address" || columnName == validationName) { if (!ValidationRules.IsAddressPort(address)) { error = "Input Address must be in format [email protected] or [email protected]:1234"; AppLogger.Add("ERROR! " + error); } } MainWindow.ConfigModifyIndicator(); return(error); } }
private void SendDaemonCommand(string nodeAddress, string cmd) { TcpClient nodeClient = new TcpClient(); try { nodeClient.Connect(nodeAddress, nodeListenerPort); NetworkStream networkStream = nodeClient.GetStream(); StreamWriter clientStreamWriter = new StreamWriter(networkStream); if (networkStream.CanWrite) { clientStreamWriter.Write(cmd); clientStreamWriter.Flush(); } else { AppLogger.Add("Can't write to client on node [" + nodeAddress + "]"); } nodeClient.Close(); } catch (Exception exception) { AppLogger.Add("Can't connect to node " + nodeAddress + ". EXCEPTION: " + exception.Message); } }
private void CreateZipLogs(string zipFilename, List <string> files) { if (files.Count == 0) { return; } string currentDir = Path.GetDirectoryName(zipFilename); string dirForZip = currentDir + temporaryZipDir; // create tmp-dir Directory.CreateDirectory(dirForZip); // copy to temporary folder for zip foreach (string file in files) { File.Copy(file, dirForZip + Path.GetFileName(file)); } try { // pack it ZipFile.CreateFromDirectory(dirForZip, zipFilename, CompressionLevel.Optimal, false); // remove tmp dir and all files after ZIP RemoveAllRecursively(dirForZip); Directory.Delete(dirForZip); } catch (Exception exception) { AppLogger.Add("CreateZipLogs. EXCEPTION: " + exception.Message); } }
public void DeleteConfig() { configs.Remove(selectedConfig); RegistrySaver.RemoveRegistryValue(RegistrySaver.configList, selectedConfig); AppLogger.Add("Configuration file [" + selectedConfig + "] deleted"); selectedConfig = configs.FirstOrDefault(); }
//Implementation IDataErrorInfo methods for validation public string this[string columnName] { get { string error = String.Empty; if (columnName == "id" || columnName == validationName) { if (!ValidationRules.IsName(id)) { error = "Cluster node ID should contain only letters, numbers and _"; AppLogger.Add("ERROR! " + error); } } if (columnName == "address" || columnName == validationName) { if (!ValidationRules.IsIp(address)) { error = "Cluster node addres should be IP address"; AppLogger.Add("ERROR! " + error); } } MainWindow.ConfigModifyIndicator(); return(error); } }
//Add Scene node private void addSceneNode_Click(object sender, RoutedEventArgs e) { SceneNode newItem = new SceneNode(); if (currentConfig.selectedSceneNodeView != null) { newItem.parent = currentConfig.selectedSceneNodeView.node; } SceneNodeView newViewItem = new SceneNodeView(newItem); newViewItem.isSelected = true; currentConfig.sceneNodes.Add(newItem); SceneNodeView parentNode = currentConfig.FindParentNode(newViewItem); if (parentNode == null) { currentConfig.sceneNodesView.Add(newViewItem); } else { parentNode.children.Add(newViewItem); parentNode.isExpanded = true; } AppLogger.Add("New scene node added"); AppLogger.Add("WARNING! Change default values"); sceneNodesTreeView.Items.Refresh(); sceneNodeIdTb.Focus(); }
public void DeleteApplication() { applications.Remove(selectedApplication); RegistrySaver.RemoveRegistryValue(RegistrySaver.appList, selectedApplication); AppLogger.Add("Application [" + selectedApplication + "] deleted"); selectedApplication = null; }
//Implementation IDataErrorInfo methods for validation public override string this[string columnName] { get { string error = base[columnName]; if (columnName == "locationX" || columnName == validationName) { if (!ValidationRules.IsFloat(locationX.ToString())) { error = "Location X should be a floating point number"; AppLogger.Add("ERROR! " + error); } } if (columnName == "locationY" || columnName == validationName) { if (!ValidationRules.IsFloat(locationY.ToString())) { error = "Location Y should be a floating point number"; AppLogger.Add("ERROR! " + error); } } if (columnName == "locationZ" || columnName == validationName) { if (!ValidationRules.IsFloat(locationZ.ToString())) { error = "Location Z should be a floating point number"; AppLogger.Add("ERROR! " + error); } } if (columnName == "rotationP" || columnName == validationName) { if (!ValidationRules.IsFloat(rotationP.ToString())) { error = "Pitch should be a floating point number"; AppLogger.Add("ERROR! " + error); } } if (columnName == "rotationY" || columnName == validationName) { if (!ValidationRules.IsFloat(rotationY.ToString())) { error = "Yaw should be a floating point number"; AppLogger.Add("ERROR! " + error); } } if (columnName == "rotationR" || columnName == validationName) { if (!ValidationRules.IsFloat(rotationR.ToString())) { error = "Roll should be a floating point number"; AppLogger.Add("ERROR! " + error); } } MainWindow.ConfigModifyIndicator(); return(error); } }
private void addNodeButton_Click(object sender, RoutedEventArgs e) { currentConfig.clusterNodes.Add(new ClusterNode()); currentConfig.selectedNode = currentConfig.clusterNodes.LastOrDefault(); nodesListBox.Items.Refresh(); nodeIdTb.Focus(); AppLogger.Add("New cluster node added"); AppLogger.Add("WARNING! Change default values"); }
public void DeleteNodes(List <ActiveNode> nodes) { foreach (ActiveNode node in nodes) { RegistrySaver.RemoveRegistryValue(RegistrySaver.nodeList, node.key); activeNodes.Remove(node); AppLogger.Add("Node [" + node.key + "] deleted"); } }
private void addViewportButton_Click(object sender, RoutedEventArgs e) { currentConfig.viewports.Add(new Viewport()); currentConfig.selectedViewport = currentConfig.viewports.LastOrDefault(); viewportsListBox.Items.Refresh(); viewportsCb.Items.Refresh(); viewportIdTb.Focus(); AppLogger.Add("New viewport added"); AppLogger.Add("WARNING! Change default values"); }
private void addScreenButton_Click(object sender, RoutedEventArgs e) { currentConfig.screens.Add(new Screen()); currentConfig.selectedScreen = currentConfig.screens.LastOrDefault(); screensListBox.Items.Refresh(); screensCb.Items.Refresh(); screenIdTb.Focus(); AppLogger.Add("New screen added"); AppLogger.Add("WARNING! Change default values"); }
//Reloading all config lists private void InitConfigLists() { applications = RegistrySaver.ReadStringsFromRegistry(RegistrySaver.appList); AppLogger.Add("Applications loaded successfully"); configs = RegistrySaver.ReadStringsFromRegistry(RegistrySaver.configList); SetSelectedConfig(); AppLogger.Add("Configs loaded successfully"); AppLogger.Add("List of Active nodes loaded successfully"); selectedCamera = cameras.SingleOrDefault(x => x == "camera_dynamic"); }
void CreateConfig() { RegistrySaver.RemoveAllRegistryValues(RegistrySaver.configName); currentConfig = new Config(); this.DataContext = currentConfig; //crutch. for refactoring currentConfig.selectedSceneNodeView = null; AppLogger.Add("New config inited"); SetTitle(); }
public override bool Validate() { bool isValid = ValidationRules.IsName(id) && ValidationRules.IsIp(address); if (!isValid) { AppLogger.Add("ERROR! Errors in Clustr Node [" + id + "]"); string a = this[validationName]; } return(isValid); }
public bool Validate() { bool isValid = ValidationRules.IsFloat(cameraLocationX.ToString()) && ValidationRules.IsFloat(cameraLocationY.ToString()) && ValidationRules.IsFloat(cameraLocationZ.ToString()) && ValidationRules.IsIntNullable(cameraTrackerCh) && ValidationRules.IsFloat(eyeDist) && ValidationRules.IsFloat(lagMaxTime) && (ValidationRules.IsInt(portCs) || (Convert.ToDouble(portCs) > 0)) && (ValidationRules.IsInt(portSs) || (Convert.ToDouble(portSs) > 0)); if (!isValid) { string a = this[validationName]; } //Validate items in lists isValid = isValid && ValidateList <Screen>(ref _screens); isValid = isValid && ValidateList <ClusterNode>(ref _clusterNodes); isValid = isValid && ValidateList <Viewport>(ref _viewports); isValid = isValid && ValidateList <SceneNode>(ref _sceneNodes); isValid = isValid && ValidateList <BaseInput>(ref _inputs); //Check id uniqueness for listitems if (screens.GroupBy(n => n.id).Any(c => c.Count() > 1)) { isValid = false; AppLogger.Add("ERROR! All Screen Id's should be unique! Rename duplicate Id's"); } if (clusterNodes.GroupBy(n => n.id).Any(c => c.Count() > 1)) { isValid = false; AppLogger.Add("ERROR! All Cluster node Id's should be unique! Rename duplicate Id's"); } if (viewports.GroupBy(n => n.id).Any(c => c.Count() > 1)) { isValid = false; AppLogger.Add("ERROR! All Viewport Id's should be unique! Rename duplicate Id's"); } if (sceneNodes.GroupBy(n => n.id).Any(c => c.Count() > 1)) { isValid = false; AppLogger.Add("ERROR! All Scene node Id's should be unique! Rename duplicate Id's"); } if (inputs.GroupBy(n => n.id).Any(c => c.Count() > 1)) { isValid = false; AppLogger.Add("ERROR! All Input Id's should be unique! Rename duplicate Id's"); } //check master node if (!clusterNodes.Exists(x => x.isMaster)) { isValid = false; AppLogger.Add("ERROR! Master Cluster Node is not selected! Check Master Node"); } return(isValid); }
private void CleanLogFolders(List <string> nodes) { foreach (string node in nodes) { string dirPath = GetLogFolder(node); if (dirPath != null) { RemoveAllRecursively(dirPath); AppLogger.Add("Removed all files in : " + dirPath); } } }
private void CleanLogFolders(List <ClusterNode> nodes) { foreach (ClusterNode node in nodes) { string dirPath = GetLogFolder(node.address); if (dirPath != null) { RemoveAllRecursively(dirPath); AppLogger.Add("Removed all files in : " + dirPath); } } }
public override bool Validate() { bool isValid = ValidationRules.IsName(id) && ValidationRules.IsInt(x.ToString()) && ValidationRules.IsInt(y.ToString()) && (ValidationRules.IsInt(width.ToString()) || Convert.ToInt32(width) > 0) && (ValidationRules.IsInt(height.ToString()) || Convert.ToInt32(height) > 0); if (!isValid) { AppLogger.Add("ERROR! Errors in Viewport [" + id + "]"); string a = this[validationName]; } return(isValid); }
private void deleteNodeButton_Click(object sender, RoutedEventArgs e) { if (currentConfig.selectedNode != null) { var id = currentConfig.selectedNode.id; int selectedIndex = currentConfig.clusterNodes.IndexOf(currentConfig.selectedNode); currentConfig.clusterNodes.RemoveAt(selectedIndex); currentConfig.selectedNode = currentConfig.clusterNodes.FirstOrDefault(); AppLogger.Add("Cluster node " + id + " deleted"); } nodesListBox.Items.Refresh(); }
//private void RewriteListToFile(string filePath, List<string> list) //{ // try // { // File.WriteAllLines(filePath, list); // } // catch(Exception exception) // { // AppLogger.Add("Can't renew file [" + RegistrySaver.nodeList + "]. EXCEPTION: " + exception.Message); // } //} public void AddApplication(string appPath) { if (!applications.Contains(appPath)) { applications.Add(appPath); RegistrySaver.AddRegistryValue(RegistrySaver.appList, appPath); AppLogger.Add("Application [" + appPath + "] added to list"); } else { AppLogger.Add("WARNING! Application [" + appPath + "] is already in the list"); } }
//Delete Scene Node private void deleteSceneNode_Click(object sender, RoutedEventArgs e) { if (sceneNodesTreeView.SelectedItem != null) { SceneNodeView item = (SceneNodeView)sceneNodesTreeView.SelectedItem; var id = item.node.id; currentConfig.DeleteSceneNode(item); currentConfig.selectedSceneNodeView = currentConfig.sceneNodesView.FirstOrDefault(); AppLogger.Add("Scene Node " + id + " deleted"); } sceneNodesTreeView.Items.Refresh(); parentWallsCb.Items.Refresh(); }
public override bool Validate() { bool isValid = ValidationRules.IsName(id) && ValidationRules.IsFloatNullable(locationX.ToString()) && ValidationRules.IsFloatNullable(locationY.ToString()) && ValidationRules.IsFloatNullable(locationZ.ToString()) && ValidationRules.IsFloatNullable(rotationP.ToString()) && ValidationRules.IsFloatNullable(rotationY.ToString()) && ValidationRules.IsFloatNullable(rotationR.ToString()); if (!isValid) { AppLogger.Add("ERROR! Errors in Scene Node [" + id + "]"); string a = this[validationName]; } return(isValid); }
public override bool Validate() { bool isValid = ValidationRules.IsName(id) && ValidationRules.IsFloat(locationX.ToString()) && ValidationRules.IsFloat(locationY.ToString()) && ValidationRules.IsFloat(locationZ.ToString()) && ValidationRules.IsFloat(rotationP.ToString()) && ValidationRules.IsFloat(rotationY.ToString()) && ValidationRules.IsFloat(rotationR.ToString()) && (ValidationRules.IsFloat(sizeX) || (Convert.ToDouble(sizeX) > 0)) && (ValidationRules.IsFloat(sizeY) || (Convert.ToDouble(sizeY) > 0)); if (!isValid) { AppLogger.Add("ERROR! Errors in Screen [" + id + "]"); string a = this[validationName]; } return(isValid); }
private void deleteScreenButton_Click(object sender, RoutedEventArgs e) { if (currentConfig.selectedScreen != null) { var id = currentConfig.selectedScreen.id; int selectedIndex = currentConfig.screens.IndexOf(currentConfig.selectedScreen); currentConfig.screens.RemoveAt(selectedIndex); currentConfig.selectedScreen = currentConfig.screens.FirstOrDefault(); AppLogger.Add("Screen " + id + " deleted"); } screensListBox.Items.Refresh(); screensCb.Items.Refresh(); }
public new bool Validate() { bool isValid = ValidationRules.IsName(id) && ValidationRules.IsAddress(address) && ValidationRules.IsFloat(locationX.ToString()) && ValidationRules.IsFloat(locationY.ToString()) && ValidationRules.IsFloat(locationZ.ToString()) && ValidationRules.IsFloat(rotationP.ToString()) && ValidationRules.IsFloat(rotationY.ToString()) && ValidationRules.IsFloat(rotationR.ToString()); if (!isValid) { AppLogger.Add("ERROR! Errors in Input [" + id + "]"); string a = this[validationName]; } return(isValid); }
public override bool Validate() { bool isValid = base.Validate() && ValidationRules.IsFloat(locationX.ToString()) && ValidationRules.IsFloat(locationY.ToString()) && ValidationRules.IsFloat(locationZ.ToString()) && ValidationRules.IsFloat(rotationP.ToString()) && ValidationRules.IsFloat(rotationY.ToString()) && ValidationRules.IsFloat(rotationR.ToString()); if (!isValid) { AppLogger.Add("ERROR! Errors in Tracker Input [" + id + "]"); string a = this[validationName]; } return(isValid); }
public void AddConfig(string configPath) { try { configs.Add(configPath); selectedConfig = configs.Find(x => x == configPath); RegistrySaver.AddRegistryValue(RegistrySaver.configList, configPath); ChangeConfigSelection(configPath); AppLogger.Add("Configuration file [" + configPath + "] added to list"); } catch (Exception) { AppLogger.Add("ERROR! Can not add configuration file [" + configPath + "] to list"); } }
private void deleteViewportButton_Click(object sender, RoutedEventArgs e) { if (currentConfig.selectedViewport != null) { var id = currentConfig.selectedViewport.id; int selectedIndex = currentConfig.viewports.IndexOf(currentConfig.selectedViewport); currentConfig.viewports.RemoveAt(selectedIndex); currentConfig.selectedViewport = currentConfig.viewports.FirstOrDefault(); AppLogger.Add("Viewport " + id + " deleted"); } viewportsListBox.Items.Refresh(); viewportsCb.Items.Refresh(); }