• 保存配置,获取配置,XML


    private void SaveSOConfig()
    {
    //保存配置
    Dictionary<string, string> PrintConfigDIC = new Dictionary<string, string>();
    PrintConfigDIC.Add("TIME1", dtTime1.Text);
    PrintConfigDIC.Add("TIME2", dtTime2.Text);
    PrintConfigDIC.Add("STARTUP1", ConvertUtility.ObjectToString(chkStartUp1.Checked));
    PrintConfigDIC.Add("STARTUP2", ConvertUtility.ObjectToString(chkStartUp2.Checked));
    try
    {
    string path = @"C:LayoutStyleStandingOrderConfig.xml";
    if (File.Exists(path))
    {
    File.Delete(path);
    }

    XmlDocument xml = new XmlDocument();//创建根节点 config
    xml.AppendChild(xml.CreateXmlDeclaration("1.0", "utf-8", ""));
    XmlElement one = xml.CreateElement("StandingOrderConfig");//把根节点加到xml文档中
    foreach (var pc in PrintConfigDIC)
    {
    one.SetAttribute(pc.Key, pc.Value);
    }
    xml.AppendChild(one);
    xml.Save(path);

    MessageBox.Show("配置保存成功", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

    LoadGridView();
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
    }
    }

    private void LoadSOConfig()
    {
    //获取配置
    string path = @"C:LayoutStyleStandingOrderConfig.xml";
    if (File.Exists(path))
    {
    XmlDocument doc = new XmlDocument();
    doc.Load(path);
    XmlNodeList nodeList = doc.SelectNodes("/StandingOrderConfig");
    if (nodeList != null)
    {
    foreach (XmlNode node in nodeList)
    {
    dtTime1.EditValue = node.Attributes["TIME1"].Value;
    dtTime2.EditValue = node.Attributes["TIME2"].Value;
    chkStartUp1.Checked = ConvertUtility.ObjectTobool(node.Attributes["STARTUP1"].Value);
    chkStartUp2.Checked = ConvertUtility.ObjectTobool(node.Attributes["STARTUP2"].Value);

    DDDs.Clear();
    if (chkStartUp1.Checked)
    {
    DDDs.Add(new DDD() { DateTimeOfExecOnce = node.Attributes["TIME1"].Value, difftime = "24H", IsRunning = "正在执行...", jobname = "长期医嘱更新" });
    }
    if (chkStartUp2.Checked)
    {
    DDDs.Add(new DDD() { DateTimeOfExecOnce = node.Attributes["TIME2"].Value, difftime = "24H", IsRunning = "正在执行...", jobname = "长期医嘱床位费更新" });
    }
    break;
    }
    }
    }
    }

  • 相关阅读:
    Linux 安装多版本Python
    ElasticSearch 镜像 & 安装 & 简易集群
    SpringBoot-异步调用@Async
    SprinigBoot整合Kafka
    Kafka快速安装部署
    Linux-JDK安装
    npm / yarn 配置镜像、使用方法
    React搭建项目(全家桶)
    原生JS 将canvas生成图片
    原生 JS 的 Base64 转码
  • 原文地址:https://www.cnblogs.com/mapstar/p/10774581.html
Copyright © 2020-2023  润新知