public bool ImportByTxt(string data, string ver) { if (string.IsNullOrEmpty(data)) { return false; } string[] list = data.Replace("\\;", "\b").Split(';'); if (list == null || list.Length < Att.HEAD_SIZE) { return false; } Clear(); Key = new Key(); foreach (string tmp in list) { if (string.IsNullOrEmpty(tmp)) { continue; } string tmp1 = tmp.Replace("\b", "\\;").Trim(); Match matche = Regex.Match(tmp1, "^\\d+:"); if (!matche.Success) { continue; } string tmp2 = matche.Value; Att item = Att.GetInstance(int.Parse(tmp2.Substring(0, tmp2.Length - 1))); if (item == null) { return false; } if (item.ImportByTxt(tmp1.Substring(tmp2.Length), ver)) { item.Id = (_Key.AttIndex++).ToString(); _AttList.Add(item); } } return true; }
public bool ImportByXml(XmlReader reader, string ver) { if (reader == null || reader.Name != "Key") { return false; } Clear(); _Key = new Key(); _Key.CatId = reader.GetAttribute("Cat"); reader.ReadToDescendant("Att"); while (reader.Name == "Att") { string type = reader.GetAttribute("Type"); if (!CharUtil.IsValidateLong(type)) { return false; } Att item = Att.GetInstance(int.Parse(type)); if (item == null) { return false; } if (item.ImportByXml(reader, ver)) { item.Id = (_Key.AttIndex++).ToString(); _AttList.Add(item); } }; if (reader.Name == "Key" && reader.NodeType == XmlNodeType.EndElement) { reader.ReadEndElement(); } return true; }
private void InitKey_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e) { if (e.Error != null) { _SignAc.HideWaiting(); Main.ShowAlert(e.Error.Message); return; } string xml = e.Result; using (XmlReader reader = XmlReader.Create(new StringReader(xml))) { if (xml.IndexOf("<Error>") > 0) { _SignAc.HideWaiting(); reader.ReadToFollowing("Error"); Main.ShowAlert(reader.ReadElementContentAsString()); return; } Key key; while (reader.Name == "Key" || reader.ReadToFollowing("Key")) { key = new Key(); if (!key.FromXml(reader)) { continue; } _DataModel.SaveVcs(key); } } BeanUtil.UnZip(CApp.FILE_DAT, _UserModel.DatHome); _SignAc.CallBack(CApp.IAPP_WPWD); }
public void UpdateKey(Key key) { key.Order += 1; _DbEngine.Save(key); }
public void Backup(Key rec) { }
private void DoShowKey(Key key) { _PwdView.ShowKey(); if (key == null) { return; } ItemGroup group = _XmlMenu.GetGroup(CPwd.KEY_LABEL); if (group != null) { group.Checked(key.Label.ToString()); } group = _XmlMenu.GetGroup(CPwd.KEY_MAJOR); if (group != null) { group.Checked(key.Major.ToString()); } _DataModel.UpdateKey(key); }
public void ShowKey(Key key) { if (key != null) { _SafeModel.Key = key; _SafeModel.Decode(); DoShowCmp(); DoShowKey(key); } }