/// <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);
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        public string ExecuteCommand(EnvironmentServicePacket packet)
        {
            string response = string.Empty;

            if (packet.Command != Common.EnvironmentServiceCommands.Deploy)
            {
                return(new CommandExecutor(packet).Execute());
            }

            return(response);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
     }
 }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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));
        }
Exemplo n.º 16
0
 public string Ping(EnvironmentServicePacket packet)
 {
     return("success");
 }
Exemplo n.º 17
0
 public int GetNumberOfInstances(EnvironmentServicePacket packet)
 {
     return(SreEnvironment.GetNumberOfInstances());
 }
Exemplo n.º 18
0
 public string DeployArtifacts(EnvironmentServicePacket packet)
 {
     Trace.TraceInformation("srecmd: Deploying artifacts...");
     return(new CommandExecutor(packet).Execute());
 }
Exemplo n.º 19
0
 public CommandExecutor(EnvironmentServicePacket packet)
 {
     this.Packet = packet;
 }
Exemplo n.º 20
0
        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)));
        }