private void commands_datagrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 2)
            {
                /*try
                 * {*/
                DialogResult delete = new DialogResult();
                delete = MessageBox.Show(resourceManager.GetString("msgIscommandDeleted", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (delete == DialogResult.Yes)
                {
                    GlobalVariables.Command_ID = Guid.Parse(commands_datagrid.Rows[e.RowIndex].Cells[0].Value.ToString());
                    using (VivosEntities db = new VivosEntities())
                    {
                        AssetCommand command = db.AssetCommands.First(x => x.Id == GlobalVariables.Command_ID);
                        db.AssetCommands.Remove(command);
                        db.SaveChanges();
                        //string key = null;
                        fill_datagrid();
                        DialogResult information = new DialogResult();
                        information = MessageBox.Show(resourceManager.GetString("msgCommandDeleted", GlobalVariables.uiLanguage), resourceManager.GetString("msgInformation", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                //}

                /*catch (Exception)
                 * {
                 *
                 *
                 * }*/
            }
        }
예제 #2
0
        public void add_scenarios(string file, Image image)
        {
            try
            {
                using (VivosEntities db = new VivosEntities())
                {
                    string   asset_imformation1 = null;
                    string[] asset_imformation  = null;
                    asset_imformation1 = file;
                    asset_imformation  = asset_imformation1.Split(new char[] { '\n' });

                    for (int i = 0; i < asset_imformation.Length - 1; i++)
                    {
                        asset_imformation[i] = asset_imformation[i].Remove(asset_imformation[i].Length - 1);
                    }

                    List <Asset>          AssetList          = (from x in db.Assets select x).ToList();
                    List <AssetThumbnail> AssetThumbnailList = (from x in db.AssetThumbnails select x).ToList();
                    List <AssetCommand>   AssetCommandList   = (from x in db.AssetCommands select x).ToList();

                    int command_count = 0;
                    for (int i = 0; i < asset_imformation.Length; i++)
                    {
                        var splitted = asset_imformation[i].Split(new char[] { ',' });
                        if (splitted[0].Contains("Komutlar") == true)
                        {
                            command_count++;
                        }
                    }
                    Asset          new_asset           = new Asset();
                    AssetThumbnail new_asset_thumbnail = new AssetThumbnail();
                    AssetCommand[] new_asset_command   = new AssetCommand[command_count];

                    for (int i = 0; i < new_asset_command.Length; i++)
                    {
                        new_asset_command[i] = new AssetCommand();
                    }

                    Guid new_asset_id = Guid.NewGuid();
                    new_asset.Id        = new_asset_id;
                    new_asset.GroupId   = new Guid("00000000-0000-0000-0000-000000000000");
                    new_asset.EntryDate = DateTime.Now;
                    int command_add_number = 0;
                    for (int i = 0; i < asset_imformation.Length; i++)
                    {
                        var splitted = asset_imformation[i].Split(new char[] { ',' });

                        if (splitted[0].Contains("Ad") == true)
                        {
                            new_asset.Name       = splitted[1];
                            new_asset.EnName     = splitted[2];
                            new_asset.ArabicName = splitted[3];
                        }
                        else if (splitted[0].Contains("Açıklama") == true)
                        {
                            new_asset.Description       = splitted[1];
                            new_asset.EnDescription     = splitted[2];
                            new_asset.ArabicDescription = splitted[3];
                        }
                        else if (splitted[0].Contains("Aktif") == true)
                        {
                            if (splitted[1].Contains("True") == true)
                            {
                                new_asset.Available = true;
                            }
                            else
                            {
                                new_asset.Available = false;
                            }
                        }
                        else if (splitted[0].Contains("Senaryo Dizini") == true)
                        {
                            new_asset.Url = splitted[1];
                        }
                        else if (splitted[0].Contains("Senaryo Exe") == true)
                        {
                            new_asset.Exe = splitted[1];
                        }
                        else if (splitted[0].Contains("Komutlar") == true)
                        {
                            Guid new_asset_command_id = Guid.NewGuid();
                            new_asset_command[command_add_number].Id                = new_asset_command_id;
                            new_asset_command[command_add_number].AssetId           = new_asset_id;
                            new_asset_command[command_add_number].Description       = splitted[1];
                            new_asset_command[command_add_number].EnDescription     = splitted[2];
                            new_asset_command[command_add_number].ArabicDescription = splitted[3];
                            new_asset_command[command_add_number].CommandText       = splitted[4];
                            try
                            {
                                new_asset_command[command_add_number].Step = Convert.ToByte(splitted[5]);
                            }
                            catch (Exception)
                            {
                                new_asset_command[command_add_number].Step = Convert.ToByte(0);
                            }
                            db.AssetCommands.Add(new_asset_command[command_add_number]);
                            command_add_number++;
                        }
                    }
                    try
                    {
                        Image          img       = image;
                        Bitmap         bmp       = new Bitmap(img);
                        ImageConverter converter = new ImageConverter();
                        new_asset_thumbnail.Thumbnail = (byte[])converter.ConvertTo(img, typeof(byte[]));
                        new_asset_thumbnail.AssetId   = new_asset_id;
                    }
                    catch (Exception)
                    {
                    }
                    db.Assets.Add(new_asset);
                    db.AssetThumbnails.Add(new_asset_thumbnail);
                    db.SaveChanges();
                }
            }
            catch (Exception)
            {
            }
        }
예제 #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)
                {
                }
            }
        }
예제 #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (GlobalVariables.Is_Edit == false)
            {
                using (VivosEntities db = new VivosEntities())
                {
                    List <Asset>          AssetList          = (from x in db.Assets select x).ToList();
                    List <AssetThumbnail> AssetThumbnailList = (from x in db.AssetThumbnails select x).ToList();
                    List <AssetCommand>   AssetCommandList   = (from x in db.AssetCommands select x).ToList();

                    Asset          new_asset           = new Asset();
                    AssetThumbnail new_asset_thumbnail = new AssetThumbnail();
                    AssetCommand[] new_asset_command   = new AssetCommand[commandsLayout.RowCount - 1];

                    for (int i = 0; i < new_asset_command.Length; i++)
                    {
                        new_asset_command[i] = new AssetCommand();
                    }

                    Guid new_asset_id = Guid.NewGuid();

                    new_asset.Id                = new_asset_id;
                    new_asset.GroupId           = new Guid("00000000-0000-0000-0000-000000000000");
                    new_asset.Name              = txtTurkishName.Text;
                    new_asset.EnName            = txtEnglishName.Text;
                    new_asset.ArabicName        = txtArabicName.Text;
                    new_asset.Description       = txtTurkishDescription.Text;
                    new_asset.EnDescription     = txtEnglishDescription.Text;
                    new_asset.ArabicDescription = txtArabicDescription.Text;
                    if (cbAvaliable.Checked == true)
                    {
                        new_asset.Available = true;
                    }
                    else
                    {
                        new_asset.Available = false;
                    }


                    new_asset.Url       = txtScenarioPath.Text;
                    new_asset.Exe       = txtScenarioExe.Text;
                    new_asset.EntryDate = DateTime.Now;

                    try
                    {
                        if (pictureBox2.Image != null)
                        {
                            Image          img       = pictureBox2.Image;
                            Bitmap         bmp       = new Bitmap(img);
                            ImageConverter converter = new ImageConverter();
                            new_asset_thumbnail.Thumbnail = (byte[])converter.ConvertTo(img, typeof(byte[]));
                            new_asset_thumbnail.AssetId   = new_asset_id;
                        }
                        else
                        {
                            new_asset_thumbnail.Thumbnail = null;
                            new_asset_thumbnail.AssetId   = new_asset_id;
                        }
                    }
                    catch (Exception)
                    {
                    }
                    for (int i = 0; i < commandsLayout.RowCount - 2; i++)
                    {
                        Guid new_asset_command_id = Guid.NewGuid();
                        new_asset_command[i].Id                = new_asset_command_id;
                        new_asset_command[i].AssetId           = new_asset_id;
                        new_asset_command[i].CommandText       = txtCommand[i].Text;
                        new_asset_command[i].Description       = txtTurkishExplanation[i].Text;
                        new_asset_command[i].EnDescription     = txtEnglishExplanation[i].Text;
                        new_asset_command[i].ArabicDescription = txtArabicExplanation[i].Text;
                        try
                        {
                            new_asset_command[i].Step = Convert.ToByte(txtStep[i].Text);
                        }
                        catch (Exception)
                        {
                            new_asset_command[i].Step = Convert.ToByte(0);
                        }



                        db.AssetCommands.Add(new_asset_command[i]);
                    }

                    db.Assets.Add(new_asset);
                    db.AssetThumbnails.Add(new_asset_thumbnail);
                    db.SaveChanges();
                    DialogResult information = new DialogResult();
                    information = MessageBox.Show(resourceManager.GetString("msgScenarioAdded", GlobalVariables.uiLanguage));
                    if (information == DialogResult.OK)
                    {
                        Admin_Page admin_page = new Admin_Page();
                        this.Hide();
                        admin_page.Show();
                    }
                }
            }
            else
            {
                using (VivosEntities db = new VivosEntities())
                {
                    List <Asset>          AssetList          = (from x in db.Assets select x).ToList();
                    List <AssetThumbnail> AssetThumbnailList = (from x in db.AssetThumbnails select x).ToList();
                    List <AssetCommand>   AssetCommandList   = (from x in db.AssetCommands select x).ToList();

                    AssetCommand[] new_asset_command = new AssetCommand[commandsLayout.RowCount - 1];

                    for (int i = 0; i < new_asset_command.Length; i++)
                    {
                        new_asset_command[i] = new AssetCommand();
                    }

                    Asset edit_asset = (from x in db.Assets where x.Id == GlobalVariables.Asset_Start_ID select x).SingleOrDefault();
                    if (edit_asset != null)
                    {
                        edit_asset.Name              = txtTurkishName.Text;
                        edit_asset.EnName            = txtEnglishName.Text;
                        edit_asset.ArabicName        = txtArabicName.Text;
                        edit_asset.Description       = txtTurkishDescription.Text;
                        edit_asset.EnDescription     = txtEnglishDescription.Text;
                        edit_asset.ArabicDescription = txtArabicDescription.Text;
                        edit_asset.Url        = txtScenarioPath.Text;
                        edit_asset.Exe        = txtScenarioExe.Text;
                        edit_asset.ModifyDate = DateTime.Now;
                        if (cbAvaliable.Checked == true)
                        {
                            edit_asset.Available = true;
                        }
                        else
                        {
                            edit_asset.Available = false;
                        }
                    }
                    AssetThumbnail edit_asset_thumbnail = (from x in db.AssetThumbnails where x.AssetId == GlobalVariables.Asset_Start_ID select x).SingleOrDefault();
                    if (edit_asset_thumbnail != null)
                    {
                        if (pictureBox2.Image != null)
                        {
                            Image          img       = pictureBox2.Image;
                            Bitmap         bmp       = new Bitmap(img);
                            ImageConverter converter = new ImageConverter();
                            try
                            {
                                edit_asset_thumbnail.Thumbnail = (byte[])converter.ConvertTo(img, typeof(byte[]));
                            }
                            catch
                            {
                            }
                        }
                    }

                    for (int i = 0; i < commandsLayout.RowCount - 2; i++)
                    {
                        int flag = 0;
                        for (int j = 0; j < AssetCommandList.Count; j++)
                        {
                            if (AssetCommandList[j].Id == Guid.Parse(txtID[i].Text))
                            {
                                AssetCommandList[j].CommandText       = txtCommand[i].Text;
                                AssetCommandList[j].Description       = txtTurkishExplanation[i].Text;
                                AssetCommandList[j].EnDescription     = txtEnglishExplanation[i].Text;
                                AssetCommandList[j].ArabicDescription = txtArabicExplanation[i].Text;
                                AssetCommandList[j].Step = Convert.ToByte(txtStep[i].Text);
                                flag = 1;
                                break;
                            }
                        }
                        if (flag == 0)
                        {
                            Guid new_asset_command_id = Guid.NewGuid();
                            new_asset_command[i].Id                = new_asset_command_id;
                            new_asset_command[i].AssetId           = GlobalVariables.Asset_Start_ID;
                            new_asset_command[i].CommandText       = txtCommand[i].Text;
                            new_asset_command[i].Description       = txtTurkishExplanation[i].Text;
                            new_asset_command[i].EnDescription     = txtEnglishExplanation[i].Text;
                            new_asset_command[i].ArabicDescription = txtArabicExplanation[i].Text;
                            new_asset_command[i].Step              = Convert.ToByte(txtStep[i].Text);
                            db.AssetCommands.Add(new_asset_command[i]);
                        }
                    }
                    db.SaveChanges();
                    DialogResult information = new DialogResult();
                    information = MessageBox.Show(resourceManager.GetString("msgScenarioEdited", GlobalVariables.uiLanguage));
                    if (information == DialogResult.OK)
                    {
                        Admin_Page admin_page = new Admin_Page();
                        this.Hide();
                        admin_page.Show();
                    }
                }
            }
        }