Esempio n. 1
0
        private void tMenuItemDelete_Click(object sender, EventArgs e)
        {//删除配置列表
            if (this.lstConfig.SelectedItems.Count > 0)
            {
                string    names     = "配置";
                ConfigXml configXml = null;
                foreach (ListViewItem item in this.lstConfig.SelectedItems)
                {
                    configXml = (ConfigXml)item.Tag;
                    if (configXml.getXmlValueById("application") == EnumClass.Application.strat.ToString())
                    {
                        names += "\r\n" + configXml.getXmlValueById("name");
                        this.showMessage(names + "\r\n在运行列表中不得删除");
                        return;
                    }
                }
                foreach (ListViewItem item in this.lstConfig.SelectedItems)
                {
                    configXml = (ConfigXml)item.Tag;
                    configXml.deleteXmlByConfig();
                    names += "\r\n" + configXml.getXmlValueById("name");
                    item.Remove();
                    LoadData.Instance.ConfigXmlList.Remove(configXml);
                }

                this.showMessage(names + "\r\n成功删除");
            }
        }
Esempio n. 2
0
        public void IniCfg()
        {
            string fic;

            // Usar el path del ejecutable
            fic = Application.StartupPath + @"\XULIA.exe.config";
            // La clase debemos instanciarla indicando el path a usar
            // y opcionalmente si se guarda cada vez que se asigne un valor.
            mCfg = new ConfigXml(fic, true);
        }
Esempio n. 3
0
        public T[] GetAttributeArray <T>(string section, string key, string attribute)
        {
            var xpath    = GetXPath(section, key, attribute);
            var nodeList = ConfigXml.SelectNodes(xpath);
            var result   = new T[nodeList.Count];

            for (var i = 0; i < nodeList.Count; i++)
            {
                result[i] = GetValueFromXmlNode <T>(section, key, attribute, nodeList[i]);
            }
            return(result);
        }
