Example #1
0
        /*
         * Create by 付文欣
         * 通过年份号号获取设置
         */
        public Setting getSettingById(String id)
        {
            SettingDBContext settingDBContext = new SettingDBContext();
            Setting          setting          = settingDBContext.settings.Find(id);

            return(setting);
        }
Example #2
0
 /*
  * Create By 高晔
  * 获取当前所用的设置信息
  * 正常返回一个Setting,异常返回null
  */
 public Setting getCurrentSetting()
 {
     try
     {
         SettingDBContext settingDBContext = new SettingDBContext();
         Setting          setting          = settingDBContext.settings.First();
         return(setting);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Example #3
0
 /*
  * Create By 付文欣
  * 添加一个设置
  * 成功添加返回1,失败返回0,异常返回-1
  */
 public int addSetting(Setting setting)
 {
     try
     {
         SettingDBContext settingDBContext = new SettingDBContext();
         settingDBContext.settings.Add(setting);
         return(settingDBContext.SaveChanges());
     }
     catch (Exception e)
     {
         //throw e;
         //LogUtil.writeLogToFile(e);
         return(-1);
     }
 }
Example #4
0
        /*
         * Create By 高晔
         * 创建和初始化本地数据库
         */
        public static void initLocalDB()
        {
            StudentDBContext studentDB = new StudentDBContext();

            studentDB.students.Find("");
            AdminDBContext adminDB = new AdminDBContext();

            adminDB.admins.Find("");
            DeanDBContext deanDB = new DeanDBContext();

            deanDB.deans.Find("");
            ProfessorDBContext professorDB = new ProfessorDBContext();

            professorDB.professors.Find("");
            SettingDBContext settingDBContext = new SettingDBContext();
            //settingDBContext.settings.Find("");
            MajorDBContext majorDBContext = new MajorDBContext();

            majorDBContext.majors.Find(0);
        }
Example #5
0
 /*
  * Create By 付文欣
  * 根据年份号删除设置
  * 成功删除返回1,失败返回0,异常返回-1
  */
 public int deleteSettingById(string id)
 {
     try
     {
         Setting          setting;
         SettingDBContext settingDBContext = new SettingDBContext();
         if ((setting = settingDBContext.settings.Find(id)) != null)
         {
             settingDBContext.settings.Remove(setting);
             return(settingDBContext.SaveChanges());
         }
         else
         {
             return(0);
         }
     }
     catch (Exception e)
     {
         //throw e;
         //LogUtil.writeLogToFile(e);
         return(-1);
     }
 }
Example #6
0
 /*
  * Create By 付文欣
  * 根据年份号修改模式
  * 成功添加返回1,失败返回0,异常返回-1
  */
 public int changeModeById(String id, int mode)
 {
     try
     {
         SettingDBContext settingDBContext = new SettingDBContext();
         Setting          setting          = settingDBContext.settings.Where(m => m.yearId == id).ToList()[0];
         if (setting != null)
         {
             setting.mode = mode;
             return(settingDBContext.SaveChanges());
         }
         else
         {
             return(0);
         }
     }
     catch (Exception e)
     {
         //throw e;
         //LogUtil.writeLogToFile(e);
         return(-1);
     }
 }
Example #7
0
 /*
  * Create By 付文欣
  * 修改更新设置信息
  * 成功添加返回1,失败返回0,异常返回-1
  */
 public int updateSetting(Setting newSetting)
 {
     try
     {
         SettingDBContext settingDBContext = new SettingDBContext();
         Setting          setting          = settingDBContext.settings.Where(m => m.yearId == newSetting.yearId).ToList()[0];
         if (setting != null)
         {
             settingDBContext.settings.Remove(setting);
             settingDBContext.settings.Add(newSetting);
             return(settingDBContext.SaveChanges());
         }
         else
         {
             return(0);
         }
     }
     catch (Exception e)
     {
         //throw e;
         //LogUtil.writeLogToFile(e);
         return(-1);
     }
 }
Example #8
0
 /*
  * Create By 高晔
  * 获取当前所处阶段
  * 正常返回1-7,1-7代表7个时间阶段,失败返回-1,异常返回-1
  */
 public int getCurrentStage()
 {
     try
     {
         SettingDBContext settingDBContext = new SettingDBContext();
         Setting          setting          = settingDBContext.settings.First();
         if (setting != null)
         {
             if (setting.on == 0)
             {
                 return(0);
             }
             if (setting.mode == 2)
             {
                 return(setting.stage);
             }
             else
             {
                 string currentTime = TimeUtil.getCurrentTime();
                 if (currentTime.CompareTo(setting.infoStart) <= 0)
                 {
                     return(1);
                 }
                 else if (currentTime.CompareTo(setting.infoEnd) <= 0)
                 {
                     return(2);
                 }
                 else if (currentTime.CompareTo(setting.firstStart) <= 0)
                 {
                     return(3);
                 }
                 else if (currentTime.CompareTo(setting.firstEnd) <= 0)
                 {
                     return(4);
                 }
                 else if (currentTime.CompareTo(setting.secondStart) <= 0)
                 {
                     return(5);
                 }
                 else if (currentTime.CompareTo(setting.secondEnd) <= 0)
                 {
                     return(6);
                 }
                 else if (currentTime.CompareTo(setting.publishStart) <= 0)
                 {
                     return(7);
                 }
                 else
                 {
                     return(8);
                 }
             }
         }
         else
         {
             return(-1);
         }
     }
     catch (Exception e)
     {
         return(-1);
     }
 }