コード例 #1
0
        protected DataRowCollection GetRows(int year, int month)
        {
            int days = DateTime.DaysInMonth(year, month);

            //"api" is an instance of CPluginApi
            CSelectQuery query = api.Database.NewSelectQuery("Holiday");

            /* ignorepermissions is required for queries against FogBugz tables */
            query.IgnorePermissions = true;
            query.AddSelect("Holiday.ixPerson, dtHoliday, dtHolidayEnd");
            query.AddLeftJoin("Person", "Holiday.ixPerson = Person.ixPerson");
            query.AddSelect("Person.sFullName");
            query.AddWhere("dtHoliday BETWEEN @startRange AND @endRange OR dtHolidayEnd BETWEEN @startRange AND @endRange");
            query.SetParamDate("startRange", new DateTime(year, month, 1));
            query.SetParamDate("endRange", new DateTime(year, month, days));
            query.AddOrderBy("Holiday.ixPerson");

            return(query.GetDataSet().Tables[0].Rows);
        }
コード例 #2
0
        protected List <DateTime> GetPublicHolidays(int year, int month)
        {
            List <DateTime> ret = new List <DateTime>();

            int days = DateTime.DaysInMonth(year, month);

            //"api" is an instance of CPluginApi
            CSelectQuery query = api.Database.NewSelectQuery("Holiday");

            /* ignorepermissions is required for queries against FogBugz tables */
            query.IgnorePermissions = true;
            query.AddSelect("Holiday.ixPerson, dtHoliday, dtHolidayEnd");
            query.AddWhere("ixPerson = 0 AND (dtHoliday BETWEEN @startRange AND @endRange OR dtHolidayEnd BETWEEN @startRange AND @endRange)");
            query.SetParamDate("startRange", new DateTime(year, month, 1));
            query.SetParamDate("endRange", new DateTime(year, month, days));

            DataSet           dataset = query.GetDataSet();
            DataRowCollection rows    = dataset.Tables[0].Rows;

            for (int i = 1; i < days; i++)
            {
                DateTime current = new DateTime(year, month, i);
                for (int j = 0; j < dataset.Tables[0].Rows.Count; j++)
                {
                    DateTime start = Convert.ToDateTime(rows[j][1].ToString());
                    DateTime end   = Convert.ToDateTime(rows[j][2].ToString());

                    if (current >= start && current <= end)
                    {
                        ret.Add(current);
                    }
                }
            }

            return(ret);
        }