Beispiel #1
0
        private void BindEnvironment()
        {
            if (SelectedEnvironment != null)
            {
                txtName.Enabled       = !SelectedEnvironment.IsLocal;
                txtName.Text          = SelectedEnvironment.Name;
                txtRootFolder.Text    = SelectedEnvironment.RootFolder;
                txtPullFolder.Text    = SelectedEnvironment.PullFolder;
                radFileSystem.Checked = !SelectedEnvironment.WcfMode;
                radTcpIp.Checked      = SelectedEnvironment.WcfMode;

                var instances = SelectedEnvironment.EnvironmentConfigs.Where(ecf => ecf.IsService).ToList();

                SreEnvironmentConfig sreEnvConfig = instances.Where(ecf => ecf.InstanceNumber == 0).SingleOrDefault();
                if (sreEnvConfig != null)
                {
                    txtRemoteServer1.Text = sreEnvConfig.RemoteUrl;
                    try
                    {
                        EnvironmentServiceDispatcherUsingWcf.GetWcfClient(sreEnvConfig);
                        btnEnsureInstances.Visible = true;
                    }
                    catch
                    {
                        btnEnsureInstances.Visible = false;
                    }
                }
                else
                {
                    btnEnsureInstances.Visible = false;
                }
                lblInstance1.Visible     = sreEnvConfig != null ? true : false;
                txtRemoteServer1.Visible = lblInstance1.Visible;


                sreEnvConfig = instances.Where(ecf => ecf.InstanceNumber == 1).SingleOrDefault();
                if (sreEnvConfig != null)
                {
                    txtRemoteServer2.Text = sreEnvConfig.RemoteUrl;
                }
                lblInstance2.Visible     = sreEnvConfig != null ? true : false;
                txtRemoteServer2.Visible = lblInstance2.Visible;

                sreEnvConfig = instances.Where(ecf => ecf.InstanceNumber == 2).SingleOrDefault();
                if (sreEnvConfig != null)
                {
                    txtRemoteServer3.Text = sreEnvConfig.RemoteUrl;
                }
                lblInstance3.Visible     = sreEnvConfig != null ? true : false;
                txtRemoteServer3.Visible = lblInstance3.Visible;

                sreEnvConfig = instances.Where(ecf => ecf.InstanceNumber == 3).SingleOrDefault();
                if (sreEnvConfig != null)
                {
                    txtRemoteServer4.Text = sreEnvConfig.RemoteUrl;
                }
                lblInstance4.Visible     = sreEnvConfig != null ? true : false;
                txtRemoteServer4.Visible = lblInstance4.Visible;
            }
        }
Beispiel #2
0
 private void DeployArtifacts(SreEnvironment toEnv, SreEnvironmentConfig config)
 {
     try
     {
         if (Dispatcher.DeployArtifacts(config) == Constants.success)
         {
             Log("Artifacts deployed on " + toEnv.Name + "! The service was restarted.");
             DisableServiceStatus();
         }
         else
         {
             Log("Artifacts deployment failed!", true, Color.DarkRed);
         }
     }
     catch (System.ServiceModel.CommunicationException) { }
 }
Beispiel #3
0
        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;
        }
Beispiel #4
0
        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;
            }
        }