Example #1
0
        public ActionResult BWEncode(string toEncode)
        {
            if (toEncode.Length == 0)
            {
                ViewData["ArgumentException"] = "Пустая строка, пожалуйста введите что-нибудь.";
                return(View());
            }

            toEncode = toEncode.Replace("\r\n", "\n");
            try
            {
                ViewData["Encoded"]           = new BWT().Encode(toEncode, out double compressionRatio);
                ViewData["CompressionDegree"] = string.Format("{0:0.##}", compressionRatio);
            }
            catch (Exception e)
            {
                ViewData["Error"] = "Пожалуйста, проверьте соответствие введенных данных нужному формату.";
            }

            ViewData["UploadedText"] = toEncode;

            return(View());
        }
Example #2
0
 public void Decode__DecodesCorrectly(string encoded, int index, string expected)
 {
     BWT.Decode(encoded, index).ShouldBe(expected);
 }
Example #3
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            try
            {
                if (File.Exists(accDataGridView.Rows[accDataGridView.CurrentRow.Index].Cells[1].Value.ToString()) == false)
                {
                    try
                    {
                        ro = accDataGridView.CurrentRow.Index;
                        if (accDataGridView.Rows[ro].Cells[6].Value.ToString() == "")
                        {
                            accDataGridView.Rows[ro].Cells[6].Value = "0";
                            accBindingSource.EndEdit();
                            CAVATableAdapter.Acc(ref accTableAdapter, ref cAVADataSet, "Update");
                            CAVATableAdapter.Acc(ref this.accTableAdapter, ref this.cAVADataSet, "Fill");
                        }
                        int a1 = Convert.ToInt32(accDataGridView.Rows[ro].Cells[6].Value.ToString());
                        int a2 = Convert.ToInt32(pupilDataGridView.Rows[Properties.Settings.Default.RP].Cells[5].Value.ToString());
                        if (a1 >= a2)
                        {
                            if (Properties.Settings.Default.LANG == "BE")
                            {
                                MessageBox.Show("Дасягнута максімальная колькасць запускаў гэтага задання.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                if (Properties.Settings.Default.LANG == "RU")
                                {
                                    MessageBox.Show("Достигнуто максимальное количество запусков этого задания.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        else
                        {
                            if (accDataGridView.Rows[ro].Cells[8].Value.ToString() == 1.ToString())
                            {
                                if (Properties.Settings.Default.LANG == "BE")
                                {
                                    MessageBox.Show("Заданне заблакавана", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                else
                                {
                                    if (Properties.Settings.Default.LANG == "RU")
                                    {
                                        MessageBox.Show("Задание заблокировано.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    }
                                }
                            }
                            else
                            {
                                TestOpen T = new TestOpen();
                                T.t = teacherDataGridView.CurrentRow.Index;
                                T.s = subDataGridView.CurrentRow.Index;
                                T.c = clasDataGridView.CurrentRow.Index;
                                T.p = pupilDataGridView.CurrentRow.Index;
                                T.a = accDataGridView.CurrentRow.Index;

                                string   t  = accDataGridView.Rows[accDataGridView.CurrentRow.Index].Cells[1].Value.ToString();
                                string[] t1 = t.Split(new char[] { ':' });
                                T.TestRow = Convert.ToInt32(t1[t1.Length - 1]);
                                T.Show();
                                this.Enabled = false;
                                this.Hide();
                                firstshowing = false;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (Properties.Settings.Default.LANG == "BE")
                        {
                            MessageBox.Show("Заданне не абрана або: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                        else
                        {
                            if (Properties.Settings.Default.LANG == "RU")
                            {
                                MessageBox.Show("Задание не выбрано или: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                        }
                    }
                }
                else
                {
                    c = 0;
                    try
                    {
                        ro = accDataGridView.CurrentRow.Index;
                        if (accDataGridView.Rows[ro].Cells[6].Value.ToString() == "")
                        {
                            accDataGridView.Rows[ro].Cells[6].Value = "0";
                            accBindingSource.EndEdit();
                            CAVATableAdapter.Acc(ref this.accTableAdapter, ref this.cAVADataSet, "Update");
                            CAVATableAdapter.Acc(ref this.accTableAdapter, ref this.cAVADataSet, "Fill");
                        }
                        int a1 = Convert.ToInt32(accDataGridView.Rows[ro].Cells[6].Value.ToString());
                        int a2 = Convert.ToInt32(pupilDataGridView.Rows[Properties.Settings.Default.RP].Cells[5].Value.ToString());
                        if (a1 >= a2)
                        {
                            if (Properties.Settings.Default.LANG == "BE")
                            {
                                MessageBox.Show("Дасягнута максімальная колькасць запускаў гэтага задання.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                if (Properties.Settings.Default.LANG == "RU")
                                {
                                    MessageBox.Show("Достигнуто максимальное количество запусков этого задания.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        else
                        {
                            if (accDataGridView.Rows[ro].Cells[8].Value.ToString() == 1.ToString())
                            {
                                if (Properties.Settings.Default.LANG == "BE")
                                {
                                    MessageBox.Show("Заданне заблакавана", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                else
                                {
                                    if (Properties.Settings.Default.LANG == "RU")
                                    {
                                        MessageBox.Show("Задание заблокировано.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    }
                                }
                            }
                            else
                            {
                                if (Convert.ToInt32(accDataGridView.Rows[ro].Cells[2].Value.ToString()) <= 0)
                                {
                                    if (Properties.Settings.Default.LANG == "BE")
                                    {
                                        MessageBox.Show("Параметр Час не адпавядае патрэбнаму значэнню.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    }
                                    else
                                    {
                                        if (Properties.Settings.Default.LANG == "RU")
                                        {
                                            MessageBox.Show("Параметр Время не соответствует требуемому значению.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        }
                                    }
                                }
                                else
                                {
                                    if (subDataGridView.Rows[subDataGridView.CurrentRow.Index].Cells[3].Value.ToString() == "")
                                    {
                                        if (Properties.Settings.Default.LANG == "BE")
                                        {
                                            MessageBox.Show("На гэтай вучэбнай дысцыпліне не ўстаноўлена тэчка вываду. Звярніцеся да адміністратара.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        }
                                        else
                                        {
                                            if (Properties.Settings.Default.LANG == "RU")
                                            {
                                                MessageBox.Show("У этой учебной дисциплины отсутствует папка вывода. Обратитесь к администратору.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        sx       = System.IO.Path.GetExtension(accDataGridView.Rows[ro].Cells[1].Value.ToString());
                                        SavePath = @"" + subDataGridView.Rows[subDataGridView.CurrentRow.Index].Cells[3].Value.ToString() + @"\"
                                                   + pupilDataGridView.Rows[pupilDataGridView.CurrentRow.Index].Cells[1].Value.ToString() + @"\";
                                        if (Directory.Exists(SavePath) == true)
                                        {
                                            SavePath += accDataGridView.Rows[ro].Cells[3].Value.ToString()
                                                        + sx;
                                        }
                                        else
                                        {
                                            Directory.CreateDirectory(SavePath);
                                            SavePath += accDataGridView.Rows[ro].Cells[3].Value.ToString()
                                                        + sx;
                                        }
                                        // Проверка на каталог
                                        try
                                        {
                                            if (System.IO.Path.HasExtension(SavePath) == false)
                                            {
                                                if (Properties.Settings.Default.LANG == "BE")
                                                {
                                                    MessageBox.Show("Шлях да задання не з'яўляецца файлам.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                }
                                                else
                                                {
                                                    if (Properties.Settings.Default.LANG == "RU")
                                                    {
                                                        MessageBox.Show("Путь к заданию не является файлом.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (c == 0)
                                                {
                                                    //Проверка наличия файла в директории вывода
                                                    try
                                                    {
                                                        if (File.Exists(SavePath) == false)
                                                        {
                                                            try
                                                            {
                                                                //Копирование
                                                                //__________________________
                                                                this.Enabled = false;
                                                                BWT bwt = new BWT();
                                                                bwt.SavePath = SavePath;
                                                                bwt.ro       = ro;
                                                                bwt.sx       = sx;
                                                                bwt.accd     = accDataGridView.Rows[ro].Cells[1].Value.ToString();
                                                                bwt.accdesc  = accDataGridView.Rows[ro].Cells[4].Value.ToString();
                                                                bwt.s        = accDataGridView.Rows[ro].Cells[2].Value.ToString();
                                                                bwt.name     = accDataGridView.Rows[ro].Cells[3].Value.ToString();
                                                                bwt.Show();
                                                            }
                                                            catch (Exception ex)
                                                            {
                                                            }
                                                        }
                                                        else
                                                        {
                                                            Properties.Settings.Default.Desc = accDataGridView.Rows[ro].Cells[4].Value.ToString();
                                                            Properties.Settings.Default.path = SavePath;
                                                            Properties.Settings.Default.r3   = ro;
                                                            Properties.Settings.Default.name = accDataGridView.Rows[ro].Cells[3].Value.ToString();
                                                            string s = accDataGridView.Rows[ro].Cells[2].Value.ToString();
                                                            int    i = Convert.ToInt32(s);
                                                            Properties.Settings.Default.tim = i;
                                                            Properties.Settings.Default.Save();
                                                            Properties.Settings.Default.Desc = accDataGridView.Rows[ro].Cells[4].Value.ToString();
                                                            Properties.Settings.Default.Save();
                                                            Properties.Settings.Default.al = 1;
                                                            Properties.Settings.Default.y  = 1;
                                                            Properties.Settings.Default.Save();
                                                            if (Convert.ToInt32(accDataGridView.Rows[ro].Cells[8].Value.ToString()) > 0)
                                                            {
                                                                if (Properties.Settings.Default.LANG == "BE")
                                                                {
                                                                    MessageBox.Show("Заданне ўстаноўлена, можаце працягнуць працу.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                                                }
                                                                else
                                                                {
                                                                    if (Properties.Settings.Default.LANG == "RU")
                                                                    {
                                                                        MessageBox.Show("Задание установлено, можете продолжить работу.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                if (Properties.Settings.Default.LANG == "BE")
                                                                {
                                                                    MessageBox.Show("Загрузка завершана, можна прыступіць да працы", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                                                }
                                                                else
                                                                {
                                                                    if (Properties.Settings.Default.LANG == "RU")
                                                                    {
                                                                        MessageBox.Show("Загрузка завершена, можно приступить к работе.", "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                                                    }
                                                                }
                                                            }
                                                            this.Close();
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                    }
                                                }
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            MessageBox.Show(ex.Message, "CAVA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (Properties.Settings.Default.LANG == "BE")
                        {
                            MessageBox.Show("Заданне не абрана або: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                        else
                        {
                            if (Properties.Settings.Default.LANG == "RU")
                            {
                                MessageBox.Show("Задание не выбрано или: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (Properties.Settings.Default.LANG == "BE")
                {
                    MessageBox.Show("Заданне не абрана.", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    if (Properties.Settings.Default.LANG == "RU")
                    {
                        MessageBox.Show("Задание не выбрано.", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
            }
        }