Example #1
0
        /// <summary>
        /// 替换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Save_Click(object sender, EventArgs e)
        {
            DataTable dt = (DataTable)gridControl1.DataSource;

            if (null == dt || dt.Rows.Count == 0)
            {
                MyMessageBox.Show("模板列表为空,请先将左侧需要删除日志的模板移动到右侧列表。", "提示", MyMessageBoxButtons.Ok, DrectSoft.Common.Ctrs.DLG.MessageBoxIcon.WarningIcon);
                return;
            }

            SetWaitDialogCaption("正在批量清除模板日志内容...");

            Emrtemplet m_Emrtemplet;
            //循环替换页眉页脚
            int losecnt    = 0;
            int successcnt = 0;

            foreach (DataRow dr in ((DataTable)gridControl1.DataSource).Rows)
            {
                try
                {
                    m_Emrtemplet = m_SQLManger.GetTemplet(dr["ID"].ToString());

                    //if (chk_Title.Checked)
                    //    m_Emrtemplet.XML_DOC_NEW = ReplaceTitle(m_Emrtemplet.XML_DOC_NEW);
                    //if (chk_Foot.Checked)
                    m_Emrtemplet.XML_DOC_NEW = ReplaceSaveLog(m_Emrtemplet.XML_DOC_NEW);

                    m_SQLManger.BatchSaveTemplet(m_Emrtemplet, "2");
                }
                catch (Exception ex)
                {
                    losecnt++;
                    m_Logger.Error("模板批量删除日志信息错误日志:" + "\t" + "模板TempletID:" + dr["ID"] + "\t" + ex.Message);

                    continue;
                }
                successcnt++;
            }

            HideWaitDialog();

            string mess = "";

            if (successcnt > 0)
            {
                mess = "替换成功,成功替换了【" + successcnt.ToString() + "】条记录。";
                if (losecnt > 0)
                {
                    mess += "\n其中有【" + losecnt + "】条记录未替换成功,\n未成功记录请查看服务器上\\Logs下日志信息。";
                }
                m_app.CustomMessageBox.MessageShow(mess);
            }
            else
            {
                m_app.CustomMessageBox.MessageShow("替换失败,有【" + losecnt + "】条记录未替换成功。\n未成功记录请查看服务器上\\Logs下日志信息。");
            }
        }
Example #2
0
        /// <summary>
        /// 替换事件
        /// edit by Yanqiao.Cai 2012-11-06
        /// add try ... catch
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                string errorStr = CheckItem();
                if (!string.IsNullOrEmpty(errorStr))
                {
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(errorStr);
                    return;
                }
                if (DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("您确定要批量替换" + (chk_Title.Checked ? "页眉" : "") + (chk_Foot.Checked ? "页脚" : "") + "吗?该操作不可恢复。", "批量替换页眉页脚", DrectSoft.Common.Ctrs.DLG.MyMessageBoxButtons.OkCancel) == DialogResult.Cancel)
                {
                    return;
                }

                SetWaitDialogCaption("正在批量替换" + (chk_Title.Checked ? "页眉" : "") + (chk_Foot.Checked ? "页脚" : "") + "...");

                GetHeaderFootEntity();

                Emrtemplet m_Emrtemplet;
                //循环替换页眉页脚
                int losecnt    = 0;
                int successcnt = 0;
                foreach (DataRow dr in ((DataTable)gridControl1.DataSource).Rows)
                {
                    try
                    {
                        m_Emrtemplet = m_SQLManger.GetTemplet(dr["ID"].ToString());

                        if (chk_Title.Checked)
                        {
                            m_Emrtemplet.XML_DOC_NEW = ReplaceTitle(m_Emrtemplet.XML_DOC_NEW);
                        }
                        if (chk_Foot.Checked)
                        {
                            m_Emrtemplet.XML_DOC_NEW = ReplaceFoot(m_Emrtemplet.XML_DOC_NEW);
                        }

                        m_SQLManger.BatchSaveTemplet(m_Emrtemplet, "2");
                    }
                    catch (Exception ex)
                    {
                        losecnt++;
                        //Log log = new Log();
                        //log.Write("模板批量替换页眉页脚错误日志:" + "\t" + "模板TempletID:" + dr["ID"] + ex.Message);
                        //(new Log()).Write("模板批量替换页眉页脚错误日志:" + "\t" + "模板TempletID:" + dr["ID"] + ex.Message);
                        m_Logger.Error("模板批量替换页眉页脚错误日志:" + "\t" + "模板TempletID:" + dr["ID"] + "\t" + ex.Message);
                        //m_Logger.Info("模板批量替换页眉页脚错误日志:" + "\t" + "模板TempletID:" + dr["ID"] + "\t" + ex.Message);
                        continue;
                    }
                    successcnt++;
                }

                HideWaitDialog();

                string mess = "";
                if (successcnt > 0)
                {
                    mess = "替换成功,成功替换了【" + successcnt.ToString() + "】记录。";
                    if (losecnt > 0)
                    {
                        mess += "\n其中有【" + losecnt + "】条记录未替换成功,\n未成功记录请查看服务器上\\Logs下日志信息。";
                    }
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(mess);
                }
                else
                {
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("替换失败,有【" + losecnt + "】条记录未替换成功,\n未成功记录请查看服务器上\\Logs下日志信息。");
                }
            }
            catch (Exception ex)
            {
                HideWaitDialog();
                DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(1, ex);
            }
        }