Ejemplo n.º 1
0
        /// <summary>
        /// 获取基础信息工人名字,以及工地信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage GetBasicInfo()
        {
            List <List <string> > list = new List <List <string> >();

            using (WorkDataClassesDataContext db = new WorkDataClassesDataContext())
            {
                list.Add(BasicMethods.GetWorkName());
                list.Add(BasicMethods.GetWorkSite());
                string json = JsonConvert.SerializeObject(list);
                return(HttpResponseMessageToJson.ToJson(json));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取管理与系统人员名下所属的工人名字,以及工地信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage GetLimitBasicInfo()
        {
            //当前登录人员
            string sesName = UserSessionInfo.SessionName();

            if (sesName != "")
            {
                List <List <string> > list = new List <List <string> >();
                using (WorkDataClassesDataContext db = new WorkDataClassesDataContext())
                {
                    //判断是否为系统人员
                    if (db.Worker.Where(n => n.WorkName == sesName && n.WorkType == "系统").Count() >= 1)
                    {
                        list.Add(BasicMethods.GetWorkName());
                        list.Add(BasicMethods.GetWorkSite());
                        string json = JsonConvert.SerializeObject(list);
                        return(HttpResponseMessageToJson.ToJson(json));
                    }
                    else
                    {  //管理人员
                        List <string> workers = db.Attendance.Where(n => n.WorkSite.WorkManage == sesName)
                                                .Select(n => n.Worker.WorkName).Distinct().ToList();
                        List <string> workSites = db.WorkSite.Where(n => n.WorkManage == sesName)
                                                  .Select(n => n.WorkSiteName).Distinct().ToList();
                        list.Add(workers);
                        list.Add(workSites);
                        string json = JsonConvert.SerializeObject(list);
                        return(HttpResponseMessageToJson.ToJson(json));
                    }
                }
            }
            else
            {
                return(HttpResponseMessageToJson.ToJson("not logged in"));
            }
        }