Example #1
0
        public override void CreateTestTextFile()
        {
            if (this.Questions.Count > 0)
            {
                string numFormat = "D1";
                if (this.Questions.Count > 99)
                {
                    numFormat = "D3";
                }
                else if (this.Questions.Count > 9)
                {
                    numFormat = "D2";
                }

                int maxLengthQuestion = 0;
                int maxLengthTime     = 0;

                foreach (AssociationQuestion item in this.Questions)
                {
                    string tmp = item.ToString(numFormat);
                    maxLengthQuestion = Math.Max(maxLengthQuestion, tmp.Length);

                    tmp           = item.Time.ToString("F2");
                    maxLengthTime = Math.Max(maxLengthTime, tmp.Length);
                }

                StringBuilder sb = new StringBuilder();

                DateTime durationTest  = new DateTime().Add(this.DateEnd.Value - this.DateStart.Value);
                DateTime durationCheck = new DateTime().Add(this.DateCheck.Value - this.DateEnd.Value);
                DateTime durationTotal = new DateTime().Add(this.DateCheck.Value - this.DateStart.Value);

                sb.AppendLine(string.Format("Тест последовательных ассоциаций на {0} слов.", this.Questions.Count));
                sb.AppendLine();
                sb.AppendLine(string.Format("Время начала теста                 {0}", this.DateStart.Value.ToString("dd.MM.yyyy HH:mm:ss")));
                sb.AppendLine(string.Format("Время окончания теста              {0}", this.DateEnd.Value.ToString("dd.MM.yyyy HH:mm:ss")));
                sb.AppendLine(string.Format("Время окончания написания ответов  {0}", this.DateCheck.Value.ToString("dd.MM.yyyy HH:mm:ss")));
                sb.AppendLine();
                sb.AppendLine(string.Format("Продолжительность теста              {0}", durationTest.ToLongTimeString()));
                sb.AppendLine(string.Format("Продолжительность написания ответов  {0}", durationCheck.ToLongTimeString()));
                sb.AppendLine(string.Format("Продолжительность общая              {0}", durationTotal.ToLongTimeString()));
                sb.AppendLine();
                sb.AppendLine(string.Format("Минимальное время на образ   {0}", this.GetTimeMinimum().ToString("F2").PadLeft(maxLengthTime)));
                sb.AppendLine(string.Format("Среднее время на образ       {0}", this.GetTimeAverange().ToString("F2").PadLeft(maxLengthTime)));
                sb.AppendLine(string.Format("Максимальное время на образ  {0}", this.GetTimeMaximum().ToString("F2").PadLeft(maxLengthTime)));
                sb.AppendLine();
                sb.AppendLine();

                for (int i = 0; i < this.Questions.Count; i++)
                {
                    AssociationQuestion item = this.Questions[i];

                    string tmp = item.ToString(numFormat);
                    tmp = tmp.PadRight(maxLengthQuestion);

                    string position = string.Empty;
                    if (this.WithNumber && this.Random)
                    {
                        position = string.Format("на {0} месте, ", item.ShowPosition.ToString(numFormat));
                    }

                    tmp += string.Format("     {0}отображался {1}c.", position, item.Time.ToString("F2").PadLeft(maxLengthTime));

                    sb.AppendLine(tmp);
                }

                string fileName = "Тест " + this.DateStart.Value.ToString("yyyy-MM-dd HH-mm-ss") + " Ассоциации " + this.Questions.Count.ToString() + ".txt";

                string pathFile = Path.Combine(Config.ReportFolder, fileName);
                if (!Directory.Exists(Config.ReportFolder))
                {
                    Directory.CreateDirectory(Config.ReportFolder);
                }

                using (StreamWriter sw = File.CreateText(pathFile))
                {
                    sw.Write(sb.ToString());
                }

                try
                {
                    Process.Start(pathFile);
                }
                catch (Exception)
                {
                }
            }
        }
        public override void CreateTestTextFile()
        {
            if (this.Questions.Count > 0)
            {
                string numFormat = "D1";
                if (this.Questions.Count > 99)
                {
                    numFormat = "D3";
                }
                else if (this.Questions.Count > 9)
                {
                    numFormat = "D2";
                }

                int    maxLengthQuestion1 = 0;
                int    maxLengthQuestion2 = 0;
                int    maxLengthTime      = 0;
                string netFormat          = "   {0}";

                foreach (AssociationQuestion item in this.Questions)
                {
                    string tmp = item.ToString(numFormat);
                    maxLengthQuestion1 = Math.Max(maxLengthQuestion1, tmp.Length);

                    tmp           = item.Time.ToString("F2");
                    maxLengthTime = Math.Max(maxLengthTime, tmp.Length);
                }

                foreach (AssociationQuestion item in this.Questions)
                {
                    string tmp = item.ToString(numFormat);
                    tmp = tmp.PadRight(maxLengthQuestion1);


                    if (!string.IsNullOrEmpty(item.NetName))
                    {
                        tmp += string.Format(netFormat, item.NetName);
                    }

                    maxLengthQuestion2 = Math.Max(maxLengthQuestion2, tmp.Length);
                }

                StringBuilder sb = new StringBuilder();

                int numberCount = this.NumberCount;

                DateTime durationTest  = new DateTime().Add(this.DateEnd.Value - this.DateStart.Value);
                DateTime durationCheck = new DateTime().Add(this.DateCheck.Value - this.DateEnd.Value);
                DateTime durationTotal = new DateTime().Add(this.DateCheck.Value - this.DateStart.Value);

                sb.AppendLine(string.Format("Тест на {0}-значное число.", numberCount));
                sb.AppendLine(string.Format("Всего образов - {0}.", this.Questions.Count));
                sb.AppendLine();
                sb.AppendLine(string.Format("Время начала теста                 {0}", this.DateStart.Value.ToString("dd.MM.yyyy HH:mm:ss")));
                sb.AppendLine(string.Format("Время окончания теста              {0}", this.DateEnd.Value.ToString("dd.MM.yyyy HH:mm:ss")));
                sb.AppendLine(string.Format("Время окончания написания ответов  {0}", this.DateCheck.Value.ToString("dd.MM.yyyy HH:mm:ss")));
                sb.AppendLine();
                sb.AppendLine(string.Format("Продолжительность теста              {0}", durationTest.ToLongTimeString()));
                sb.AppendLine(string.Format("Продолжительность написания ответов  {0}", durationCheck.ToLongTimeString()));
                sb.AppendLine(string.Format("Продолжительность общая              {0}", durationTotal.ToLongTimeString()));
                sb.AppendLine();
                sb.AppendLine(string.Format("Минимальное время на образ   {0}", this.GetTimeMinimum().ToString("F2").PadLeft(maxLengthTime)));
                sb.AppendLine(string.Format("Среднее время на образ       {0}", this.GetTimeAverange().ToString("F2").PadLeft(maxLengthTime)));
                sb.AppendLine(string.Format("Максимальное время на образ  {0}", this.GetTimeMaximum().ToString("F2").PadLeft(maxLengthTime)));
                sb.AppendLine();
                sb.AppendLine();

                StringBuilder fullNumber          = new StringBuilder();
                StringBuilder fullNumberWithSplit = new StringBuilder();

                for (int i = 0; i < this.Questions.Count; i++)
                {
                    AssociationQuestion item = this.Questions[i];

                    string tmp = item.ToString(numFormat);
                    tmp = tmp.PadRight(maxLengthQuestion1);
                    if (!string.IsNullOrEmpty(item.NetName))
                    {
                        tmp += string.Format(netFormat, item.NetName);
                    }
                    tmp = tmp.PadRight(maxLengthQuestion2);

                    string position = string.Empty;
                    if (this.WithNumber && this.Random)
                    {
                        position = string.Format("на {0} месте, ", item.ShowPosition.ToString(numFormat));
                    }

                    tmp += string.Format("     {0}отображался {1}c.", position, item.Time.ToString("F2").PadLeft(maxLengthTime));

                    sb.AppendLine(tmp);

                    if (fullNumberWithSplit.Length != 0)
                    {
                        fullNumberWithSplit.Append("-");
                    }
                    fullNumberWithSplit.Append(item.Question);
                    fullNumber.Append(item.Question);
                }

                sb.AppendLine();
                sb.AppendLine(string.Format("Строка чисел: {0}.", fullNumberWithSplit.ToString()));
                sb.Append(string.Format("Полное число: {0}.", fullNumber.ToString()));

                string fileName = "Тест " + this.DateStart.Value.ToString("yyyy-MM-dd HH-mm-ss") + " Числа " + numberCount.ToString() + ".txt";

                string pathFile = Path.Combine(Config.ReportFolder, fileName);
                if (!Directory.Exists(Config.ReportFolder))
                {
                    Directory.CreateDirectory(Config.ReportFolder);
                }

                using (StreamWriter sw = File.CreateText(pathFile))
                {
                    sw.Write(sb.ToString());
                }

                try
                {
                    Process.Start(pathFile);
                }
                catch (Exception)
                {
                }
            }
        }