示例#1
0
        /// <summary>
        /// Initiailize with current year and month.
        /// Author: ChuyangLiu
        /// </summary>
        public CalendarPageViewModel()
        {
            DateTime today = DateTime.Today;

            DayGrids = new DayGridCollection(today.Year, today.Month);
            Weeks    = new WeekCollection();
        }
示例#2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <returns></returns>
        public static List <WeekInfo> GetList()
        {
            string cacheKey = GetCacheKey();

            //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
            if (CachedEntityCommander.IsTypeRegistered(typeof(WeekInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
            {
                return(CachedEntityCommander.GetCache(cacheKey) as List <WeekInfo>);
            }
            else
            {
                List <WeekInfo> list       = new List <WeekInfo>();
                WeekCollection  collection = new  WeekCollection();
                Query           qry        = new Query(Week.Schema);
                collection.LoadAndCloseReader(qry.ExecuteReader());
                foreach (Week week in collection)
                {
                    WeekInfo weekInfo = new WeekInfo();
                    LoadFromDAL(weekInfo, week);
                    list.Add(weekInfo);
                }
                //生成缓存
                if (CachedEntityCommander.IsTypeRegistered(typeof(WeekInfo)))
                {
                    CachedEntityCommander.SetCache(cacheKey, list);
                }
                return(list);
            }
        }
示例#3
0
    public static WeekCollection GetWeek(int CourseID, int SemesterID, string Session, int FillBy)
    {
        WeekCollection WC = new WeekCollection();

        NewDAL.DBManager objDB = new DBManager();
        objDB.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["FeesManagementConn"].ConnectionString;
        objDB.DBManager(DataAccessLayer.DataProvider.SqlServer, objDB.ConnectionString);
        objDB.Open();
        objDB.CreateParameters(4);
        objDB.AddParameters(0, "CourseID", CourseID, DbType.Int32);
        objDB.AddParameters(1, "Session", Session, DbType.String);
        objDB.AddParameters(2, "SemesterID", SemesterID, DbType.Int32);
        objDB.AddParameters(3, "FillBy", FillBy, DbType.Int32);
        SqlDataReader dr = (SqlDataReader)objDB.ExecuteReader(CommandType.StoredProcedure, "FillWeek");

        while (dr.Read())
        {
            TimeTableDM.WeekFill week = new TimeTableDM.WeekFill();
            week.weekID   = Education.DataHelper.GetInt(dr, "weekID");
            week.WeekName = Education.DataHelper.GetString(dr, "WeekName");
            WC.Add(week);
        }
        objDB.DataReader.Close();
        objDB.Connection.Close();
        return(WC);
    }
示例#4
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List <WeekInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <WeekInfo> list = new List <WeekInfo>();

            Query q = Week.CreateQuery();

            q.PageIndex = pPageIndex;
            q.PageSize  = pPageSize;
            q.ORDER_BY(pSortExpression, pOrderBy.ToString());
            WeekCollection collection = new  WeekCollection();

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Week week  in collection)
            {
                WeekInfo weekInfo = new WeekInfo();
                LoadFromDAL(weekInfo, week);
                list.Add(weekInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
示例#5
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List <WeekInfo> pList, WeekCollection pCollection)
 {
     foreach (Week week in pCollection)
     {
         WeekInfo weekInfo = new WeekInfo();
         LoadFromDAL(weekInfo, week);
         pList.Add(weekInfo);
     }
 }
        public ActionResult Index(int?year, int?userId)
        {
            var model    = new HourIndexModel();
            var projects = ProjectRepository.ProjectFetchInfoList();

            model.UserId = userId ?? ((IBusinessIdentity)Csla.ApplicationContext.User.Identity).UserId;

            var weeks = WeekCollection.GetWeeks(year ?? DateTime.Now.Year);

            model.Weeks = weeks;

            var criteria =
                new HourDataCriteria
            {
                Date   = CriteriaHelper.ToDateRangeCriteria(weeks.StartDate, weeks.EndDate),
                UserId = model.UserId
            };

            var hours = HourRepository.HourFetchInfoList(criteria);

            model.Hours = hours;

            model.Year = year ?? DateTime.Now.Year;

            var years = new List <int>();

            for (var currentYear = year ?? DateTime.Now.Year; currentYear <= DateTime.Now.Year; currentYear++)
            {
                years.Add(currentYear);
            }

            model.Years = years;

            var users = UserRepository.UserFetchInfoList(projects);

            model.Users = users;

            return(this.View(model));
        }
        public ActionResult Index()
        {
            var model = new HomeIndexModel();
            var user  = UserRepository.UserFetch();

            model.User             = user;
            model.StartDate        = DateTime.Now.AddDays(-48).ToStartOfWeek(Settings.StartDayOfWeek).Date;
            model.EndDate          = DateTime.Now.ToStartOfWeek(Settings.StartDayOfWeek).Date.AddDays(6);
            model.Hours            = HourRepository.HourFetchInfoList(user, model.StartDate, model.EndDate);
            model.ProjectListModel =
                new ProjectListModel
            {
                Projects = ProjectRepository.ProjectFetchInfoList()
            };
            model.FeedListModel =
                new FeedListModel
            {
                Feeds = FeedRepository.FeedFetchInfoList(20)
            };
            model.TimelineListModel =
                new TimelineListModel
            {
                Timelines    = TimelineRepository.TimelineFetchInfoList(model.User),
                SourceId     = model.User.SourceId,
                SourceTypeId = (int)model.User.SourceType
            };
            model.CurrentWeekHourSummaryByDateListModel =
                new HourSummaryByDateListModel
            {
                User  = user,
                Hours = this.FetchHoursForWeek(
                    DateTime.Now.ToStartOfWeek(Settings.StartDayOfWeek),
                    model.Hours)
            };
            model.TrailingWeeksHourSummaryByDateListModel =
                new HourSummaryByDateListModel
            {
                User  = user,
                Hours = this.FetchHoursForTrailingWeeks(
                    model.StartDate,
                    model.EndDate,
                    model.Hours)
            };


            var weeks = WeekCollection.GetWeeks(DateTime.Now.Year);

            var hours = HourRepository.HourFetchInfoList(
                user, weeks.Min(row => row.StartDate), weeks.Max(row => row.EndDate));
            var hourSummaries = new List <HourSummary>();

            hourSummaries.Add(
                new HourSummary
            {
                Name        = "Week",
                Value       = (double)hours.Where(row => row.Date >= weeks.StartDate.Date && row.Date <= weeks.StartDate.AddDays(6)).Sum(row => row.Duration),
                NormalValue = 25
            });
            hourSummaries.Add(
                new HourSummary
            {
                Name        = "Year",
                Value       = (double)hours.Sum(row => row.Duration),
                NormalValue = 1250
            });

            model.HourSummaryListModel =
                new HourSummaryListModel
            {
                User  = user,
                Hours = hourSummaries
            };

            return(View(model));
        }
示例#8
0
 /// <summary>
 /// Initiailize with given year and month.
 /// Author: ChuyangLiu
 /// </summary>
 public CalendarPageViewModel(int year, int month)
 {
     DayGrids = new DayGridCollection(year, month);
     Weeks    = new WeekCollection();
 }
示例#9
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< WeekInfo> pList, WeekCollection pCollection)
 {
     foreach (Week week in pCollection)
     {
         WeekInfo weekInfo = new WeekInfo();
         LoadFromDAL(weekInfo, week );
         pList.Add(weekInfo);
     }
 }
示例#10
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<WeekInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< WeekInfo> list = new List< WeekInfo>();

            Query q = Week .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            WeekCollection  collection=new  WeekCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Week  week  in collection)
            {
                WeekInfo weekInfo = new WeekInfo();
                LoadFromDAL(weekInfo,   week);
                list.Add(weekInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
示例#11
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<WeekInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(WeekInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< WeekInfo>;
     }
     else
     {
         List< WeekInfo>  list =new List< WeekInfo>();
         WeekCollection  collection=new  WeekCollection();
         Query qry = new Query(Week.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(Week week in collection)
         {
             WeekInfo weekInfo= new WeekInfo();
             LoadFromDAL(weekInfo,week);
             list.Add(weekInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(WeekInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }