コード例 #1
0
    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 + "/" + "T_BG_0602", dt, true, true);
        T_BG_0602ApplicationLogic instanceT_BG_0602ApplicationLogic = (T_BG_0602ApplicationLogic)CreateApplicationLogicInstance(typeof(T_BG_0602ApplicationLogic));

        foreach (DataRow dr in dt.Rows)
        {
            appData = new T_BG_0602ApplicationData();

            appData.LMH = instanceT_BG_0602ApplicationLogic.AutoGenerateLMH(appData);

            int i = 0;

            appData = instanceT_BG_0602ApplicationLogic.Add(appData);
        }
    }
コード例 #2
0
    protected void btnInfoFromDS_Click(object sender, EventArgs e)
    {
        int totalCount  = 0;
        int importCount = 0;
        int updateCount = 0;

        try
        {
            var appDatas = T_BG_0602ApplicationData.GetDataFromDataFile <T_BG_0602ApplicationData>(InfoFromDoc.Text, true, true, recordStartLine: T_BG_0602Contants.ImportDataSetStartLineNum);
            T_BG_0602ApplicationLogic instanceT_BG_0602ApplicationLogic = (T_BG_0602ApplicationLogic)CreateApplicationLogicInstance(typeof(T_BG_0602ApplicationLogic));
            totalCount = appDatas.Count;
            foreach (var app in appDatas)
            {
                app.LMH = instanceT_BG_0602ApplicationLogic.AutoGenerateLMH(app);

                if (!LMM.Text.IsHtmlNullOrWiteSpace())
                {
                    app.LMM = Convert.ToString(LMM.Text);
                }

                string strSJLMH = GetValue(new RICH.Common.BM.T_BG_0602.T_BG_0602ApplicationLogicBase().GetValueByFixCondition("LMM", app.SJLMH, "LMH"));
                if (!DataValidateManager.ValidateIsNull(strSJLMH))
                {
                    app.SJLMH = strSJLMH;
                }
                if (!SJLMH.SelectedValue.IsHtmlNullOrWiteSpace())
                {
                    app.SJLMH = Convert.ToString(SJLMH.SelectedValue);
                }

                if (!LMTP.Text.IsHtmlNullOrWiteSpace())
                {
                    app.LMTP = Convert.ToString(LMTP.Text);
                }

                if (!LMNR.Text.IsHtmlNullOrWiteSpace())
                {
                    app.LMNR = Convert.ToString(LMNR.Text);
                }

                string strLMLBYS = GetValue(new RICH.Common.BM.Dictionary.DictionaryApplicationLogicBase().GetValueByFixCondition("MC", app.LMLBYS, "DM"));
                if (!DataValidateManager.ValidateIsNull(strLMLBYS))
                {
                    app.LMLBYS = strLMLBYS;
                }
                if (!LMLBYS.SelectedValue.IsHtmlNullOrWiteSpace())
                {
                    app.LMLBYS = Convert.ToString(LMLBYS.SelectedValue);
                }

                string strSFLBLM = GetValue(new RICH.Common.BM.Dictionary.DictionaryApplicationLogicBase().GetValueByFixCondition("MC", app.SFLBLM, "DM"));
                if (!DataValidateManager.ValidateIsNull(strSFLBLM))
                {
                    app.SFLBLM = strSFLBLM;
                }
                if (!SFLBLM.SelectedValue.IsHtmlNullOrWiteSpace())
                {
                    app.SFLBLM = Convert.ToString(SFLBLM.SelectedValue);
                }

                string strSFWBURL = GetValue(new RICH.Common.BM.Dictionary.DictionaryApplicationLogicBase().GetValueByFixCondition("MC", app.SFWBURL, "DM"));
                if (!DataValidateManager.ValidateIsNull(strSFWBURL))
                {
                    app.SFWBURL = strSFWBURL;
                }
                if (!SFWBURL.SelectedValue.IsHtmlNullOrWiteSpace())
                {
                    app.SFWBURL = Convert.ToString(SFWBURL.SelectedValue);
                }

                if (!WBURL.Text.IsHtmlNullOrWiteSpace())
                {
                    app.WBURL = Convert.ToString(WBURL.Text);
                }

                instanceT_BG_0602ApplicationLogic.Add(app);
                if (app.ResultCode == RICH.Common.Base.ApplicationData.ApplicationDataBase.ResultState.Succeed)
                {
                    importCount++;
                }
                else
                {
                    app.OPCode = RICH.Common.Base.ApplicationData.ApplicationDataBase.OPType.PK;
                    instanceT_BG_0602ApplicationLogic.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);
        }
    }