/// <summary> /// Restarts service /// </summary> /// <param name="targetConfig">Target environment</param> /// <param name="dataSourceId">Data source id</param> public override string StartSqlPuller(SreEnvironmentConfig targetConfig, int dataSourceId) { EnvironmentServicePacket packet = new EnvironmentServicePacket(EnvironmentServiceCommands.StartSqlPuller); packet.DataSourceId = dataSourceId; return(CreateAndCopyFile(targetConfig, packet) ? Constants.success : Constants.failed); }
/// <summary> /// Executes command or batch file /// </summary> /// <param name="targetConfig">Target environment</param> /// <param name="commandFileName">Command file name relative to target service path</param> public override string ExecuteCommand(SreEnvironmentConfig targetConfig, string commandFileName) { EnvironmentServicePacket packet = new EnvironmentServicePacket(EnvironmentServiceCommands.ExecuteDOSCommand); packet.Params.Add("Command", commandFileName); return(CreateAndCopyFile(targetConfig, packet) ? Constants.success : Constants.failed); }
public override DataTable GenerateFileContent(string fileName) { EnvironmentServicePacket packet = File.ReadAllText(fileName).Deserialize <EnvironmentServicePacket>(); if (System.IO.Path.GetExtension(fileName) == ".sred") { if (packet.Command == EnvironmentServiceCommands.Deploy) { new IdpeEnvironmentService().Deploy(packet); } else { new IdpeEnvironmentService().ExecuteCommand(packet); } return(ReturnTable()); } else if (Path.GetExtension(fileName) == ".sdf") { //FileTransferPacket request = new FileTransferPacket(); //request.FileName = fileName; new IdpeEnvironmentService().DeploySdf(packet); return(ReturnTable()); } else { return(ReturnTable(false)); } }
public override FileTransferPacket GetConfigFile(SreEnvironmentConfig toEnvironment, string configFileName) { EnvironmentServicePacket packet = new EnvironmentServicePacket(); packet.ConfigFileName = configFileName; return(GetWcfClient(toEnvironment).GetConfigFile(packet)); }
public List <IdpeDataSource> GetDataSources(EnvironmentServicePacket packet) { List <IdpeDataSource> dataSources = new Manager().GetDataSources().OrderBy(ds => ds.Name).ToList(); dataSources.Where(ds => ds.DataFeederType == null).ToList().ForEach(ds1 => ds1.DataFeederType = 0); return(dataSources); }
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 string ExecuteCommand(EnvironmentServicePacket packet) { string response = string.Empty; if (packet.Command != Common.EnvironmentServiceCommands.Deploy) { return(new CommandExecutor(packet).Execute()); } return(response); }
public string Deploy(EnvironmentServicePacket packet) { string response = string.Empty; if (packet.Command == Common.EnvironmentServiceCommands.Deploy) { packet.DataSourceBundle.IsImporting = true; Trace.TraceInformation("srecmd: Deploying"); packet.DataSourceBundle.Import(packet.FromEnvironment.IpAddress, packet.FromEnvironment.MachineName); } return(response); }
public string DeploySdf(EnvironmentServicePacket packet) { string response = "success"; string fileName = packet.FileTransferPacket.FileName; if (packet.FileTransferPacket.Content != null) { //save locally in temp location fileName = Path.Combine(Information.TempDirectoryIdpe, Path.GetFileName(packet.FileTransferPacket.FileName)); this.SaveFileStream(fileName, new MemoryStream(packet.FileTransferPacket.Content)); } DeploySdfInternal(fileName); return(response); }
public string SetServiceLogonUser(EnvironmentServicePacket packet) { Trace.TraceInformation("srecmd: Setting logon user credentials..."); string batchFile = Path.Combine(Information.TempDirectoryTempData, DateTime.Now.ToString("yyyyMMddHHmmss") + ".bat"); StreamWriter sw = new StreamWriter(batchFile); sw.Write(packet.Params["BatchFileContent"]); sw.Close(); Eyedia.Core.Windows.Utilities.WindowsUtility.ExecuteBatchFile(batchFile, true); Trace.TraceInformation("srecmd: Restarting the service(s)..."); Trace.Flush(); Eyedia.Core.Windows.Utilities.WindowsUtility.ExecuteBatchFile(EnvironmentFiles.RestartFileName, true); return(Constants.success); }
private bool CreateAndCopyFile(SreEnvironmentConfig targetConfig, EnvironmentServicePacket packet) { try { string sourceFileName = Path.Combine(Path.GetTempPath(), ShortGuid.NewGuid().Value + ".sred"); StreamWriter sw = new StreamWriter(sourceFileName); sw.Write(packet.Serialize()); sw.Close(); File.Copy(sourceFileName, GetEnvironmentTargetLocation(targetConfig), true); return(true); } catch (Exception ex) { CallCallBack(ex.Message, true); return(false); } }
public string SetConfigFile(EnvironmentServicePacket packet) { string tempFileName = Path.Combine(Information.TempDirectoryIdpe, Path.GetFileName(packet.FileTransferPacket.FileName)); if (packet.FileTransferPacket.Content != null) { this.SaveFileStream(tempFileName, new MemoryStream(packet.FileTransferPacket.Content)); } if (File.Exists(packet.FileTransferPacket.FileName)) { new FileUtility().Backup(packet.FileTransferPacket.FileName); } File.Copy(tempFileName, packet.FileTransferPacket.FileName, true); return(Constants.success); }
public string ProcessFile(EnvironmentServicePacket packet) { if (string.IsNullOrEmpty(new Manager().GetApplicationName(packet.DataSourceId))) { return("No data source defined with id " + packet.DataSourceId); } string response = "success"; string fileName = packet.FileTransferPacket.FileName; if (packet.FileTransferPacket.Content != null) { //save locally in temp location fileName = Path.Combine(Information.TempDirectoryIdpe, Path.GetFileName(packet.FileTransferPacket.FileName)); this.SaveFileStream(fileName, new MemoryStream(packet.FileTransferPacket.Content)); } ProcessFileInternal(fileName, packet.DataSourceId); return(response); }
private void DeploySdfInternal(string newFileNameToBeDeployed) { Trace.TraceInformation("srecmd: Deploying sdf " + Path.GetFileName(newFileNameToBeDeployed)); //backup string currentSdfFile = ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].GetSdfFileName(); new FileUtility().Backup(currentSdfFile, false); //delete old File.Delete(currentSdfFile); //copy keep same file name so that we dont have to update config files File.Copy(newFileNameToBeDeployed, currentSdfFile, true); //restart EnvironmentServicePacket packet = new EnvironmentServicePacket(); packet.Command = Common.EnvironmentServiceCommands.Restart; new CommandExecutor(packet).Execute(); }
public override List <IdpeDataSource> GetDataSources(SreEnvironmentConfig targetConfig) { EnvironmentServicePacket packet = new EnvironmentServicePacket(); return(new IdpeEnvironmentService().GetDataSources(packet)); }
public string Ping(EnvironmentServicePacket packet) { return("success"); }
public int GetNumberOfInstances(EnvironmentServicePacket packet) { return(SreEnvironment.GetNumberOfInstances()); }
public string DeployArtifacts(EnvironmentServicePacket packet) { Trace.TraceInformation("srecmd: Deploying artifacts..."); return(new CommandExecutor(packet).Execute()); }
public CommandExecutor(EnvironmentServicePacket packet) { this.Packet = packet; }
public int GetNumberOfInstances(string remoteUrl) { EnvironmentServicePacket packet = new EnvironmentServicePacket(); return(EnvironmentServiceDispatcherUsingWcf.GetWcfClient(remoteUrl).GetNumberOfInstances(packet)); }
public override List <IdpeDataSource> GetDataSources(SreEnvironmentConfig toEnvironment) { EnvironmentServicePacket packet = new EnvironmentServicePacket(); return(new List <IdpeDataSource>(GetWcfClient(toEnvironment).GetDataSources(packet))); }