Пример #1
0
 private void lbEnvs_KeyUp(object sender, KeyEventArgs e)
 {
     if ((e.KeyCode == Keys.Delete) && (lbEnvs.SelectedIndex > -1))
     {
         EnvironmentServiceDispatcherFactory.SaveEnvironment(Envs);
     }
 }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (SelectedEnvironment == null)
            {
                return;
            }

            SelectedEnvironment.Name       = txtName.Text;
            SelectedEnvironment.RootFolder = txtRootFolder.Text;
            SelectedEnvironment.PullFolder = txtPullFolder.Text;
            SelectedEnvironment.WcfMode    = radTcpIp.Checked;

            SelectedEnvironment.SetRemoteUrl(0, txtRemoteServer1.Text);
            SelectedEnvironment.SetRemoteUrl(1, txtRemoteServer2.Text);
            SelectedEnvironment.SetRemoteUrl(2, txtRemoteServer3.Text);
            SelectedEnvironment.SetRemoteUrl(3, txtRemoteServer4.Text);
            SelectedEnvironment.SetEnvironmentConfigsPath();
            if (!ValidateData())
            {
                return;
            }

            EnvironmentServiceDispatcherFactory.SaveEnvironment(Envs);
            Bind(SelectedEnvironment);

            lbEnvs.Focus();
        }
Пример #3
0
        private void GetTargetEnvironmentDataSources()
        {
            if (((SelectedCommand == EnvironmentServiceCommands.ProcessFile) ||
                 (SelectedCommand == EnvironmentServiceCommands.StopSqlPuller) ||
                 (SelectedCommand == EnvironmentServiceCommands.StartSqlPuller)) &&
                (SelectedEnvironment.WcfMode))
            {
                lblDataSources.ForeColor = SystemColors.HotTrack;
                Log(string.Format("Retrieving data sources from '{0}' environment...", SelectedEnvironment.Name), false);

                List <IdpeDataSource> dataSources = EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).GetDataSources(SelectedEnvironmentConfig);
                if (SelectedCommand == EnvironmentServiceCommands.ProcessFile)
                {
                    dataSources = dataSources.Where(ds => (DataFeederTypes)ds.DataFeederType != DataFeederTypes.PullSql).ToList();
                    dataSources = dataSources.Where(ds => ds.IsSystem == false).ToList();
                    Log(string.Format("{0} retrieved.", dataSources.Count));
                }
                else if ((SelectedCommand == EnvironmentServiceCommands.StopSqlPuller) ||
                         (SelectedCommand == EnvironmentServiceCommands.StartSqlPuller))
                {
                    dataSources = dataSources.Where(ds => (DataFeederTypes)ds.DataFeederType == DataFeederTypes.PullSql).ToList();
                    Log(string.Format("{0} retrieved & filtered on sql pull type datasources.", dataSources.Count));
                }

                cbDataSources.DataSource    = null;
                cbDataSources.DataSource    = dataSources;
                cbDataSources.DisplayMember = "Name";
            }
            else
            {
                cbDataSources.DataSource = null;
                List <IdpeDataSource> dataSources = new Manager().GetDataSources().OrderBy(ds => ds.Name).ToList();
                dataSources.Where(ds => ds.DataFeederType == null).ToList().ForEach(ds1 => ds1.DataFeederType = 0);
                if ((SelectedCommand == EnvironmentServiceCommands.StopSqlPuller) ||
                    (SelectedCommand == EnvironmentServiceCommands.StartSqlPuller))
                {
                    dataSources = dataSources.Where(ds => (DataFeederTypes)ds.DataFeederType == DataFeederTypes.PullSql).ToList();
                }
                else
                {
                    dataSources = dataSources.Where(ds => (DataFeederTypes)ds.DataFeederType != DataFeederTypes.PullSql).ToList();
                }

                dataSources = dataSources.Where(ds => ds.IsSystem == false).ToList();
                cbDataSources.DataSource    = dataSources;
                cbDataSources.DisplayMember = "Name";
                lblDataSources.ForeColor    = SystemColors.ControlText;
                if ((((SelectedCommand == EnvironmentServiceCommands.ProcessFile) ||
                      (SelectedCommand == EnvironmentServiceCommands.StopSqlPuller) ||
                      (SelectedCommand == EnvironmentServiceCommands.StartSqlPuller))) &&
                    (radFileSystem.Checked))
                {
                    Log("As mode is filesystem, environment service will assume that target environment has same set of data sources!", true, Color.DarkBlue);
                }
            }
        }
