static void _bgLLoadUDT_DoWork(object sender, DoWorkEventArgs e) { UDTTransfer.CreateUDTTable(); #region 自訂驗證規則 FactoryProvider.FieldFactory.Add(new FieldValidatorFactory()); #endregion #region 加入自動加入班級類別 List <string> nameList = new List <string> (); nameList.Add("普通班"); nameList.Add("體育班"); nameList.Add("美術班"); nameList.Add("音樂班"); nameList.Add("舞蹈班"); nameList.Add("資優班"); nameList.Add("資源班"); nameList.Add("特教班"); nameList.Add("技藝專班"); nameList.Add("機構式非學校自學班"); // 取得班級分類 List <TagConfigRecord> TagRecList = TagConfig.SelectByCategory(TagCategory.Class); List <TagConfigRecord> AddTagRecList = new List <TagConfigRecord>(); List <string> hasNameList = new List <string>(); foreach (TagConfigRecord rec in TagRecList) { if (rec.Prefix == "班級分類") { hasNameList.Add(rec.Name); } } // 檢查是否新增 foreach (string name in nameList) { if (!hasNameList.Contains(name)) { TagConfigRecord rec = new TagConfigRecord(); rec.Name = name; rec.Prefix = "班級分類"; rec.Category = "Class"; AddTagRecList.Add(rec); } } if (AddTagRecList.Count > 0) { TagConfig.Insert(AddTagRecList); } #endregion }
static void _bgLLoadUDT_DoWork(object sender, DoWorkEventArgs e) { UDTTransfer.CreateUDTTable(); //FISCA.ServerModule.AutoManaged("http://module.ischool.com.tw/module/137/KHCentralOffice/udm.xml"); //// 因為 UDT 調整,需要檢查不自動解鎖相對鎖定欄位是鎖定 // List<UDT_ClassLock> classLockList = UDTTransfer.GetClassLocList(); // if(classLockList.Count>0) // { // foreach (UDT_ClassLock data in classLockList) // { // if(data.isLock == null) // { // if (data.UnAutoUnlock) // data.isLock = true; // } // } // classLockList.SaveAll(); // } // 檢查是否需要全部班級解鎖 // 取得Server時間 DateTime?serDT = Utility.GetDBServerDateTime(); // 2015 年開始 if (serDT.HasValue && serDT.Value.Year >= 2015) { // 第一學期 DateTime dt1b = new DateTime(DateTime.Now.Year, 8, 1); DateTime dt1e = new DateTime(DateTime.Now.Year + 1, 2, 1); // 第二學期 DateTime dt2b = new DateTime(DateTime.Now.Year, 2, 1); DateTime dt2e = new DateTime(DateTime.Now.Year, 8, 1); //檢查是否符合解鎖規則 bool chkUnLock = false; if (serDT.Value >= dt1b || serDT.Value >= dt2b) { chkUnLock = true; } // 需要解鎖 if (chkUnLock) { bool runUnLock = true; // 取得最後解鎖日期 DateTime?unLockDate = Utility.GetLastUnlockDate(); if (unLockDate.HasValue) { if (unLockDate.Value.Month > 7) { if (unLockDate.Value >= dt1b && unLockDate.Value < dt1e) { runUnLock = false; } } else { if (serDT.Value >= dt1b && serDT.Value < dt2e) { } else { if (unLockDate.Value >= dt2b && unLockDate.Value < dt2e) { runUnLock = false; } } } } // 執行全部解鎖 if (runUnLock) { // 寫入解鎖log UDT_ClassLock_Log lo = new UDT_ClassLock_Log(); lo.Action = "班級解鎖"; lo.Date = serDT.Value; lo.Save(); UDTTransfer.UnlockAllClass(); } } } }