예제 #1
0
        private void CallsIvrStat(object sender)
        {
            var model = new SelectPeriodDialogViewModel();

            model.FromDate = DateTime.Today.AddDays(-7);
            model.ToDate   = DateTime.Today;
            var view = new SelectPeriodDialog();

            view.Owner = Application.Current.MainWindow;
            model.SetView(view);
            view.DataContext = model;
            if (view.ShowDialog() ?? false)
            {
                try
                {
                    var saveDialog = new SaveFileDialog();
                    saveDialog.AddExtension = true;
                    saveDialog.DefaultExt   = ".xml";
                    saveDialog.Filter       = "XML ‘айл|*.xml";
                    if (saveDialog.ShowDialog() == true)
                    {
                        List <StatIvrCallListDto> results;
                        using (var con = new MySqlConnection(AppSettings.ConnectionString))
                        {
                            _requestService = new RequestService(AppSettings.DbConnection);
                            results         = _requestService.GetIvrStatCalls(model.FromDate.Date,
                                                                              model.ToDate.Date.AddDays(1).AddSeconds(-1)).ToList();
                        }
                        var      fileName = saveDialog.FileName;
                        XElement root     = new XElement("Records");
                        foreach (var record in results)
                        {
                            root.AddFirst(
                                new XElement("Record",
                                             new[]
                            {
                                new XElement("ID", record.LinkedId),
                                new XElement("Ќомер", record.CallerIdNum),
                                new XElement("¬х«вонок", record.InCreateTime.ToString("dd.MM.yyyy HH:mm")),
                                new XElement("ќтветЌа¬х", record.InBridgedTime?.ToString("dd.MM.yyyy HH:mm")),
                                new XElement("ќкончан褬х", record.InEndTime.ToString("dd.MM.yyyy HH:mm")),
                                new XElement("¬нутреннийЌомер", record.Phone),
                                new XElement("ќтвет", record.Result),
                                new XElement("«вонок¬нут", record.CreateTime.ToString("dd.MM.yyyy HH:mm")),
                                new XElement("ќтвет¬нут", record.BridgedTime?.ToString("dd.MM.yyyy HH:mm")),
                                new XElement("ќкончан褬нут", record.EndTime.ToString("dd.MM.yyyy HH:mm")),
                                new XElement("ќжидание", record.ClientWaitSec),
                                new XElement("¬ре줫вонка", record.CallDuration),
                                new XElement("¬рем¤–азговора", record.TalkDuration),
                            }));
                        }
                        var saver = new FileStream(fileName, FileMode.Create);
                        root.Save(saver);
                        saver.Close();
                        MessageBox.Show("ƒанные сохранены в файл\r\n" + fileName);
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show("ѕроизошла ошибка:\r\n" + exc.Message);
                }
            }
        }
예제 #2
0
        private void CallsStat(object sender)
        {
            var model = new SelectPeriodDialogViewModel();

            model.FromDate = DateTime.Today.AddDays(-7);
            model.ToDate   = DateTime.Today;
            var view = new SelectPeriodDialog();

            view.Owner = Application.Current.MainWindow;
            model.SetView(view);
            view.DataContext = model;
            if (view.ShowDialog() ?? false)
            {
                try
                {
                    var saveDialog = new SaveFileDialog();
                    saveDialog.AddExtension = true;
                    saveDialog.DefaultExt   = ".xml";
                    saveDialog.Filter       = "XML ‘айл|*.xml";
                    if (saveDialog.ShowDialog() == true)
                    {
                        List <StatCallListDto> results;
                        using (var con = new MySqlConnection(AppSettings.ConnectionString))
                        {
                            _requestService = new RequestService(AppSettings.DbConnection);
                            results         = _requestService.GetStatCalls(model.FromDate.Date,
                                                                           model.ToDate.Date.AddDays(1).AddSeconds(-1)).ToList();
                        }
                        var      fileName = saveDialog.FileName;
                        XElement root     = new XElement("Records");
                        foreach (var record in results)
                        {
                            root.AddFirst(
                                new XElement("Record",
                                             new[]
                            {
                                new XElement("Ќаправление", record.Direction),
                                new XElement("Exten", record.Exten),
                                new XElement("” ", record.ServiceCompany),
                                new XElement("Ќомер", record.PhoneNum),
                                new XElement("ƒата«вонка", record.CreateDate),
                                new XElement("¬ре줫вонка", record.CreateTime),
                                new XElement("ƒатаќтвета", record.BridgeDate),
                                new XElement("¬рем¤ќтвета", record.BridgeTime),
                                new XElement("ƒатаќкончани¤", record.EndDate),
                                new XElement("¬рем¤ќкончани¤", record.EndTime),
                                new XElement("ќжидание", record.WaitSec),
                                new XElement("ѕродолжительность", record.CallTime),
                                new XElement("ќператор", record.Fio)
                            }));
                        }
                        var saver = new FileStream(fileName, FileMode.Create);
                        root.Save(saver);
                        saver.Close();
                        MessageBox.Show("ƒанные сохранены в файл\r\n" + fileName);
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show("ѕроизошла ошибка:\r\n" + exc.Message);
                }
            }
        }