Esempio n. 1
0
        private PrintingPress.calc_Cost return_Cost
            (PrintingPress.Product _product,
            PrintingPress.Paper _paper,
            PrintingPress.Printer printer,
            decimal _page_Long,
            decimal _page_Short)
        {
            List <PrintingPress.calc_Cost> _calc_CostList = new List <PrintingPress.calc_Cost>();

            PrintingPress.Paper papertt = new PrintingPress.Paper();
            papertt.Cost       = _paper.Cost;
            papertt.Id         = _paper.Id;
            papertt.IsSelected = _paper.IsSelected;
            papertt.Long       = _paper.Long;
            papertt.Name       = _paper.Name;
            papertt.Qty        = _paper.Qty;
            papertt.Qty_Fit    = _paper.Qty_Fit;
            papertt.Short      = _paper.Short;
            papertt.Weight     = _paper.Weight;

            PrintingPress.Printer Printertt = new PrintingPress.Printer();
            Printertt.Color_Limit = printer.Color_Limit;
            Printertt.Cost        = printer.Cost;
            Printertt.Cost_DieSet = printer.Cost_DieSet;
            Printertt.Id          = printer.Id;
            Printertt.IsSelected  = printer.IsSelected;
            Printertt.Max_Long    = printer.Max_Long;
            Printertt.Max_Short   = printer.Max_Short;
            Printertt.Min_Long    = printer.Min_Long;
            Printertt.Min_Short   = printer.Min_Short;
            Printertt.Name        = printer.Name;
            Printertt.Runs        = printer.Runs;
            Printertt.Speed       = printer.Speed;
            Printertt.Time        = printer.Time;

            //True True
            PrintingPress.calc_Cost calc_Cost_TT = new PrintingPress.calc_Cost();
            calc_Cost_TT._printer = Printertt;
            calc_Cost_TT._product = _product;
            calc_Cost_TT._toner   = _toner;

            calc_Cost_TT._paper      = papertt; //_paperList.Where(x => x.IsSelected).FirstOrDefault();
            calc_Cost_TT._page       = new PrintingPress.Page();
            calc_Cost_TT._page.Long  = _page_Long;
            calc_Cost_TT._page.Short = _page_Short;
            calc_Cost_TT.calc_Automatic(ref _inkList, ref _accessoryList, true, true);
            if (calc_Cost_TT._paper.Qty_Fit >= 1)
            {
                _calc_CostList.Add(calc_Cost_TT);
            }
            PrintingPress.Paper papertf = new PrintingPress.Paper();
            papertf.Cost       = _paper.Cost;
            papertf.Id         = _paper.Id;
            papertf.IsSelected = _paper.IsSelected;
            papertf.Long       = _paper.Long;
            papertf.Name       = _paper.Name;
            papertf.Qty        = _paper.Qty;
            papertf.Qty_Fit    = _paper.Qty_Fit;
            papertf.Short      = _paper.Short;
            papertf.Weight     = _paper.Weight;

            PrintingPress.Printer Printertf = new PrintingPress.Printer();
            Printertf.Color_Limit = printer.Color_Limit;
            Printertf.Cost        = printer.Cost;
            Printertf.Cost_DieSet = printer.Cost_DieSet;
            Printertf.Id          = printer.Id;
            Printertf.IsSelected  = printer.IsSelected;
            Printertf.Max_Long    = printer.Max_Long;
            Printertf.Max_Short   = printer.Max_Short;
            Printertf.Min_Long    = printer.Min_Long;
            Printertf.Min_Short   = printer.Min_Short;
            Printertf.Name        = printer.Name;
            Printertf.Runs        = printer.Runs;
            Printertf.Speed       = printer.Speed;
            Printertf.Time        = printer.Time;

            //True False
            PrintingPress.calc_Cost calc_Cost_TF = new PrintingPress.calc_Cost();
            calc_Cost_TF._printer = Printertf;
            calc_Cost_TF._product = _product;
            calc_Cost_TF._toner   = _toner;

            calc_Cost_TF._paper      = papertf; //_paperList.Where(x => x.IsSelected).FirstOrDefault();
            calc_Cost_TF._page       = new PrintingPress.Page();
            calc_Cost_TF._page.Long  = _page_Long;
            calc_Cost_TF._page.Short = _page_Short;
            calc_Cost_TF.calc_Automatic(ref _inkList, ref _accessoryList, true, false);
            if (calc_Cost_TF._paper.Qty_Fit >= 1)
            {
                _calc_CostList.Add(calc_Cost_TF);
            }
            PrintingPress.Paper paperft = new PrintingPress.Paper();
            paperft.Cost       = _paper.Cost;
            paperft.Id         = _paper.Id;
            paperft.IsSelected = _paper.IsSelected;
            paperft.Long       = _paper.Long;
            paperft.Name       = _paper.Name;
            paperft.Qty        = _paper.Qty;
            paperft.Qty_Fit    = _paper.Qty_Fit;
            paperft.Short      = _paper.Short;
            paperft.Weight     = _paper.Weight;


            PrintingPress.Printer Printerft = new PrintingPress.Printer();
            Printerft.Color_Limit = printer.Color_Limit;
            Printerft.Cost        = printer.Cost;
            Printerft.Cost_DieSet = printer.Cost_DieSet;
            Printerft.Id          = printer.Id;
            Printerft.IsSelected  = printer.IsSelected;
            Printerft.Max_Long    = printer.Max_Long;
            Printerft.Max_Short   = printer.Max_Short;
            Printerft.Min_Long    = printer.Min_Long;
            Printerft.Min_Short   = printer.Min_Short;
            Printerft.Name        = printer.Name;
            Printerft.Runs        = printer.Runs;
            Printerft.Speed       = printer.Speed;
            Printerft.Time        = printer.Time;

            //False True
            PrintingPress.calc_Cost calc_Cost_FT = new PrintingPress.calc_Cost();
            calc_Cost_FT._printer = Printerft;
            calc_Cost_FT._product = _product;
            calc_Cost_FT._toner   = _toner;

            calc_Cost_FT._paper      = paperft; //_paperList.Where(x => x.IsSelected).FirstOrDefault();
            calc_Cost_FT._page       = new PrintingPress.Page();
            calc_Cost_FT._page.Long  = _page_Long;
            calc_Cost_FT._page.Short = _page_Short;
            calc_Cost_FT.calc_Automatic(ref _inkList, ref _accessoryList, false, true);
            if (calc_Cost_FT._paper.Qty_Fit >= 1)
            {
                _calc_CostList.Add(calc_Cost_FT);
            }
            PrintingPress.Paper paperff = new PrintingPress.Paper();
            paperff.Cost       = _paper.Cost;
            paperff.Id         = _paper.Id;
            paperff.IsSelected = _paper.IsSelected;
            paperff.Long       = _paper.Long;
            paperff.Name       = _paper.Name;
            paperff.Qty        = _paper.Qty;
            paperff.Qty_Fit    = _paper.Qty_Fit;
            paperff.Short      = _paper.Short;
            paperff.Weight     = _paper.Weight;

            PrintingPress.Printer Printerff = new PrintingPress.Printer();
            Printerff.Color_Limit = printer.Color_Limit;
            Printerff.Cost        = printer.Cost;
            Printerff.Cost_DieSet = printer.Cost_DieSet;
            Printerff.Id          = printer.Id;
            Printerff.IsSelected  = printer.IsSelected;
            Printerff.Max_Long    = printer.Max_Long;
            Printerff.Max_Short   = printer.Max_Short;
            Printerff.Min_Long    = printer.Min_Long;
            Printerff.Min_Short   = printer.Min_Short;
            Printerff.Name        = printer.Name;
            Printerff.Runs        = printer.Runs;
            Printerff.Speed       = printer.Speed;
            Printerff.Time        = printer.Time;

            //False False
            PrintingPress.calc_Cost calc_Cost_FF = new PrintingPress.calc_Cost();
            calc_Cost_FF._printer = Printerff;
            calc_Cost_FF._product = _product;
            calc_Cost_FF._toner   = _toner;

            calc_Cost_FF._paper      = paperff; //_paperList.Where(x => x.IsSelected).FirstOrDefault();
            calc_Cost_FF._page       = new PrintingPress.Page();
            calc_Cost_FF._page.Long  = _page_Long;
            calc_Cost_FF._page.Short = _page_Short;
            calc_Cost_FF.calc_Automatic(ref _inkList, ref _accessoryList, false, false);
            if (calc_Cost_FF._paper.Qty_Fit >= 1)
            {
                _calc_CostList.Add(calc_Cost_FF);
            }

            //Returning Cheapest
            if (_calc_CostList.Count > 0)
            {
                return(_calc_CostList.OrderBy(x => x.cost).First());
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        private void thread_Calculate_Cost()
        {
            //PrintingPress.Cut _cut = _cut;
            PrintingPress.Product _product = new PrintingPress.Product();
            _product.Long   = _product_Long;
            _product.Short  = _product_Short;
            _product.Qty    = _product_Qty;
            _product.Change = _change_Qty;
            _product.Color  = _color_Qty;

            _product.Weight = Convert.ToInt16(cmbweight.SelectedValue);

            List <PrintingPress.calc_Cost> _calc_Cost_PrinterList = new List <PrintingPress.calc_Cost>();

            foreach (PrintingPress.Printer printer in _printerList)
            {
                List <PrintingPress.calc_Cost> _calc_Cost_PaperList = new List <PrintingPress.calc_Cost>();
                foreach (PrintingPress.Paper _paper in _paperList.Where(i => i.Weight == Convert.ToDecimal(_product.Weight)))
                {
                    List <PrintingPress.calc_Cost> _calc_Cost_WorkList = new List <PrintingPress.calc_Cost>();

                    //Minimum
                    PrintingPress.calc_Cost calc_Cost_Min = new PrintingPress.calc_Cost();
                    calc_Cost_Min = return_Cost(_product, _paper, printer,
                                                printer.Min_Long,
                                                printer.Min_Short);
                    if (calc_Cost_Min != null && calc_Cost_Min._paper.Qty_Fit >= 1)
                    {
                        _calc_Cost_WorkList.Add(calc_Cost_Min);
                    }

                    //Maximum
                    PrintingPress.calc_Cost calc_Cost_Max = new PrintingPress.calc_Cost();
                    calc_Cost_Max = return_Cost(_product, _paper, printer,
                                                printer.Max_Long,
                                                printer.Max_Short);
                    if (calc_Cost_Max != null && calc_Cost_Max._paper.Qty_Fit >= 1)
                    {
                        _calc_Cost_WorkList.Add(calc_Cost_Max);
                    }

                    //Optimal based on Integer Min >= Increments >= Max.
                    for (decimal _page_Long = printer.Min_Long; _page_Long < printer.Max_Long; _page_Long += 0.10M)
                    {
                        for (decimal _page_Short = printer.Min_Short; _page_Short < printer.Max_Short; _page_Short += 0.10M)
                        {
                            PrintingPress.calc_Cost calc_Cost_Optimal = new PrintingPress.calc_Cost();
                            calc_Cost_Optimal = return_Cost(_product, _paper, printer,
                                                            _page_Long,
                                                            _page_Short);
                            if (calc_Cost_Optimal != null && calc_Cost_Optimal._paper.Qty_Fit >= 1 && calc_Cost_Optimal._page.Qty_Fit >= 1)
                            {
                                _calc_Cost_WorkList.Add(calc_Cost_Optimal);
                            }
                            calc_Cost_Optimal = null;
                        }
                    }

                    //Gets cheapest Iteration of this Printer and Paper selection.
                    if (_calc_Cost_WorkList.Count != 0)
                    {
                        PrintingPress.calc_Cost _calc_Cost_BestWork = _calc_Cost_WorkList.OrderBy(x => x.cost).First();
                        //_calc_Cost_WorkList.Clear();
                        _calc_Cost_PaperList.Add(_calc_Cost_BestWork);
                    }
                }
                //Gets cheapest Paper in the List
                if (_calc_Cost_PaperList.Count != 0)
                {
                    PrintingPress.calc_Cost _calc_Cost_BestPaper = _calc_Cost_PaperList.OrderBy(x => x.cost).First();
                    //_calc_Cost_PaperList.Clear();
                    _calc_Cost_PrinterList.Add(_calc_Cost_BestPaper);
                }
            }
            //Gets cheapest Printer in the List
            if (_calc_Cost_PrinterList.Count != 0)
            {
                _calc_Cost_BestPrinter = _calc_Cost_PrinterList.OrderBy(x => x.cost).First();
                CollectionViewSource cost_calviewsource = ((CollectionViewSource)(FindResource("cost_calviewsource")));
                cost_calviewsource.Source = _calc_Cost_PrinterList;
            }
            //Task calcCost = Task.Factory.StartNew(() => calculate_Cost());
        }