private void btnBack_Click(object sender, EventArgs e)
        {
            New_Scenario_Page new_scenario_page = new New_Scenario_Page();

            this.Hide();
            new_scenario_page.Show();
        }
示例#2
0
        private void btnNewScenario_Click(object sender, EventArgs e)
        {
            GlobalVariables.Is_Edit = false;
            New_Scenario_Page new_scenario = new New_Scenario_Page();

            this.Hide();
            new_scenario.Show();
        }
示例#3
0
        private void scenarios_datagrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 4)
            {
                try
                {
                    using (VivosEntities db = new VivosEntities())
                    {
                        GlobalVariables.Asset_Start_ID = Guid.Parse(scenarios_datagrid.Rows[e.RowIndex].Cells[1].Value.ToString());
                        Asset exported_asset = (from x in db.Assets where x.Id == GlobalVariables.Asset_Start_ID select x).SingleOrDefault();
                        List <AssetCommand> exported_asset_commands  = (from x in db.AssetCommands where x.AssetId == GlobalVariables.Asset_Start_ID orderby x.Step select x).ToList();
                        AssetThumbnail      exported_asset_thumbnail = (from x in db.AssetThumbnails where x.AssetId == GlobalVariables.Asset_Start_ID select x).SingleOrDefault();
                        SaveFileDialog      file1 = new SaveFileDialog();
                        file1.InitialDirectory = ".\\desktop";
                        file1.Filter           = "Text|*.txt";
                        file1.FileName         = exported_asset.Name;
                        if (file1.ShowDialog() == DialogResult.OK)
                        {
                            data = data + resourceManager.GetString("lblName", GlobalVariables.uiLanguage) + "," + exported_asset.Name + "," + exported_asset.EnName + "," + exported_asset.ArabicName + Environment.NewLine;
                            data = data + resourceManager.GetString("lblDescription", GlobalVariables.uiLanguage) + "," + exported_asset.Description + "," + exported_asset.EnDescription + "," + exported_asset.ArabicDescription + Environment.NewLine;
                            data = data + resourceManager.GetString("lblScenarioPath", GlobalVariables.uiLanguage) + "," + exported_asset.Url + Environment.NewLine;
                            data = data + resourceManager.GetString("lblScenarioExe", GlobalVariables.uiLanguage) + "," + exported_asset.Exe + Environment.NewLine;
                            data = data + resourceManager.GetString("lblAvailable", GlobalVariables.uiLanguage) + "," + exported_asset.Available + Environment.NewLine;

                            for (int i = 0; i < exported_asset_commands.Count; i++)
                            {
                                data = data + resourceManager.GetString("lblCommands", GlobalVariables.uiLanguage) + i + "," + exported_asset_commands[i].Description + "," + exported_asset_commands[i].EnDescription + "," + exported_asset_commands[i].ArabicDescription + "," + exported_asset_commands[i].CommandText + "," + exported_asset_commands[i].Step + Environment.NewLine;
                            }

                            /*byte[] thumbnail= exported_asset_thumbnail.Thumbnail;
                             * data = data + resourceManager.GetString("headerThumbnail", GlobalVariables.uiLanguage) + ",";
                             * for (int i = 0; i < thumbnail.Length; i++)
                             * {
                             *  data = data + thumbnail[i] + "-";
                             * }
                             * data = data + Environment.NewLine;*/
                            /* using (MemoryStream memoryStream = new MemoryStream(exported_asset_thumbnail.Thumbnail))
                             * {
                             *   Bitmap bmp = new Bitmap(memoryStream);
                             *   data = data + resourceManager.GetString("headerThumbnail", GlobalVariables.uiLanguage) + "," + bmp + Environment.NewLine;
                             * }*/
                            data = data.Replace("\r\n,", ",");
                            data = data.Replace("\r\n\r\n", "\r\n");
                            System.IO.File.WriteAllText(file1.FileName, data);
                            MessageBox.Show(resourceManager.GetString("msgScenarioExported", GlobalVariables.uiLanguage));
                            data = null;
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            else if (e.ColumnIndex == 5)
            {
                try
                {
                    DialogResult delete = new DialogResult();
                    delete = MessageBox.Show(resourceManager.GetString("msgIsScenarioDeleted", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (delete == DialogResult.Yes)
                    {
                        GlobalVariables.Asset_Start_ID = Guid.Parse(scenarios_datagrid.Rows[e.RowIndex].Cells[1].Value.ToString());
                        using (VivosEntities db = new VivosEntities())
                        {
                            List <AssetCommand> AssetCommandList = (from x in db.AssetCommands where x.AssetId == GlobalVariables.Asset_Start_ID select x).ToList();
                            AssetCommand[]      asset_command    = new AssetCommand[AssetCommandList.Count];

                            for (int i = 0; i < asset_command.Length; i++)
                            {
                                asset_command[i] = AssetCommandList[i];
                                db.AssetCommands.Remove(asset_command[i]);
                            }

                            Asset asset = db.Assets.First(x => x.Id == GlobalVariables.Asset_Start_ID);
                            try
                            {
                                AssetThumbnail asset_thumbnail = db.AssetThumbnails.First(x => x.AssetId == GlobalVariables.Asset_Start_ID);
                                db.AssetThumbnails.Remove(asset_thumbnail);
                            }
                            catch (Exception)
                            {
                            }
                            db.Assets.Remove(asset);
                            db.SaveChanges();
                            GlobalVariables.NewSessions_Search_Flag = 0;
                            string key = null;
                            fill_datagrid(key);
                            DialogResult information = new DialogResult();
                            information = MessageBox.Show(resourceManager.GetString("msgScenarioDeleted", GlobalVariables.uiLanguage), resourceManager.GetString("msgInformation", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            else if (e.ColumnIndex == 6)
            {
                try
                {
                    GlobalVariables.Asset_Start_ID = Guid.Parse(scenarios_datagrid.Rows[e.RowIndex].Cells[1].Value.ToString());
                    GlobalVariables.Is_Edit        = true;
                    New_Scenario_Page new_scenario = new New_Scenario_Page();
                    this.Hide();
                    new_scenario.Show();
                }
                catch (Exception)
                {
                }
            }
        }