Exemplo n.º 1
0
        public void LoadXmlFunc(object parameter)
        {
            //var dialog = new FolderBrowserDialog();
            //if (dialog.ShowDialog() == DialogResult.OK)
            //{
            ProcessStatus = LoadProcessEnum.InProcess;

            Task <bool> .Factory
            .StartNew(() =>
            {
                try
                {
                    var xml             = File.ReadAllText(Path.Combine(ConfigurationManager.AppSettings["DataDirectory"], "GroupProduct.xml"));
                    _appData.GroupTypes = XmlStructure.GetGroups(xml);

                    xml = File.ReadAllText(Path.Combine(ConfigurationManager.AppSettings["DataDirectory"], "Product.xml"));
                    _appData.ProductTypes = XmlStructure.GetProducts(xml);

                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            })
            .ContinueWith(
                res => { ProcessStatus = res.Result ? LoadProcessEnum.Success : LoadProcessEnum.Fail; });

            //}
        }
Exemplo n.º 2
0
        public void Load()
        {
            StatusText = "ЗАГРУЗКА ДАННЫХ";
            Task <bool> .Factory
            .StartNew(() =>
            {
                if (_appdata.DataDestination == DataDestinationEnum.Db)
                {
                    var includeSumm = _appdata.StatType == StatTypeEnum.StatSalesWithReceipts;
                    var isStatSales = _appdata.StatType == StatTypeEnum.StatSales || _appdata.StatType == StatTypeEnum.StatSalesWithReceipts;

                    if (_appdata.FilterType == FilterTypeEnum.GroupOrSubgroup)
                    {
                        if (_appdata.SelectedGroupFilter.HasValue)
                        {
                            _appdata.Data = DbService.GetStatSalesTypesByGroup(_connectionString, _appdata.StartDateFilter, _appdata.EndDateFilter,
                                                                               _appdata.SelectedGroupFilter.Value, includeSumm, isStatSales);
                        }
                        else if (_appdata.SelectedSubGroupFilter != null && _appdata.SelectedSubGroupFilter.Count == 1)
                        {
                            _appdata.Data = DbService.GetStatSalesTypesBySubgroup(_connectionString, _appdata.StartDateFilter, _appdata.EndDateFilter,
                                                                                  _appdata.SelectedSubGroupFilter, includeSumm, isStatSales);
                        }
                        else
                        {
                            throw new Exception("не выбрана группа или подгруппа");
                        }
                    }
                    else if (_appdata.FilterType == FilterTypeEnum.ProductOrBarcode)
                    {
                        _appdata.Data = DbService.GetStatSalesTypesByProductType(_connectionString, _appdata.StartDateFilter, _appdata.EndDateFilter,
                                                                                 _appdata.SelectedProductFilter, includeSumm, isStatSales);
                    }
                    else if (_appdata.FilterType == FilterTypeEnum.AnyProducts)
                    {
                        _appdata.Data = DbService.GetStatSalesTypesByProductType(_connectionString, _appdata.StartDateFilter, _appdata.EndDateFilter,
                                                                                 _appdata.SelectedProductFilter, includeSumm, isStatSales);
                    }
                    else if (_appdata.FilterType == FilterTypeEnum.AnySubgroups)
                    {
                        _appdata.Data = DbService.GetStatSalesTypesBySubgroup(_connectionString, _appdata.StartDateFilter, _appdata.EndDateFilter,
                                                                              _appdata.SelectedSubGroupFilter, includeSumm, isStatSales);
                    }
                    else
                    {
                        throw new Exception("Нет функции для выборки");
                    }
                }
                else
                {
                    if (_appdata.FilterType == FilterTypeEnum.GroupOrSubgroup)
                    {
                        if (_appdata.SelectedGroupFilter.HasValue)
                        {
                            _appdata.Data = XmlStructure.GetStatSalesTypesByGroup(_dataDirectory, _appdata.StartDateFilter, _appdata.EndDateFilter,
                                                                                  _appdata.SelectedGroupFilter.Value, _appdata.GroupTypes);
                        }
                        else if (_appdata.SelectedSubGroupFilter != null && _appdata.SelectedSubGroupFilter.Count == 1)
                        {
                            _appdata.Data = XmlStructure.GetStatSalesTypesBySubgroup(_dataDirectory, _appdata.StartDateFilter, _appdata.EndDateFilter,
                                                                                     _appdata.SelectedSubGroupFilter, _appdata.GroupTypes);
                        }
                        else
                        {
                            throw new Exception("не выбрана группа или подгруппа");
                        }
                    }
                    else if (_appdata.FilterType == FilterTypeEnum.ProductOrBarcode)
                    {
                        _appdata.Data = XmlStructure.GetStatSalesTypesByProductType(_dataDirectory, _appdata.StartDateFilter, _appdata.EndDateFilter,
                                                                                    _appdata.SelectedProductFilter);
                    }
                    else if (_appdata.FilterType == FilterTypeEnum.AnyProducts)
                    {
                        _appdata.Data = XmlStructure.GetStatSalesTypesByProductType(_dataDirectory, _appdata.StartDateFilter, _appdata.EndDateFilter,
                                                                                    _appdata.SelectedProductFilter);
                    }
                    else if (_appdata.FilterType == FilterTypeEnum.AnySubgroups)
                    {
                        _appdata.Data = XmlStructure.GetStatSalesTypesBySubgroup(_dataDirectory, _appdata.StartDateFilter, _appdata.EndDateFilter,
                                                                                 _appdata.SelectedSubGroupFilter, _appdata.GroupTypes);
                    }
                    else
                    {
                        throw new Exception("Нет функции для выборки");
                    }
                }
                return(true);
            })
            .ContinueWith(res =>
            {
                _dispatcher.Invoke(DispatcherPriority.Background, new Action(LoadChart));
                StatusText = "ГОТОВО";
            });
        }