コード例 #1
0
        /// <summary>
        /// 点击保存格式按钮时触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Lbl_baocun_Click(object sender, EventArgs e)
        {
            string formatname = cbb_geshi.Text;

            mycontroller.DeleteFormat(formatname);
            //形成模板信息
            MubanInfo mubaninfo = new MubanInfo();

            mubaninfo._mubanname = formatname;
            List <string> list_buzhou = new List <string>();

            for (int i = 0; i < Setting.list_guize.Count; i++)
            {
                var myrow = dgv_guize.Rows[i];
                mubaninfo.list_buzhou.Add(Setting.list_guize[i]);
            }
            string json = JsonConvert.SerializeObject(mubaninfo);
            Dictionary <string, object> dic_muban = new Dictionary <string, object>()
            {
                { "模板名称", formatname },
                { "模板信息", json },
                //{ "日志路径",tb_rizhilujing.Text},
                { "正文", cb_zhengwen.Checked },
                { "文件名", cb_wenjianming.Checked }
            };

            mycontroller.SaveFormat(dic_muban);
            MessageBox.Show($"格式 {formatname} 已保存成功!");
        }
コード例 #2
0
        /// <summary>
        /// 下拉框选项发生改变时触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Cbb_geshi_SelectedIndexChanged(object sender, EventArgs e)
        {
            string str_setting = cbb_geshi.Text;
            var    dic_setting = mycontroller.GetMuBan(str_setting);
            Dictionary <string, object> dic = dic_setting as Dictionary <string, object>;
            //获得日志路径,赋值到tb_rizhilujing
            string rizhilujing = dic["日志路径"].ToString();

            //tb_rizhilujing.Text = rizhilujing;
            //cb_wenjianming赋值
            cb_wenjianming.Checked = Convert.ToBoolean(dic["文件名"]);
            //cb_zhengwen赋值
            cb_zhengwen.Checked = Convert.ToBoolean(dic["正文"]);
            //获得模板信息
            string mubanjson = dic["模板信息"].ToString();

            //转化为模板类
            MubanInfo mymubaninfo = JsonConvert.DeserializeObject <MubanInfo>(mubanjson);

            //得到模板信息
            Setting.list_guize = mymubaninfo.list_buzhou;
            //刷新规则列表
            UpdateDgvGuize();



            //tb_rizhilujing.Text = Setting._rizhilujing = dic_setting["日志路径"].ToString();
            //Setting._currentformat = str_setting;
            ////添加数据库ucdatabase
            //string str_shujukushai = dic_setting["数据库筛"].ToString();
            //Setting.list_ucdb.Clear();

            //if (str_shujukushai.Trim().Equals(string.Empty))
            //{
            //    return;
            //}
            //List<string> list_db = str_shujukushai.Split(new char[] { ',' }).ToList();
            ////虚幻实例化UC
            //foreach (string item in list_db)
            //{
            //    var myuc = new Common.WinForm.UCDatabase(item);
            //}
        }