コード例 #1
0
        /// <summary>
        /// 加载磁盘信息
        /// </summary>
        public void LoadList()
        {
            string filename = GetFileName();

            try
            {
                XmlSerializerHelper _serialize = new XmlSerializerHelper(filename);
                _list = _serialize.XmlDeserialize <List <HostInfo> >();
            }
            catch (Exception ex)
            {
                ServiceLog.Log("反序列化获取主机列表信息失败:" + ex.Message + "----文件位置:" + filename);
            }
        }
コード例 #2
0
        /// <summary>
        /// 保存信息到磁盘
        /// </summary>
        public void SaveList()
        {
            string filename = GetFileName();

            try
            {
                XmlSerializerHelper _serialize = new XmlSerializerHelper(filename);
                _serialize.XmlSerialize <List <HostInfo> >(_list);
            }
            catch (Exception ex)
            {
                string msg = "序列化保存主机信息失败:" + ex.Message + "----文件位置:" + filename;
                ServiceLog.Log(msg);
                throw new Exception(msg);
            }
        }
コード例 #3
0
 /// <summary>
 /// 线程运行方法
 /// </summary>
 private void Run()
 {
     while (true)
     {
         try
         {
             //获取所有主机信息,执行备份
             HostInfoOperate _operate = new HostInfoOperate();
             List <HostInfo> list     = _operate.GetList();
             foreach (var item in list)
             {
                 item.Exec_Back();
             }
         }
         catch (Exception ex)
         {
             ServiceLog.Log("线程方法执行失败:" + ex.Message);
         }
         //等待10分钟
         Thread.Sleep(RunSpan);
     }
 }