Пример #1
0
 //向任务添加工作人员
 public static void AddServerToMission(uint mission_id, Worker server)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         try
         {
             entity.ResidentMissions.Find(mission_id).Server = server;
             entity.SaveChanges();
         }
         catch (Exception ex)
         {
             string errorInfo = ex.Message;
             if (ex is DbEntityValidationException)
             {
                 foreach (var validationResult in ((DbEntityValidationException)ex).EntityValidationErrors)
                 {
                     foreach (var error in validationResult.ValidationErrors)
                     {
                         errorInfo = $"{errorInfo}" + "\n" + $"{error.ErrorMessage}";
                     }
                 }
             }
             throw new ApplicationException("更新时出错!\n" + $"{errorInfo}");
         }
     }
 }
 //删除居民的出入记录
 public static void RemoveRecord(string id)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         try
         {
             entity.ResidentAccessManagements.Remove(Get(id));
             entity.SaveChanges();
         }
         catch (Exception ex)
         {
             string errorInfo = ex.Message;
             if (ex is DbEntityValidationException)
             {
                 foreach (var validationResult in ((DbEntityValidationException)ex).EntityValidationErrors)
                 {
                     foreach (var error in validationResult.ValidationErrors)
                     {
                         errorInfo = $"{errorInfo}" + "\n" + $"{error.ErrorMessage}";
                     }
                 }
             }
             throw new ApplicationException("删除时出错!\n" + $"{errorInfo}");
         }
     }
 }
Пример #3
0
        }                                             //居民

        public ResidentAccessManagement()
        {
            using (var entity = new CommunityEpidemicManagementSystemContext())
            {
                ResidentAccessManagementId = (Int16.Parse(entity.ResidentAccessManagements.Last().ResidentAccessManagementId) + 1).ToString();
            }
        }
 //获取全部
 public static List <ResidentAccessManagement> GetAll()
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         return(entity.ResidentAccessManagements.ToList());
     }
 }
 //由ID获取
 public static ResidentAccessManagement Get(string id)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         return(entity.ResidentAccessManagements.Find(id));
     }
 }
Пример #6
0
        }                                     //用户名

        public Worker()
        {
            using (var entity = new CommunityEpidemicManagementSystemContext())
            {
                WorkerId = (Int16.Parse(entity.Workers.Last().WorkerId) + 1).ToString();
            }
        }
Пример #7
0
 public TravelRecord()
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         TravelRecordId = (Int16.Parse(entity.TravelRecords.Last().TravelRecordId) + 1).ToString();
     }
 }
Пример #8
0
 //由ID获取
 public static Emergency Get(string id)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         return(entity.Emergencies.Find(id));
     }
 }
Пример #9
0
 //添加紧急事件
 public static void Add(Emergency emerg)
 {
     try
     {
         using (var entity = new CommunityEpidemicManagementSystemContext())
         {
             entity.Emergencies.Add(emerg);
             entity.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         string errorInfo = ex.Message;
         if (ex is DbEntityValidationException)
         {
             foreach (var validationResult in ((DbEntityValidationException)ex).EntityValidationErrors)
             {
                 foreach (var error in validationResult.ValidationErrors)
                 {
                     errorInfo = $"{errorInfo}" + "\n" + $"{error.ErrorMessage}";
                 }
             }
         }
         throw new ApplicationException("添加时出错!\n" + $"{errorInfo}");
     }
 }
Пример #10
0
 //删除
 public static void Remove(string task_id)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         try
         {
             AdministratorTask task = Get(task_id);
             entity.AdministratorTasks.Remove(task);
             entity.SaveChanges();
         }
         catch (Exception ex)
         {
             string errorInfo = ex.Message;
             if (ex is DbEntityValidationException)
             {
                 foreach (var validationResult in ((DbEntityValidationException)ex).EntityValidationErrors)
                 {
                     foreach (var error in validationResult.ValidationErrors)
                     {
                         errorInfo = $"{errorInfo}" + "\n" + $"{error.ErrorMessage}";
                     }
                 }
             }
             throw new ApplicationException("删除时出错!\n" + $"{errorInfo}");
         }
     }
 }
Пример #11
0
 //获取全部
 public static List <Emergency> GetAll()
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         return(entity.Emergencies.ToList());
     }
 }
