Example #1
0
        public YosanTable(models.db.KaikeiDatabase db, int currentYear, int lastYear, int hoseiKaisuuBegin, int hoseiKaisuuEnd)
        {
            CurrentYear      = currentYear;
            LastYear         = lastYear;
            HoseiKaisuuBegin = hoseiKaisuuBegin;
            HoseiKaisuuEnd   = hoseiKaisuuEnd;
            Db = db;

            kaikeiKubunId2YosanList            = null;
            kamokuKubunId2YosanListIndex       = null;
            kaikeiKubunId2YobihiRow            = null;
            kaikeiKubunId2ZenkimatsuZandakaRow = null;

            dummyRow = new YosanRow(0, 0, "", 0, 0, 0, false);
        }
Example #2
0
        public void InitYosanList(bool withSyoukubun, bool withHojokamoku)
        {
            kamokuKubunId2YosanListIndex       = new Dictionary <int, int>();
            kaikeiKubunId2YosanList            = new Dictionary <int, List <YosanRow> >();
            kaikeiKubunId2YobihiRow            = new Dictionary <int, YosanRow>();
            kaikeiKubunId2ZenkimatsuZandakaRow = new Dictionary <int, YosanRow>();

            foreach (var row in Db.MTKaikeiKubun.Select(""))
            {
                int id = (int)row.GetLong("id", -1);
                kaikeiKubunId2YosanList[id]            = new List <YosanRow>();
                kaikeiKubunId2YobihiRow[id]            = new YosanRow(0, 0, "yobihi", -1, -1, -1, true);
                kaikeiKubunId2ZenkimatsuZandakaRow[id] = new YosanRow(0, 0, "zandaka", -1, -1, -1, true);
            }

            int rootId = (int)models.constants.MTKamokuKubun.ShikinRoot;

            foreach (var kubunRow in Db.MTKamokuKubun.Select("where parent_id = " + rootId + " order by display_order"))
            {
                int kubunId = (int)kubunRow.GetLong("id", -1);

                foreach (var daikubunRow in Db.MTKamokuKubun.Select("where parent_id = " + kubunId + " order by display_order"))
                {
                    int daikubunId = (int)daikubunRow.GetLong("id", -1);
                    foreach (var kamokuRow in Db.MTKamokuKubun.Select("where parent_id = " + daikubunId + " order by display_order"))
                    {
                        var kanjouKamokuRow = Db.MTKanjouKamoku.Select("where id=" + kamokuRow.GetLong("kanjou_kamoku_id", -1)).First();
                        if (!kanjouKamokuRow.GetBool("usable", false))
                        {
                            continue;
                        }
                        int    kamokuId  = (int)kamokuRow.GetLong("id", -1);
                        string kamokuStr = " " + kamokuRow.GetStr("name", "");

                        kamokuKubunId2YosanListIndex[kamokuId] = kaikeiKubunId2YosanList.First().Value.Count;
                        foreach (var pair in kaikeiKubunId2YosanList)
                        {
                            pair.Value.Add(new YosanRow(0, 0, kamokuStr, daikubunId, kubunId, kamokuId, false));
                        }

                        if (withSyoukubun)
                        {
                            foreach (var syoukubunRow in Db.MTKamokuKubun.Select("where parent_id = " + kamokuId + " order by display_order"))
                            {
                                int    syoukubunId  = (int)syoukubunRow.GetLong("id", -1);
                                string syoukubunStr = "  " + syoukubunRow.GetStr("name", "");

                                kamokuKubunId2YosanListIndex[syoukubunId] = kaikeiKubunId2YosanList.First().Value.Count;
                                foreach (var pair in kaikeiKubunId2YosanList)
                                {
                                    pair.Value.Add(new YosanRow(0, 0, syoukubunStr, daikubunId, kubunId, syoukubunId, true));
                                }

                                if (withHojokamoku)
                                {
                                    foreach (var hojoRow in Db.MTKamokuKubun.Select("where parent_id = " + syoukubunId + " order by display_order"))
                                    {
                                        int    hojoId  = (int)hojoRow.GetLong("id", -1);
                                        string hojoStr = "    " + hojoRow.GetStr("name", "");

                                        kamokuKubunId2YosanListIndex[hojoId] = kaikeiKubunId2YosanList.First().Value.Count;
                                        foreach (var pair in kaikeiKubunId2YosanList)
                                        {
                                            pair.Value.Add(new YosanRow(0, 0, hojoStr, daikubunId, kubunId, hojoId, true));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }