Esempio n. 1
0
        public List<Category> GetEssayCategories()
        {
            var categories = new List<Category>();

            foreach (var essayDictItem in essaysDictionary)
            {
                if (!categories.Exists(e => e.Name == essayDictItem.Value.Category))
                {
                    categories.Add(new Category(essayDictItem.Value.Category));
                }

                categories.Single(e => e.Name == essayDictItem.Value.Category).EssaysForCategory.Add(
                    new EssayForCategory(essayDictItem.Value.Title, essayDictItem.Key, essayDictItem.Value.PublishInfo.OriginalPublishDate));
            }

            categories.ForEach(c => c.EssaysForCategory = c.EssaysForCategory.OrderByDescending(e => e.PublishDate).ToList());
            return categories;
        }
Esempio n. 2
0
        private int ThemMoi(BOXuLyKho item, List<BOXuLyKhoChiTiet> lsArray, Transit mTransit)
        {
            if (lsArray != null)
            {
                List<Data.TONKHOTONG> lsTonKhoTong = new List<TONKHOTONG>();
                List<Data.TONKHO> lsTonKho = new List<TONKHO>();
                foreach (BOXuLyKhoChiTiet line in lsArray)
                {
                    IQueryable<Data.TONKHO> lsArrayLine = null;
                    switch (item.XuLyKho.LoaiID)
                    {
                        case 1:
                            lsArrayLine = frmTonKho.Query().Where(s => s.DonViID == line.TonKho.DonViID && s.MonID == line.TonKho.MonID && s.KhoID == item.XuLyKho.KhoID && s.SoLuongTon > 0).OrderBy(s => s.NgayHetHan).ThenBy(s => s.TonKhoID);
                            if (lsArrayLine.Count() > 0 && line.TonKho.SoLuongNhap < lsArrayLine.Sum(s => s.SoLuongTon) && line.TonKho.SoLuongNhap > 0)
                            {
                                foreach (var l in lsArrayLine)
                                {
                                    if (line.TonKho.SoLuongNhap > 0)
                                    {
                                        Data.TONKHOTONG tonkhotong = null;
                                        if (lsTonKhoTong.Exists(s => s.KhoID == item.XuLyKho.KhoID && s.MonID == line.TonKho.MonID && s.DonViID == line.TonKho.DonViID))
                                        {
                                            tonkhotong = lsTonKhoTong.Find(s => s.KhoID == item.XuLyKho.KhoID && s.MonID == line.TonKho.MonID && s.DonViID == line.TonKho.DonViID);
                                        }
                                        else
                                        {
                                            tonkhotong = KiemTraTonKhoTong(frmTonKhoTong, (int)item.XuLyKho.KhoID, (int)line.TonKho.MonID, (int)line.TonKho.DonViID);
                                            lsTonKhoTong.Add(tonkhotong);
                                        }
                                        tonkhotong.SoLuongTon += line.TonKho.SoLuongNhap;
                                        tonkhotong.SoLuongDieuChinh += line.TonKho.SoLuongNhap;
                                        Data.TONKHO tonkho = null;
                                        if (lsTonKho.Exists(s => s.TonKhoID == l.TonKhoID))
                                        {
                                            tonkho = lsTonKho.Find(s => s.TonKhoID == l.TonKhoID);
                                        }
                                        else
                                        {
                                            tonkho = l;
                                            lsTonKho.Add(tonkho);
                                        }
                                        line.XuLyKhoChiTiet.TONKHO = new TONKHO();
                                        line.XuLyKhoChiTiet.TONKHO.PhatSinhTuTonKhoID = tonkho.TonKhoID;
                                        line.XuLyKhoChiTiet.TONKHO.LoaiPhatSinhID = (int)item.XuLyKho.LoaiID;
                                        CopyTonKho(line.XuLyKhoChiTiet.TONKHO, tonkho);

                                        if (tonkho.SoLuongTon > line.TonKho.SoLuongNhap)
                                        {
                                            line.XuLyKhoChiTiet.TONKHO.SoLuongPhatSinh = tonkho.SoLuongTon - line.TonKho.SoLuongNhap;
                                            tonkho.SoLuongTon += line.TonKho.SoLuongNhap;
                                            line.TonKho.SoLuongNhap = 0;
                                        }
                                        else
                                        {
                                            line.XuLyKhoChiTiet.TONKHO.SoLuongPhatSinh = line.TonKho.SoLuongNhap - tonkho.SoLuongTon;
                                            line.TonKho.SoLuongNhap += tonkho.SoLuongTon;
                                            tonkho.SoLuongTon = 0;
                                        }
                                    }
                                }
                            }
                            break;
                        case 2:
                        case 3:
                            lsArrayLine = frmTonKho.Query().Where(s => s.DonViID == line.TonKho.DonViID && s.MonID == line.TonKho.MonID && s.KhoID == item.XuLyKho.KhoID && s.SoLuongTon > 0).OrderBy(s => s.NgayHetHan).ThenBy(s => s.TonKhoID);
                            if (lsArrayLine.Count() > 0 && line.TonKho.SoLuongNhap < lsArrayLine.Sum(s => s.SoLuongTon) && line.TonKho.SoLuongNhap > 0)
                            {
                                foreach (var l in lsArrayLine)
                                {
                                    if (line.TonKho.SoLuongNhap > 0)
                                    {
                                        Data.TONKHOTONG tonkhotong = null;
                                        if (lsTonKhoTong.Exists(s => s.KhoID == item.XuLyKho.KhoID && s.MonID == line.TonKho.MonID && s.DonViID == line.TonKho.DonViID))
                                        {
                                            tonkhotong = lsTonKhoTong.Find(s => s.KhoID == item.XuLyKho.KhoID && s.MonID == line.TonKho.MonID && s.DonViID == line.TonKho.DonViID);
                                        }
                                        else
                                        {
                                            tonkhotong = KiemTraTonKhoTong(frmTonKhoTong, (int)item.XuLyKho.KhoID, (int)line.TonKho.MonID, (int)line.TonKho.DonViID);
                                            lsTonKhoTong.Add(tonkhotong);
                                        }
                                        tonkhotong.SoLuongTon -= line.TonKho.SoLuongNhap;
                                        if (item.XuLyKho.LoaiID == 2)
                                        {
                                            tonkhotong.SoLuongMat += line.TonKho.SoLuongNhap;
                                        }
                                        if (item.XuLyKho.LoaiID == 3)
                                        {
                                            tonkhotong.SoLuongHu += line.TonKho.SoLuongNhap;
                                        }

                                        Data.TONKHO tonkho = null;
                                        if (lsTonKho.Exists(s => s.TonKhoID == l.TonKhoID))
                                        {
                                            tonkho = lsTonKho.Find(s => s.TonKhoID == l.TonKhoID);
                                        }
                                        else
                                        {
                                            tonkho = l;
                                            lsTonKho.Add(tonkho);
                                        }
                                        line.XuLyKhoChiTiet.TONKHO = new TONKHO();
                                        line.XuLyKhoChiTiet.TONKHO.PhatSinhTuTonKhoID = tonkho.TonKhoID;
                                        line.XuLyKhoChiTiet.TONKHO.LoaiPhatSinhID = (int)item.XuLyKho.LoaiID;
                                        CopyTonKho(line.XuLyKhoChiTiet.TONKHO, tonkho);

                                        if (tonkho.SoLuongTon > line.TonKho.SoLuongNhap)
                                        {
                                            line.XuLyKhoChiTiet.TONKHO.SoLuongPhatSinh = tonkho.SoLuongTon - line.TonKho.SoLuongNhap;
                                            tonkho.SoLuongTon -= line.TonKho.SoLuongNhap;
                                            line.TonKho.SoLuongNhap = 0;
                                        }
                                        else
                                        {
                                            line.XuLyKhoChiTiet.TONKHO.SoLuongPhatSinh = line.TonKho.SoLuongNhap - tonkho.SoLuongTon;
                                            line.TonKho.SoLuongNhap -= tonkho.SoLuongTon;
                                            tonkho.SoLuongTon = 0;
                                        }
                                    }
                                }
                            }
                            break;
                        default:
                            break;
                    }

                    line.XuLyKho = new XULYKHO();
                    line.XuLyKho.KhoID = item.XuLyKho.KhoID;
                    item.XuLyKho.XULYKHOCHITIETs.Add(line.XuLyKhoChiTiet);
                }
                item.XuLyKho.TongTien = lsArray.Sum(s => s.TonKho.SoLuongNhap * s.TonKho.GiaBan);
                foreach (TONKHO i in lsTonKho)
                {
                    frmTonKho.Update(i);
                }
                foreach (TONKHOTONG i in lsTonKhoTong)
                {
                    frmTonKhoTong.Update(i);
                }
                frmTonKho.Commit();
                frmTonKhoTong.Commit();
            }
            return item.XuLyKho.ChinhKhoID;
        }
