protected void btnInfoFromDocBatch_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); dt = GetTemplateColumn(dt); dt = FileLibrary.GetDataFromWordBatch(ConstantsManager.WEBSITE_VIRTUAL_ROOT_DIR + "/" + ConstantsManager.UPLOAD_DOC_DIR + "/" + "Dictionary", dt, true, true); DictionaryApplicationLogic instanceDictionaryApplicationLogic = (DictionaryApplicationLogic)CreateApplicationLogicInstance(typeof(DictionaryApplicationLogic)); foreach (DataRow dr in dt.Rows) { appData = new DictionaryApplicationData(); int i = 0; appData = instanceDictionaryApplicationLogic.Add(appData); } }
protected void btnInfoFromDS_Click(object sender, EventArgs e) { int totalCount = 0; int importCount = 0; int updateCount = 0; try { var appDatas = DictionaryApplicationData.GetDataFromDataFile <DictionaryApplicationData>(InfoFromDoc.Text, true, true, recordStartLine: DictionaryContants.ImportDataSetStartLineNum); DictionaryApplicationLogic instanceDictionaryApplicationLogic = (DictionaryApplicationLogic)CreateApplicationLogicInstance(typeof(DictionaryApplicationLogic)); totalCount = appDatas.Count; foreach (var app in appDatas) { if (!DM.Text.IsHtmlNullOrWiteSpace()) { app.DM = Convert.ToString(DM.Text); } string strLX = GetValue(new RICH.Common.BM.DictionaryType.DictionaryTypeApplicationLogicBase().GetValueByFixCondition("MC", app.LX, "DM")); if (!DataValidateManager.ValidateIsNull(strLX)) { app.LX = strLX; } if (!LX.SelectedValue.IsHtmlNullOrWiteSpace()) { app.LX = Convert.ToString(LX.SelectedValue); } if (!MC.Text.IsHtmlNullOrWiteSpace()) { app.MC = Convert.ToString(MC.Text); } string strSJDM = GetValue(new RICH.Common.BM.Dictionary.DictionaryApplicationLogicBase().GetValueByFixCondition("MC", app.SJDM, "DM")); if (!DataValidateManager.ValidateIsNull(strSJDM)) { app.SJDM = strSJDM; } if (!SJDM.SelectedValue.IsHtmlNullOrWiteSpace()) { app.SJDM = Convert.ToString(SJDM.SelectedValue); } if (!SM.Text.IsHtmlNullOrWiteSpace()) { app.SM = Convert.ToString(SM.Text); } instanceDictionaryApplicationLogic.Add(app); if (app.ResultCode == RICH.Common.Base.ApplicationData.ApplicationDataBase.ResultState.Succeed) { importCount++; } else { app.OPCode = RICH.Common.Base.ApplicationData.ApplicationDataBase.OPType.PK; instanceDictionaryApplicationLogic.Modify(app); if (app.ResultCode == RICH.Common.Base.ApplicationData.ApplicationDataBase.ResultState.Succeed) { updateCount++; } } } MessageContent += @"<font color=""green"">共{0}条数据,导入数据{1}条,更新数据{2}条。</font>".FormatInvariantCulture(totalCount, importCount, updateCount); } catch (Exception ex) { MessageContent += @"<font color=""red"">导入数据过程出错:{0}<br/>共{1}条数据,已导入数据{2}条,已更新数据{3}条。</font>".FormatInvariantCulture(ex.Message, totalCount, importCount, updateCount); } }