Пример #12
0
        //新增
        public static void Add(AdministratorTask task)
        {
            using (var entity = new CommunityEpidemicManagementSystemContext())
            {
                if (Get(task.AdministratorTaskId) != null)
                {
                    throw new ApplicationException("已经存在!");
                }

                try
                {
                    entity.AdministratorTasks.Add(task);
                    entity.SaveChanges();
                }
                catch (Exception ex)
                {
                    string errorInfo = ex.Message;
                    if (ex is DbEntityValidationException)
                    {
                        foreach (var validationResult in ((DbEntityValidationException)ex).EntityValidationErrors)
                        {
                            foreach (var error in validationResult.ValidationErrors)
                            {
                                errorInfo = $"{errorInfo}" + "\n" + $"{error.ErrorMessage}";
                            }
                        }
                    }
                    throw new ApplicationException("添加时出错!\n" + $"{errorInfo}");
                }
            }
        }
Пример #13
0
 //由ID获取
 public static AdministratorTask Get(string task_id)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         return(entity.AdministratorTasks.Find(task_id));
     }
 }
Пример #14
0
 //获取全部
 public static List <AdministratorTask> GetAll()
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         return(entity.AdministratorTasks.ToList());
     }
 }
Пример #15
0
 //由ID获取
 public static HealthInformation Get(string id)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         return(entity.HealthInformations.Find(id));
     }
 }
Пример #16
0
 //获取全部
 public static List <HealthInformation> GetAll()
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         return(entity.HealthInformations.ToList <HealthInformation>());
     }
 }
Пример #17
0
 //更新
 public static void Update(Worker worker)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         try
         {
             entity.Workers.Remove(Get(worker.WorkerId));
             entity.Workers.Add(worker);
             entity.SaveChanges();
         }
         catch (Exception ex)
         {
             string errorInfo = ex.Message;
             if (ex is DbEntityValidationException)
             {
                 foreach (var validationResult in ((DbEntityValidationException)ex).EntityValidationErrors)
                 {
                     foreach (var error in validationResult.ValidationErrors)
                     {
                         errorInfo = $"{errorInfo}" + "\n" + $"{error.ErrorMessage}";
                     }
                 }
             }
             throw new ApplicationException("更新时出错!\n" + $"{errorInfo}");
         }
     }
 }
Пример #18
0
 //由ID获取
 public static Worker Get(string id)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         return(entity.Workers.Find(id));
     }
 }
Пример #19
0
 public HealthInformation()
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         HealthInformationId = (Int16.Parse(entity.HealthInformations.Last().HealthInformationId) + 1).ToString();
     }
 }
Пример #20
0
 //获取全部
 public static List <Worker> GetAll()
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         return(entity.Workers.ToList <Worker>());
     }
 }
Пример #21
0
 //获取全部出行经历
 public static List <TravelRecord> GetAll()
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         return(entity.TravelRecords.ToList <TravelRecord>());
     }
 }
Пример #22
0
 //由ID获取出行经历
 public static TravelRecord Get(string id)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         return(entity.TravelRecords.Find(id));
     }
 }
Пример #23
0
 //按委托查找
 public static List <Worker> QueryByFunc(Func <Worker, bool> func)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         var query = entity.Workers.Where(u => func(u));
         return(query.ToList());
     }
 }
Пример #24
0
 //按用户名查询
 public static List <Worker> QueryByUser(string userid)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         var query = entity.Workers.Where(u => u.User.UserId == userid);
         return(query.ToList());
     }
 }
Пример #25
0
 //按姓名查询
 public static List <Worker> QueryByName(string name)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         var query = entity.Workers.Where(u => u.Name == name);
         return(query.ToList());
     }
 }
Пример #26
0
 }                                      //用户名和id
 public Emergency()
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         EmergencyId = (Int16.Parse(entity.Emergencies.Last().EmergencyId) + 1).ToString();
     }
     EmergState = EmergencyStatus.已完成;
 }
Пример #27
0
 }                                        //管理员
 public AdministratorTask()
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         AdministratorTaskId = (Int16.Parse(entity.AdministratorTasks.Last().AdministratorTaskId) + 1).ToString();
     }
     CreatedTime = DateTime.Now;
 }
Пример #28
0
 //查询一户的出行经历
 public static List <TravelRecord> QueryByUserID(String ID)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         var query = entity.TravelRecords.Where(t => t.User.UserId == ID);
         return(query.ToList());
     }
 }
Пример #29
0
 //查询某一天出发的的出行情况
 public static List <TravelRecord> QueryTravelRecordByDateCome(DateTime date)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         var query = entity.TravelRecords.Where(t => t.DateCome == date);
         return(query.ToList());
     }
 }
Пример #30
0
 //查询某个日期所有居民的打卡记录
 public static List <HealthInformation> QueryByDate(DateTime date)
 {
     using (var entity = new CommunityEpidemicManagementSystemContext())
     {
         var query = entity.HealthInformations.Where(u => u.Date.Date == date.Date);
         return(query.ToList());
     }
 }