public List <string> DeployArtifacts(FileTransferPacket packet) { if (packet.Content == null) { return(new List <string>()); } //store file into a temp folder string directoryName = Path.Combine(Information.TempDirectoryTempData, DateTime.Now.ToString("yyyyMMddHHmmss") + "_d"); Directory.CreateDirectory(directoryName); string fileName = Path.Combine(directoryName, DateTime.Now.ToString("yyyyMMddHHmmss") + ".zip"); SaveFileStream(fileName, new MemoryStream(packet.Content)); List <string> files = ZipFileHandler.UnZip(fileName, directoryName); File.Delete(fileName); //pass over to batch file string batchFile = ExtractBatchFile(directoryName); Trace.TraceInformation("The system is going to update. Waiting for stop signal..."); Trace.Flush(); Eyedia.Core.Windows.Utilities.WindowsUtility.ExecuteBatchFile(batchFile, true); //List<string> output = new List<string>(); //List<string> error = new List<string>(); //Eyedia.Core.Windows.Utilities.WindowsUtility.ExecuteDosCommand(batchFile, true, ref output, ref error); //Trace.TraceInformation("srecmd: Batch file '{0}' was exeucted, output was:{1},{2}Error:{3}{4}", // batchFile, output.ToLine(), Environment.NewLine, error.ToLine(), Environment.NewLine); return(files); }
private void timerDelayedCommand_Tick(object sender, EventArgs e) { if ((delayedCommandSelectedEnvironment == null) || (delayedCommandEnvironmentConfig == null)) { timerDelayedCommand.Enabled = false; return; } switch (delayedCommand) { case EnvironmentServiceCommands.GetLastDeploymentLog: FileTransferPacket packet = Dispatcher.GetLastDeploymentLog(delayedCommandEnvironmentConfig); if ((packet != null) && (packet.Content != null)) { string tempFile = Path.Combine(Information.TempDirectoryTempData, DateTime.Now.ToString("yyyyMMddHHmmss") + ".log"); Log("Last artifacts from " + delayedCommandSelectedEnvironment.Name + ":"); SaveFileStream(tempFile, new MemoryStream(packet.Content)); Log(File.ReadAllLines(tempFile), true, Color.DarkBlue); } else { Log("Could not find last artifacts deployment log, either nothing was deployed recently on " + delayedCommandSelectedEnvironment.Name + ", or the log file has been deleted." , true, Color.DarkRed); } break; } }
public override FileTransferPacket GetConfigFile(SreEnvironmentConfig targetConfig, string configFileName) { FileTransferPacket packet = new FileTransferPacket(); packet.FileName = configFileName + ".config"; packet.Content = File.ReadAllBytes(configFileName + ".config"); return(packet); }
private FileTransferPacket CreatePacket(string zipFile) { FileTransferPacket packet = new FileTransferPacket(); packet.FileName = zipFile; packet.Content = File.ReadAllBytes(zipFile); return(packet); }
public override FileTransferPacket GetLastDeploymentLog(SreEnvironmentConfig fromEnvironment) { FileTransferPacket packet = new FileTransferPacket(); packet.FileName = Path.Combine(fromEnvironment.Environment.RootFolder, "sreupdate.log"); if (File.Exists(packet.FileName)) { packet.Content = File.ReadAllBytes(packet.FileName); } return(packet); }
public FileTransferPacket GetConfigFile(EnvironmentServicePacket packet) { FileTransferPacket response = new FileTransferPacket(); if (File.Exists(packet.ConfigFileName + ".config")) { response.FileName = packet.ConfigFileName; response.Content = File.ReadAllBytes(packet.ConfigFileName + ".config"); } return(response); }
public FileTransferPacket GetLastDeploymentLog() { FileTransferPacket response = new FileTransferPacket(); string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sreupdate.log"); if (File.Exists(fileName)) { response.FileName = fileName; response.Content = File.ReadAllBytes(fileName); } return(response); }
private void btnSaveConfig_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; if (propGrid.SelectedObject is IdpeConfigurationSectionEditable) { ((IdpeConfigurationSectionEditable)propGrid.SelectedObject). Save(ConfigurationManager.OpenExeConfiguration(GetExeNameFromConfigName(currentConfigFileName))); } else { ((EyediaCoreConfigurationSectionEditable)propGrid.SelectedObject). Save(ConfigurationManager.OpenExeConfiguration(GetExeNameFromConfigName(currentConfigFileName))); } Log(Path.GetFileName(SelectedEnvironmentConfig.ConfigFileName) + ".config - Saved!", true, Color.DarkGreen); if (currentConfigFileIsRemote) { Log("Sending updated config file to " + SelectedEnvironment.Name + "...", false); FileTransferPacket packet = new FileTransferPacket(); //this should be remote save path packet.FileName = Path.Combine(SelectedEnvironment.RootFolder, Path.GetFileName(currentConfigFileName)); packet.Content = File.ReadAllBytes(currentConfigFileName); SreEnvironmentConfig selConfig = (SreEnvironmentConfig)cbEnvConfigs.SelectedItem; EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).SetConfigFile(SelectedEnvironmentConfig, packet); Log("Sent."); if (!currentConfigFileName.Contains("idped.exe")) { Log("Sending restart signal to " + SelectedEnvironment.Name + "...", false); try { EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).RestartService(selConfig); } catch (System.ServiceModel.CommunicationException commEx) { //we can eat this exception as the server must have been restarted } Log("Sent."); } } this.Cursor = Cursors.Default; }
public abstract string SetConfigFile(SreEnvironmentConfig toEnvironment, FileTransferPacket fileTransferPacket);
private void cbEnvConfigs_SelectedIndexChanged(object sender, EventArgs e) { if (cbEnvConfigs.SelectedIndex > -1) { SreEnvironmentConfig selConfig = (SreEnvironmentConfig)cbEnvConfigs.SelectedItem; this.Cursor = Cursors.WaitCursor; //string configFileName = string.Empty; if (SelectedEnvironment.IsLocal) { currentConfigFileName = selConfig.ConfigFileName; lblConfigFileName.Text = selConfig.ConfigFileName; currentConfigFileIsRemote = false; } else { Log("Retrieving remote config file from " + SelectedEnvironment.Name + "...", false); FileTransferPacket packet = null; try { packet = EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).GetConfigFile(SelectedEnvironmentConfig, selConfig.ConfigFileName); } catch (Exception ex) { Log("Failed. " + ex.Message); } if ((packet == null) || (packet.Content == null)) { Log(string.Format("The config file '{0}' was not found in the server", selConfig.ConfigFileName)); this.Cursor = Cursors.Default; return; } else { Log("Retrieved."); //make sure the exes are exist, else config exe won't open if (!File.Exists(Path.Combine(Information.TempDirectoryIdpe, "idpe.exe"))) { File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "idpe.exe"), Path.Combine(Information.TempDirectoryIdpe, "idpe.exe"), true); File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "idpe.exe"), Path.Combine(Information.TempDirectoryIdpe, "idpe1.exe"), true); File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "idpe.exe"), Path.Combine(Information.TempDirectoryIdpe, "idpe2.exe"), true); File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "idpe.exe"), Path.Combine(Information.TempDirectoryIdpe, "idpe3.exe"), true); } if (!File.Exists(Path.Combine(Information.TempDirectoryIdpe, "idped.exe"))) { File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "idped.exe"), Path.Combine(Information.TempDirectoryIdpe, "idped.exe"), true); } lblConfigFileName.Text = SelectedEnvironment.Name + ":" + selConfig.ConfigFileName; currentConfigFileName = Path.Combine(Information.TempDirectoryIdpe, Path.GetFileName(packet.FileName)); this.SaveFileStream(currentConfigFileName, new MemoryStream(packet.Content)); currentConfigFileIsRemote = true; } } if ((!File.Exists(selConfig.ConfigFileName)) || (!File.Exists(selConfig.ConfigFileName))) { Log(Path.GetFileName(selConfig.ConfigFileName) + ".config does not exists!", true, Color.DarkRed); } else { if (!selConfig.IsService) { propGrid.SelectedObject = new EyediaCoreConfigurationSectionEditable(ConfigurationManager.OpenExeConfiguration(GetExeNameFromConfigName(currentConfigFileName))); } else { propGrid.SelectedObject = new IdpeConfigurationSectionEditable(ConfigurationManager.OpenExeConfiguration(GetExeNameFromConfigName(currentConfigFileName))); } } this.Cursor = Cursors.Default; } }
public override string SetConfigFile(SreEnvironmentConfig targetConfig, FileTransferPacket fileTransferPacket) { Packet.FileTransferPacket = fileTransferPacket; return(new IdpeEnvironmentService().SetConfigFile(Packet)); }
public override string SetConfigFile(SreEnvironmentConfig toEnvironment, FileTransferPacket fileTransferPacket) { Packet.FileTransferPacket = fileTransferPacket; return(GetWcfClient(toEnvironment).SetConfigFile(Packet)); }