Пример #4
0
 private void btnDeployRule_Click(object sender, EventArgs e)
 {
     this.Cursor = Cursors.WaitCursor;
     EnableAll(false);
     EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).DeployRule(SelectedEnvironmentConfig, SelectedRule);
     Log(string.Format("The rule '{0}' deployed on {1}",
                       SelectedRule.Name, SelectedEnvironment.Name));
     EnableAll(true);
     this.Cursor = Cursors.Default;
 }
Пример #5
0
 private void Bind()
 {
     Envs = EnvironmentServiceDispatcherFactory.GetEnvironments();
     cbCommands.Enabled   = Envs.Count == 0 ? false : true;
     cbEnvs.DataSource    = null;
     cbEnvs.DataSource    = Envs;
     cbEnvs.DisplayMember = "Name";
     BindCommands();
     BindDataSources();
     cbRules.DataSource    = null;
     cbRules.DataSource    = new Manager().GetRules().OrderBy(r => r.Name).ToList();
     cbRules.DisplayMember = "Name";
 }
Пример #6
0
        private void SaveCookie(bool clean = false)
        {
            foreach (SreEnvironment env in Envs)
            {
                if (env.Name == SelectedEnvironment.Name)
                {
                    if (clean == false)
                    {
                        if (string.IsNullOrEmpty(env.Param1))
                        {
                            env.Param1 = cbParam1.Text;
                        }
                        else
                        {
                            env.Param1 += "," + cbParam1.Text;
                        }

                        if (string.IsNullOrEmpty(env.Param2))
                        {
                            env.Param2 = cbParam2.Text;
                        }
                        else
                        {
                            env.Param2 += "," + cbParam2.Text;
                        }
                    }
                    else
                    {
                        env.Param1          = string.Empty;
                        cbParam1.DataSource = null;
                        cbParam1.Text       = "";

                        env.Param2          = string.Empty;
                        cbParam2.DataSource = null;
                        cbParam2.Text       = "";
                    }
                    //remove duplicates
                    List <string> items = new List <string>(env.Param1.Split(",".ToCharArray()));
                    items      = items.Distinct().ToList();
                    env.Param1 = string.Join(",", items);

                    //remove duplicates
                    items      = new List <string>(env.Param2.Split(",".ToCharArray()));
                    items      = items.Distinct().ToList();
                    env.Param2 = string.Join(",", items);

                    EnvironmentServiceDispatcherFactory.SaveEnvironment(Envs);
                    //Bind();
                }
            }
        }
Пример #7
0
        private void btnDeployDataSource_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            EnableAll(false);

            try
            {
                if (btnDeployDataSource.Text == "Deploy")
                {
                    if (chkIncludeSystemDS.Checked)
                    {
                        EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).DeployDataSource(SelectedEnvironmentConfig, (int)SelectedDataSource.SystemDataSourceId);
                        if (radFileSystem.Checked)
                        {
                            Log(string.Format("The system data source '{0}' being deployed on {1}. Waiting 30 seconds to finish deployment.",
                                              new Manager().GetDataSourceDetails((int)SelectedDataSource.SystemDataSourceId).Name, SelectedEnvironment.Name));
                            this.Cursor = Cursors.Default;
                            Application.DoEvents();
                            System.Threading.Thread.Sleep(30 * 1000);
                        }
                    }
                    this.Cursor = Cursors.WaitCursor;
                    Application.DoEvents();
                    EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).DeployDataSource(SelectedEnvironmentConfig, SelectedDataSource.Id);
                    Log(string.Format("The data source '{0}' is being deployed on {1}",
                                      SelectedDataSource.Name, SelectedEnvironment.Name));
                }
                else if (btnDeployDataSource.Text == "Stop")
                {
                    EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).StopSqlPuller(SelectedEnvironmentConfig, SelectedDataSource.Id);
                    Log(string.Format("The sql puller data source '{0}' stopped on {1}",
                                      SelectedDataSource.Name, SelectedEnvironment.Name));
                }
                else if (btnDeployDataSource.Text == "Start")
                {
                    EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).StartSqlPuller(SelectedEnvironmentConfig, SelectedDataSource.Id);
                    Log(string.Format("The sql puller data source '{0}' started on {1}",
                                      SelectedDataSource.Name, SelectedEnvironment.Name));
                }
            }
            catch (Exception ex)
            {
                Log(ex.Message, true, Color.DarkRed);
                EnableAll(true);
                this.Cursor = Cursors.Default;
            }
            EnableAll(true);
            this.Cursor = Cursors.Default;
        }
