/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SignInDownloadStringCompleted(object sender, System.Net.UploadStringCompletedEventArgs e) { string xml = e.Result; string code = null; string pass = null; int view = 0; List<LibHeader> libKey = new List<LibHeader>(); using (XmlReader reader = XmlReader.Create(new StringReader(xml))) { if (xml.IndexOf("<error>") > 0) { BeanUtil.HideLoading(); reader.ReadToFollowing("error"); BeanUtil.ShowAlert(reader.ReadElementContentAsString()); return; } if (!reader.ReadToFollowing("code")) { return; } code = reader.ReadElementContentAsString(); pass = reader.ReadElementContentAsString(); view = reader.ReadElementContentAsInt(); if (reader.Name == "libs" || reader.ReadToNextSibling("libs")) { while (reader.ReadToFollowing("lib")) { LibHeader header = new LibHeader(); header.FromXml(reader); libKey.Add(header); if (reader.Name == "atts" || reader.ReadToNextSibling("atts")) { List<LibDetail> libD = new List<LibDetail>(); if (reader.ReadToDescendant("att")) { LibDetail detail = new LibDetail(); detail.FromXml(reader); libD.Add(detail); } while (reader.ReadToNextSibling("att")) { LibDetail detail = new LibDetail(); detail.FromXml(reader); libD.Add(detail); } header.Details = libD; } } } } UserModel userMdl = new UserModel(); if (userMdl.SignIn(_Name, pass, code)) { userMdl.View = view; userMdl.LibKey = libKey; _Main.ShowUser(); Awin mpwd = new Awin(userMdl); mpwd.InitView(_Main); mpwd.InitData(); } }
/// <summary> /// 口令数据 /// </summary> /// <param name="index"></param> public bool InitData(LibHeader header) { for (int i = _AttList.Count - 1; i >= Att.HEAD_SIZE; i -= 1) { _AttList.RemoveAt(i); } int order = 1; foreach (LibDetail detail in header.Details) { Att att = Att.GetInstance(detail.Type, detail.Name, detail.Data); att.Order = (order++).ToString(); _AttList.Add(att); } return true; }