public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard) { wizard.ExportableFields.AddRange(ExportItemList); wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e) { int RowCount = 0; List <DAO.UDT_CounselUserDefDataDef> CounselUserDefDataList = _UDTTransfer.GetCounselUserDefineDataByStudentIDList(e.List); foreach (DAO.UDT_CounselUserDefDataDef udd in CounselUserDefDataList) { RowData row = new RowData(); row.ID = udd.StudentID.ToString(); foreach (string field in e.ExportFields) { if (wizard.ExportableFields.Contains(field)) { switch (field) { case "欄位名稱": row.Add(field, udd.FieldName); break; case "值": row.Add(field, udd.Value); break; case "狀態": row.Add(field, udd.StudentStatus); break; } } } RowCount++; e.Items.Add(row); } }; }
void _BGWorker_DoWork(object sender, DoWorkEventArgs e) { _StudentIDList.Clear(); _StudentIDList.Add(PrimaryKey); // 取得使用者設定欄位型態 _UseDefineDataType = Global.GetUserConfigData(); _UserDefineData = _UDTTransfer.GetCounselUserDefineDataByStudentIDList(_StudentIDList); }
public override string Import(List <IRowStream> Rows) { List <DAO.UDT_CounselUserDefDataDef> InsertData = new List <DAO.UDT_CounselUserDefDataDef>(); List <DAO.UDT_CounselUserDefDataDef> UpdateData = new List <DAO.UDT_CounselUserDefDataDef>(); List <DAO.UDT_CounselUserDefDataDef> HasData = new List <DAO.UDT_CounselUserDefDataDef>(); List <string> StudentIDList = new List <string>(); // 取得學生狀態對應 foreach (IRowStream ir in Rows) { if (ir.Contains("學號") && ir.Contains("狀態")) { StudentIDList.Add(Utility.GetStudentID(ir.GetValue("學號"), ir.GetValue("狀態")).ToString()); } } // 已有資料 HasData = _UDTTransfer.GetCounselUserDefineDataByStudentIDList(StudentIDList); foreach (IRowStream ir in Rows) { DAO.UDT_CounselUserDefDataDef CounselUserDefineData = null; int sid = 0; if (ir.Contains("學號") && ir.Contains("狀態")) { string key = ir.GetValue("學號") + "_"; if (Global._StudentStatusDBDict.ContainsKey(ir.GetValue("狀態"))) { sid = Utility.GetStudentID(ir.GetValue("學號"), ir.GetValue("狀態")); } foreach (DAO.UDT_CounselUserDefDataDef rec in HasData.Where(x => x.StudentID == sid)) { if (rec.FieldName == ir.GetValue("欄位名稱")) { CounselUserDefineData = rec; } } if (CounselUserDefineData == null) { CounselUserDefineData = new DAO.UDT_CounselUserDefDataDef(); } // 學生編號 CounselUserDefineData.StudentID = sid; // 欄位名稱 CounselUserDefineData.FieldName = ir.GetValue("欄位名稱"); // 值 CounselUserDefineData.Value = ir.GetValue("值"); if (string.IsNullOrEmpty(CounselUserDefineData.UID)) { InsertData.Add(CounselUserDefineData); } else { UpdateData.Add(CounselUserDefineData); } } } if (InsertData.Count > 0) { _UDTTransfer.InsertCounselUsereDefinfDataList(InsertData); } if (UpdateData.Count > 0) { _UDTTransfer.UpdateCounselUserDefineDataList(UpdateData); } return(""); }