コード例 #1
0
ファイル: CommandProcessor.cs プロジェクト: Konan777/TechnoN
        private void SaveClientMenu()
        {
            ShowSaveClientMenu();
            var command = _console.ReadLine();

            while (command != "q")
            {
                if (command != "" && (!command.Contains(":") || !command.Contains(@"\")))
                {
                    _console.WriteLine("неверный путь или имя файла");
                    _console.Write("введите путь и имя файла>");
                    command = _console.ReadLine();
                    continue;
                }

                try
                {
                    reqParams.Clear();
                    var employees = _request.RequestList <EmployeeBase>(_apiUrl + urlSix, reqParams);
                    var empl      = new List <object>();
                    empl.AddRange(employees);

                    var xsz = new XmlSerializer(typeof(List <EmployeeBase>),
                                                new[] { typeof(EmployeeOnSalary), typeof(EmployeeOnRate) });
                    using (var streamWriter = File.CreateText(command))
                    {
                        xsz.Serialize(streamWriter, employees);
                    }

                    Console.WriteLine("Файл сохранен");
                    _console.Write("Главное меню>");
                    return;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                _console.Write("введите путь и имя файла>");
                command = _console.ReadLine();
            }

            _console.Write("Главное меню>");
        }