public ActionResult Search(SearchParam param)
        {
            var list = dc.Set <V_Resource>().Where(a => a.ResourceKindID == 4 && ParkList.Contains(a.Loc1));

            if (!string.IsNullOrEmpty(param.Park))
            {
                list = list.Where(a => a.Loc1 == param.Park);
            }
            if (!string.IsNullOrEmpty(param.ID))
            {
                list = list.Where(a => a.ID.Contains(param.ID));
            }
            if (!string.IsNullOrEmpty(param.Name))
            {
                list = list.Where(a => a.Name.Contains(param.Name));
            }
            if (!string.IsNullOrEmpty(param.Cust))
            {
                list = list.Where(a => a.CustLongName.Contains(param.Cust));
            }
            if (!string.IsNullOrEmpty(param.Group))
            {
                list = list.Where(a => a.GroupName.Contains(param.Group));
            }
            int count = list.Count();

            list = list.OrderBy(a => a.ID).Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize);
            return(Json(new { count = count, data = list.ToList() }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Search(SearchParam param)
        {
            var list = dc.Set <V_Stage>().Where(a => ParkList.Contains(a.ParkID));

            if (!string.IsNullOrEmpty(param.Park))
            {
                list = list.Where(a => a.ParkID == param.Park);
            }
            if (!string.IsNullOrEmpty(param.ID))
            {
                list = list.Where(a => a.ID.Contains(param.ID));
            }
            if (!string.IsNullOrEmpty(param.Name))
            {
                list = list.Where(a => a.Name.Contains(param.Name));
            }
            if (param.Enable != null)
            {
                list = list.Where(a => a.Enable == param.Enable);
            }
            int count = list.Count();

            list = list.OrderBy(a => a.ID).Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize);
            return(Json(new { count = count, data = list.ToList() }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult PublicSearch(SearchParam param)
        {
            string[] pubList = dc.Set <T_ResourcePublic>().Where(a => a.Status != 6).Select(a => a.ResourceID).ToArray();
            var      list    = dc.Set <V_Resource>().Where(a => !pubList.Contains(a.ID));

            if (!string.IsNullOrEmpty(param.Park))
            {
                list = list.Where(a => a.Loc1 == param.Park);
            }
            else
            {
                list = list.Where(a => ParkList.Contains(a.Loc1));
            }
            if (!string.IsNullOrEmpty(param.ID))
            {
                list = list.Where(a => a.ID.Contains(param.ID));
            }
            if (!string.IsNullOrEmpty(param.Name))
            {
                list = list.Where(a => a.Name.Contains(param.Name));
            }
            if (!string.IsNullOrEmpty(param.Group))
            {
                list = list.Where(a => a.GroupID == param.Group);
            }
            if (param.Kind != null)
            {
                list = list.Where(a => a.ResourceKindID == param.Kind);
            }
            int count = list.Count();

            list = list.OrderBy(a => a.ResourceKindID).Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize);
            return(Json(new { count = count, data = list.ToList() }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Search(SearchParam param)
        {
            var list = dc.Set <V_Resource>().Where(a => a.ResourceKindID == 3 && ParkList.Contains(a.Loc1));

            if (!string.IsNullOrEmpty(param.Park))
            {
                list = list.Where(a => a.Loc1 == param.Park);
            }
            if (!string.IsNullOrEmpty(param.ID))
            {
                list = list.Where(a => a.ID.Contains(param.ID));
            }
            if (!string.IsNullOrEmpty(param.Name))
            {
                list = list.Where(a => a.Name.Contains(param.Name));
            }
            int count = list.Count();

            list = list.OrderBy(a => a.ID).Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize);
            var obj = list.Select(a => new
            {
                a.ID,
                a.Name,
                a.Loc1Name,
                a.ResourceTypeName,
                a.GroupName,
                a.Enable,
                a.RangeNum
            }).ToList();

            return(Json(new { count = count, data = obj }, JsonRequestBehavior.AllowGet));
        }
        public ContentResult Search(SearchParam param)
        {
            var list = dc.Set <V_Public>().Where(a => ParkList.Contains(a.Loc1));

            if (!string.IsNullOrEmpty(param.Park))
            {
                list = list.Where(a => a.Loc1 == param.Park);
            }
            if (!string.IsNullOrEmpty(param.ID))
            {
                list = list.Where(a => a.ResourceID.Contains(param.ID));
            }
            if (!string.IsNullOrEmpty(param.Name))
            {
                list = list.Where(a => a.ResourceName.Contains(param.Name));
            }
            if (!string.IsNullOrEmpty(param.Group))
            {
                list = list.Where(a => a.GroupID == param.Group);
            }
            if (param.Stime != null)
            {
                list = list.Where(a => a.UpdateTime >= param.Stime);
            }
            if (param.Etime != null)
            {
                list = list.Where(a => a.UpdateTime <= param.Etime);
            }
            if (param.Kind != null)
            {
                list = list.Where(a => a.ResourceKindID == param.Kind);
            }
            if (param.Status != null)
            {
                list = list.Where(a => a.Status == param.Status);
            }
            int count = list.Count();

            list = list.OrderByDescending(a => a.UpdateTime).Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize);
            JsonSerializerSettings setting = new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                DateFormatString      = "yyyy-MM-dd HH:mm"
            };
            var obj = JsonConvert.SerializeObject(new { count = count, data = list.ToList() }, setting);

            return(Content(obj));
        }
Beispiel #6
0
        public JsonResult Search(SearchParam param)
        {
            var list = from a in dc.Set <T_ResourceGroup>()
                       join b in dc.Set <T_Park>() on a.ParkID equals b.ID into t1
                       from park in t1.DefaultIfEmpty()
                       join c in dc.Set <T_ResourceKind>() on a.ResourceKindID equals c.ID into t2
                       from type in t2.DefaultIfEmpty()
                       select new
            {
                a.ID,
                a.Name,
                a.ParkID,
                a.ResourceKindID,
                a.Enable,
                ParkName         = park.Name,
                ResourceKindName = type.Name
            };

            if (!string.IsNullOrEmpty(param.Park))
            {
                list = list.Where(a => a.ParkID == param.Park);
            }
            else
            {
                list = list.Where(a => ParkList.Contains(a.ParkID));
            }
            if (!string.IsNullOrEmpty(param.ID))
            {
                list = list.Where(a => a.ID.Contains(param.ID));
            }
            if (!string.IsNullOrEmpty(param.Name))
            {
                list = list.Where(a => a.Name.Contains(param.Name));
            }
            if (param.Kind != null)
            {
                list = list.Where(a => a.ResourceKindID == param.Kind);
            }
            if (param.Enable != null)
            {
                list = list.Where(a => a.Enable == param.Enable);
            }
            int count = list.Count();

            list = list.OrderBy(a => a.ID).Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize);
            return(Json(new { count = count, data = list.ToList() }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult RSSearch(SearchParam param)
        {
            var list = dc.Set <V_Resource>().Where(a => a.Enable == true);

            if (!string.IsNullOrEmpty(param.Park))
            {
                list = list.Where(a => a.Loc1 == param.Park);
            }
            else
            {
                list = list.Where(a => ParkList.Contains(a.Loc1));
            }
            if (!string.IsNullOrEmpty(param.ID))
            {
                list = list.Where(a => a.ID.Contains(param.ID));
            }
            if (!string.IsNullOrEmpty(param.Name))
            {
                list = list.Where(a => a.Name.Contains(param.Name));
            }
            if (!string.IsNullOrEmpty(param.Group))
            {
                list = list.Where(a => a.GroupID == param.Group);
            }
            if (param.Kind != null)
            {
                list = list.Where(a => a.ResourceKindID == param.Kind);
            }
            int count = list.Count();

            list = list.OrderByDescending(a => a.ResourceKindID).Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize);
            var result = list.Select(a => new { a.ID, a.Name, a.Loc1Name, a.GroupName, a.RentArea });
            var obj    = JsonConvert.SerializeObject(new { count = count, data = result.ToList() });

            return(Content(obj));
        }
        public ActionResult Search(SearchParam param)
        {
            var list = dc.Set <V_ResourceStatus>().Where(a => true);

            if (!string.IsNullOrEmpty(param.Park))
            {
                list = list.Where(a => a.Loc1 == param.Park);
            }
            else
            {
                list = list.Where(a => ParkList.Contains(a.Loc1));
            }
            if (!string.IsNullOrEmpty(param.ID))
            {
                list = list.Where(a => a.ResourceID.Contains(param.ID));
            }
            if (!string.IsNullOrEmpty(param.Name))
            {
                list = list.Where(a => a.ResourceName.Contains(param.Name));
            }
            if (!string.IsNullOrEmpty(param.Group))
            {
                list = list.Where(a => a.GroupID == param.Group);
            }
            if (param.Kind != null)
            {
                list = list.Where(a => a.ResourceKindID == param.Kind);
            }
            if (param.IType != null)
            {
                list = list.Where(a => a.BusinessType == param.IType);
            }
            if (param.Status != null)
            {
                list = list.Where(a => a.Status == param.Status);
            }
            if (param.Stime != null)
            {
                list = list.Where(a => param.Stime <= a.RentEndTime && param.Etime >= a.RentBeginTime);
            }
            int count = list.Count();

            list = list.OrderByDescending(a => a.RentBeginTime).Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize);
            var result = list.Select(a => new
            {
                a.ID,
                a.SysID,
                a.Status,
                a.ResourceID,
                a.ResourceName,
                a.ResourceKindName,
                a.GroupName,
                a.Loc1Name,
                a.RentType,
                a.BusinessType,
                a.CustShortName,
                a.RentBeginTime,
                a.RentEndTime,
                a.UpdateTime,
                a.UpdateUser
            });
            JsonSerializerSettings setting = new JsonSerializerSettings
            {
                DateFormatString = "yyyy-MM-dd HH:mm"
            };
            var obj = JsonConvert.SerializeObject(new { count = count, data = result.ToList() }, setting).Replace(" 00:00", "");

            return(Content(obj));
        }
        public ActionResult Search(SearchParam param)
        {
            try
            {
                if (param.Stime == null)
                {
                    return(Json(Result.Fail(msg: "请选择时间!"), JsonRequestBehavior.AllowGet));
                }
                DateTime begin       = Convert.ToDateTime(Convert.ToDateTime(param.Stime).ToString("yyyy-MM-dd") + " 09:00:00");
                DateTime end         = Convert.ToDateTime(Convert.ToDateTime(param.Stime).ToString("yyyy-MM-dd") + " 21:00:00");
                DateTime selectTime1 = begin.Date;
                DateTime selectTime2 = begin.Date.AddDays(1);
                string   tableStr    = string.Empty;
                string   detailStr   = string.Empty;
                var      crList      = dc.Set <V_Resource>().Where(a => a.ResourceKindID == 3 && ParkList.Contains(a.Loc1));
                //会议室数据
                if (!string.IsNullOrEmpty(param.Park))
                {
                    crList = crList.Where(a => a.Loc1 == param.Park);
                }
                var crTable = crList.Select(a => new { a.ID, a.Name }).ToList();
                if (crTable.Count() <= 0)
                {
                    tableStr += "<tr><td colspan='25' style='text-align:center;'>暂无数据</td></tr>";
                }
                foreach (var item in crTable)//遍历会议室
                {
                    var tempTime = begin;

                    tableStr += string.Format("<tr><td>{0}</td>", item.Name);

                    var statusList = dc.Set <V_ResourceStatus>()
                                     .Where(a => a.ResourceID == item.ID && selectTime1 < a.RentBeginTime && a.RentEndTime < selectTime2)
                                     .OrderBy(a => a.RentBeginTime)
                                     .ToList();
                    if (statusList.Count() > 0)
                    {
                        //存在数据
                        foreach (var status in statusList)
                        {
                            if (status.RentBeginTime <= tempTime)//小于正常开始时间
                            {
                                if (status.RentEndTime <= end)
                                {
                                    tableStr += TimeSplit(tempTime, status.RentEndTime, status);
                                    tempTime  = Convert.ToDateTime(status.RentEndTime);
                                }
                                else//大于正常结束时间
                                {
                                    tableStr += TimeSplit(tempTime, end, status);
                                    tempTime  = end;
                                }
                            }
                            else
                            {
                                tableStr += TimeSplit(tempTime, Convert.ToDateTime(status.RentBeginTime), null); //空隙
                                if (end < status.RentEndTime)                                                    //超越正常时间
                                {
                                    tableStr += TimeSplit(tempTime, end, status);
                                    tempTime  = end;
                                }
                                else
                                {
                                    tableStr += TimeSplit(Convert.ToDateTime(status.RentBeginTime), Convert.ToDateTime(status.RentEndTime), status);
                                    tempTime  = Convert.ToDateTime(status.RentEndTime);
                                }
                            }

                            //状态详情组装
                            detailStr += string.Format(@"<div class='detail' data-id='{0}'>
                                                                <p><span>资源编号:</span><span>{1}</span></p>
                                                                <p><span>公司(个人):</span><span>{2}</span></p>
                                                                <p><span>联系电话:</span><span>{3}</span></p>
                                                                <p><span>开始时间:</span>{4}<span></span></p>
                                                                <p><span>结束时间:</span>{5}<span></span></p>
                                                                </div>",
                                                       status.ID,
                                                       status.ResourceID,
                                                       status.CustLongName,
                                                       status.CustTel,
                                                       status.RentBeginTime,
                                                       status.RentEndTime);
                        }
                        if (tempTime < end)//时间刻度数据组装:后面空格
                        {
                            tableStr += TimeSplit(tempTime, end, null);
                        }
                    }
                    else
                    {
                        //没有数据
                        tableStr += TimeSplit(begin, end, null);
                    }
                }

                return(Json(new { Flag = 1, table = tableStr, detail = detailStr }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(Result.Exception(exmsg: ex.StackTrace), JsonRequestBehavior.AllowGet));
            }
        }