Esempio n. 3
0
            //lastKier - kierunek z ktorego weszlismy 0-gora 1-prawo 2-dol 3-lewo
            private static int[] znajdzDrogePowrotnaRek(int x, int y, int lastKier, List<Wspolrzedne> before, int upCost, int limit)
            {
                if (before.Count > limit)
                {
                    int[] wczesniak = new int[2];
                    wczesniak[0] = limit * cennikSwiata.moveCost * 2;
                    wczesniak[1] = 0;
                    return wczesniak;
                }
                int firstStep = 0;
                int overalCost = limit * cennikSwiata.moveCost;
                int koszt = upCost;

                //Sprawdzenie, czy dalej mamy "po x" czy "po y".
                //if (Math.Abs(mojaPozycjaX - x) > Math.Abs(mojaPozycjaY - y))

                //Sprawdzenie, czy jestesmy u celu!
                #region jestesUCelu
                if ((mojaPozycjaX == x) && (mojaPozycjaY == y))
                {
                    switch (lastKier)
                    {
                        case 0:
                            switch (kierunek[0])
                            {
                                case 1:
                                    koszt += cennikSwiata.rotateCost;
                                    firstStep = 2;
                                    break;
                                case 0:
                                    if (kierunek[1] == 1)
                                    {
                                        firstStep = 1;
                                    }
                                    else
                                    {
                                        koszt += cennikSwiata.rotateCost * 2;
                                        firstStep = 4;
                                    }
                                    break;
                                case -1:
                                    koszt += cennikSwiata.rotateCost;
                                    firstStep = 3;
                                    break;
                            };
                            break;
                        case 1:
                            switch (kierunek[0])
                            {
                                case 1:
                                    firstStep = 1;
                                    break;
                                case 0:
                                    koszt += cennikSwiata.rotateCost;
                                    if (kierunek[1] == 1)
                                    {
                                        firstStep = 3;
                                    }
                                    else
                                    {
                                        firstStep = 2;
                                    }
                                    break;
                                case -1:
                                    koszt += cennikSwiata.rotateCost * 2;
                                    firstStep = 4;
                                    break;
                            };
                            break;
                        case 2:
                            switch (kierunek[0])
                            {
                                case 1:
                                    koszt += cennikSwiata.rotateCost;
                                    firstStep = 3;
                                    break;
                                case 0:
                                    if (kierunek[1] == 1)
                                    {
                                        koszt += cennikSwiata.rotateCost * 2;
                                        firstStep = 4;
                                    }
                                    else
                                    {
                                        firstStep = 1;
                                    }
                                    break;
                                case -1:
                                    koszt += cennikSwiata.rotateCost;
                                    firstStep = 2;
                                    break;
                            };
                            break;
                        case 3:
                            switch (kierunek[0])
                            {
                                case 1:
                                    koszt += cennikSwiata.rotateCost * 2;
                                    firstStep = 4;
                                    break;
                                case 0:
                                    koszt += cennikSwiata.rotateCost;
                                    if (kierunek[1] == 1)
                                    {
                                        firstStep = 2;
                                    }
                                    else
                                    {
                                        firstStep = 3;
                                    }
                                    break;
                                case -1:
                                    firstStep = 1;
                                    break;
                            };
                            break;
                    }
                    overalCost = koszt;
                }
                #endregion
                #region ifZachod
                //Sprawdzenie, czy idziemy na wschod czy na zachod.
                else if (mojaPozycjaX - x > 0)
                {
                    ZbadanePole nextStep = ZnanaMapa.znajdzPole(x + 1, y);
                    before.Add(new Wspolrzedne(x, y));
                    if (nextStep != null)
                        if (!((nextStep.getPrzeszkoda()) || (nextStep.getUnrechable())))
                        {
                            int nextKier = 3;
                            int[] temp = new int[2];
                            temp[0] = upCost;
                            if (!before.Exists(delegate(Wspolrzedne w)
                            {
                                if ((w.x == x + 1) && (w.y == y))
                                    return true;
                                else
                                    return false;
                            }))
                            {
                                if (before.Count > 1)
                                {
                                    ZbadanePole tuStoje = ZnanaMapa.znajdzPole(x, y);
                                    int nowaWysokosc = nextStep.getWysokosc();

                                    temp[0] += cennikSwiata.moveCost;
                                    temp[0] += Convert.ToInt32(Math.Ceiling(Convert.ToDouble
                                        (cennikSwiata.moveCost * (nowaWysokosc - tuStoje
                                        .getWysokosc())) / 100));
                                    if ((lastKier == 0) || (lastKier == 2))
                                        temp[0] += cennikSwiata.rotateCost;
                                    if (lastKier == 1)
                                        temp[0] += cennikSwiata.rotateCost * 2;
                                }
                                temp = znajdzDrogePowrotnaRek(x + 1, y, nextKier, before, temp[0], limit);

                                if (overalCost > temp[0])
                                {
                                    overalCost = temp[0];
                                    firstStep = temp[1];
                                }
                            }
                        }
                    if (mojaPozycjaY - y > 0)
                    {
                        nextStep = ZnanaMapa.znajdzPole(x, y + 1);
                        if (nextStep != null)
                            if (!((nextStep.getPrzeszkoda()) || (nextStep.getUnrechable())))
                            {
                                int nextKier = 2;
                                int[] temp = new int[2];
                                temp[0] = upCost;
                                if (!before.Exists(delegate(Wspolrzedne w)
                                {
                                    if ((w.x == x) && (w.y == y + 1))
                                        return true;
                                    else
                                        return false;
                                }))
                                {
                                    if (before.Count > 1)
                                    {
                                        ZbadanePole tuStoje = ZnanaMapa.znajdzPole(x, y);
                                        int nowaWysokosc = nextStep.getWysokosc();

                                        temp[0] += cennikSwiata.moveCost;
                                        temp[0] += Convert.ToInt32(Math.Ceiling(Convert.ToDouble
                                            (cennikSwiata.moveCost * (nowaWysokosc - tuStoje
                                            .getWysokosc())) / 100));
                                        if ((lastKier == 1) || (lastKier == 3))
                                            temp[0] += cennikSwiata.rotateCost;
                                        if (lastKier == 2)
                                            temp[0] += cennikSwiata.rotateCost * 2;
                                    }
                                    temp = znajdzDrogePowrotnaRek(x, y + 1, nextKier, before, temp[0], limit);

                                    if (overalCost > temp[0])
                                    {
                                        overalCost = temp[0];
                                        firstStep = temp[1];
                                    }
                                }
                            }
                        nextStep = ZnanaMapa.znajdzPole(x, y - 1);
                        if (nextStep != null)
                            if (!((nextStep.getPrzeszkoda()) || (nextStep.getUnrechable())))
                            {
                                int nextKier = 0;
                                int[] temp = new int[2];
                                temp[0] = upCost;
                                if (!before.Exists(delegate(Wspolrzedne w)
                                {
                                    if ((w.x == x) && (w.y == y - 1))
                                        return true;
                                    else
                                        return false;
                                }))
                                {
                                    if (before.Count > 1)
                                    {
                                        ZbadanePole tuStoje = ZnanaMapa.znajdzPole(x, y);
                                        int nowaWysokosc = nextStep.getWysokosc();

                                        temp[0] += cennikSwiata.moveCost;
                                        temp[0] += Convert.ToInt32(Math.Ceiling(Convert.ToDouble
                                            (cennikSwiata.moveCost * (nowaWysokosc - tuStoje
                                            .getWysokosc())) / 100));
                                        if ((lastKier == 1) || (lastKier == 3))
                                            temp[0] += cennikSwiata.rotateCost;
                                        if (lastKier == 0)
                                            temp[0] += cennikSwiata.rotateCost * 2;
                                    }
                                    temp = znajdzDrogePowrotnaRek(x, y - 1, nextKier, before, temp[0], limit);

                                    if (overalCost > temp[0])
                                    {
                                        overalCost = temp[0];
                                        firstStep = temp[1];
                                    }
                                }
                            }
                    }
                    else
                    {
                        nextStep = ZnanaMapa.znajdzPole(x, y - 1);
                        if (nextStep != null)
                            if (!((nextStep.getPrzeszkoda()) || (nextStep.getUnrechable())))
                            {
                                int nextKier = 0;
                                int[] temp = new int[2];
                                temp[0] = upCost;
                                if (!before.Exists(delegate(Wspolrzedne w)
                                {
                                    if ((w.x == x) && (w.y == y - 1))
                                        return true;
                                    else
                                        return false;
                                }))
                                {
                                    if (before.Count > 1)
                                    {
                                        ZbadanePole tuStoje = ZnanaMapa.znajdzPole(x, y);
                                        int nowaWysokosc = nextStep.getWysokosc();

                                        temp[0] += cennikSwiata.moveCost;
                                        temp[0] += Convert.ToInt32(Math.Ceiling(Convert.ToDouble
                                            (cennikSwiata.moveCost * (nowaWysokosc - tuStoje
                                            .getWysokosc())) / 100));
                                        if ((lastKier == 1) || (lastKier == 3))
                                            temp[0] += cennikSwiata.rotateCost;
                                        if (lastKier == 0)
                                            temp[0] += cennikSwiata.rotateCost * 2;
                                    }
                                    temp = znajdzDrogePowrotnaRek(x, y - 1, nextKier, before, temp[0], limit);

                                    if (overalCost > temp[0])
                                    {
                                        overalCost = temp[0];
                                        firstStep = temp[1];
                                    }
                                }
                            }
                        nextStep = ZnanaMapa.znajdzPole(x, y + 1);
                        if (nextStep != null)
                            if (!((nextStep.getPrzeszkoda()) || (nextStep.getUnrechable())))
                            {
                                int nextKier = 2;
                                int[] temp = new int[2];
                                temp[0] = upCost;
                                if (!before.Exists(delegate(Wspolrzedne w)
                                {
                                    if ((w.x == x) && (w.y == y + 1))
                                        return true;
                                    else
                                        return false;
                                }))
                                {
                                    if (before.Count > 1)
                                    {
                                        ZbadanePole tuStoje = ZnanaMapa.znajdzPole(x, y);
                                        int nowaWysokosc = nextStep.getWysokosc();

                                        temp[0] += cennikSwiata.moveCost;
                                        temp[0] += Convert.ToInt32(Math.Ceiling(Convert.ToDouble
                                            (cennikSwiata.moveCost * (nowaWysokosc - tuStoje
                                            .getWysokosc())) / 100));
                                        if ((lastKier == 1) || (lastKier == 3))
                                            temp[0] += cennikSwiata.rotateCost;
                                        if (lastKier == 2)
                                            temp[0] += cennikSwiata.rotateCost * 2;
                                    }
                                    temp = znajdzDrogePowrotnaRek(x, y + 1, nextKier, before, temp[0], limit);

                                    if (overalCost > temp[0])
                                    {
                                        overalCost = temp[0];
                                        firstStep = temp[1];
                                    }
                                }
                            }
                    }
                    nextStep = ZnanaMapa.znajdzPole(x - 1, y);
                    if (nextStep != null)
                        if (!((nextStep.getPrzeszkoda()) || (nextStep.getUnrechable())))
                        {
                            int nextKier = 1;
                            int[] temp = new int[2];
                            temp[0] = upCost;
                            if (!before.Exists(delegate(Wspolrzedne w)
                            {
                                if ((w.x == x - 1) && (w.y == y))
                                    return true;
                                else
                                    return false;
                            }))
                            {
                                if (before.Count > 1)
                                {
                                    ZbadanePole tuStoje = ZnanaMapa.znajdzPole(x, y);
                                    int nowaWysokosc = nextStep.getWysokosc();

                                    temp[0] += cennikSwiata.moveCost;
                                    temp[0] += Convert.ToInt32(Math.Ceiling(Convert.ToDouble
                                        (cennikSwiata.moveCost * (nowaWysokosc - tuStoje
                                        .getWysokosc())) / 100));
                                    if ((lastKier == 0) || (lastKier == 2))
                                        temp[0] += cennikSwiata.rotateCost;
                                    if (lastKier == 3)
                                        temp[0] += cennikSwiata.rotateCost * 2;
                                }
                                temp = znajdzDrogePowrotnaRek(x - 1, y, nextKier, before, temp[0], limit);

                                if (overalCost > temp[0])
                                {
                                    overalCost = temp[0];
                                    firstStep = temp[1];
                                }
                            }
                        }
                }
                #endregion
                #region elseWschod
                else //Idziemy na wschod
                {
                    ZbadanePole nextStep = ZnanaMapa.znajdzPole(x - 1, y);
                    before.Add(new Wspolrzedne(x, y));
                    if (nextStep != null)
                        if (!((nextStep.getPrzeszkoda()) || (nextStep.getUnrechable())))
                        {
                            int nextKier = 1;
                            int[] temp = new int[2];
                            temp[0] = upCost;
                            if (!before.Exists(delegate(Wspolrzedne w)
                            {
                                if ((w.x == x - 1) && (w.y == y))
                                    return true;
                                else
                                    return false;
                            }))
                            {
                                if (before.Count > 1)
                                {
                                    ZbadanePole tuStoje = ZnanaMapa.znajdzPole(x, y);
                                    int nowaWysokosc = nextStep.getWysokosc();

                                    temp[0] += cennikSwiata.moveCost;
                                    temp[0] += Convert.ToInt32(Math.Ceiling(Convert.ToDouble
                                        (cennikSwiata.moveCost * (nowaWysokosc - tuStoje
                                        .getWysokosc())) / 100));
                                    if ((lastKier == 0) || (lastKier == 2))
                                        temp[0] += cennikSwiata.rotateCost;
                                    if (lastKier == 3)
                                        temp[0] += cennikSwiata.rotateCost * 2;
                                }
                                temp = znajdzDrogePowrotnaRek(x - 1, y, nextKier, before, temp[0], limit);

                                if (overalCost > temp[0])
                                {
                                    overalCost = temp[0];
                                    firstStep = temp[1];
                                }
                            }
                        }
                    if (mojaPozycjaY - y > 0)
                    {
                        nextStep = ZnanaMapa.znajdzPole(x, y + 1);
                        if (nextStep != null)
                            if (!((nextStep.getPrzeszkoda()) || (nextStep.getUnrechable())))
                            {
                                int nextKier = 2;
                                int[] temp = new int[2];
                                temp[0] = upCost;
                                if (!before.Exists(delegate(Wspolrzedne w)
                                {
                                    if ((w.x == x) && (w.y == y + 1))
                                        return true;
                                    else
                                        return false;
                                }))
                                {
                                    if (before.Count > 1)
                                    {
                                        ZbadanePole tuStoje = ZnanaMapa.znajdzPole(x, y);
                                        int nowaWysokosc = nextStep.getWysokosc();

                                        temp[0] += cennikSwiata.moveCost;
                                        temp[0] += Convert.ToInt32(Math.Ceiling(Convert.ToDouble
                                            (cennikSwiata.moveCost * (nowaWysokosc - tuStoje
                                            .getWysokosc())) / 100));
                                        if ((lastKier == 1) || (lastKier == 3))
                                            temp[0] += cennikSwiata.rotateCost;
                                        if (lastKier == 2)
                                            temp[0] += cennikSwiata.rotateCost * 2;
                                    }
                                    temp = znajdzDrogePowrotnaRek(x, y + 1, nextKier, before, temp[0], limit);

                                    if (overalCost > temp[0])
                                    {
                                        overalCost = temp[0];
                                        firstStep = temp[1];
                                    }
                                }
                            }
                        nextStep = ZnanaMapa.znajdzPole(x, y - 1);
                        if (nextStep != null)
                            if (!((nextStep.getPrzeszkoda()) || (nextStep.getUnrechable())))
                            {
                                int nextKier = 0;
                                int[] temp = new int[2];
                                temp[0] = upCost;
                                if (!before.Exists(delegate(Wspolrzedne w)
                                {
                                    if ((w.x == x) && (w.y == y - 1))
                                        return true;
                                    else
                                        return false;
                                }))
                                {
                                    if (before.Count > 1)
                                    {
                                        ZbadanePole tuStoje = ZnanaMapa.znajdzPole(x, y);
                                        int nowaWysokosc = nextStep.getWysokosc();

                                        temp[0] += cennikSwiata.moveCost;
                                        temp[0] += Convert.ToInt32(Math.Ceiling(Convert.ToDouble
                                            (cennikSwiata.moveCost * (nowaWysokosc - tuStoje
                                            .getWysokosc())) / 100));
                                        if ((lastKier == 1) || (lastKier == 3))
                                            temp[0] += cennikSwiata.rotateCost;
                                        if (lastKier == 0)
                                            temp[0] += cennikSwiata.rotateCost * 2;
                                    }
                                    temp = znajdzDrogePowrotnaRek(x, y - 1, nextKier, before, temp[0], limit);

                                    if (overalCost > temp[0])
                                    {
                                        overalCost = temp[0];
                                        firstStep = temp[1];
                                    }
                                }
                            }
                    }
                    else
                    {
                        nextStep = ZnanaMapa.znajdzPole(x, y - 1);
                        if (nextStep != null)
                            if (!((nextStep.getPrzeszkoda()) || (nextStep.getUnrechable())))
                            {
                                int nextKier = 0;
                                int[] temp = new int[2];
                                temp[0] = upCost;
                                if (!before.Exists(delegate(Wspolrzedne w)
                                {
                                    if ((w.x == x) && (w.y == y - 1))
                                        return true;
                                    else
                                        return false;
                                }))
                                {
                                    if (before.Count > 1)
                                    {
                                        ZbadanePole tuStoje = ZnanaMapa.znajdzPole(x, y);
                                        int nowaWysokosc = nextStep.getWysokosc();

                                        temp[0] += cennikSwiata.moveCost;
                                        temp[0] += Convert.ToInt32(Math.Ceiling(Convert.ToDouble
                                            (cennikSwiata.moveCost * (nowaWysokosc - tuStoje
                                            .getWysokosc())) / 100));
                                        if ((lastKier == 1) || (lastKier == 3))
                                            temp[0] += cennikSwiata.rotateCost;
                                        if (lastKier == 0)
                                            temp[0] += cennikSwiata.rotateCost * 2;
                                    }
                                    temp = znajdzDrogePowrotnaRek(x, y - 1, nextKier, before, temp[0], limit);

                                    if (overalCost > temp[0])
                                    {
                                        overalCost = temp[0];
                                        firstStep = temp[1];
                                    }
                                }
                            }
                        nextStep = ZnanaMapa.znajdzPole(x, y + 1);
                        if (nextStep != null)
                            if (!((nextStep.getPrzeszkoda()) || (nextStep.getUnrechable())))
                            {
                                int nextKier = 2;
                                int[] temp = new int[2];
                                temp[0] = upCost;
                                if (!before.Exists(delegate(Wspolrzedne w)
                                {
                                    if ((w.x == x) && (w.y == y + 1))
                                        return true;
                                    else
                                        return false;
                                }))
                                {
                                    if (before.Count > 1)
                                    {
                                        ZbadanePole tuStoje = ZnanaMapa.znajdzPole(x, y);
                                        int nowaWysokosc = nextStep.getWysokosc();

                                        temp[0] += cennikSwiata.moveCost;
                                        temp[0] += Convert.ToInt32(Math.Ceiling(Convert.ToDouble
                                            (cennikSwiata.moveCost * (nowaWysokosc - tuStoje
                                            .getWysokosc())) / 100));
                                        if ((lastKier == 1) || (lastKier == 3))
                                            temp[0] += cennikSwiata.rotateCost;
                                        if (lastKier == 2)
                                            temp[0] += cennikSwiata.rotateCost * 2;
                                    }
                                    temp = znajdzDrogePowrotnaRek(x, y + 1, nextKier, before, temp[0], limit);

                                    if (overalCost > temp[0])
                                    {
                                        overalCost = temp[0];
                                        firstStep = temp[1];
                                    }
                                }
                            }
                    }
                    nextStep = ZnanaMapa.znajdzPole(x + 1, y);
                    if (nextStep != null)
                        if (!((nextStep.getPrzeszkoda()) || (nextStep.getUnrechable())))
                        {
                            int nextKier = 3;
                            int[] temp = new int[2];
                            temp[0] = upCost;
                            if (!before.Exists(delegate(Wspolrzedne w)
                            {
                                if ((w.x == x + 1) && (w.y == y))
                                    return true;
                                else
                                    return false;
                            }))
                            {
                                if (before.Count > 1)
                                {
                                    ZbadanePole tuStoje = ZnanaMapa.znajdzPole(x, y);
                                    int nowaWysokosc = nextStep.getWysokosc();

                                    temp[0] += cennikSwiata.moveCost;
                                    temp[0] += Convert.ToInt32(Math.Ceiling(Convert.ToDouble
                                        (cennikSwiata.moveCost * (nowaWysokosc - tuStoje
                                        .getWysokosc())) / 100));
                                    if ((lastKier == 0) || (lastKier == 2))
                                        temp[0] += cennikSwiata.rotateCost;
                                    if (lastKier == 1)
                                        temp[0] += cennikSwiata.rotateCost * 2;
                                }
                                temp = znajdzDrogePowrotnaRek(x + 1, y, nextKier, before, temp[0], limit);

                                if (overalCost > temp[0])
                                {
                                    overalCost = temp[0];
                                    firstStep = temp[1];
                                }
                            }
                        }
                }
                #endregion
                before.Remove(
                    before.Find(delegate(Wspolrzedne w)
                    {
                        if ((w.x == x) && (w.y == y))
                            return true;
                        else
                            return false;
                    })
                );
                int[] zwrot = new int[2];
                zwrot[0] = overalCost;
                zwrot[1] = firstStep;
                return zwrot;
            }
Esempio n. 4
0
        public List<Year> GetEssayYears()
        {
            var years = new List<Year>();

            foreach (var essayDictItem in essaysDictionary)
            {
                if (!years.Exists(e => e.YearValue == essayDictItem.Value.PublishYear))
                {
                    years.Add(new Year(essayDictItem.Value.PublishYear));
                }

                years.Single(e => e.YearValue == essayDictItem.Value.PublishYear).EssaysForYear.Add(
                    new EssayForYear(essayDictItem.Value.Title, essayDictItem.Key, essayDictItem.Value.Category, essayDictItem.Value.PublishInfo.OriginalPublishDate));
            }

            years.ForEach(c => c.EssaysForYear = c.EssaysForYear.OrderByDescending(e => e.PublishDate).ToList());
            return years.OrderByDescending(y => y.YearValue).ToList();
        }