コード例 #1
0
        public IEnumerable <ModelMR> GetMeetingRoom(string site, string plant, string loc)
        {
            APIHelper ws = new APIHelper();

            List <ModelMR> lis = ws.GetMeetingRoom(site, plant, loc).ToList <ModelMR>();

            UserInfo vUserInfo = new UserInfo();
            string   userAD    = vUserInfo.UserId.ToLower();
            HR       ff        = new HR();
            DataSet  ds        = ff.GetManager(userAD);

            List <string> DeptArray = ds.Tables[0].AsEnumerable().Select(x => x["DEPTID"].ToString()).ToList();

            ds.Dispose();
            DeptArray.Add(userAD);

            lis = lis.Where(x =>
                            x.ACCESSRIGHT == "" || DeptArray.Any(
                                y => x.ACCESSRIGHT.Contains(y))
                            ).Select(x => x).ToList <ModelMR>();
            return(lis);
        }
コード例 #2
0
        public IEnumerable <ModelRecord> GetFreeEventByRoom(string site, string plant, string loc, string stime)
        {
            APIHelper ws        = new APIHelper();
            UserInfo  vUserInfo = new UserInfo();
            string    userAD    = vUserInfo.UserId.ToLower();

            // 取得有權限的ROOM
            List <ModelMR> lis = ws.GetMeetingRoom(site, plant, loc).ToList <ModelMR>();

            HR            ff        = new HR();
            DataSet       ds        = ff.GetManager(userAD);
            List <string> DeptArray = ds.Tables[0].AsEnumerable().Select(x => x["DEPTID"].ToString()).ToList();

            ds.Dispose();
            DeptArray.Add(userAD);
            lis = lis.Where(x =>
                            x.ACCESSRIGHT == "" || DeptArray.Any(
                                y => x.ACCESSRIGHT.Contains(y))
                            ).Select(x => x).ToList <ModelMR>();

            DateTime dts   = DateTime.Parse(stime);
            string   sdate = dts.ToString("yyyy/MM/dd");


            // 取得結束日期 大於起始時間的記錄
            IEnumerable <ModelRecord> RecordList = ws.GetBookingData(
                sdate, userAD,
                lis.Select(x => x.ROOMID).ToList())
                                                   .Where(x => DateTime.Compare(DateTime.Parse(x.ENDTIME), dts) > 0)
                                                   .ToList <ModelRecord>();

            List <ModelRecord> ret = new List <ModelRecord>();

            foreach (ModelMR mr in lis)
            {
                IEnumerable <ModelRecord> tRecord = RecordList.Where(x => x.ROOMID == mr.ROOMID).ToList();



                if (tRecord.Count() > 0)
                {
                    DateTime minStartTime = RecordList.Where(x => x.ROOMID == mr.ROOMID).Select(x => DateTime.Parse(x.STARTTIME)).Min();
                    if (DateTime.Compare(dts, minStartTime) > 0)
                    {
                        // 此會議室忙碌
                    }
                    else
                    {
                        ret.Add(new ModelRecord {
                            APPLIER    = "PreBooking",
                            APPLIEREXT = "PreBooking",
                            APPLIERID  = "PreBooking",
                            BOOKTYPE   = "PreBooking",
                            DATEDAY    = dts.DayOfWeek.ToString(),
                            ENDTIME    = minStartTime.ToString("yyyy/MM/dd HH:mm:ss"),
                            STARTTIME  = dts.ToString("yyyy/MM/dd HH:mm:ss"),
                            ROOMNAME   = mr.ROOMNAME,
                            RECORDID   = Guid.NewGuid().ToString(),
                            ROOMID     = mr.ROOMID
                        });
                    }
                }

                else
                {
                    ret.Add(new ModelRecord
                    {
                        APPLIER     = "PreBooking",
                        APPLIEREXT  = "PreBooking",
                        APPLIERID   = "PreBooking",
                        BOOKTYPE    = "PreBooking",
                        DATEDAY     = dts.DayOfWeek.ToString(),
                        ENDTIME     = DateTime.Parse(sdate).AddHours(22).ToString("yyyy/MM/dd HH:mm:ss"),
                        STARTTIME   = dts.ToString("yyyy/MM/dd HH:mm:ss"),
                        ROOMNAME    = mr.ROOMNAME,
                        RECORDID    = Guid.NewGuid().ToString(),
                        ROOMID      = mr.ROOMID,
                        ALLOWPERSON = mr.MINP.ToString() + " ~ " + mr.MAXP.ToString()
                    });
                }
            }
            return(ret);
        }