Exemplo n.º 1
0
        private void OnSaveReportInFile()
        {
            var reportObject = new List <FormReportFileModel>();

            GetAdditionalRecord();
            var item = GetAdditionalRecord();

            if (item.Shift != null)
            {
                reportObject.Add(item);
            }

            foreach (var data in DateReportItems.Where(s => s.Shift == SelectedShiftItem))
            {
                reportObject.Add(new FormReportFileModel()
                {
                    Silos = data.Silos,
                    AvgDensityOfPearls = data.DetailedReportForChamber.First().AvgDensityOfPearls,
                    Chamber            = data.Chamber,
                    NumberOfBlocks     = data.NumberOfBlocks,
                    Operator           = data.Operator,
                    PzNumber           = data.DetailedReportForChamber.First().PzNumber,
                    Shift          = data.Shift,
                    SumBlockWeight = data.DetailedReportForChamber.Sum(s => s.Weight),
                    TimeFrom       = data.TimeFrom,
                    TimeTo         = data.TimeTo,
                });
            }

            var pathToReport = Path.Combine(ConfigurationManager.AppSettings["PathToFormReport"], "Raport_Forma_" + reportObject.First().TimeFrom.Date.ToString("yyyy-MM-dd") + ".xml");

            SaveInFileLogic.OnSaveReportInFile <List <FormReportFileModel> >(reportObject, pathToReport, logger);
            Process.Start(pathToReport);
        }
Exemplo n.º 2
0
        private FormReportFileModel GetAdditionalRecord()
        {
            FormDateReportModel item = null;

            switch (SelectedShiftItem)
            {
            case "1":
                item = DateReportItems.FirstOrDefault(s => s.Shift == "3\\1");
                if (item != null)
                {
                    item.Shift = "1";
                }
                break;

            case "2":
                item = DateReportItems.FirstOrDefault(s => s.Shift == "1\\2");
                if (item != null)
                {
                    item.Shift = "2";
                }
                break;

            case "3":
                item = DateReportItems.FirstOrDefault(s => s.Shift == "2\\3");
                if (item != null)
                {
                    item.Shift = "3";
                }
                break;
            }
            return(item != null
                ? new FormReportFileModel()
            {
                Silos = item.Silos,
                AvgDensityOfPearls = item.DetailedReportForChamber.First().AvgDensityOfPearls,
                Chamber = item.Chamber,
                NumberOfBlocks = item.NumberOfBlocks,
                Operator = item.Operator,
                PzNumber = item.DetailedReportForChamber.First().PzNumber,
                Shift = item.Shift,
                SumBlockWeight = item.DetailedReportForChamber.Sum(s => s.Weight),
                TimeFrom = item.TimeFrom,
                TimeTo = item.TimeTo,
            }
                : new FormReportFileModel());
        }
Exemplo n.º 3
0
        private void SetFormDetailedReport()
        {
            if (ActualDatedReportRow != null && SelectedChamberItem != ActualDatedReportRow.Chamber)
            {
                SelectedChamberItem = ActualDatedReportRow.Chamber;
            }

            logger.logger.ErrorFormat("Method SetFormDetailedReport");
            if (ActualDatedReportRow == null)
            {
                return;                               // 2 warunek jak przyjdzie timer i nie wybrano zadnej komory zeby sie nie wywalilo
            }
            switch (DetailedReportType)
            {
            case FormDetailedReportTypeEnum.ShortVersionDetailedReport:
                DetailedReportItems = new ObservableCollection <FormDatailedReportModel>((from li in DateReportItems
                                                                                          where li.Chamber == ActualDatedReportRow.Chamber &&
                                                                                          li.NumberOfBlocks == ActualDatedReportRow.NumberOfBlocks &&
                                                                                          li.Silos == ActualDatedReportRow.Silos &&
                                                                                          li.Operator == ActualDatedReportRow.Operator
                                                                                          select li).First().DetailedReportForChamber);

                this.SettingsAndFilterPanelViewModel.SetTimer(TimerActionEnum.Reset);
                break;

            case FormDetailedReportTypeEnum.FullVersionDetailedReport:
                DetailedFullVersionReportItems = new ObservableCollection <FormDateReportDBModel>(DateReportItems.First(s =>
                                                                                                                        s.Chamber == ActualDatedReportRow.Chamber &&
                                                                                                                        s.NumberOfBlocks == ActualDatedReportRow.NumberOfBlocks &&
                                                                                                                        s.Silos == ActualDatedReportRow.Silos &&
                                                                                                                        s.Operator == ActualDatedReportRow.Operator).DetailedReportForChamber);
                SelectedDatedReportRow = null;
                this.SettingsAndFilterPanelViewModel.SetTimer(TimerActionEnum.Stop);
                break;

            case FormDetailedReportTypeEnum.Any:
                DetailedReportItems            = new ObservableCollection <FormDatailedReportModel>();
                DetailedFullVersionReportItems = new ObservableCollection <FormDateReportDBModel>();
                SelectedDatedReportRow         = null;
                break;
            }

            logger.logger.ErrorFormat("End method SetFormDetailedReport");
        }
Exemplo n.º 4
0
        private void SetAvailableShifts()
        {
            var items = DateReportItems.ToList().FindAll(s => s.Shift == "1" || s.Shift == "2" || s.Shift == "3").Select(s => s.Shift).Distinct();

            ShiftItems = new ObservableCollection <string>(items);
        }