示例#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());
     }
 }