示例#1
0
        public static void MakeFuck(MySqlConnection sql, int femaleId, int maleId, int daysPast, int worker, bool syntetic)
        {
            OneRabbit f    = RabbitGetter.GetRabbit(sql, femaleId);
            String    type = F**k.GetFuckTypeStr(FuckType.Sluchka);
            string    when = DBHelper.DaysPastSqlDate(daysPast);

            if (syntetic)
            {
                type = F**k.GetFuckTypeStr(FuckType.Syntetic);
            }
            else if (f.Status > 0)
            {
                type = F**k.GetFuckTypeStr(FuckType.Vyazka);
            }
            MySqlCommand cmd = new MySqlCommand(String.Format("UPDATE f***s SET f_last=0 WHERE f_rabid={0:d};", femaleId), sql);

            cmd.ExecuteNonQuery();
            cmd.CommandText = String.Format(@"INSERT INTO f***s(f_rabid,f_date,f_partner,f_state,f_type,f_last,f_notes,f_worker) 
VALUES({0:d},{1:s},{2:d},'sukrol','{3:s}',1,'',{4:d});", femaleId, when, maleId, type, worker);
            cmd.ExecuteNonQuery();
            //            cmd.CommandText = String.Format("SELECT r_status,TODAYS(r_last_fuck_okrol FROM rabbits WHERE r_id=");
            cmd.CommandText = String.Format("UPDATE rabbits SET r_event_date={0:s}, r_event='{1:s}', r_rate=r_rate+IF(MONTH(r_event_date) BETWEEN 8 AND 12,{3:d},0) WHERE r_id={2:d};",
                                            when, type, femaleId, Rate.AUTUMN_FUCK_RATE);
            cmd.ExecuteNonQuery();
            if (!syntetic)///если ИО то не ставим, что самец работал
            {
                cmd.CommandText = String.Format("UPDATE rabbits SET r_last_fuck_okrol={0:s}, r_rate=r_rate+1 WHERE r_id={1:d};",
                                                when, maleId);
                cmd.ExecuteNonQuery();
            }
        }
示例#2
0
        /// <summary>
        /// Получает родословную кролика с заданным rabId
        /// </summary>
        /// <param name="rabId">ID кролика</param>
        /// <param name="con"></param>
        /// <param name="lineage">Стэк родословной для предотвращения рекурсии</param>
        /// <returns></returns>
        private static RabTreeData getRabbitGenTree(MySqlConnection con, int rabId, int birthplace, int nameId, Stack <int> lineage)//, int level)
        {
            if (rabId == 0)
            {
                return(null);
            }
            //проверка на рекурсию, которая могла возникнуть после конвертации из старой mia-файла
            if (lineage.Count > 700)
            {
                //_logger.Warn("cnt:" + lineage.Count.ToString() + " we have suspect infinity inheritance loop: " + String.Join(",", Array.ConvertAll<int, string>(lineage.ToArray(), new Converter<int, string>(convIntToString))));
                return(null);
            }
            lineage.Push(rabId);
            MySqlCommand    cmd    = new MySqlCommand("", con);
            MySqlDataReader rd     = null;
            RabAliveState   state  = RabAliveState.ALIVE;
            bool            inFarm = true;
            string          query  = @"SELECT
        r_id,
        {0:s} name,
        Coalesce(r_name,0) AS r_name,
        Coalesce(r_surname,0) AS r_surname,
        Coalesce(r_secname,0) AS r_secname,      
        Coalesce(r_mother, 0) AS r_mother,
        Coalesce(r_father, 0) AS r_father,
        r_bon,
        r_born,
        r_breed,
        b_short_name,
        TO_DAYS(NOW())-TO_DAYS(r_born) age,
        Coalesce(r_birthplace,0) birthplace
    FROM {1:s} 
        INNER JOIN breeds ON b_id = r_breed
    WHERE r_id={2:d} LIMIT 1;";

#if !DEMO
            if (birthplace != 0)  //если ищем импортированного кролика
            {
                List <OneImport> lst = Import.Search(con, new Filters(Filters.RAB_ID, rabId.ToString()));
                inFarm = lst.Count > 0;                                       ///если кролик не был импортирован в поголовье
                ///может возникнуть ситуация, что импортированный кролик имеет id родителя, который содержится и в import_ascendants и в imports
                if (inFarm && Import.AscendantExists(con, rabId, birthplace)) ///устранение неоднозначности
                {
                    inFarm = RabbitGetter.GetRabbit(con, rabId).NameID == nameId;
                }
            }
#endif

            if (inFarm)
            {
                cmd.CommandText = String.Format(query, "rabname(r_id,1)", "rabbits", rabId);
                rd = cmd.ExecuteReader();

                if (!rd.HasRows)
                {
                    rd.Close();
                    cmd.CommandText = String.Format(query, "deadname(r_id,1)", "dead", rabId);
                    rd    = cmd.ExecuteReader();
                    state = RabAliveState.DEAD;
                }
            }

            if (!inFarm)
            {
                cmd.CommandText = String.Format(query, String.Format("ascname(r_id,{0:d},1)", birthplace), "import_ascendants", rabId);
                rd    = cmd.ExecuteReader();
                state = RabAliveState.IMPORTED_ASCENDANT;
            }

            RabTreeData res = null;
            if (rd != null && rd.Read())
            {
                res = new RabTreeData(
                    rd.GetInt32("r_id"),
                    rd.GetString("name"),
                    rd.GetInt32("r_name"),
                    rd.GetDateTime("r_born"),
                    rd.GetInt32("r_breed")
                    );
                res.Bon            = Rabbit.GetFBon(rd.GetString("r_bon"), true);
                res.BreedShortName = rd.GetString("b_short_name");
                res.BirthPlace     = rd.GetInt32("birthplace");
                int mom     = rd.GetInt32("r_mother");
                int dad     = rd.GetInt32("r_father");
                int surname = rd.GetInt32("r_surname");
                int secname = rd.GetInt32("r_secname");
                rd.Close();

                res.State = state;
                RabTreeData m = getRabbitGenTree(con, mom, birthplace, surname, lineage);
                RabTreeData d = getRabbitGenTree(con, dad, birthplace, secname, lineage);
                if (m != null)
                {
                    res.Mother = m;
                }
                if (d != null)
                {
                    res.Father = d;
                }
            }
            rd.Close();
            return(res);
        }
示例#3
0
 public OneRabbit GetRabbit(int rid, RabAliveState state)
 {
     return(RabbitGetter.GetRabbit(sql, rid, state));
 }
示例#4
0
 public OneRabbit GetRabbit(int rid)
 {
     return(RabbitGetter.GetRabbit(sql, rid));
 }