Пример #8
0
 private void Bind(SreEnvironment selected, SreEnvironments envs = null)
 {
     lbEnvs.DataSource    = null;
     lbEnvs.SelectionMode = SelectionMode.None;
     lbEnvs.DisplayMember = "Name";
     Envs = (envs == null) ? EnvironmentServiceDispatcherFactory.GetEnvironments() : envs;
     lbEnvs.DataSource    = Envs;
     lbEnvs.SelectionMode = SelectionMode.One;
     if ((selected == null) && lbEnvs.Items.Count > 0)
     {
         lbEnvs.SelectedIndex = 0;
     }
     else if (selected != null)
     {
         lbEnvs.SelectedItem = selected;
     }
 }
Пример #9
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;
        }
Пример #10
0
        private void btnAction_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                switch ((EnvironmentServiceCommands)cbCommands.SelectedItem)
                {
                case EnvironmentServiceCommands.Stop:
                    try
                    {
                        EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).StopService(SelectedEnvironmentConfig);
                    }
                    catch (System.ServiceModel.CommunicationException) { }
                    Log("Stop service command processed on " + SelectedEnvironment.Name + "! The service was stopped.");
                    DisableServiceStatus();
                    break;

                case EnvironmentServiceCommands.Restart:
                    try
                    {
                        EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).RestartService(SelectedEnvironmentConfig);
                    }
                    catch (System.ServiceModel.CommunicationException) { }
                    Log("Restart command processed on " + SelectedEnvironment.Name + "! The service was restarted.");
                    DisableServiceStatus();
                    break;

                case EnvironmentServiceCommands.DeploySdf:
                    try
                    {
                        EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).DeploySdf(SelectedEnvironmentConfig);
                    }
                    catch (System.ServiceModel.CommunicationException) { }
                    Log("SDF deployed on " + SelectedEnvironment.Name + "! The service was restarted.");
                    DisableServiceStatus();
                    break;

                case EnvironmentServiceCommands.DeployArtifacts:
                    if (!chkAllEnvs.Checked)
                    {
                        DeployArtifacts(SelectedEnvironment, SelectedEnvironmentConfig);
                    }
                    else
                    {
                        foreach (SreEnvironment env in Envs)
                        {
                            if (!env.IsLocal)
                            {
                                DeployArtifacts(env, env.EnvironmentConfigs[0]);
                            }
                        }
                    }
                    break;

                case EnvironmentServiceCommands.GetLastDeploymentLog:
                    delayedCommand = EnvironmentServiceCommands.GetLastDeploymentLog;
                    delayedCommandSelectedEnvironment = SelectedEnvironment;
                    delayedCommandEnvironmentConfig   = SelectedEnvironmentConfig;
                    timerDelayedCommand_Tick(sender, e);
                    break;

                case EnvironmentServiceCommands.SetServiceLogonUser:
                    if (string.IsNullOrEmpty(SetLogOnUserBatchFileName))
                    {
                        Log("Please click on 'Set User' to set user name and password", true, Color.DarkRed);
                    }
                    else
                    {
                        EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).SetServiceLogonUser(SelectedEnvironmentConfig, SetLogOnUserBatchFileName);
                        Log("Service logon user was set on " + SelectedEnvironment.Name + "! The service(s) will be restarted.");
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Environment Manager - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                EnableAll(true);
                this.Cursor = Cursors.Default;
            }
            this.Cursor = Cursors.Default;
        }
Пример #11
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            if (!ValidateExecuteParams())
            {
                this.Cursor = Cursors.Default;
                return;
            }

            EnableAll(false);
            if (btnExecute.Text == "Execute")
            {
                string result = EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).ExecuteCommand(SelectedEnvironmentConfig, cbParam1.Text);

                if (result == Constants.success)
                {
                    Log(string.Format("The command '{0}' executed on {1}",
                                      cbParam1.Text, SelectedEnvironment.Name));
                }
                else
                {
                    Log(string.Format("Failed to process file on : '{0}': '{1}'",
                                      SelectedEnvironment.Name, result));
                }
                SaveCookie();
            }
            else if (btnExecute.Text == "Process")
            {
                string result = EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).ProcessFile(SelectedEnvironmentConfig, SelectedDataSource.Id, cbParam2.Text);
                if (result == Constants.success)
                {
                    Log(string.Format("The file '{0}' is being processed on {1}",
                                      cbParam2.Text, SelectedEnvironment.Name));
                }
                else
                {
                    Log(string.Format("Failed to process file on : '{0}'. Fail Reason: '{1}'",
                                      SelectedEnvironment.Name, result));
                }
                SaveCookie();
            }
            else if (btnExecute.Text == "Artifacts")
            {
                DeploymentArtifacts deploymentArtifacts = new DeploymentArtifacts();
                deploymentArtifacts.ShowDialog();
                listOfdeploymentArtifacts = deploymentArtifacts.SelectedFiles;
            }
            else if (btnExecute.Text == "Set User")
            {
                WindowsServiceLogOnAsDialog logonUser = new WindowsServiceLogOnAsDialog(SelectedEnvironment.EnvironmentConfigsInstancesOnly.Count);
                if (logonUser.ShowDialog() == DialogResult.OK)
                {
                    SetLogOnUserBatchFileName = logonUser.BatchFileName != null?File.ReadAllText(logonUser.BatchFileName) : string.Empty;
                }
            }
            else if (btnExecute.Text == "Deploy")
            {
                DeployableKeysWindow keyWindow = new DeployableKeysWindow();
                if (keyWindow.ShowDialog() == DialogResult.OK)
                {
                    Log(string.Format("Deploying '{0}' keys on {1}...",
                                      keyWindow.SelectedKeys.Count, SelectedEnvironment.Name), false);
                    string result = EnvironmentServiceDispatcherFactory.GetInstance(radTcpIp.Checked).DeployKeys(SelectedEnvironmentConfig, keyWindow.SelectedKeys);

                    if (result == Constants.success)
                    {
                        Log("Deplyed.");
                    }
                    else
                    {
                        Log("Failed.");
                    }
                }
            }
            EnableAll(true);
            this.Cursor = Cursors.Default;
        }
Пример #12
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;
            }
        }
Пример #13
0
        public void runTestToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            if (m_dm_Property.propertyGrid.SelectedObject is SreDataSourceProperty)
            {
                SreDataSourceProperty dsProp = m_dm_Property.propertyGrid.SelectedObject as SreDataSourceProperty;
                if (string.IsNullOrEmpty(dsProp.TestFileName))
                {
                    MessageBox.Show("Cannot start test bed, please set a test file on property window!",
                                    "IDPE - Test Bed", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    {
                        this.Cursor = Cursors.Default;
                        return;
                    }
                }

                if (!File.Exists(dsProp.TestFileName))
                {
                    MessageBox.Show("Cannot start test bed, " + dsProp.TestFileName + "  does not exist!",
                                    "IDPE - Test Bed", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    {
                        this.Cursor = Cursors.Default;
                        return;
                    }
                }
                string traceFileName = string.Empty;
                bool   useWcf        = false; //todo
                if (useWcf)
                {
                    traceFileName = EnvironmentFiles.StartTestBed(true);
                    SreEnvironment local  = EnvironmentServiceDispatcherFactory.GetEnvironmentLocal();
                    string         result = EnvironmentServiceDispatcherFactory.GetInstance(true).ProcessFile(local.EnvironmentConfigsInstancesOnly[0],
                                                                                                              dsProp.DataSource.Id, dsProp.TestFileName);
                }
                else
                {
                    string pullFolder = DataSource.GetPullFolder(dsProp.DataSource.Id, dsProp.DataSourceKeys);
                    traceFileName = EnvironmentFiles.ProcessTestFile(pullFolder, dsProp.TestFileName);
                }

                if (!string.IsNullOrEmpty(traceFileName))
                {
                    System.Threading.Thread.Sleep(1000);//service needs time to start
                    if (Application.OpenForms.OfType <Log>().Count() == 1)
                    {
                        Application.OpenForms.OfType <Log>().First().Focus();
                    }
                    else
                    {
                        Log log = new Log("IDPE - Test Bed", traceFileName);
                        log.Show();
                    }
                }
                else
                {
                    MessageBox.Show("Cannot start test bed, please contact support or reinstall IDPE!",
                                    "IDPE - Test Bed", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
            this.Cursor = Cursors.Default;
        }