Esempio n. 4
0
        public static void Load()
        {
            XElement ConfigXml;

            try
            {
                ConfigXml = XElement.Load("GetOnlineCfg.xml");
            }
            catch (Exception e)
            {
                //Log.WriteError("Não foi possivel Ler o Arquivo de Config.xml");
                Log.WriteInfo("Creating GetOnlineCfg.xml");

                try { CreateConfig(); }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }

                Load();
                return;
            }

            ConfigXml = XElement.Load("GetOnlineCfg.xml");

            try
            {
                XElement Cfg = ConfigXml.Element("Config");
                Config.ManagePathLog = ConfigXml.Element("ManageLogPath").Value;
                Config.Timer         = int.Parse(ConfigXml.Element("TimerCheck").Value);


                XElement MySQL = ConfigXml.Element("MySQL");
                Config.UseMySQL   = Boolean.Parse(MySQL.Attribute("Use").Value);
                Config.MyIP       = MySQL.Element("IP").Value;
                Config.MyPort     = MySQL.Element("Port").Value;
                Config.MyDatabase = MySQL.Element("Database").Value;
                Config.MyPassword = MySQL.Element("Password").Value;
                Config.MyUser     = MySQL.Element("User").Value;
                Config.MyTable    = MySQL.Element("Table").Value;
            }
            catch (Exception e)
            {
                CreateConfig();
                //Log.WriteError(e.Message);
                //throw new Exception(e.ToString());
                //Load();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 获取基础数据更新时间
        /// </summary>
        /// <returns></returns>
        public JsonResult GetUpdateTime()
        {
            LycJsonResult lycResult = new LycJsonResult();

            try
            {
                ConfigXml cx = new ConfigXml();
                lycResult.Data = new JsonResultModel(true, "获取基础数据更新时间成功", new { updateDate = cx.BaseDataUpdateTime });
            }
            catch
            {
                lycResult.Data = new JsonResultModel(false, "获取基础数据更新时间失败", null);
            }
            return(lycResult);
        }
Esempio n. 6
0
 private void tMenuItemExitRun_Click(object sender, EventArgs e)
 {//退出运行列表
     if (this.lstRun.SelectedItems.Count > 0)
     {
         string    names     = "配置";
         ConfigXml configXml = null;
         foreach (ListViewItem item in this.lstRun.SelectedItems)
         {
             configXml = (ConfigXml)item.Tag;
             configXml.setXmlValueById("application", EnumClass.Application.end.ToString());
             item.Remove();
             names += "\r\n" + configXml.getXmlValueById("name");
         }
         this.showMessage(names + "\r\n退出运行列表");
     }
 }
Esempio n. 7
0
        private void lstConfig_Click(object sender, EventArgs e)
        {//选择配置文件
            if (this.lstConfig.SelectedItems.Count > 0)
            {
                this.groupBox.Enabled = true;
                this.configXml        = (ConfigXml)this.lstConfig.SelectedItems[0].Tag;
                this.txtConfig.Text   = this.configXml.getXmlValueById("name");

                if (this.configXml.getXmlValueById("cycle") == EnumClass.Cycle.day.ToString())
                {
                    this.rbtnD.Checked = true;
                    DateTime dt = DateTime.Now;
                    if (DateTime.TryParse(this.configXml.getXmlValueById("day"), out dt))
                    {
                        this.dtpD.Value = dt;
                    }
                    else
                    {
                        this.dtpD.Value = DateTime.Now;
                    }
                }
                else if (this.configXml.getXmlValueById("cycle") == EnumClass.Cycle.time.ToString())
                {
                    this.rbtnT.Checked = true;
                    DateTime dt = DateTime.Now;
                    if (DateTime.TryParse(this.configXml.getXmlValueById("time"), out dt))
                    {
                        this.dtpT.Value = dt;
                    }
                    else
                    {
                        this.dtpT.Value = DateTime.Now;
                    }
                    int num = 0;
                    if (int.TryParse(this.configXml.getXmlValueById("hour"), out num))
                    {
                        this.numT.Value = num;
                    }
                    else
                    {
                        this.numT.Value = 1;
                    }
                }

                this.btnES.Enabled = true;
            }
        }
Esempio n. 8
0
        public void ReadXmlFile()
        {
            // 使用xml库
            //XmlDocument aXml = new XmlDocument();
            //aXml.Load(ConfigFileName);

            // 使用Xml的linq库
            if (ConfigXml != null)
            {
                IEnumerable <XElement> childList = from el in ConfigXml.Elements() select el;
                ConfigString = "";
                foreach (XElement e in childList)
                {
                    ConfigString += e;
                }
            }
            Console.WriteLine(ConfigString);
        }
Esempio n. 9
0
 private void tMenuItemAddRun_Click(object sender, EventArgs e)
 {//添加运行列表
     if (this.lstConfig.SelectedItems.Count > 0)
     {
         string    names     = "配置";
         ConfigXml configXml = null;
         foreach (ListViewItem item in this.lstConfig.SelectedItems)
         {
             configXml = (ConfigXml)item.Tag;
             if (configXml.getXmlValueById("application") != EnumClass.Application.strat.ToString())
             {
                 configXml.setXmlValueById("application", EnumClass.Application.strat.ToString());
                 this.lstRun.Items.Add(configXml.listViewItemRunConfigXml());
                 names += "\r\n" + configXml.getXmlValueById("name");
             }
         }
         this.showMessage(names + "\r\n加入运行列表");
     }
 }
Esempio n. 10
0
        private void timer_Tick(object sender, EventArgs e)
        {//自动导出
            if (this.lstRun.Items.Count > 0)
            {
                ConfigXml configXml = null;
                foreach (ListViewItem item in this.lstRun.Items)
                {
                    configXml = (ConfigXml)item.Tag;
                    if (configXml.NextRunTime.CompareTo(DateTime.Now) < 0)
                    {
                        this.showMessage(configXml.getXmlValueById("name") + " 导出数据开始!");
                        try
                        {
                            this.eeu.autoRunExportXml(configXml);

                            configXml.aountNextRunTime();
                            configXml.PreviousRunInt = 0;
                            item.SubItems[1].Text    = configXml.NextRunTime.ToShortDateString() + " " + configXml.NextRunTime.ToLongTimeString();
                            item.SubItems[2].Text    = configXml.getPreviousRunInt();
                            this.showMessage(configXml.getXmlValueById("name") + " 获取数据成功!");

                            Thread.Sleep(60000);
                            string filsPath = configXml.getXmlValueById("path") + "\\";

                            //CsvAnalytical xa = new CsvAnalytical();
                            //xa.ParseCsv(filsPath);

                            this.showMessage("导入数据成功!");
                        }
                        catch (Exception ex)
                        {
                            configXml.PreviousRunInt = 1;
                            item.SubItems[2].Text    = configXml.getPreviousRunInt();
                            this.showMessage(configXml.getXmlValueById("name") + " 导出数据失败!\r\n" + ex.Message);
                        }
                    }
                }
            }
            else
            {
                this.btnEnd_Click(sender, e);
            }
        }
Esempio n. 11
0
        public void loadConfigXml()
        {
            this.configXmlList = new List <ConfigXml>();
            ConfigXml     configXml = null;
            DirectoryInfo mydir     = new DirectoryInfo(this.configFilePath);

            FileInfo[] myFiles = mydir.GetFiles();
            foreach (FileInfo myFile in myFiles)
            {
                if (myFile.Name.ToLower().EndsWith(".config"))
                {
                    try
                    {
                        configXml = new ConfigXml(myFile.FullName);
                        this.configXmlList.Add(configXml);
                    }
                    catch (Exception ex)
                    {
                        LogManager.Instance.Out(ex.Message);
                    }
                }
            }
        }
Esempio n. 12
0
        public IConfig GetConfigSection(string section)
        {
            var key = string.Format("{0}:{1}", ConfigKey, section);

            if (innerConfigurations.Contains(key))
            {
                return(innerConfigurations[key]);
            }
            lock (padlock) {
                if (!innerConfigurations.Contains(key))
                {
                    var node          = ConfigXml.SelectSingleNode(section);
                    var configElement = node as XmlElement;

                    if (configElement == null)
                    {
                        return(null);
                    }

                    innerConfigurations.Add(new Config(key, configElement));
                }
            }
            return(innerConfigurations[key]);
        }
Esempio n. 13
0
 public static ID LatestID(string file_name)
 {
     return(ConfigXml.Element("latest_ids").Element(Path.GetFileName(file_name)).Value.Trim());
 }
Esempio n. 14
0
 public static void LatestID(string file_name, ID id)
 {
     ConfigXml.Element("latest_ids").Element(Path.GetFileName(file_name)).Value = id;
     Root.Save(Path.Combine(BaseConfigPath, "config.xml"));
 }
 public IElementConfiguration CreateElementConfigurationFor(ModelBase originalModel, string newElementName)
 {
     return(new ElementConfiguration(this, originalModel?.Node, ConfigXml.CreateElement(newElementName)));
 }
Esempio n. 16
0
        public XmlNode GetKey(string section, string key)
        {
            var xpath = GetXPath(section, key);

            return(ConfigXml.SelectSingleNode(xpath));
        }
Esempio n. 17
0
 /// <remarks/>
 public FeeService()
 {
     this.Url = ConfigXml.GetXmlNode("KoufeiUrl", "");
     //this.Url = "http://127.0.0.1/jd/feeservice.asmx";
 }