Пример #1
0
 public void ShowData(Dir item)
 {
     _Item = item;
     TbName.Text = _Item.Text;
     TbTips.Text = _Item.Tips;
     TbMemo.Text = _Item.Memo;
 }
Пример #2
0
 public void UpdateDir(Dir item)
 {
     bool update = CharUtil.IsValidateHash(item.Id);
     _DataModel.SaveVcs(item);
     if (update)
     {
         LsDir.Items[LsDir.SelectedIndex] = item;
     }
     else
     {
         item.Path = HashUtil.UtcTimeInHex();
         Directory.CreateDirectory(Path.Combine(_RootDir, item.Path));
         LsDir.Items.Add(item);
         LsDir.SelectedItem = item;
     }
 }
Пример #3
0
        /// <summary>
        /// 目录
        /// </summary>
        /// <param name="userModel"></param>
        /// <param name="setting"></param>
        private void ImportWPwdDir(AUserModel userModel, XmlReaderSettings setting)
        {
            string file = Path.Combine(userModel.DatHome, "WPwd-Dir.xml");
            if (!File.Exists(file))
            {
                return;
            }

            StreamReader stream = new StreamReader(file);
            using (XmlReader reader = XmlReader.Create(stream, setting))
            {
                Dir dir;
                while (reader.Name == "Dir" || reader.ReadToFollowing("Dir"))
                {
                    dir = new Dir();
                    if (!dir.FromXml(reader))
                    {
                        continue;
                    }
                    _DataModel.DeleteVcs(dir);
                    _DataModel.SaveVcs(dir);
                }
            }
            stream.Close();
        }
Пример #4
0
        private void InitDat()
        {
            _UserModel.Load();
            BeanUtil.UnZip(CApp.FILE_DAT, _UserModel.DatHome);
            _DataModel = new ADataModel(_UserModel);
            _DataModel.Init();

            string file;
            StreamReader stream;
            XmlReaderSettings setting = new XmlReaderSettings { IgnoreWhitespace = true };

            #region 字符
            file = Path.Combine(_UserModel.DatHome, "App-Udc.xml");
            if (File.Exists(file))
            {
                stream = new StreamReader(file);
                using (XmlReader reader = XmlReader.Create(stream, setting))
                {
                    Udc udc;
                    while (reader.Name == "Udc" || reader.ReadToFollowing("Udc"))
                    {
                        udc = new Udc();
                        if (!udc.FromXml(reader))
                        {
                            continue;
                        }
                        _DataModel.SaveVcs(udc);
                    }
                }
                stream.Close();
            }
            #endregion

            #region 类别
            file = Path.Combine(_UserModel.DatHome, "App-Cat.xml");
            if (File.Exists(file))
            {
                stream = new StreamReader(file);
                using (XmlReader reader = XmlReader.Create(stream, setting))
                {
                    Cat cat;
                    while (reader.Name == "Cat" || reader.ReadToFollowing("Cat"))
                    {
                        cat = new Cat();
                        if (!cat.FromXml(reader))
                        {
                            continue;
                        }
                        _DataModel.SaveVcs(cat);
                    }
                }
                stream.Close();
            }
            #endregion

            #region 模板
            file = Path.Combine(_UserModel.DatHome, "WPwd-Lib.xml");
            if (File.Exists(file))
            {
                stream = new StreamReader(file);
                using (XmlReader reader = XmlReader.Create(stream, setting))
                {
                    Lib header;
                    while (reader.Name == "Lib" || reader.ReadToFollowing("Lib"))
                    {
                        header = new Lib();
                        if (!header.FromXml(reader))
                        {
                            continue;
                        }
                        _DataModel.SaveVcs(header);
                    }
                }
                stream.Close();
            }
            #endregion

            #region 目录
            file = Path.Combine(_UserModel.DatHome, "WPwd-Dir.xml");
            if (File.Exists(file))
            {
                stream = new StreamReader(file);
                using (XmlReader reader = XmlReader.Create(stream, setting))
                {
                    Dir dir;
                    while (reader.Name == "Dir" || reader.ReadToFollowing("Dir"))
                    {
                        dir = new Dir();
                        if (!dir.FromXml(reader))
                        {
                            continue;
                        }
                        _DataModel.SaveVcs(dir);
                    }
                }
                stream.Close();
            }
            #endregion

            _DataModel.Dispose();
            _SignAc.CallBack(CApp.IAPP_WPWD);
        }